From fade8562839779a93d36bbe435163b6c66a7c36d Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Sun, 3 May 2020 14:19:13 +0000 Subject: [PATCH] --- source/Plugins/AyaNova.Plugin.V8/V8.cs | 70 +++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index 5ae260c..c87509b 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -259,7 +259,7 @@ namespace AyaNova.PlugIn.V8 await ExportLoanItems(progress); await ExportParts(progress); await ExportProjects(progress); - //await ExportPurchaseOrders(progress); + await ExportPurchaseOrders(progress); //await ExportUnits(progress); //await ExportUnitModels(progress); //await ExportVendors(progress); @@ -881,6 +881,74 @@ namespace AyaNova.PlugIn.V8 } #endregion Projects + #region PurchaseOrders + private async System.Threading.Tasks.Task ExportPurchaseOrders(ProgressForm progress) + { + if (!progress.KeepGoing) return; + var ObjectTypeName = "PurchaseOrder"; + //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 + PurchaseOrderList pl = PurchaseOrderList.GetListByCriteria(""); + progress.Append("Exporting " + pl.Count.ToString() + " " + ObjectTypeName + "s"); + + foreach (PurchaseOrderList.PurchaseOrderListInfo i in pl) + { + if (!progress.KeepGoing) return; + List tags = new List(); + tags.Add(ImportTag); + + PurchaseOrder c = PurchaseOrder.GetItem(i.LT_PurchaseOrder_Label_PONumber.Value); + var ObjectTID = new TypeAndID(RootObjectTypes.PurchaseOrder, c.ID); + + dynamic d = new JObject(); + d.name = c.PONumber.ToString(); + progress.Op(ObjectTypeName + " " + d.name); + // d.active = c.Active; + d.notes = c.Notes; + // Tagit(c.RegionID, tags); + SetTags(d, tags); + + var hasWiki = WikiPage.HasWiki(c.ID); + if (hasWiki) + { + d.wiki = GetWikiContent(ObjectTID); + } + + //Custom fields? + if (ShouldExportCustom) + d.customFields = CustomFieldData(c, DateCustomFields); + + var rMainObject = await util.PostAsync(ObjectTypeName, d.ToString()); + long RavenId = util.IdFromResponse(rMainObject); + Map.Add(c.ID, RavenId); + + //Attachments / FILES + await ExportAttachments(ObjectTID, progress); + + ////docs + //string NonFileUrls = await ExportDocs(ObjectTID, c.Docs, progress); + //if (!string.IsNullOrEmpty(NonFileUrls)) + //{ + // //need to repost the object with the notes modified + // d = rMainObject.ObjectResponse["data"]; + // d.notes = NonFileUrls + "\n-----------------\n" + d.notes; + // await util.PutAsync(ObjectTypeName + "/" + RavenId.ToString(), d.ToString()); + //} + + //Event log fixup + await util.EventLog(util.AyaType.PurchaseOrder, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified); + + } + } + #endregion PurchaseOrders + + + + #region locales