This commit is contained in:
@@ -206,12 +206,8 @@ namespace AyaNova.PlugIn.V8
|
||||
TODO:
|
||||
FINISH THIS BLOCK TO BIG TEST
|
||||
|
||||
currently it *will* export all attachments on workorders and still needs quote and pm to complete the list
|
||||
|
||||
Also the unique name thing should really be added or it will likely run into trouble
|
||||
|
||||
Keep list of names for each object of type and check against it to prevent dupes and adjust name before export
|
||||
- Just do it for all because who knows what fucked up data people will be coming from
|
||||
Quote
|
||||
PM
|
||||
|
||||
Global wiki export to user
|
||||
Regions export wiki to user
|
||||
@@ -283,8 +279,8 @@ namespace AyaNova.PlugIn.V8
|
||||
await ExportUnitModels(progress);
|
||||
await ExportVendors(progress);
|
||||
await ExportServiceWorkorders(progress);
|
||||
|
||||
|
||||
await ExportQuotes(progress);
|
||||
await ExportPMs(progress);
|
||||
|
||||
|
||||
//NOTE: when get to PRIORITY, or WORKORDER STATUS be sure to add color code as per already done in USER export
|
||||
@@ -1300,10 +1296,12 @@ namespace AyaNova.PlugIn.V8
|
||||
progress.SubOp("");
|
||||
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");
|
||||
|
||||
//TODO: this in the workorder Items loop
|
||||
////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("");
|
||||
@@ -1374,7 +1372,171 @@ namespace AyaNova.PlugIn.V8
|
||||
}
|
||||
#endregion Workorders
|
||||
|
||||
#region Quote Workorders
|
||||
private async System.Threading.Tasks.Task ExportQuotes(ProgressForm progress)
|
||||
{
|
||||
if (!progress.KeepGoing) return;
|
||||
progress.Op("Start Quote export");
|
||||
progress.SubOp("");
|
||||
var ObjectTypeName = "Quote";
|
||||
var RavenObjectName = "Quote";
|
||||
//TODO: this in the workorder Items loop
|
||||
////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
|
||||
WorkorderQuoteList pl = WorkorderQuoteList.GetList("");
|
||||
progress.Append("Exporting " + pl.Count.ToString() + " " + ObjectTypeName + "s");
|
||||
|
||||
foreach (WorkorderQuoteList.WorkorderQuoteListInfo i in pl)
|
||||
{
|
||||
if (!progress.KeepGoing) return;
|
||||
List<string> tags = new List<string>();
|
||||
tags.Add(ImportTag);
|
||||
|
||||
Workorder c = Workorder.GetItem(i.LT_O_WorkorderQuote.Value);
|
||||
var ObjectTID = new TypeAndID(RootObjectTypes.WorkorderQuote, c.ID);
|
||||
//make one on the server to update
|
||||
var rMainObject = await util.PostAsync(RavenObjectName + "/Create?serial=" + c.WorkorderQuote.QuoteNumber);
|
||||
long RavenId = util.IdFromResponse(rMainObject);
|
||||
Map.Add(c.ID, RavenId);
|
||||
|
||||
dynamic d = new JObject();
|
||||
d.concurrencyToken = util.CTokenFromResponse(rMainObject);
|
||||
progress.Op(ObjectTypeName + " " + c.WorkorderQuote.QuoteNumber);
|
||||
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, util.AyaType.Quote);
|
||||
|
||||
//-----
|
||||
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, util.AyaType.Quote);
|
||||
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);
|
||||
|
||||
//todo: workorder items etc
|
||||
}
|
||||
}
|
||||
#endregion Quotes
|
||||
|
||||
#region PM Workorders
|
||||
private async System.Threading.Tasks.Task ExportPMs(ProgressForm progress)
|
||||
{
|
||||
if (!progress.KeepGoing) return;
|
||||
progress.Op("Start Preventive Maintenance export");
|
||||
progress.SubOp("");
|
||||
var ObjectTypeName = "Preventive Maintenance";
|
||||
var RavenObjectName = "PM";
|
||||
//TODO: this in the workorder Items loop
|
||||
////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
|
||||
WorkorderPMList pl = WorkorderPMList.GetList("");
|
||||
progress.Append("Exporting " + pl.Count.ToString() + " Service " + ObjectTypeName + "s");
|
||||
|
||||
foreach (WorkorderPMList.WorkorderPMListInfo i in pl)
|
||||
{
|
||||
if (!progress.KeepGoing) return;
|
||||
List<string> tags = new List<string>();
|
||||
tags.Add(ImportTag);
|
||||
|
||||
Workorder c = Workorder.GetItem(i.LT_O_WorkorderPreventiveMaintenance.Value);
|
||||
var ObjectTID = new TypeAndID(RootObjectTypes.WorkorderPreventiveMaintenance, c.ID);
|
||||
//make one on the server to update
|
||||
var rMainObject = await util.PostAsync(RavenObjectName + "/Create?serial=" + c.WorkorderPreventiveMaintenance.PreventiveMaintenanceNumber);
|
||||
long RavenId = util.IdFromResponse(rMainObject);
|
||||
Map.Add(c.ID, RavenId);
|
||||
|
||||
dynamic d = new JObject();
|
||||
d.concurrencyToken = util.CTokenFromResponse(rMainObject);
|
||||
progress.Op(ObjectTypeName + " " + c.WorkorderPreventiveMaintenance.PreventiveMaintenanceNumber);
|
||||
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, util.AyaType.PM);
|
||||
|
||||
//-----
|
||||
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, util.AyaType.PM);
|
||||
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);
|
||||
|
||||
//todo: workorder items etc
|
||||
}
|
||||
}
|
||||
#endregion PM Workorders
|
||||
|
||||
|
||||
#region locales
|
||||
|
||||
Reference in New Issue
Block a user