diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index 99cfe33..2444e66 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -163,20 +163,26 @@ namespace AyaNova.PlugIn.V8 #endregion - private Dictionary Map = new Dictionary(); - private void AddMap(Guid v7id, long v8id) + //this holds all objects set to use banking + //so that as a final step the servicebank can iterate + //it and migrate (objects need to exist first in v8) + private Dictionary BankedObjects = new Dictionary(); + + + private Dictionary V7ToV8IdMap = new Dictionary(); + private void Addv7v8IdMap(Guid v7id, long v8id) { - if (Map.ContainsKey(v7id)) + if (V7ToV8IdMap.ContainsKey(v7id)) { throw new Exception("Error: AddMap - v7id already mapped previously, id is " + v7id.ToString()); } - else Map.Add(v7id, v8id); + else V7ToV8IdMap.Add(v7id, v8id); } - private bool IsDuplicateMapItem(Guid v7id, string name, ProgressForm progress) + private bool IsDuplicatev7v8IdMapItem(Guid v7id, string name, ProgressForm progress) { - if (Map.ContainsKey(v7id)) + if (V7ToV8IdMap.ContainsKey(v7id)) { progress.Append("DUPLICATE: " + name + " - has duplicate ID, not exported"); return true; @@ -184,20 +190,20 @@ namespace AyaNova.PlugIn.V8 return false; } - private long GetMap(Guid id, string details) + private long Getv7v8IdMap(Guid id, string details) { - if (!Map.ContainsKey(id)) + if (!V7ToV8IdMap.ContainsKey(id)) { throw new Exception("Error: GetMap (source id: " + id.ToString() + ") [" + details + "] - v7 Id not previously exported, missing or corrupted source data, export can not complete until fixed"); } - return Map[id]; + return V7ToV8IdMap[id]; } private long SafeGetUserMap(Guid id) { - if (!Map.ContainsKey(id)) return 1;//1=raven administrator account - return Map[id]; + if (!V7ToV8IdMap.ContainsKey(id)) return 1;//1=raven administrator account + return V7ToV8IdMap[id]; } private enum RavenUserType : int @@ -230,14 +236,14 @@ namespace AyaNova.PlugIn.V8 try { progress.Op("Preparing to export...."); - Map.Clear(); + V7ToV8IdMap.Clear(); TagMap.Clear(); LocaleMap.Clear(); //admin user (not exported but is there already) - Map.Add(User.AdministratorID, 1); + V7ToV8IdMap.Add(User.AdministratorID, 1); //not sure if this is a good idea or not because in some cases would want to know if something is unexpectedly empty but will see for now //Map.Add(Guid.Empty, 0); @@ -330,7 +336,8 @@ namespace AyaNova.PlugIn.V8 //Must be after all root objects due to followups await ExportScheduleMarkers(progress); - + //must be after all clients, ho, units and workorders + await ExportServiceBank(progress); //NOTE: when get to PRIORITY, or WORKORDER STATUS be sure to add color code as per already done in USER export @@ -477,7 +484,7 @@ namespace AyaNova.PlugIn.V8 dynamic d = new JObject(); d.name = GetUniqueName(c.FirstName + " " + c.LastName); - if (IsDuplicateMapItem(c.ID, c.FirstName + " " + c.LastName, progress)) continue; + if (IsDuplicatev7v8IdMapItem(c.ID, c.FirstName + " " + c.LastName, progress)) continue; progress.Op("User " + d.name); //throw new System.Exception("TODO: UserTypes sb done differently now to align"); //TODO: User type @@ -528,7 +535,7 @@ namespace AyaNova.PlugIn.V8 var rMainObject = await util.PostAsync("user", d.ToString()); long RavenId = util.IdFromResponse(rMainObject); - AddMap(c.ID, RavenId); + Addv7v8IdMap(c.ID, RavenId); //USER OPTIONS if (c.ScheduleBackColor != 0 || !string.IsNullOrWhiteSpace(c.EmailAddress)) @@ -636,7 +643,7 @@ namespace AyaNova.PlugIn.V8 dynamic d = new JObject(); d.name = GetUniqueName(c.FirstName + " " + c.LastName); - if (IsDuplicateMapItem(c.ID, c.FirstName + " " + c.LastName, progress)) continue; + if (IsDuplicatev7v8IdMapItem(c.ID, c.FirstName + " " + c.LastName, progress)) continue; progress.Op("User " + d.name); //throw new System.Exception("TODO: UserTypes sb done differently now to align"); //TODO: User type @@ -668,17 +675,17 @@ namespace AyaNova.PlugIn.V8 if (c.VendorID != Guid.Empty) { d.userType = RavenUserType.ServiceContractor; - d.vendorId = GetMap(c.VendorID, "Vendor for subcontractor User " + d.name); + d.vendorId = Getv7v8IdMap(c.VendorID, "Vendor for subcontractor User " + d.name); } if (c.ClientID != Guid.Empty) { - d.customerId = GetMap(c.ClientID, "Client for Client type User " + d.name); //Map[c.ClientID]; + d.customerId = Getv7v8IdMap(c.ClientID, "Client for Client type User " + d.name); //Map[c.ClientID]; } if (c.HeadOfficeID != Guid.Empty) { - d.headOfficeId = GetMap(c.HeadOfficeID, "Headoffice for HeadOffice type User " + d.name); //Map[c.HeadOfficeID]; + d.headOfficeId = Getv7v8IdMap(c.HeadOfficeID, "Headoffice for HeadOffice type User " + d.name); //Map[c.HeadOfficeID]; } @@ -707,7 +714,7 @@ namespace AyaNova.PlugIn.V8 var rMainObject = await util.PostAsync("user", d.ToString()); long RavenId = util.IdFromResponse(rMainObject); - AddMap(c.ID, RavenId); + Addv7v8IdMap(c.ID, RavenId); //USER OPTIONS if (c.ScheduleBackColor != 0 || !string.IsNullOrWhiteSpace(c.EmailAddress)) @@ -762,7 +769,7 @@ namespace AyaNova.PlugIn.V8 { if (!progress.KeepGoing) return; User c = User.GetItem(i.ID); - var newId = GetMap(c.ID, "User for event log synchro. " + c.FirstName + " " + c.LastName); //Map[c.ID]; + var newId = Getv7v8IdMap(c.ID, "User for event log synchro. " + c.FirstName + " " + c.LastName); //Map[c.ID]; var creator = SafeGetUserMap(c.Creator); var modifier = SafeGetUserMap(c.Modifier); @@ -846,7 +853,7 @@ namespace AyaNova.PlugIn.V8 */ dynamic d = new JObject(); d.name = GetUniqueName(c.Name); - if (IsDuplicateMapItem(c.ID, c.Name, progress)) continue; + if (IsDuplicatev7v8IdMapItem(c.ID, c.Name, progress)) continue; progress.Op(ObjectTypeName + " " + d.name); d.active = c.Active; d.notes = c.Notes; @@ -863,15 +870,17 @@ namespace AyaNova.PlugIn.V8 if (c.HeadOfficeID != Guid.Empty) { - d.headOfficeId = GetMap(c.HeadOfficeID, "HeadOffice for Client " + d.name); + d.headOfficeId = Getv7v8IdMap(c.HeadOfficeID, "HeadOffice for Client " + d.name); } d.techNotes = c.TechNotes; d.accountNumber = c.AccountNumber; d.usesBanking = c.UsesBanking; + if (c.UsesBanking) + BankedObjects.Add(c.ID, RootObjectTypes.Client); if (c.ContractID != Guid.Empty) { - d.contractId = GetMap(c.ContractID, "Contract for Client " + d.name); + d.contractId = Getv7v8IdMap(c.ContractID, "Contract for Client " + d.name); } d.contractExpires = c.ContractExpires;//?? dates //todo d.defaultServiceTemplateId = c.defaultservicetemplateid @@ -905,7 +914,7 @@ namespace AyaNova.PlugIn.V8 var rMainObject = await util.PostAsync("customer", d.ToString()); long RavenId = util.IdFromResponse(rMainObject); - AddMap(c.ID, RavenId); + Addv7v8IdMap(c.ID, RavenId); //Attachments / FILES await ExportAttachments(ObjectTID, progress); @@ -1049,7 +1058,7 @@ namespace AyaNova.PlugIn.V8 dynamic d = new JObject(); d.name = GetUniqueName(c.Name); - if (IsDuplicateMapItem(c.ID, c.Name, progress)) continue; + if (IsDuplicatev7v8IdMapItem(c.ID, c.Name, progress)) continue; progress.Op(ObjectTypeName + " " + d.name); d.active = c.Active; d.notes = c.Notes; @@ -1064,9 +1073,12 @@ namespace AyaNova.PlugIn.V8 d.accountNumber = c.AccountNumber; d.usesBanking = c.UsesBanking; + if (c.UsesBanking) + BankedObjects.Add(c.ID, RootObjectTypes.HeadOffice); + if (c.ContractID != Guid.Empty) { - d.contractId = GetMap(c.ContractID, "Contract for Head Office " + d.name); + d.contractId = Getv7v8IdMap(c.ContractID, "Contract for Head Office " + d.name); } d.contractExpires = c.ContractExpires;//?? dates @@ -1103,7 +1115,7 @@ namespace AyaNova.PlugIn.V8 var rMainObject = await util.PostAsync("head-office", d.ToString()); long RavenId = util.IdFromResponse(rMainObject); - AddMap(c.ID, RavenId); + Addv7v8IdMap(c.ID, RavenId); //Attachments / FILES await ExportAttachments(ObjectTID, progress); @@ -1207,7 +1219,7 @@ namespace AyaNova.PlugIn.V8 dynamic d = new JObject(); d.name = GetUniqueName(c.Name); - if (IsDuplicateMapItem(c.ID, c.Name, progress)) continue; + if (IsDuplicatev7v8IdMapItem(c.ID, c.Name, progress)) continue; progress.Op(ObjectTypeName + " " + d.name); d.active = c.Active; d.notes = c.Notes; @@ -1221,7 +1233,7 @@ namespace AyaNova.PlugIn.V8 var rMainObject = await util.PostAsync("contract", d.ToString()); long RavenId = util.IdFromResponse(rMainObject); - AddMap(c.ID, RavenId); + Addv7v8IdMap(c.ID, RavenId); //Attachments / FILES await ExportAttachments(ObjectTID, progress); @@ -1284,7 +1296,7 @@ namespace AyaNova.PlugIn.V8 dynamic d = new JObject(); d.name = GetUniqueName(c.Name); - if (IsDuplicateMapItem(c.ID, c.Name, progress)) continue; + if (IsDuplicatev7v8IdMapItem(c.ID, c.Name, progress)) continue; progress.Op(ObjectTypeName + " " + d.name); d.active = c.Active; d.notes = c.Notes; @@ -1297,7 +1309,7 @@ namespace AyaNova.PlugIn.V8 var rMainObject = await util.PostAsync("loan-unit", d.ToString()); long RavenId = util.IdFromResponse(rMainObject); - AddMap(c.ID, RavenId); + Addv7v8IdMap(c.ID, RavenId); //Attachments / FILES await ExportAttachments(ObjectTID, progress); @@ -1361,7 +1373,7 @@ namespace AyaNova.PlugIn.V8 dynamic d = new JObject(); d.name = GetUniqueName(i.DisplayName(AyaBizUtils.GlobalSettings.DefaultPartDisplayFormat));//todo: temporary for testing - if (IsDuplicateMapItem(c.ID, c.Name, progress)) continue; + if (IsDuplicatev7v8IdMapItem(c.ID, c.Name, progress)) continue; progress.Op(ObjectTypeName + " " + d.name); d.active = c.Active; d.notes = c.Notes; @@ -1375,7 +1387,7 @@ namespace AyaNova.PlugIn.V8 var rMainObject = await util.PostAsync("part", d.ToString()); long RavenId = util.IdFromResponse(rMainObject); - AddMap(c.ID, RavenId); + Addv7v8IdMap(c.ID, RavenId); //Attachments / FILES await ExportAttachments(ObjectTID, progress); @@ -1437,7 +1449,7 @@ namespace AyaNova.PlugIn.V8 dynamic d = new JObject(); d.name = GetUniqueName(c.Name); - if (IsDuplicateMapItem(c.ID, c.Name, progress)) continue; + if (IsDuplicatev7v8IdMapItem(c.ID, c.Name, progress)) continue; progress.Op(ObjectTypeName + " " + d.name); d.active = c.Active; d.notes = c.Notes; @@ -1456,7 +1468,7 @@ namespace AyaNova.PlugIn.V8 var rMainObject = await util.PostAsync("project", d.ToString()); long RavenId = util.IdFromResponse(rMainObject); - AddMap(c.ID, RavenId); + Addv7v8IdMap(c.ID, RavenId); //Attachments / FILES await ExportAttachments(ObjectTID, progress); @@ -1516,7 +1528,7 @@ namespace AyaNova.PlugIn.V8 dynamic d = new JObject(); d.name = c.PONumber.ToString(); - if (IsDuplicateMapItem(c.ID, i.LT_PurchaseOrder_Label_PONumber.Display, progress)) continue; + if (IsDuplicatev7v8IdMapItem(c.ID, i.LT_PurchaseOrder_Label_PONumber.Display, progress)) continue; progress.Op(ObjectTypeName + " " + d.name); // d.active = c.Active; d.notes = c.Notes; @@ -1529,7 +1541,7 @@ namespace AyaNova.PlugIn.V8 var rMainObject = await util.PostAsync("purchase-order", d.ToString()); long RavenId = util.IdFromResponse(rMainObject); - AddMap(c.ID, RavenId); + Addv7v8IdMap(c.ID, RavenId); //Attachments / FILES await ExportAttachments(ObjectTID, progress); @@ -1586,20 +1598,23 @@ namespace AyaNova.PlugIn.V8 dynamic d = new JObject(); d.name = GetUniqueName(c.Serial); - if (IsDuplicateMapItem(c.ID, c.Serial, progress)) continue; + if (IsDuplicatev7v8IdMapItem(c.ID, c.Serial, progress)) continue; progress.Op(ObjectTypeName + " " + d.name); d.active = c.Active; d.notes = c.Notes; // Tagit(c.RegionID, tags); SetTags(d, tags); + if (c.UsesBanking) + BankedObjects.Add(c.ID, RootObjectTypes.Unit); + //Custom fields? if (ShouldExportCustom) d.customFields = CustomFieldData(c, DateCustomFields); var rMainObject = await util.PostAsync("unit", d.ToString()); long RavenId = util.IdFromResponse(rMainObject); - AddMap(c.ID, RavenId); + Addv7v8IdMap(c.ID, RavenId); //Attachments / FILES await ExportAttachments(ObjectTID, progress); @@ -1664,7 +1679,7 @@ namespace AyaNova.PlugIn.V8 dynamic d = new JObject(); d.name = GetUniqueName(c.Name); - if (IsDuplicateMapItem(c.ID, c.Name, progress)) continue; + if (IsDuplicatev7v8IdMapItem(c.ID, c.Name, progress)) continue; progress.Op(ObjectTypeName + " " + d.name); d.active = c.Active; d.notes = c.Notes; @@ -1678,7 +1693,7 @@ namespace AyaNova.PlugIn.V8 var rMainObject = await util.PostAsync("unit-model", d.ToString()); long RavenId = util.IdFromResponse(rMainObject); - AddMap(c.ID, RavenId); + Addv7v8IdMap(c.ID, RavenId); //Attachments / FILES await ExportAttachments(ObjectTID, progress); @@ -1739,7 +1754,7 @@ namespace AyaNova.PlugIn.V8 dynamic d = new JObject(); d.name = GetUniqueName(c.Name); - if (IsDuplicateMapItem(c.ID, c.Name, progress)) continue; + if (IsDuplicatev7v8IdMapItem(c.ID, c.Name, progress)) continue; progress.Op(ObjectTypeName + " " + d.name); d.active = c.Active; @@ -1794,7 +1809,7 @@ namespace AyaNova.PlugIn.V8 var rMainObject = await util.PostAsync("vendor", d.ToString()); long RavenId = util.IdFromResponse(rMainObject); - AddMap(c.ID, RavenId); + Addv7v8IdMap(c.ID, RavenId); //Attachments / FILES await ExportAttachments(ObjectTID, progress); @@ -1852,7 +1867,7 @@ namespace AyaNova.PlugIn.V8 dynamic d = new JObject(); d.name = GetUniqueName(i.Name); - if (IsDuplicateMapItem(i.ID, i.Name, progress)) continue; + if (IsDuplicatev7v8IdMapItem(i.ID, i.Name, progress)) continue; progress.Op(ObjectTypeName + " " + d.name); d.active = i.Active; d.notes = i.Description; @@ -1881,7 +1896,7 @@ namespace AyaNova.PlugIn.V8 var rMainObject = await util.PostAsync(route, d.ToString()); long RavenId = util.IdFromResponse(rMainObject); - AddMap(i.ID, RavenId); + Addv7v8IdMap(i.ID, RavenId); //----- @@ -1907,7 +1922,7 @@ namespace AyaNova.PlugIn.V8 TaxCodes pl = TaxCodes.GetItems(); progress.Append("Exporting " + pl.Count.ToString() + " " + ObjectTypeName + "s"); - + foreach (TaxCode i in pl) { @@ -1917,20 +1932,20 @@ namespace AyaNova.PlugIn.V8 dynamic d = new JObject(); d.name = GetUniqueName(i.Name); - if (IsDuplicateMapItem(i.ID, i.Name, progress)) continue; + if (IsDuplicatev7v8IdMapItem(i.ID, i.Name, progress)) continue; progress.Op(ObjectTypeName + " " + d.name); d.active = i.Active; - + d.taxA = i.TaxA; d.taxB = i.TaxB; d.taxOnTax = i.TaxOnTax; SetTags(d, tags); - + var rMainObject = await util.PostAsync("tax-code", d.ToString()); long RavenId = util.IdFromResponse(rMainObject); - AddMap(i.ID, RavenId); + Addv7v8IdMap(i.ID, RavenId); //----- @@ -1941,8 +1956,7 @@ namespace AyaNova.PlugIn.V8 } } #endregion Tax codes - - + #region Memos private async System.Threading.Tasks.Task ExportMemos(ProgressForm progress) { @@ -2029,7 +2043,7 @@ namespace AyaNova.PlugIn.V8 tags.Add(ImportTag); Workorder c = Workorder.GetItem(i.LT_O_Workorder.Value); - if (IsDuplicateMapItem(c.ID, c.WorkorderService.ServiceNumber.ToString(), progress)) continue; + if (IsDuplicatev7v8IdMapItem(c.ID, c.WorkorderService.ServiceNumber.ToString(), progress)) continue; var ObjectTID = new TypeAndID(RootObjectTypes.WorkorderService, c.ID); @@ -2045,7 +2059,7 @@ namespace AyaNova.PlugIn.V8 var rMainObject = await util.PostAsync("workorder", d.ToString()); long RavenId = util.IdFromResponse(rMainObject); - AddMap(c.ID, RavenId); + Addv7v8IdMap(c.ID, RavenId); d = rMainObject.ObjectResponse["data"]; d.serial = c.WorkorderService.ServiceNumber; d.notes = c.Summary; @@ -2137,12 +2151,12 @@ namespace AyaNova.PlugIn.V8 tags.Add(ImportTag); Workorder c = Workorder.GetItem(i.LT_O_WorkorderQuote.Value); - if (IsDuplicateMapItem(c.ID, c.WorkorderQuote.QuoteNumber.ToString(), progress)) continue; + if (IsDuplicatev7v8IdMapItem(c.ID, c.WorkorderQuote.QuoteNumber.ToString(), progress)) continue; var ObjectTID = new TypeAndID(RootObjectTypes.WorkorderQuote, c.ID); //make one on the server to update var rMainObject = await util.PostAsync("quote" + "/Create?serial=" + c.WorkorderQuote.QuoteNumber); long RavenId = util.IdFromResponse(rMainObject); - AddMap(c.ID, RavenId); + Addv7v8IdMap(c.ID, RavenId); dynamic d = new JObject(); d.concurrency = util.CTokenFromResponse(rMainObject); @@ -2217,12 +2231,12 @@ namespace AyaNova.PlugIn.V8 tags.Add(ImportTag); Workorder c = Workorder.GetItem(i.LT_O_WorkorderPreventiveMaintenance.Value); - if (IsDuplicateMapItem(c.ID, c.WorkorderPreventiveMaintenance.PreventiveMaintenanceNumber.ToString(), progress)) continue; + if (IsDuplicatev7v8IdMapItem(c.ID, c.WorkorderPreventiveMaintenance.PreventiveMaintenanceNumber.ToString(), progress)) continue; var ObjectTID = new TypeAndID(RootObjectTypes.WorkorderPreventiveMaintenance, c.ID); //make one on the server to update var rMainObject = await util.PostAsync("pm" + "/Create?serial=" + c.WorkorderPreventiveMaintenance.PreventiveMaintenanceNumber); long RavenId = util.IdFromResponse(rMainObject); - AddMap(c.ID, RavenId); + Addv7v8IdMap(c.ID, RavenId); dynamic d = new JObject(); d.concurrency = util.CTokenFromResponse(rMainObject); @@ -2302,7 +2316,7 @@ namespace AyaNova.PlugIn.V8 dynamic d = new JObject(); //It's a Review / followup tied to another object that should have already been migrated - if (!Map.ContainsKey(c.FollowID)) + if (!V7ToV8IdMap.ContainsKey(c.FollowID)) { progress.Append("FollowUp target missing; skipping export: ID " + c.ID.ToString() + ",targetid " + c.FollowID.ToString() + ",type " + c.FollowType.ToString()); continue; @@ -2311,7 +2325,7 @@ namespace AyaNova.PlugIn.V8 //export //FollowUps only ever apply to a single user in v7 so no need to split them out here it's just for one user - if (!Map.ContainsKey(c.SourceID)) + if (!V7ToV8IdMap.ContainsKey(c.SourceID)) { progress.Append("FollowUp User missing; skipping export: UserID " + c.SourceID.ToString()); continue; @@ -2349,15 +2363,15 @@ namespace AyaNova.PlugIn.V8 d.name = c.Name; d.notes = c.Notes; - d.userId = Map[c.SourceID]; + d.userId = V7ToV8IdMap[c.SourceID]; d.assignedByUserId = SafeGetUserMap(c.Creator); - d.objectId = Map[c.FollowID]; + d.objectId = V7ToV8IdMap[c.FollowID]; d.objectType = util.RootObjectToAyaType(c.FollowType); SetTags(d, tags); progress.Op("FollowUp " + c.ID.ToString()); var rMainObject = await util.PostAsync("review", d.ToString()); long RavenId = util.IdFromResponse(rMainObject); - AddMap(c.ID, RavenId); + Addv7v8IdMap(c.ID, RavenId); await util.EventLog(util.AyaType.Review, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified); } else @@ -2378,7 +2392,7 @@ namespace AyaNova.PlugIn.V8 List tags = new List(); tags.Add(ImportTag); dynamic d = new JObject(); - if (!Map.ContainsKey(gUserId)) + if (!V7ToV8IdMap.ContainsKey(gUserId)) { progress.Append("ScheduleMarker User missing; skipping export: UserID " + c.SourceID.ToString()); continue; @@ -2390,7 +2404,7 @@ namespace AyaNova.PlugIn.V8 d.name = c.Name; d.notes = c.Notes; - d.userId = Map[gUserId]; + d.userId = V7ToV8IdMap[gUserId]; d.startDate = sStartDate; d.stopDate = sStopDate; d.color = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(c.ARGB)); @@ -2398,8 +2412,8 @@ namespace AyaNova.PlugIn.V8 progress.Op("ScheduleMarker " + c.ID.ToString()); var rMainObject = await util.PostAsync("reminder", d.ToString()); long RavenId = util.IdFromResponse(rMainObject); - if (!Map.ContainsKey(c.ID)) - AddMap(c.ID, RavenId); + if (!V7ToV8IdMap.ContainsKey(c.ID)) + Addv7v8IdMap(c.ID, RavenId); await util.EventLog(util.AyaType.Review, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified); } } @@ -2407,6 +2421,56 @@ namespace AyaNova.PlugIn.V8 } #endregion ScheduleMarkers + #region ServiceBank + private async System.Threading.Tasks.Task ExportServiceBank(ProgressForm progress) + { + ResetUniqueNames(); + if (!progress.KeepGoing) return; + progress.Op("Start Service Bank export"); + progress.SubOp(""); + var ObjectTypeName = "ServiceBank"; + + + //Step 2: export the objects + TaxCodes pl = TaxCodes.GetItems(); + progress.Append("Exporting " + pl.Count.ToString() + " " + ObjectTypeName + "s"); + + + + foreach (TaxCode i in pl) + { + if (!progress.KeepGoing) return; + List tags = new List(); + tags.Add(ImportTag); + + dynamic d = new JObject(); + d.name = GetUniqueName(i.Name); + if (IsDuplicatev7v8IdMapItem(i.ID, i.Name, progress)) continue; + progress.Op(ObjectTypeName + " " + d.name); + d.active = i.Active; + + d.taxA = i.TaxA; + d.taxB = i.TaxB; + d.taxOnTax = i.TaxOnTax; + + SetTags(d, tags); + + + var rMainObject = await util.PostAsync("tax-code", d.ToString()); + long RavenId = util.IdFromResponse(rMainObject); + Addv7v8IdMap(i.ID, RavenId); + + + //----- + + //Event log fixup + await util.EventLog(util.AyaType.TaxCode, RavenId, SafeGetUserMap(i.Creator), SafeGetUserMap(i.Modifier), i.Created, i.Modified); + + } + } + #endregion ServiceBank + + #region locales private async System.Threading.Tasks.Task ExportLocales(ProgressForm progress) @@ -3047,7 +3111,7 @@ namespace AyaNova.PlugIn.V8 if (af == null) continue; progress.SubOp("Wikifile: \"" + af.Name + "\" " + AyaBizUtils.FileSizeDisplay((decimal)af.FileSize)); - if (IsDuplicateMapItem(i.LT_O_AyaFile.Value, i.LT_O_AyaFile.Display, progress)) continue; + if (IsDuplicatev7v8IdMapItem(i.LT_O_AyaFile.Value, i.LT_O_AyaFile.Display, progress)) continue; //Compile the FileData property var sDate = i.LT_Common_Label_Created.ToString(); DateTimeOffset dtLastModified = DateTime.UtcNow; @@ -3079,7 +3143,7 @@ namespace AyaNova.PlugIn.V8 formDataContent.Add(new StringContent(RavenTypeAsString), name: "AttachToObjectType"); //formDataContent.Add(new StringContent(Map[tid.ID].ToString()), name: "AttachToObjectId"); - formDataContent.Add(new StringContent(GetMap(tid.ID, "Object ID for attachment export (tid:" + tid.ToString() + ") ").ToString()), name: "AttachToObjectId"); + formDataContent.Add(new StringContent(Getv7v8IdMap(tid.ID, "Object ID for attachment export (tid:" + tid.ToString() + ") ").ToString()), name: "AttachToObjectId"); formDataContent.Add(new StringContent(ImportTag), name: "Notes"); formDataContent.Add(new StringContent(dFileData.ToString()), name: "FileData"); @@ -3113,7 +3177,7 @@ namespace AyaNova.PlugIn.V8 if (oId > ravenId) ravenId = oId; } - AddMap(af.ID, ravenId); + Addv7v8IdMap(af.ID, ravenId); } progress.SubOp(""); @@ -3176,7 +3240,7 @@ namespace AyaNova.PlugIn.V8 RavenTypeAsString = ((int)util.RootObjectToAyaType(tid.RootObjectType)).ToString(); formDataContent.Add(new StringContent(RavenTypeAsString), name: "AttachToObjectType"); // formDataContent.Add(new StringContent(Map[tid.ID].ToString()), name: "AttachToObjectId"); - formDataContent.Add(new StringContent(GetMap(tid.ID, "Object ID for attached docs export (tid:" + tid.ToString() + ") ").ToString()), name: "AttachToObjectId"); + formDataContent.Add(new StringContent(Getv7v8IdMap(tid.ID, "Object ID for attached docs export (tid:" + tid.ToString() + ") ").ToString()), name: "AttachToObjectId"); @@ -3222,7 +3286,7 @@ namespace AyaNova.PlugIn.V8 MatchCollection mc = AyaBizUtils.rxAyaImageTags.Matches(content); foreach (Match m in mc) { - var RavenId = GetMap(new Guid(m.Groups["guid"].Value), "Object id for Wiki export (tid:" + tid.ToString() + ")"); //Map[new Guid(m.Groups["guid"].Value)]; + var RavenId = Getv7v8IdMap(new Guid(m.Groups["guid"].Value), "Object id for Wiki export (tid:" + tid.ToString() + ")"); //Map[new Guid(m.Groups["guid"].Value)]; content = content.Replace(m.Value, ""); }