From a30ac95be621b2f7e0a02422384ffcbf4fadf3b8 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 4 May 2020 18:02:47 +0000 Subject: [PATCH] --- source/Plugins/AyaNova.Plugin.V8/V8.cs | 75 ++++++++++++++++---------- 1 file changed, 48 insertions(+), 27 deletions(-) diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index ec26b9b..dfe8eee 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -326,9 +326,10 @@ namespace AyaNova.PlugIn.V8 #region BIZ OBJECT Export methods List UsedNames = new List(); long LUniqueName = 1; - private string GetUniqueName(string tryName) { - - string retName=tryName; + private string GetUniqueName(string tryName) + { + + string retName = tryName; do { if (!UsedNames.Contains(retName)) @@ -338,7 +339,7 @@ namespace AyaNova.PlugIn.V8 } retName = util.UniqueNameBuilder(tryName, LUniqueName++, 255); } while (true); - + } private void ResetUniqueNames() @@ -419,7 +420,7 @@ namespace AyaNova.PlugIn.V8 var ObjectTID = new TypeAndID(RootObjectTypes.User, c.ID); dynamic d = new JObject(); - d.name =GetUniqueName(c.FirstName + " " + c.LastName); + d.name = GetUniqueName(c.FirstName + " " + c.LastName); progress.Op("User " + d.name); d.userType = (int)c.UserType; @@ -534,6 +535,7 @@ namespace AyaNova.PlugIn.V8 private async System.Threading.Tasks.Task ExportClients(ProgressForm progress) { if (!progress.KeepGoing) return; + ResetUniqueNames(); var ObjectTypeName = "Client"; //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(ObjectTypeName); @@ -554,7 +556,7 @@ namespace AyaNova.PlugIn.V8 var ObjectTID = new TypeAndID(RootObjectTypes.Client, c.ID); dynamic d = new JObject(); - d.name = c.Name; + d.name = GetUniqueName(c.Name); progress.Op(ObjectTypeName + " " + d.name); d.active = c.Active; d.notes = c.Notes; @@ -612,6 +614,7 @@ namespace AyaNova.PlugIn.V8 private async System.Threading.Tasks.Task ExportHeadOffices(ProgressForm progress) { if (!progress.KeepGoing) return; + ResetUniqueNames(); var ObjectTypeName = "HeadOffice"; //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(ObjectTypeName); @@ -633,7 +636,7 @@ namespace AyaNova.PlugIn.V8 var ObjectTID = new TypeAndID(RootObjectTypes.HeadOffice, c.ID); dynamic d = new JObject(); - d.name = c.Name; + d.name = GetUniqueName(c.Name); progress.Op(ObjectTypeName + " " + d.name); d.active = c.Active; d.notes = c.Notes; @@ -689,6 +692,7 @@ namespace AyaNova.PlugIn.V8 #region Contracts private async System.Threading.Tasks.Task ExportContracts(ProgressForm progress) { + ResetUniqueNames(); if (!progress.KeepGoing) return; var ObjectTypeName = "Contract"; //Step 1: export the CustomFields to FormCustom if applicable so that when doing individual items we can export their custom data too @@ -710,7 +714,7 @@ namespace AyaNova.PlugIn.V8 var ObjectTID = new TypeAndID(RootObjectTypes.Contract, c.ID); dynamic d = new JObject(); - d.name = c.Name; + d.name = GetUniqueName(c.Name); progress.Op(ObjectTypeName + " " + d.name); d.active = c.Active; d.notes = c.Notes; @@ -765,6 +769,7 @@ namespace AyaNova.PlugIn.V8 #region LoanItems private async System.Threading.Tasks.Task ExportLoanItems(ProgressForm progress) { + ResetUniqueNames(); if (!progress.KeepGoing) return; var ObjectTypeName = "LoanItem"; var RavenObjectName = "LoanUnit"; @@ -787,7 +792,7 @@ namespace AyaNova.PlugIn.V8 var ObjectTID = new TypeAndID(RootObjectTypes.LoanItem, c.ID); dynamic d = new JObject(); - d.name = c.Name; + d.name = GetUniqueName(c.Name); progress.Op(ObjectTypeName + " " + d.name); d.active = c.Active; d.notes = c.Notes; @@ -841,6 +846,7 @@ namespace AyaNova.PlugIn.V8 #region Parts private async System.Threading.Tasks.Task ExportParts(ProgressForm progress) { + ResetUniqueNames(); if (!progress.KeepGoing) return; var ObjectTypeName = "Part"; var RavenObjectName = "Part"; @@ -864,7 +870,7 @@ namespace AyaNova.PlugIn.V8 var ObjectTID = new TypeAndID(RootObjectTypes.Part, c.ID); dynamic d = new JObject(); - d.name = i.DisplayName(AyaBizUtils.GlobalSettings.DefaultPartDisplayFormat); + d.name = GetUniqueName(i.DisplayName(AyaBizUtils.GlobalSettings.DefaultPartDisplayFormat));//todo: temporary for testing progress.Op(ObjectTypeName + " " + d.name); d.active = c.Active; d.notes = c.Notes; @@ -919,6 +925,7 @@ namespace AyaNova.PlugIn.V8 #region Projects private async System.Threading.Tasks.Task ExportProjects(ProgressForm progress) { + ResetUniqueNames(); if (!progress.KeepGoing) return; var ObjectTypeName = "Project"; //Step 1: export the CustomFields to FormCustom if applicable so that when doing individual items we can export their custom data too @@ -940,7 +947,7 @@ namespace AyaNova.PlugIn.V8 var ObjectTID = new TypeAndID(RootObjectTypes.Project, c.ID); dynamic d = new JObject(); - d.name = c.Name; + d.name = GetUniqueName(c.Name); progress.Op(ObjectTypeName + " " + d.name); d.active = c.Active; d.notes = c.Notes; @@ -1059,6 +1066,7 @@ namespace AyaNova.PlugIn.V8 #region Units private async System.Threading.Tasks.Task ExportUnits(ProgressForm progress) { + ResetUniqueNames(); if (!progress.KeepGoing) return; var ObjectTypeName = "Unit"; //Step 1: export the CustomFields to FormCustom if applicable so that when doing individual items we can export their custom data too @@ -1080,7 +1088,7 @@ namespace AyaNova.PlugIn.V8 var ObjectTID = new TypeAndID(RootObjectTypes.Unit, c.ID); dynamic d = new JObject(); - d.name = c.Serial; + d.name = GetUniqueName(c.Serial); progress.Op(ObjectTypeName + " " + d.name); d.active = c.Active; d.notes = c.Notes; @@ -1135,6 +1143,7 @@ namespace AyaNova.PlugIn.V8 #region UnitModels private async System.Threading.Tasks.Task ExportUnitModels(ProgressForm progress) { + ResetUniqueNames(); if (!progress.KeepGoing) return; var ObjectTypeName = "UnitModel"; //Step 1: export the CustomFields to FormCustom if applicable so that when doing individual items we can export their custom data too @@ -1156,7 +1165,7 @@ namespace AyaNova.PlugIn.V8 var ObjectTID = new TypeAndID(RootObjectTypes.UnitModel, c.ID); dynamic d = new JObject(); - d.name = c.Name; + d.name = GetUniqueName(c.Name); progress.Op(ObjectTypeName + " " + d.name); d.active = c.Active; d.notes = c.Notes; @@ -1210,6 +1219,7 @@ namespace AyaNova.PlugIn.V8 #region Vendors private async System.Threading.Tasks.Task ExportVendors(ProgressForm progress) { + ResetUniqueNames(); if (!progress.KeepGoing) return; var ObjectTypeName = "Vendor"; //Step 1: export the CustomFields to FormCustom if applicable so that when doing individual items we can export their custom data too @@ -1231,7 +1241,7 @@ namespace AyaNova.PlugIn.V8 var ObjectTID = new TypeAndID(RootObjectTypes.Vendor, c.ID); dynamic d = new JObject(); - d.name = c.Name; + d.name = GetUniqueName(c.Name); progress.Op(ObjectTypeName + " " + d.name); d.active = c.Active; d.notes = c.Notes; @@ -1397,6 +1407,7 @@ namespace AyaNova.PlugIn.V8 LocaleList l = LocaleList.GetList(); foreach (LocaleList.LocaleListInfo i in l) { + ResetUniqueNames(); if (!progress.KeepGoing) return; LocalizedTextTable lt = LocalizedTextTable.Load(i.Locale); @@ -1439,7 +1450,7 @@ namespace AyaNova.PlugIn.V8 //MAKE A DUPLICATE //name like this: "My custom (Espanol)" etc one for each target stock language - var exportName = i.Locale + " (" + RavenLocaleName + ")"; + var exportName = GetUniqueName(i.Locale + " (" + RavenLocaleName + ")"); progress.SubOp(""); progress.Op("Exporting " + i.Locale + " to " + exportName); @@ -1646,106 +1657,116 @@ namespace AyaNova.PlugIn.V8 #region Unitmodelcategories private void ExportUnitModelCategories(ProgressForm progress) { + ResetUniqueNames(); UnitModelCategories l = UnitModelCategories.GetItems(); progress.Append("Compiling " + l.Count.ToString() + " Unit model categories"); - foreach (UnitModelCategory i in l) TagMap.Add(i.ID, util.NormalizeTag(i.Name + "." + "unitmodelcategory")); + foreach (UnitModelCategory i in l) TagMap.Add(i.ID, util.NormalizeTag(GetUniqueName(i.Name) + "." + "unitmodelcategory")); } #endregion #region Unitservicetypes private void ExportUnitServiceTypes(ProgressForm progress) { + ResetUniqueNames(); UnitServiceTypes l = UnitServiceTypes.GetItems(); progress.Append("Compiling " + l.Count.ToString() + " Unit service types"); foreach (UnitServiceType i in l) - TagMap.Add(i.ID, util.NormalizeTag(i.Name + "." + "unitservicetype")); + TagMap.Add(i.ID, util.NormalizeTag(GetUniqueName(i.Name) + "." + "unitservicetype")); } #endregion #region WorkorderItemTypes private void ExportWorkorderItemTypes(ProgressForm progress) { - + ResetUniqueNames(); WorkorderItemTypes l = WorkorderItemTypes.GetItems(); progress.Append("Compiling " + l.Count.ToString() + " Workorder item types"); foreach (WorkorderItemType i in l) - TagMap.Add(i.ID, util.NormalizeTag(i.Name + "." + "workorderitemtype")); + TagMap.Add(i.ID, util.NormalizeTag(GetUniqueName(i.Name) + "." + "workorderitemtype")); } #endregion #region REGIONS private void ExportRegions(ProgressForm progress) { + ResetUniqueNames(); RegionList l = RegionList.GetList(string.Empty); progress.Append("Compiling " + l.Count.ToString() + " Regions"); foreach (RegionList.RegionListInfo i in l) - TagMap.Add(i.LT_Region_Label_Name.Value, util.NormalizeTag(i.LT_Region_Label_Name.Display + "." + "region")); + TagMap.Add(i.LT_Region_Label_Name.Value, util.NormalizeTag(GetUniqueName(i.LT_Region_Label_Name.Display) + "." + "region")); } #endregion #region Client groups private void ExportClientGroups(ProgressForm progress) { + ResetUniqueNames(); ClientGroups l = ClientGroups.GetItems(); progress.Append("Compiling " + l.Count.ToString() + " Client groups"); foreach (ClientGroup i in l) - TagMap.Add(i.ID, util.NormalizeTag(i.Name + "." + "clientgroup")); + TagMap.Add(i.ID, util.NormalizeTag(GetUniqueName(i.Name) + "." + "clientgroup")); } #endregion #region Workorder categories private void ExportWorkorderCategories(ProgressForm progress) { + ResetUniqueNames(); WorkorderCategories l = WorkorderCategories.GetItems(); progress.Append("Compiling " + l.Count.ToString() + " Workorder categories"); foreach (WorkorderCategory i in l) - TagMap.Add(i.ID, util.NormalizeTag(i.Name + "." + "workordercategory")); + TagMap.Add(i.ID, util.NormalizeTag(GetUniqueName(i.Name) + "." + "workordercategory")); } #endregion #region Part categories private void ExportPartCategories(ProgressForm progress) { + ResetUniqueNames(); PartCategories l = PartCategories.GetItems(); progress.Append("Compiling " + l.Count.ToString() + " Part categories"); - foreach (PartCategory i in l) TagMap.Add(i.ID, util.NormalizeTag(i.Name + "." + "partcategory")); + foreach (PartCategory i in l) TagMap.Add(i.ID, util.NormalizeTag(GetUniqueName(i.Name) + "." + "partcategory")); } #endregion #region ScheduleableUserGroups private void ExportScheduleableUserGroups(ProgressForm progress) { + ResetUniqueNames(); ScheduleableUserGroupPickList pl = ScheduleableUserGroupPickList.GetList(); progress.Append("Compiling " + pl.Count.ToString() + " Scheduleable user groups"); foreach (ScheduleableUserGroupPickList.ScheduleableUserGroupPickListInfo i in pl) - TagMap.Add(i.ID, util.NormalizeTag(i.Name + "." + "partcategory")); + TagMap.Add(i.ID, util.NormalizeTag(GetUniqueName(i.Name) + "." + "partcategory")); } #endregion clients #region Dispatch zones private void ExportDispatchZones(ProgressForm progress) { + ResetUniqueNames(); DispatchZones l = DispatchZones.GetItems(false); progress.Append("Compiling " + l.Count.ToString() + " Dispatch zones"); foreach (DispatchZone i in l) - TagMap.Add(i.ID, util.NormalizeTag(i.Name + "." + "dispatchzone")); + TagMap.Add(i.ID, util.NormalizeTag(GetUniqueName(i.Name) + "." + "dispatchzone")); } #endregion private void ExportUserSkills(ProgressForm progress) { + ResetUniqueNames(); UserSkills l = UserSkills.GetItems(); progress.Append("Compiling " + l.Count.ToString() + " User skills"); foreach (UserSkill i in l) - TagMap.Add(i.ID, util.NormalizeTag(i.Name + "." + "user-skill")); + TagMap.Add(i.ID, util.NormalizeTag(GetUniqueName(i.Name) + "." + "user-skill")); } private void ExportUserCertifications(ProgressForm progress) { + ResetUniqueNames(); UserCertifications l = UserCertifications.GetItems(); progress.Append("Compiling " + l.Count.ToString() + " User certifications"); foreach (UserCertification i in l) - TagMap.Add(i.ID, util.NormalizeTag(i.Name + "." + "user-certification")); + TagMap.Add(i.ID, util.NormalizeTag(GetUniqueName(i.Name) + "." + "user-certification")); } #endregion TAG ITEMS