过程通过过程屏幕而不是下自动时间表运行时运行良好(Process runs fine while r

2019-10-23 08:16发布

我有我试图安排的过程。 当计划运行时,我得到以下错误:

       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);

该图并调用过程中的图形是定制基于我创建一个自定义表。 我已经加入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();

            });
    }

}

Answer 1:

By using async/await, your code will run in a different thread, which isn't guaranteed to be initialized properly with session variables. I don't believe Acumatica guarantees any sort of thread-safety with the graph or any of the caches, so you should separate any code that interacts with it from your asynchronous operations.

Furthermore, I don't see any reason to use an asynchronous operation; it will just make your life harder in this case - just run your API synchronization from the main thread. If you want to run multiple operations at once, and wait for them to return, then isolate these operations from the graph and caches.



文章来源: Process runs fine while running through process screen but not under automated schedule
标签: acumatica