今天的乐趣: 有一个处理屏幕,可以处理很多事情 可以创建/发布: 一步转移 IN 2步传输 SO 2步转移 采购单 套件组装
有趣的部分#1:发布(显然)不能在事务之内
所以,它一直很好,直到套件套件发布为止。
但是,我不断得到:
2018-08-23 19:07:16Z [23] Error w3wp.exe 0: 23803b8a-d4f4-4523-b310-a6ddd16bc3bd 100035 PX.Data.PXOperationCompletedSingleErrorException: Error: Another process has updated the 'INRegister' record. Your changes will be lost. ---> PX.Data.PXLockViolationException: Error: Another process has updated the 'INRegister' record. Your changes will be lost.
at PX.Data.PXTableAttribute.PersistUpdated(PXCache sender, Object row)
at PX.Data.PXCache`1.PersistUpdated(Object row)
at PX.Data.PXCache`1.Persist(PXDBOperation operation)
at PX.Data.PXGraph.Persist(Type cacheType, PXDBOperation operation)
at PX.Data.PXGraph.Persist()
at PX.Objects.IN.INReleaseProcess.ReleaseDocProc(JournalEntry je, INRegister doc)
at PX.Objects.IN.INReleaseProcess.ReleaseDocProcR(JournalEntry je, INRegister doc)
at PX.Objects.IN.INDocumentRelease.ReleaseDoc(List`1 list, Boolean isMassProcess)
--- End of inner exception stack trace ---
at PX.Objects.IN.INDocumentRelease.ReleaseDoc(List`1 list, Boolean isMassProcess)
at MaxQ.Products.SupplyChain.WorkOrderReportProductionProcess.KitAssemblyReleaseOrDelete(MQSCWorkOrd& workOrd) in C:\_Development\Acumatica Development\MaxQ Products\Supply Chain Planning\Source\Graph\WorkOrderReportProductionProcess.cs:line 1370
at MaxQ.Products.SupplyChain.WorkOrderReportProductionProcess.ProcessWOrders(List`1 WOrdersToProcess, Nullable`1 Consolidate) in C:\_Development\Acumatica Development\MaxQ Products\Supply Chain Planning\Source\Graph\WorkOrderReportProductionProcess.cs:line 155
我可能会搞砸什么?
代码块:
WorkOrderMaint workOrderMaint = PXGraph.CreateInstance<WorkOrderMaint>();
INKitRegister iNKitRegister = new PXSelectReadonly<INKitRegister, Where<MQSCInKitRegisterExt.wONbr, Equal<Required<MQSCInKitRegisterExt.wONbr>>, And<INKitRegister.released, Equal<False>>>>(workOrderMaint).SelectSingle(workOrd.WONbr);
// using (PXTransactionScope XAct = new PXTransactionScope())
{
Trace.TraceInformation(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", "1b2010c2-be46-4da7-8f29-e496a7cc240d"));
#region Handle the assembly Release
if (iNKitRegister != null)
{
if (workOrd.CloseWO.GetValueOrDefault() && workOrd.QtyToComplete.GetValueOrDefault() == Decimal.Zero)
{
Trace.TraceInformation(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", "fefb4f77-b33c-4ade-a187-b1fb1f7dafba"));
// If closing the WO, AND none to complete remove existing assembly doc
KitAssemblyEntry kitAssemblyEntry = PXGraph.CreateInstance<KitAssemblyEntry>();
kitAssemblyEntry.Document.Current = new PXSelect<INKitRegister, Where<MQSCInKitRegisterExt.wONbr, Equal<Required<MQSCInKitRegisterExt.wONbr>>, And<INKitRegister.released, Equal<False>>>>(workOrderMaint).SelectSingle(workOrd.WONbr); ;
kitAssemblyEntry.Document.Delete(kitAssemblyEntry.Document.Current);
kitAssemblyEntry.Actions.PressSave();
}
else
{
// Need to Release. Make sure we don't get an "another process has updated..." message.
Trace.TraceInformation(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", "1a4b3f1c-23a8-49ed-943e-722abbfcad60"));
// At this point, this is throwing error messages about cost (e.g. "Error: 'Total Cost' cannot be empty", "Error: 'Ext. Cost' cannot be empty"
// This does NOT happen when do through the screen, or the IN document release process
// kitAssemblyEntry.release.Press();
// INRegister doc = PXSelect<INRegister, Where<INRegister.docType, Equal<Required<INRegister.docType>>, And<INRegister.refNbr, Equal<Required<INRegister.refNbr>>>>>.Select(workOrderMaint, iNKitRegister.DocType, iNKitRegister.RefNbr);
INRegister iNRegister = new PXSelectReadonly<INRegister, Where<INRegister.docType, Equal<Required<INRegister.docType>>, And<INRegister.refNbr, Equal<Required<INRegister.refNbr>>>>>(workOrderMaint).SelectSingle(iNKitRegister.DocType, iNKitRegister.RefNbr);
INDocumentRelease.ReleaseDoc(new List<INRegister>() { iNRegister }, false);
Trace.TraceInformation(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", "0798d686-a736-4f77-97b7-d808ec082e09"));
}
}
#endregion
答案 0 :(得分:0)
与一位名叫Dmitry的Acumatica开发人员进行了一次屏幕共享会话(姓氏不予透露,如果他希望共享,可以保留给他)。
在其中,他建议在INRegister选择之前(以及其他一些地方)添加.SelectTimeStamp()。 并清除明确的缓存,例如.Caches [“ INRegister] .ClearQueryCache();
如果您要在非保存事件(例如,在进程或LongRunningProcess中)中更新“当前”记录,则可能需要此操作。它告诉图形从数据库“刷新”时间戳。
按照建议添加后,其余代码运行正常。
// Generic graph, to allow the selects, no real use other than that. Chose a simple one for speed
MachineMaint graph = PXGraph.CreateInstance<MachineMaint>();
INKitRegister iNKitRegister = new PXSelect<INKitRegister, Where<MQSCInKitRegisterExt.wONbr, Equal<Required<MQSCInKitRegisterExt.wONbr>>, And<INKitRegister.released, Equal<False>>>>(graph).SelectSingle(workOrd.WONbr);
PXTrace.WriteVerbose(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", "1b2010c2-be46-4da7-8f29-e496a7cc240d"));
#region Handle the assembly Release
if (iNKitRegister != null)
{
if (workOrd.CloseWO.GetValueOrDefault() && workOrd.QtyToComplete.GetValueOrDefault() == Decimal.Zero)
{
PXTrace.WriteVerbose(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", "fefb4f77-b33c-4ade-a187-b1fb1f7dafba"));
// If closing the WO, AND none to complete remove existing assembly doc
KitAssemblyEntry kitAssemblyEntry = PXGraph.CreateInstance<KitAssemblyEntry>();
kitAssemblyEntry.Document.Current = new PXSelect<INKitRegister, Where<MQSCInKitRegisterExt.wONbr, Equal<Required<MQSCInKitRegisterExt.wONbr>>, And<INKitRegister.released, Equal<False>>>>(graph).SelectSingle(workOrd.WONbr); ;
kitAssemblyEntry.Document.Delete(kitAssemblyEntry.Document.Current);
kitAssemblyEntry.Actions.PressSave();
}
else
{
// Need to Release. Make sure we don't get an "another process has updated..." message.
PXTrace.WriteVerbose(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", "1a4b3f1c-23a8-49ed-943e-722abbfcad60"));
graph.Caches["INRegister"].ClearQueryCache();
PXTrace.WriteVerbose(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", "55a5134a-75fe-4d53-881a-381e2eb8d485"));
INRegister iNRegister = new PXSelect<INRegister, Where<INRegister.docType, Equal<Required<INRegister.docType>>, And<INRegister.refNbr, Equal<Required<INRegister.refNbr>>>>>(graph).SelectSingle(iNKitRegister.DocType, iNKitRegister.RefNbr);
using (new PXConnectionScope())
{
using (PXTransactionScope ts = new PXTransactionScope())
{
PXTrace.WriteVerbose(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", "63a21017-41a0-4aa2-8049-959a465fb81f"));
graph.SelectTimeStamp();
INDocumentRelease.ReleaseDoc(new List<INRegister>() { iNRegister }, false);
PXTrace.WriteVerbose(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", "08e980a8-b729-4607-b507-69b3ddd15a08"));
ts.Complete();
}
}
PXTrace.WriteVerbose(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", "0798d686-a736-4f77-97b7-d808ec082e09"));
}