From 0da0bf4a11ea8cd1800fefd403f68f3dccf59d21 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 8 Jan 2021 23:12:20 +0000 Subject: [PATCH] --- source/Plugins/AyaNova.Plugin.V8/V8.cs | 80 +++++++++++--------------- 1 file changed, 35 insertions(+), 45 deletions(-) diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index 09457f5..630babc 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -355,6 +355,7 @@ namespace AyaNova.PlugIn.V8 //must be after all clients, ho, units and workorders await ExportServiceBank(progress); + await ExportClientServiceRequests(progress); //NOTE: when get to PRIORITY, or WORKORDER STATUS be sure to add color code as per already done in USER export @@ -1331,7 +1332,7 @@ namespace AyaNova.PlugIn.V8 d.serial = c.Serial; //MIGRATE_OUTSTANDING //fixup after workorders - // d.workorderItemLoanId= + // d.workorderItemLoanId= d.rateHour = c.RateHour; d.rateHalfDay = c.RateHalfDay; d.rateDay = c.RateDay; @@ -1339,7 +1340,7 @@ namespace AyaNova.PlugIn.V8 d.rateMonth = c.RateMonth; d.rateYear = c.RateYear; d.defaultRate = 1; - + TagFromv7Guid(c.RegionID, tags); SetTags(d, tags); @@ -2624,73 +2625,62 @@ namespace AyaNova.PlugIn.V8 progress.Op("Start ClientServiceRequests export"); progress.SubOp(""); var ObjectTypeName = "ClientServiceRequest"; - //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(ObjectTypeName); - bool ShouldExportCustom = ocf != null; - var DateCustomFields = await ExportCustomFieldSchema(ocf, ObjectTypeName, ObjectTypeName); + //Step 2: export the objects - PickListAutoComplete pl = PickListAutoComplete.GetList("**", "ClientServiceRequest"); + ClientServiceRequestList pl = ClientServiceRequestList.GetList(string.Empty); progress.Append("Exporting " + pl.Count.ToString() + " " + ObjectTypeName + "s"); - foreach (PickListAutoComplete.PickListAutoCompleteInfo i in pl) + foreach (ClientServiceRequestList.ClientServiceRequestListInfo i in pl) { if (!progress.KeepGoing) return; List tags = new List(); tags.Add(ImportTag); - ClientServiceRequest c = ClientServiceRequest.GetItem(i.ID); + ClientServiceRequest c = ClientServiceRequest.GetItem(i.LT_O_ClientServiceRequest.Value); var ObjectTID = new TypeAndID(RootObjectTypes.ClientServiceRequest, c.ID); dynamic d = new JObject(); - d.name = GetUniqueName(c.Name); - if (IsDuplicatev7v8IdMapItem(c.ID, c.Name, progress)) continue; + d.name = c.Title; progress.Op(ObjectTypeName + " " + d.name); - d.active = c.Active; - d.notes = c.Notes; - d.dateStarted = util.DateToV8(c.DateStarted, true); - d.dateCompleted = util.DateToV8(c.DateCompleted, false); - d.accountNumber = c.AccountNumber; - d.ClientServiceRequestOverseerId = SafeGetUserMap(c.ClientServiceRequestOverseerID); + if (!string.IsNullOrWhiteSpace(c.RequestedBy)) + d.notes = "Requested by " + c.RequestedBy + "\n" + c.Details; + else + d.notes = c.Details; + d.dateRequested = util.DateToV8(c.Created, true); + d.customerId = Getv7v8IdMap(c.ClientID, "Client for CSR"); + d.unitId = Getv7v8IdMapNullOk(c.UnitID); + d.workorderItemId = Getv7v8IdMapNullOk(c.WorkorderItemID); + d.requestedByUserId = 0;//this is a weird one because in v8 it will be a real user account and it's required in the schema so trying 0 + d.customerReferenceNumber = c.ClientRef; + d.priority = (int)c.Priority;//same int value + if (c.Status == ClientServiceRequestStatus.Closed) + { + //no closed status in v8 so either accepted or rejected based upon if it has a workorderitemid or not + if (c.WorkorderItemID == Guid.Empty) + + //no woitem id, but is closed so guessing rejected? + d.status = (int)ClientServiceRequestStatus.Declined; + + else + d.status = (int)ClientServiceRequestStatus.Accepted; + } + else + d.status = (int)c.Status; - TagFromv7Guid(c.RegionID, tags); SetTags(d, tags); - //Custom fields? - if (ShouldExportCustom) - d.customFields = CustomFieldData(c, DateCustomFields); + var rMainObject = await util.PostAsync("ClientServiceRequest", d.ToString()); long RavenId = util.IdFromResponse(rMainObject); - Addv7v8IdMap(c.ID, RavenId); + Addv7v8IdMap(c.ID, RavenId); - //Attachments / FILES - await ExportAttachments(ObjectTID, progress); - //----- - bool repost = false; - d = rMainObject.ObjectResponse["data"]; - // wiki - if (WikiPage.HasWiki(c.ID)) - { - // await ExportAttachments(ObjectTID, progress); - d.wiki = GetWikiContent(ObjectTID); - repost = true; - } - - //docs - string NonFileUrls = await ExportDocs(ObjectTID, c.Docs, progress); - if (!string.IsNullOrEmpty(NonFileUrls)) - { - d.notes = NonFileUrls + "\n-----------------\n" + d.notes; - repost = true; - } - if (repost) - await util.PutAsync("ClientServiceRequest", d.ToString()); //----- //Event log fixup - await util.EventLog(util.AyaType.ClientServiceRequest, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified); + await util.EventLog(util.AyaType.CustomerServiceRequest, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified); } }