Acumatica 流程在流程屏幕中运行时运行正常,但不在自动计划下运行

Acumatica 流程在流程屏幕中运行时运行正常,但不在自动计划下运行,acumatica,Acumatica,我有一个过程,我正试图安排。当计划运行时,出现以下错误: Message: Error #199: You are not currently logged in. Date/Time: 09/06/2015 10:20 Platform: Browser: Source: PX.Data Target Site: Int32 GetCurrentCompany() Stack Trace: at PX.Data.PXDatabaseProviderBase.GetC

我有一个过程,我正试图安排。当计划运行时,出现以下错误:

       Message: Error #199: You are not currently logged in.

Date/Time: 09/06/2015 10:20
Platform: 
Browser: 

Source: PX.Data
Target Site: Int32 GetCurrentCompany()
Stack Trace:    at PX.Data.PXDatabaseProviderBase.GetCurrentCompany()
   at PX.Data.PXDatabaseProviderBase.getCompanyID(String tableName, companySetting& setting)
   at PX.Data.PXDatabaseProviderBase.getRestriction(String table, String alias, Boolean mainRestriction, Boolean isRightJoin, Nullable`1 effectiveCid)
   at PX.Data.PXDatabaseProviderBase.alterText(String text, Int32 start, Int32 stop, Boolean isTopLevelQuery)
   at PX.Data.PXDatabaseProviderBase.alterText(String text, Int32 start, Int32 stop, Boolean isTopLevelQuery)
   at PX.Data.PXDatabaseProviderBase.Select(PXGraph graph, BqlCommand command, Int32 topCount, PXView view, PXDataValue[] pars)
   at PX.Data.PXGraph.ProviderSelect(BqlCommand command, Int32 topCount, PXView view, PXDataValue[] pars)
   at PX.Data.PXView.GetResult(Object[] parameters, PXFilterRow[] filters, Boolean reverseOrder, Int32 topCount, PXSearchColumn[] sorts, Boolean& overrideSort, Boolean& extFilter)
   at PX.Data.PXView.Select(Object[] currents, Object[] parameters, Object[] searches, String[] sortcolumns, Boolean[] descendings, PXFilterRow[] filters, Int32& startRow, Int32 maximumRows, Int32& totalRows)
   at PX.Data.PXSelectBase`1.selectBound[Resultset](BqlCommand command, Boolean readOnly, PXGraph graph, Int32 startRow, Int32 totalRows, Object[] currents, Object[] pars)
   at PX.Data.PXSelectBase`1.select[Resultset](BqlCommand command, Boolean readOnly, PXGraph graph, Int32 startRow, Int32 totalRows, Object[] pars)
   at PX.Data.PXSelectReadonly`2.SelectWindowed[Resultset](PXGraph graph, Int32 startRow, Int32 totalRows, Object[] pars)
   at PX.Data.PXSelectReadonly`2.Select[Resultset](PXGraph graph, Object[] pars)
   at Exosoft.MP.MikePero.Graphs.RexApiMaint.GetCustomerByCD(String id)
当我在流程屏幕上运行流程时,流程运行良好,但不是在自动计划下运行

错误发生时,我调用下面的

PXSelectReadonly<PX.Objects.AR.Customer, Where<PX.Objects.AR.Customer.acctCD, Equal<Required<PX.Objects.AR.Customer.acctCD>>>>.Select(this, id);
PXSelectReadonly.选择(此,id);
图形及其调用处理的图形是基于我创建的自定义表定制的。我已将CompanyID和其他审核字段添加到自定义表中。这就是我所说的

public class SyncRexApiProcess : PXGraph<SyncRexApiProcess>
{

    public PXCancel<RexApiLogin> Cancel;
    public PXProcessing<RexApiLogin> RexApiLogins;

    public SyncRexApiProcess()
    {
        RexApiLogins.SetProcessCaption("Sync From Rex Api Login");
        RexApiLogins.SetProcessAllCaption("Sync From All Rex Api Logins");
        RexApiLogins.SetProcessDelegate<RexApiMaint>(
            delegate(RexApiMaint graph, RexApiLogin login)
            {
                graph.Clear();
                Func<Task> task = async () =>
                {
                    await graph.SyncAPIDataAsync(login);
                };
                task().Wait();

            });
    }

}
public类SyncRexApiProcess:PXGraph
{
公共服务取消;
公共图书馆;
公共SyncRexApiProcess()
{
SetProcessCaption(“从Rex Api登录同步”);
SetProcessAllCaption(“从所有Rex Api登录同步”);
RexApiLogins.SetProcessDelegate(
委托(RexApiMaint图、RexApiLogin登录)
{
graph.Clear();
Func task=async()=>
{
wait graph.SyncAPIDataAsync(登录);
};
task().Wait();
});
}
}

通过使用async/await,您的代码将在不同的线程中运行,不能保证使用会话变量正确初始化。我认为Acumatica不能保证图形或任何缓存的线程安全,所以您应该将与它交互的任何代码与异步操作分开


此外,我认为没有任何理由使用异步操作;在这种情况下,这只会让你的生活更加艰难——只需从主线程运行API同步。如果要同时运行多个操作,并等待它们返回,请将这些操作与图形和缓存隔离。

发布代码以更好地理解。尝试将进程附加到调试器并运行整个计划,以便调试代码以查找问题。堆栈跟踪和错误表明登录存在问题。您发布的代码行没有任何问题。我相信,当Acumcatica试图对DB执行它时,图形中的公司ID不可用。使用PX.Common.PXContext.GetSlot(“singleCompanyID”);在即时窗口中查找当前登录的company.PX.Common.PXContext.GetSlot(“singleCompanyID”);返回nullOkay,这意味着问题在于该特定图形的登录会话,而不是此处提到的代码行。请参阅上面的流程图中的代码,调用另一个图形上的方法。关于登录会话,我需要做哪些考虑,我需要先初始化一些东西吗?