1

我有一个场景,服务将数据传递给 AX,然后我们使用 SysOperationFramework 处理该数据,而无需让服务客户端等待处理完成。

如果用户在处理仍在进行时尝试在外部应用程序中打开记录,则会出现问题。

有没有办法在 X++ 中查看当前正在执行的作业(并进一步查看传入的参数),以便我们可以向用户发送可以处理的错误?

4

1 回答 1

2

有办法,是的。您要查找的数据存储在Batch表中。您将找到一个ClassNumber和一个状态字段。只需选择与您的班级匹配且状态为正在执行的记录。如果记录存在,则正在执行。

参数存储在Parameters容器的字段中。你可以解压容器,创建你的类的一个实例并解压它,就像这样(快速代码不会编译,但你明白了):

Batch batch;
SysOperationServiceController sysOperationServiceController;
YourDataContract yourDataContract;

select batch 
    where batch.ClassNumber = YourClassNumber
    && batch.Status == BatchStatus::Executing;

// todo: you might have to check the type of the object before assignment
// todo: also check if batch record has been found
sysOperationServiceController = batch.object();

if (sysOperationServiceController.unpack(batch.Parameters))
{
    // todo: you might have to check the type of the object before assignment
    yourDataContract = sysOperationServiceController.getDataContractObject('_theParemterNameOfyourDataContract');

    // todo: here you can read the parameters from your contract
}
else
{
    throw error("Unpack failed");
}
于 2014-07-16T11:45:54.433 回答