0

我刚刚开始使用 SysOperation 框架,并且我有一些 ReliableAsynchronous 进程可以运行和调用info("starting...")等。

我想要这些信息日志消息,以便当我查看 时BatchHistory,我可以看到它们,以便以后进行调查。

但他们也批次向客户推出。而且我可以告诉他们来自批次,因为您无法双击信息日志以转到源。有没有办法抑制这些在用户屏幕上弹出并只显示在批处理日志中?

使用一些代码进行编辑: 用户单击表单操作窗格上的按钮,该按钮调用引用类的操作菜单项。

在类中,新方法:

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.");
}

然后一瞬间,这将启动到我的会话: 在此处输入图像描述

4

1 回答 1

2

SysOperationServiceController.afterOperation方法,:

[...]
if (_executionMode == SysOperationExecutionMode::ReliableAsynchronous)
{
    batch = this.operationReturnValue();
    if (batch)
    {
        infolog.view(Batch::showLog(batch.RecId));
    }
}
[...]

这是将信息日志显示到屏幕以进行可靠异步处理的代码。

您可以通过在菜单项或代码中扩展和使用它来创建自己的控制器SysOperationServiceController,所以这样做并覆盖afterOperation新控制器上的,例如像这样(没有测试,但应该适用于您的情况):

if (_executionMode != SysOperationExecutionMode::ReliableAsynchronous)
{
    super(_executionMode, _asyncResult);
}
于 2014-07-11T14:41:02.623 回答