This commit is contained in:
@@ -272,7 +272,7 @@ namespace AyaNova.PlugIn.V8
|
||||
await ExportUnits(progress);
|
||||
await ExportUnitModels(progress);
|
||||
await ExportVendors(progress);
|
||||
//workorders once work out the actual objects and routes at server end
|
||||
await ExportServiceWorkorders(progress);
|
||||
|
||||
|
||||
|
||||
@@ -1248,6 +1248,86 @@ namespace AyaNova.PlugIn.V8
|
||||
}
|
||||
#endregion Vendors
|
||||
|
||||
#region Service Workorders
|
||||
private async System.Threading.Tasks.Task ExportServiceWorkorders(ProgressForm progress)
|
||||
{
|
||||
if (!progress.KeepGoing) return;
|
||||
var ObjectTypeName = "Workorder";
|
||||
var RavenObjectName = "WorkOrder";
|
||||
//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("WorkorderItem");
|
||||
bool ShouldExportCustom = ocf != null;
|
||||
var DateCustomFields = await ExportCustomFieldSchema(ocf, "WorkorderItem", "WorkorderItem");
|
||||
|
||||
//Step 2: export the objects
|
||||
WorkorderServiceList pl = WorkorderServiceList.GetList("");
|
||||
progress.Append("Exporting " + pl.Count.ToString() + " Service " + ObjectTypeName + "s");
|
||||
|
||||
foreach (WorkorderServiceList.WorkorderServiceListInfo i in pl)
|
||||
{
|
||||
if (!progress.KeepGoing) return;
|
||||
List<string> tags = new List<string>();
|
||||
tags.Add(ImportTag);
|
||||
|
||||
Workorder c = Workorder.GetItem(i.LT_O_Workorder.Value);
|
||||
var ObjectTID = new TypeAndID(RootObjectTypes.WorkorderService, c.ID);
|
||||
//make one on the server to update
|
||||
var rMainObject = await util.PostAsync(RavenObjectName+"/Create?serial="+c.WorkorderService.ServiceNumber);
|
||||
long RavenId = util.IdFromResponse(rMainObject);
|
||||
Map.Add(c.ID, RavenId);
|
||||
|
||||
dynamic d = new JObject();
|
||||
d.concurrencyToken = util.CTokenFromResponse(rMainObject);
|
||||
progress.Op(ObjectTypeName + " " + c.WorkorderService.ServiceNumber);
|
||||
d.active = true;//probably can remove this at server, just stubbed in for now
|
||||
|
||||
Tagit(c.RegionID, tags);
|
||||
SetTags(d, tags);
|
||||
|
||||
////Custom fields?
|
||||
//if (ShouldExportCustom)
|
||||
// d.customFields = CustomFieldData(c, DateCustomFields);
|
||||
|
||||
// var rMainObject = await util.PostAsync(RavenObjectName, d.ToString());
|
||||
|
||||
|
||||
//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))
|
||||
{
|
||||
//need to repost the user with the notes modified
|
||||
|
||||
d.login = null;
|
||||
d.password = null;
|
||||
d.notes = NonFileUrls + "\n-----------------\n" + d.notes;
|
||||
repost = true;
|
||||
}
|
||||
if (repost)
|
||||
await util.PutAsync(RavenObjectName + "/" + RavenId.ToString(), d.ToString());
|
||||
//-----
|
||||
|
||||
//Event log fixup
|
||||
await util.EventLog(util.AyaType.WorkOrder, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified);
|
||||
|
||||
}
|
||||
}
|
||||
#endregion Workorders
|
||||
|
||||
|
||||
|
||||
|
||||
#region locales
|
||||
|
||||
Reference in New Issue
Block a user