This commit is contained in:
2021-08-09 22:26:23 +00:00
parent 4079002c1a
commit c6bc3a835a

View File

@@ -384,7 +384,8 @@ namespace AyaNova.PlugIn.V8
await ExportScheduleMarkers(progress); await ExportScheduleMarkers(progress);
//must be after all clients, ho, units and workorders //must be after all clients, ho, units and workorders
await ExportServiceBank(progress); //await ExportServiceBank(progress);//deprecated for v8 (so far)
await ExportClientServiceRequests(progress); await ExportClientServiceRequests(progress);
@@ -2260,8 +2261,41 @@ namespace AyaNova.PlugIn.V8
#endregion Memos #endregion Memos
//await (progress);//item and workorder both as split in v8 #region WorkOrderItemPriorities
//await ExportWorkOrderItemPriorities(progress); private async System.Threading.Tasks.Task ExportWorkOrderItemPriorities(ProgressForm progress)
{
if (!progress.KeepGoing) return;
progress.Op("Start WorkOrderItem Priority export");
progress.SubOp("");
var ObjectTypeName = "WorkorderItem Priority";
progress.Append("Exporting all "+ ObjectTypeName + " objects");
List<string> tags = new List<string>();
AddImportTag(tags);
Priorities w = Priorities.GetItems();
ResetUniqueNames();
foreach (Priority s in w)
{
if (!progress.KeepGoing) return;
dynamic d = new JObject();
d.name = GetUniqueName(s.Name);
progress.Op(ObjectTypeName + " " + d.name);
d.active = s.Active;
d.color = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(s.Color));
SetTags(d, tags);
var rMainObject = await util.PostAsync("work-order-item-priority", d.ToString());
long RavenId = util.IdFromResponse(rMainObject);
Addv7v8IdMap(s.ID, RavenId);
await util.EventLog(util.AyaType.WorkOrderItemPriority, RavenId, SafeGetUserMap(s.Creator), SafeGetUserMap(s.Modifier), s.Created, s.Modified);
}
//------
}
#endregion workorder priorities
#region WorkorderStatus #region WorkorderStatus
private async System.Threading.Tasks.Task ExportWorkorderStatus(ProgressForm progress) private async System.Threading.Tasks.Task ExportWorkorderStatus(ProgressForm progress)
{ {
@@ -2752,85 +2786,85 @@ namespace AyaNova.PlugIn.V8
#endregion ScheduleMarkers #endregion ScheduleMarkers
#region ServiceBank #region ServiceBank
private async System.Threading.Tasks.Task ExportServiceBank(ProgressForm progress) //private async System.Threading.Tasks.Task ExportServiceBank(ProgressForm progress)
{ //{
if (BankedObjects.Count == 0) return; // if (BankedObjects.Count == 0) return;
ResetUniqueNames(); // ResetUniqueNames();
if (!progress.KeepGoing) return; // if (!progress.KeepGoing) return;
progress.Op("Start Service Bank export"); // progress.Op("Start Service Bank export");
progress.SubOp(""); // progress.SubOp("");
var ObjectTypeName = "ServiceBank"; // var ObjectTypeName = "ServiceBank";
progress.Append("Exporting service bank records for " + BankedObjects.Count.ToString() + " banked objects"); // progress.Append("Exporting service bank records for " + BankedObjects.Count.ToString() + " banked objects");
foreach (var bo in BankedObjects) // foreach (var bo in BankedObjects)
{ // {
ServiceBankListRI pl = ServiceBankListRI.GetList(bo.Key, -1); // ServiceBankListRI pl = ServiceBankListRI.GetList(bo.Key, -1);
progress.Append("Exporting " + pl.Count.ToString() + " service bank records for object id " + bo.Key.ToString() + " type: " + bo.Value.ToString()); // progress.Append("Exporting " + pl.Count.ToString() + " service bank records for object id " + bo.Key.ToString() + " type: " + bo.Value.ToString());
//foreach (ServiceBankListRI.ServiceBankListRIInfo i in pl) // //foreach (ServiceBankListRI.ServiceBankListRIInfo i in pl)
//for (int x = 0; x < pl.Count; x++) // //for (int x = 0; x < pl.Count; x++)
//list is backwards order most recent first // //list is backwards order most recent first
bool FirstEntry = true; // bool FirstEntry = true;
for (int x = pl.Count - 1; x > -1; x--) // for (int x = pl.Count - 1; x > -1; x--)
{ // {
if (!progress.KeepGoing) return; // if (!progress.KeepGoing) return;
ServiceBankListRI.ServiceBankListRIInfo i = pl[x]; // ServiceBankListRI.ServiceBankListRIInfo i = pl[x];
dynamic d = new JObject(); // dynamic d = new JObject();
d.name = i.LT_ServiceBank_Label_Description; // d.name = i.LT_ServiceBank_Label_Description;
progress.Op(ObjectTypeName + " " + d.name); // progress.Op(ObjectTypeName + " " + d.name);
d.entryDate = util.DateToV8(i.LT_ServiceBank_Label_Created); // d.entryDate = util.DateToV8(i.LT_ServiceBank_Label_Created);
//Guid empty is valid, particularly if it's an adjustment for a deleted workorder or something // //Guid empty is valid, particularly if it's an adjustment for a deleted workorder or something
if (i.LT_ServiceBank_Label_SourceRootObjectType.Value == Guid.Empty) // if (i.LT_ServiceBank_Label_SourceRootObjectType.Value == Guid.Empty)
{ // {
d.sourceId = 0; // d.sourceId = 0;
} // }
else // else
{ // {
if (!V7ToV8IdMap.ContainsKey(i.LT_ServiceBank_Label_SourceRootObjectType.Value)) // if (!V7ToV8IdMap.ContainsKey(i.LT_ServiceBank_Label_SourceRootObjectType.Value))
{ // {
d.name = i.LT_ServiceBank_Label_Description + " v7-import: source object missing object id " + i.LT_ServiceBank_Label_SourceRootObjectType.Value.ToString() + " type: " + i.LT_ServiceBank_Label_SourceRootObjectType.RootObjectType.ToString(); // d.name = i.LT_ServiceBank_Label_Description + " v7-import: source object missing object id " + i.LT_ServiceBank_Label_SourceRootObjectType.Value.ToString() + " type: " + i.LT_ServiceBank_Label_SourceRootObjectType.RootObjectType.ToString();
} // }
else // else
{ // {
d.sourceId = Getv7v8IdMap(i.LT_ServiceBank_Label_SourceRootObjectType.Value, "Service bank record's source object id"); // d.sourceId = Getv7v8IdMap(i.LT_ServiceBank_Label_SourceRootObjectType.Value, "Service bank record's source object id");
} // }
} // }
// // //
d.sourceType = util.RootObjectToAyaType(i.LT_ServiceBank_Label_SourceRootObjectType.RootObjectType); // d.sourceType = util.RootObjectToAyaType(i.LT_ServiceBank_Label_SourceRootObjectType.RootObjectType);
d.objectId = Getv7v8IdMap(bo.Key, "Service bank record's root object id"); // d.objectId = Getv7v8IdMap(bo.Key, "Service bank record's root object id");
d.objectType = util.RootObjectToAyaType(bo.Value); // d.objectType = util.RootObjectToAyaType(bo.Value);
d.incidents = i.LT_ServiceBank_Label_Incidents; // d.incidents = i.LT_ServiceBank_Label_Incidents;
d.incidentsBalance = i.LT_ServiceBank_Label_IncidentsBalance; // d.incidentsBalance = i.LT_ServiceBank_Label_IncidentsBalance;
d.currency = i.LT_ServiceBank_Label_Currency; // d.currency = i.LT_ServiceBank_Label_Currency;
d.currencyBalance = i.LT_ServiceBank_Label_CurrencyBalance; // d.currencyBalance = i.LT_ServiceBank_Label_CurrencyBalance;
d.hours = i.LT_ServiceBank_Label_Hours; // d.hours = i.LT_ServiceBank_Label_Hours;
d.hoursBalance = i.LT_ServiceBank_Label_HoursBalance; // d.hoursBalance = i.LT_ServiceBank_Label_HoursBalance;
//Last values // //Last values
if (!FirstEntry) // if (!FirstEntry)
{ // {
ServiceBankListRI.ServiceBankListRIInfo iLast = pl[x + 1]; // ServiceBankListRI.ServiceBankListRIInfo iLast = pl[x + 1];
d.lastEntryDate = util.DateToV8(iLast.LT_ServiceBank_Label_Created); // d.lastEntryDate = util.DateToV8(iLast.LT_ServiceBank_Label_Created);
d.lastIncidentsBalance = iLast.LT_ServiceBank_Label_IncidentsBalance; // d.lastIncidentsBalance = iLast.LT_ServiceBank_Label_IncidentsBalance;
d.lastCurrencyBalance = iLast.LT_ServiceBank_Label_CurrencyBalance; // d.lastCurrencyBalance = iLast.LT_ServiceBank_Label_CurrencyBalance;
d.lastHoursBalance = iLast.LT_ServiceBank_Label_HoursBalance; // d.lastHoursBalance = iLast.LT_ServiceBank_Label_HoursBalance;
} // }
var rMainObject = await util.PostAsync("service-bank/migrate", d.ToString()); // var rMainObject = await util.PostAsync("service-bank/migrate", d.ToString());
long RavenId = util.IdFromResponse(rMainObject); // long RavenId = util.IdFromResponse(rMainObject);
// Addv7v8IdMap(i.ID, RavenId); // // Addv7v8IdMap(i.ID, RavenId);
//----- // //-----
//Event log fixup // //Event log fixup
ServiceBank sb = ServiceBank.GetItem(i.LT_ServiceBank_Label_ID); // ServiceBank sb = ServiceBank.GetItem(i.LT_ServiceBank_Label_ID);
await util.EventLog(util.AyaType.ServiceBank, RavenId, SafeGetUserMap(sb.Creator), SafeGetUserMap(sb.Creator), sb.Created, sb.Created); // await util.EventLog(util.AyaType.ServiceBank, RavenId, SafeGetUserMap(sb.Creator), SafeGetUserMap(sb.Creator), sb.Created, sb.Created);
FirstEntry = false; // FirstEntry = false;
} // }
} // }
} //}
#endregion ServiceBank #endregion ServiceBank