【问题标题】:Acumatica override method - Scan and Receive screenAcumatica 覆盖方法 - 扫描和接收屏幕
【发布时间】:2021-06-08 14:33:02
【问题描述】:

美好的一天

我正在寻找一种方法来覆盖公共类 INScanReceive 中的函数 ProcessItemBarcode(string Barcode):WMSBase

这个想法是扩展 INScanReceiveHost 图并在处理条形码之前对其进行操作。这是为了更改扫描和接收页面扫描条形码的方式,以便我可以读取和操作 QR 码

namespace PX.Objects.IN
{

    // Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
    public class INScanReceiveHost_Extension : PXGraphExtension<INScanReceive>
    {
        #region Event Handlers
        [PXOverride]
        public virtual void ProcessItemBarcode(string barcode)
        {
            //change barcode
            Base.ProcessItemBarcode.Invoke(barcode);
        }
        #endregion
    }
}

但它告诉我我无法访问该功能?

2021/06/15 更新

感谢 Sean Prouty 迄今为止的帮助。我已经非常接近解决方案了。

我有一个后续问题。

我已经覆盖了 ProcessItemBarcode 函数和 ProcessLotSerialBarcode

问题:我可以从 ProcessItemBarcode 调用 ProcessLotSerialBarcode 因为我有二维码的位置,所以我可以在第一次扫描时设置它:

#region Overrides ProcessItemBarcode
//ProcessItemBarcode
public delegate void ProcessItemBarcodeDelegate(string barcode);

[PXOverride]
public virtual void ProcessItemBarcode(string barcode, ProcessItemBarcodeDelegate baseMethod)
{
    try
    {
        string inventoryBC = barcode;
        //...//get InvetoryID using Barcode
        baseMethod?.Invoke(inventoryBC);

        //how do you call the ProcessLotSerialBarcode function?
        ProcessLotSerialBarcode(barcode,  ProcessLotSerialBarcodeDelegate);
    }
    catch (Exception ex)
    {//TODO: check if not a QR code  
        PXTrace.WriteError("ProcessItemBarcode Override: " + ex.Message);
        baseMethod?.Invoke(barcode);
    }
}
#endregion

#region Overrides ProcessLotSerialBarcode
//ProcessLotSerialBarcode
public delegate void ProcessLotSerialBarcodeDelegate(string barcode);

[PXOverride]
public virtual void ProcessLotSerialBarcode(string barcode, ProcessLotSerialBarcodeDelegate baseMethod)
{
    try
    {
        string inventoryBC = "LOgic";
        baseMethod?.Invoke(inventoryBC);
    }
    catch (Exception)
    {
        //TODO: check if not a QR code  
        baseMethod?.Invoke(barcode);
    }

}
#endregion


    [PXProtectedAccess]
public abstract class INScanReceiveHostExtProtectedAccess : PXGraphExtension<INScanReceiveHostExtCustomPackage, INScanReceive, INScanReceiveHost>
{
    [PXProtectedAccess(typeof(INScanReceive))]
    protected abstract void ProcessItemBarcode(string barcode);

    [PXProtectedAccess(typeof(INScanReceive))]
    protected abstract void ApplyState(string state);

    [PXProtectedAccess(typeof(INScanReceive))]
    protected abstract void ProcessLotSerialBarcode(string barcode);
}

我也在考虑从第一种方法设置状态,但后来我需要调用

Base.ApplyState(INScanIssue.ScanStates.Confirm);

然后我可以设置标题并继续将扫描仪重置为确认状态。你怎么看?

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    由于您尝试覆盖的方法是受保护的,而不是公开的,因此您需要使用 PXProtectedAccess 属性和抽象图形扩展以不同的方式覆盖逻辑。

    namespace MyCustomPackage.Graph.Extension
    {
        public class INScanReceiveHostExtCustomPackage : PXGraphExtension<INScanReceive, INScanReceiveHost>
        {
            public static bool IsActive() => true;
    
            #region Overrides
    
            public delegate void ProcessItemBarcodeDelegate(string barcode);
    
            [PXOverride]
            public virtual void ProcessItemBarcode(string barcode, ProcessItemBarcodeDelegate baseMethod)
            {
                PXTrace.WriteInformation("Running abstract override");
                baseMethod?.Invoke(barcode);
    
            }
    
            #endregion
        }
    
    
        [PXProtectedAccess]
        public abstract class INScanReceiveHostExtProtectedAccess : PXGraphExtension<INScanReceiveHostExtCustomPackage, INScanReceive, INScanReceiveHost>
        {
            [PXProtectedAccess(typeof(INScanReceive))]
            protected abstract void ProcessItemBarcode(string barcode);        
        }
    }
    

    不幸的是,我没有很好的方法来测试它,因此您可能需要调整传递给抽象方法上方的 PXProtectedAccess 属性的类型。如果这不起作用,请尝试将 INScanReceiveHost 类型传递给属性,看看是否适合您。

    【讨论】:

    • 谢谢肖恩我试一试
    • 当然!如果这不能解决您的问题,请告诉我。
    • 感谢肖恩到目前为止的帮助,如果你有第二个问题,我在上面的问题中有一个后续问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-07-19
    • 1970-01-01
    • 1970-01-01
    • 2011-03-03
    • 2023-02-24
    • 2022-11-08
    • 1970-01-01
    相关资源
    最近更新 更多