From 5ef621add961cb9e438a65ec1c37b1f9917c0e2e Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 10 Aug 2021 15:35:42 +0000 Subject: [PATCH] --- source/Plugins/AyaNova.Plugin.V8/V8.cs | 51 +++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index 2d4f0a0..04d21af 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -254,6 +254,9 @@ namespace AyaNova.PlugIn.V8 } private bool ExportAssignedDocs = false; + + private long ClosedWorkOrderStatus = 0; + /// /// Dump the objects into a temporary directory as a series of JSON files /// then zip it all up into a single archive file and then erase the temporary folder @@ -2350,6 +2353,27 @@ namespace AyaNova.PlugIn.V8 } + //Third export for service completed / closed status + ResetUniqueNames(); + { + if (!progress.KeepGoing) return; + dynamic d = new JObject(); + d.name = GetUniqueName("Closed / Service Completed"); + progress.Op("WorkOrder status " + d.name); + d.active = true; + d.locked = true; + d.completed = true; + d.selectRoles = 1290;//biz-admin, service full, service tech, subcontractor + d.removeRoles = 10;//bizadmin,servicefull + d.color = "#000000"; + d.notes = "This status automatically created by the v8 migrate process for closed work orders"; + SetTags(d, tags); + var rMainObject = await util.PostAsync("work-order-status", d.ToString()); + ClosedWorkOrderStatus = util.IdFromResponse(rMainObject); + //Event log fixup + //await util.EventLog(util.AyaType.WorkOrderStatus, RavenId, SafeGetUserMap(s.Creator), SafeGetUserMap(s.Modifier), s.Created, s.Modified); + } + //------ @@ -2435,7 +2459,7 @@ namespace AyaNova.PlugIn.V8 } - //TODO: signatures, items* + //TODO: signatures @@ -2482,6 +2506,31 @@ namespace AyaNova.PlugIn.V8 //Event log fixup await util.EventLog(util.AyaType.WorkOrder, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified); + //######### STATE ####### + //if closed then set that state as well but always first set the current state + { + if (c.WorkorderService.WorkorderStatusID != Guid.Empty) + { + dynamic state = new JObject(); + state.workOrderId = RavenId; + state.workOrderStatusId = Getv7v8IdMap(c.WorkorderService.WorkorderStatusID,"Workorder status"); + state.created = util.DateToV8(c.Created, true); + state.userId = Getv7v8IdMap(c.Creator, "Workorder creator for status"); + await util.PostAsync("workorder/states", state.ToString()); + } + if (c.Closed) + { + dynamic state = new JObject(); + state.workOrderId = RavenId; + state.workOrderStatusId =ClosedWorkOrderStatus; + state.created = util.DateToV8(c.Created, true); + state.userId = Getv7v8IdMap(c.Creator, "Workorder creator for status"); + await util.PostAsync("workorder/states", state.ToString()); + } + //todo:? maybe if service completed but not closed we have a separate state for that?? + } + + //iterate all workorder items foreach (WorkorderItem wi in c.WorkorderItems) {