This commit is contained in:
2020-12-30 01:04:32 +00:00
parent fe12a1310f
commit 098f3390e3

View File

@@ -2424,50 +2424,65 @@ namespace AyaNova.PlugIn.V8
#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;
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");
foreach (var bo in BankedObjects)
//Step 2: export the objects
TaxCodes pl = TaxCodes.GetItems();
progress.Append("Exporting " + pl.Count.ToString() + " " + ObjectTypeName + "s");
foreach (TaxCode i in pl)
{ {
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());
//foreach (ServiceBankListRI.ServiceBankListRIInfo i in pl)
for (int x = 0; x < pl.Count; x++)
{
if (!progress.KeepGoing) return; if (!progress.KeepGoing) return;
List<string> tags = new List<string>(); ServiceBankListRI.ServiceBankListRIInfo i = pl[x];
tags.Add(ImportTag);
dynamic d = new JObject(); dynamic d = new JObject();
d.name = GetUniqueName(i.Name); d.name = i.LT_ServiceBank_Label_Description;
if (IsDuplicatev7v8IdMapItem(i.ID, i.Name, progress)) continue;
progress.Op(ObjectTypeName + " " + d.name); progress.Op(ObjectTypeName + " " + d.name);
d.active = i.Active; 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
d.sourceId = i.LT_ServiceBank_Label_SourceRootObjectType.Value == Guid.Empty ? 0 : 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.taxA = i.TaxA; d.objectId = Getv7v8IdMap(bo.Key, "Service bank record's root object id");
d.taxB = i.TaxB; d.objectType = util.RootObjectToAyaType(bo.Value);
d.taxOnTax = i.TaxOnTax; d.incidents = i.LT_ServiceBank_Label_Incidents;
d.incidentsBalance = i.LT_ServiceBank_Label_IncidentsBalance;
d.currency = i.LT_ServiceBank_Label_Currency;
d.currencyBalance = i.LT_ServiceBank_Label_CurrencyBalance;
d.hours = i.LT_ServiceBank_Label_Hours;
d.hoursBalance = i.LT_ServiceBank_Label_HoursBalance;
//Last values
if (x > 0)
{
ServiceBankListRI.ServiceBankListRIInfo iLast = pl[x - 1];
d.lastEntryDate = util.DateToV8(iLast.LT_ServiceBank_Label_Created);
d.lastIncidentsBalance = iLast.LT_ServiceBank_Label_IncidentsBalance;
d.lastCurrencyBalance = iLast.LT_ServiceBank_Label_CurrencyBalance;
d.lastHoursBalance = iLast.LT_ServiceBank_Label_HoursBalance;
}
SetTags(d, tags); var rMainObject = await util.PostAsync("service-bank", d.ToString());
var rMainObject = await util.PostAsync("tax-code", 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
await util.EventLog(util.AyaType.TaxCode, RavenId, SafeGetUserMap(i.Creator), SafeGetUserMap(i.Modifier), i.Created, i.Modified); 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);
} }
} }
}
#endregion ServiceBank #endregion ServiceBank