我刚刚开始使用SysOperation框架,我有一些ReliableAsynchronous进程可以运行并调用info("starting...")
等。
我想要这些infolog消息,以便当我查看BatchHistory
时,我可以看到它们以便稍后进行调查。
但是他们也会从批次中启动客户端。我可以告诉他们他们来自批处理,因为你不能双击infologs去源。有没有办法阻止这些弹出在用户屏幕上弹出并仅显示在批处理日志中?
使用一些代码进行编辑: 用户单击表单操作窗格上的按钮,该窗格调用引用类的操作菜单项。
在课堂上,新方法:
public void new()
{
super();
this.parmClassName(classStr(MyControllerClass));
this.parmMethodName(methodStr(MyControllerClass, pickTransLines));
this.parmExecutionMode(SysOperationExecutionMode::ReliableAsynchronous);
// This is meant to be running as a batch task, so don't load syslastvalue
this.parmLoadFromSysLastValue(false);
}
主要方法来自菜单项:
public static void main (Args _args)
{
MyControllerClass controller = new MyControllerClass();
MyContract contract;
WMSOrderTrans wmsOrderTrans;
RefRecId refRecId;
if (_args && _args.dataset() == tableNum(WMSOrderTrans) && _args.record())
{
contract = controller.getDataContractObject();
contract.parmRefRecId(_args.record().RecId);
controller.parmShowDialog(false);
refRecId = controller.doBatch().BatchJobId;
// This creates a batch tracking record
controller.updateCreateTracking(refRecId, _args.record().RecId);
}
}
启动的控制器方法:
// Main picking method
private void pickTransLines(MyContract_contract)
{
MyTrackingTable tracking;
boolean finished;
BatchHeader batchHeader = BatchHeader::getCurrentBatchHeader();
boolean updateTracking = false;
// NOTE - This infolog launches after a few seconds to the user, but
// you can't double click on the info message to go to the code
// because it's fired from the batch somehow.
info(strFmt("Working on wmsordertrans.recid == %1", _contract.parmRefRecId()));
// Create/Update batch tracker if needed
if (this.isInBatch())
{
// NOTE - This code gets executed so we ARE in batch
this.updateTrackingStuff(...);
}
// Do the pick work
finished = this.doPick(_contract);
if(!finished)
throw error("An error occurred during the picking process.");
}
然后一瞬间,这将启动到我的会话:
答案 0 :(得分:2)
查看SysOperationServiceController.afterOperation
方法:
[...]
if (_executionMode == SysOperationExecutionMode::ReliableAsynchronous)
{
batch = this.operationReturnValue();
if (batch)
{
infolog.view(Batch::showLog(batch.RecId));
}
}
[...]
这是显示可靠异步处理屏幕的信息的代码。
您可以通过扩展SysOperationServiceController
并在菜单项或代码中使用它来创建自己的控制器,这样做并覆盖新控制器上的afterOperation
,例如这样(didn&# 39; t测试,但应该适合你的情况):
if (_executionMode != SysOperationExecutionMode::ReliableAsynchronous)
{
super(_executionMode, _asyncResult);
}