This commit is contained in:
2020-05-03 14:24:49 +00:00
parent fade856283
commit c678d4636c

View File

@@ -260,7 +260,7 @@ namespace AyaNova.PlugIn.V8
await ExportParts(progress);
await ExportProjects(progress);
await ExportPurchaseOrders(progress);
//await ExportUnits(progress);
await ExportUnits(progress);
//await ExportUnitModels(progress);
//await ExportVendors(progress);
//workorders once work out the actual objects and routes at server end
@@ -815,7 +815,6 @@ namespace AyaNova.PlugIn.V8
}
#endregion Parts
#region Projects
private async System.Threading.Tasks.Task ExportProjects(ProgressForm progress)
{
@@ -946,6 +945,70 @@ namespace AyaNova.PlugIn.V8
}
#endregion PurchaseOrders
#region Units
private async System.Threading.Tasks.Task ExportUnits(ProgressForm progress)
{
if (!progress.KeepGoing) return;
var ObjectTypeName = "Unit";
//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("**", "unit");
progress.Append("Exporting " + pl.Count.ToString() + " " + ObjectTypeName + "s");
foreach (PickListAutoComplete.PickListAutoCompleteInfo i in pl)
{
if (!progress.KeepGoing) return;
List<string> tags = new List<string>();
tags.Add(ImportTag);
Unit c = Unit.GetItem(i.ID);
var ObjectTID = new TypeAndID(RootObjectTypes.Unit, c.ID);
dynamic d = new JObject();
d.name = c.Serial;
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.Unit, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
}
}
#endregion Units