This commit is contained in:
2020-05-03 14:19:13 +00:00
parent fb1f8d32b4
commit fade856283

View File

@@ -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<string> tags = new List<string>();
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