From c11ff167a8ab3697fe4c924634b55f0ad504cab6 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 11 May 2020 21:43:01 +0000 Subject: [PATCH] --- source/Plugins/AyaNova.Plugin.V8/V8.cs | 66 ++++++++++++++++++-------- 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index 08548bc..25c2a14 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -35,7 +35,7 @@ namespace AyaNova.PlugIn.V8 public string PluginVersion { - get { return "7.6 (Alpha)"; } + get { return "7.6.1-alpha.8"; } } public string About @@ -207,6 +207,7 @@ namespace AyaNova.PlugIn.V8 progress.Show(); progress.StartedImport(); progress.Append("Exporting data to AyaNova server @ " + util.ApiBaseUrl); + progress.Append(util.PRE_RELEASE_VERSION_STRING); try { progress.Op("Preparing to export...."); @@ -291,8 +292,10 @@ namespace AyaNova.PlugIn.V8 await ExportUnitModels(progress); await ExportVendors(progress); await ExportServiceWorkorders(progress); - await ExportQuotes(progress); - await ExportPMs(progress); + //todo: these are now invalid and awaiting RAVEN end implementation + //after which can copy mostly from service workorder block + // await ExportQuotes(progress); + // await ExportPMs(progress); //NOTE: when get to PRIORITY, or WORKORDER STATUS be sure to add color code as per already done in USER export @@ -1344,13 +1347,13 @@ namespace AyaNova.PlugIn.V8 progress.Op("Start Service workorders export"); progress.SubOp(""); var ObjectTypeName = "Workorder"; - var RavenObjectName = "WorkOrder"; + var RavenRouteName = "workorders"; //TODO: this in the workorder Items loop - ////Step 1: export the CustomFields to FormCustom if applicable so that when doing individual items we can export their custom data too - //var ocf = ObjectHasCustomFieldDataToExport("WorkorderItem"); - //bool ShouldExportCustom = ocf != null; - //var DateCustomFields = await ExportCustomFieldSchema(ocf, "WorkorderItem", "WorkOrderItem"); + //Step 1: export the CustomFields to FormCustom if applicable so that when doing individual items we can export their custom data too + var ocf = ObjectHasCustomFieldDataToExport("WorkorderItem"); + bool ShouldExportCustom = ocf != null; + var DateCustomFields = await ExportCustomFieldSchema(ocf, "WorkorderItem", "WorkOrderItem"); //Step 2: export the objects WorkorderServiceList pl = WorkorderServiceList.GetList(""); @@ -1366,7 +1369,7 @@ namespace AyaNova.PlugIn.V8 if (IsDuplicateMapItem(c.ID, c.WorkorderService.ServiceNumber.ToString(), progress)) continue; var ObjectTID = new TypeAndID(RootObjectTypes.WorkorderService, c.ID); //make one on the server to update - var rMainObject = await util.PostAsync(RavenObjectName + "/Create?serial=" + c.WorkorderService.ServiceNumber); + var rMainObject = await util.PostAsync(RavenRouteName); long RavenId = util.IdFromResponse(rMainObject); AddMap(c.ID, RavenId); @@ -1378,25 +1381,20 @@ namespace AyaNova.PlugIn.V8 Tagit(c.RegionID, tags); SetTags(d, tags); - ////Custom fields? - //if (ShouldExportCustom) - // d.customFields = CustomFieldData(c, DateCustomFields); - - // var rMainObject = await util.PostAsync(RavenObjectName, d.ToString()); //Attachments / FILES await ExportAttachments(ObjectTID, progress, util.AyaType.WorkOrder); - //----- - bool repost = false; + //----- + d.serial = c.WorkorderService.ServiceNumber; d = rMainObject.ObjectResponse["data"]; // wiki if (WikiPage.HasWiki(c.ID)) { // await ExportAttachments(ObjectTID, progress); d.wiki = GetWikiContent(ObjectTID); - repost = true; + } //docs @@ -1408,16 +1406,42 @@ namespace AyaNova.PlugIn.V8 //d.login = null; //d.password = null; d.notes = NonFileUrls + "\n-----------------\n" + d.notes; - repost = true; + } - if (repost) - await util.PutAsync(RavenObjectName + "/" + RavenId.ToString(), d.ToString()); + + //put the final object + await util.PutAsync(RavenRouteName + "/" + RavenId.ToString(), d.ToString()); //----- //Event log fixup await util.EventLog(util.AyaType.WorkOrder, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified); - //todo: workorder items etc + //iterate all workorder items + foreach (WorkorderItem wi in c.WorkorderItems) + { + dynamic dwi = new JObject(); + dwi.workOrderId = RavenId; + + // d.concurrencyToken = util.CTokenFromResponse(rMainObject); + progress.Op("WorkorderItem " + wi.ID.ToString()); + dwi.active = true;//probably can remove this at server, just stubbed in for now + + Tagit(wi.TypeID, tags); + Tagit(wi.WorkorderItemUnitServiceTypeID, tags); + SetTags(dwi, tags); + + ////Custom fields? + if (ShouldExportCustom) + dwi.customFields = CustomFieldData(wi, DateCustomFields); + + dwi.notes = "Summary:\n" + wi.Summary + "TechNotes: \n" + wi.TechNotes; + + await util.PostAsync("workorders/items", d.ToString()); + + //and rest of tree below here... + + + } } } #endregion Workorders