acumatica - Acumatica 覆盖方法 - 扫描和接收屏幕
问题描述
再会
我正在寻找一种方法来覆盖公共类 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,因为我有来自 QR 码的位置,我可以在第一次扫描时设置它:
#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);
然后我可以设置标题并继续将扫描仪重置为确认状态。你怎么看?
解决方案
因为您尝试覆盖的方法是受保护的,而不是公开的,所以您需要使用 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 类型传递给属性,看看是否适合您。
推荐阅读
- flutter - Flutter:需要更新身份验证服务类
- python - 为什么我的 s3 存储桶的预签名 URL 在部署时看起来不同?
- android - 在android studio上保存按钮状态
- python - 使用 Apache 光束写入 postgres 时出现光束块错误:CompileError: Unconsumed column names
- python - 如何在 Pygame 中设置帧率?
- python - 将 users.signals 导入用户应用中的 apps.py 时出现 django 错误
- flutter - 在列表视图构建器中显示项目列表
- sql - 如何将嵌套的语句复制到嵌套的 with 语句?
- python - 通过 lambda 函数添加新列在 Python 中引发了值错误
- node.js - 创建多个 LocalStrategies 并能够与它们一起使用会话