From 6beba726753635a792aeb09a9416979e28f342af Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 8 Jan 2021 20:55:44 +0000 Subject: [PATCH] --- source/Plugins/AyaNova.Plugin.V8/V8.cs | 90 ++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index f6df30e..09457f5 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -2616,6 +2616,96 @@ namespace AyaNova.PlugIn.V8 + #region ClientServiceRequests + private async System.Threading.Tasks.Task ExportClientServiceRequests(ProgressForm progress) + { + ResetUniqueNames(); + if (!progress.KeepGoing) return; + 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"); + progress.Append("Exporting " + pl.Count.ToString() + " " + ObjectTypeName + "s"); + + foreach (PickListAutoComplete.PickListAutoCompleteInfo i in pl) + { + if (!progress.KeepGoing) return; + List tags = new List(); + tags.Add(ImportTag); + + ClientServiceRequest c = ClientServiceRequest.GetItem(i.ID); + 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; + 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); + + 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); + + //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); + + } + } + #endregion ClientServiceRequests + + //############################################################################################################### + //############################################################################################################### + //############################################################################################################### + //############################################################################################################### + //############################################################################################################### + //############################################################################################################### + + + + #region locales private async System.Threading.Tasks.Task ExportLocales(ProgressForm progress) {