This commit is contained in:
2020-05-04 18:02:47 +00:00
parent 1c45005c86
commit a30ac95be6

View File

@@ -326,9 +326,10 @@ namespace AyaNova.PlugIn.V8
#region BIZ OBJECT Export methods #region BIZ OBJECT Export methods
List<string> UsedNames = new List<string>(); List<string> UsedNames = new List<string>();
long LUniqueName = 1; long LUniqueName = 1;
private string GetUniqueName(string tryName) { private string GetUniqueName(string tryName)
{
string retName=tryName;
string retName = tryName;
do do
{ {
if (!UsedNames.Contains(retName)) if (!UsedNames.Contains(retName))
@@ -338,7 +339,7 @@ namespace AyaNova.PlugIn.V8
} }
retName = util.UniqueNameBuilder(tryName, LUniqueName++, 255); retName = util.UniqueNameBuilder(tryName, LUniqueName++, 255);
} while (true); } while (true);
} }
private void ResetUniqueNames() private void ResetUniqueNames()
@@ -419,7 +420,7 @@ namespace AyaNova.PlugIn.V8
var ObjectTID = new TypeAndID(RootObjectTypes.User, c.ID); var ObjectTID = new TypeAndID(RootObjectTypes.User, c.ID);
dynamic d = new JObject(); dynamic d = new JObject();
d.name =GetUniqueName(c.FirstName + " " + c.LastName); d.name = GetUniqueName(c.FirstName + " " + c.LastName);
progress.Op("User " + d.name); progress.Op("User " + d.name);
d.userType = (int)c.UserType; d.userType = (int)c.UserType;
@@ -534,6 +535,7 @@ namespace AyaNova.PlugIn.V8
private async System.Threading.Tasks.Task ExportClients(ProgressForm progress) private async System.Threading.Tasks.Task ExportClients(ProgressForm progress)
{ {
if (!progress.KeepGoing) return; if (!progress.KeepGoing) return;
ResetUniqueNames();
var ObjectTypeName = "Client"; 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 //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); var ocf = ObjectHasCustomFieldDataToExport(ObjectTypeName);
@@ -554,7 +556,7 @@ namespace AyaNova.PlugIn.V8
var ObjectTID = new TypeAndID(RootObjectTypes.Client, c.ID); var ObjectTID = new TypeAndID(RootObjectTypes.Client, c.ID);
dynamic d = new JObject(); dynamic d = new JObject();
d.name = c.Name; d.name = GetUniqueName(c.Name);
progress.Op(ObjectTypeName + " " + d.name); progress.Op(ObjectTypeName + " " + d.name);
d.active = c.Active; d.active = c.Active;
d.notes = c.Notes; d.notes = c.Notes;
@@ -612,6 +614,7 @@ namespace AyaNova.PlugIn.V8
private async System.Threading.Tasks.Task ExportHeadOffices(ProgressForm progress) private async System.Threading.Tasks.Task ExportHeadOffices(ProgressForm progress)
{ {
if (!progress.KeepGoing) return; if (!progress.KeepGoing) return;
ResetUniqueNames();
var ObjectTypeName = "HeadOffice"; 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 //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); var ocf = ObjectHasCustomFieldDataToExport(ObjectTypeName);
@@ -633,7 +636,7 @@ namespace AyaNova.PlugIn.V8
var ObjectTID = new TypeAndID(RootObjectTypes.HeadOffice, c.ID); var ObjectTID = new TypeAndID(RootObjectTypes.HeadOffice, c.ID);
dynamic d = new JObject(); dynamic d = new JObject();
d.name = c.Name; d.name = GetUniqueName(c.Name);
progress.Op(ObjectTypeName + " " + d.name); progress.Op(ObjectTypeName + " " + d.name);
d.active = c.Active; d.active = c.Active;
d.notes = c.Notes; d.notes = c.Notes;
@@ -689,6 +692,7 @@ namespace AyaNova.PlugIn.V8
#region Contracts #region Contracts
private async System.Threading.Tasks.Task ExportContracts(ProgressForm progress) private async System.Threading.Tasks.Task ExportContracts(ProgressForm progress)
{ {
ResetUniqueNames();
if (!progress.KeepGoing) return; if (!progress.KeepGoing) return;
var ObjectTypeName = "Contract"; 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 //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); var ObjectTID = new TypeAndID(RootObjectTypes.Contract, c.ID);
dynamic d = new JObject(); dynamic d = new JObject();
d.name = c.Name; d.name = GetUniqueName(c.Name);
progress.Op(ObjectTypeName + " " + d.name); progress.Op(ObjectTypeName + " " + d.name);
d.active = c.Active; d.active = c.Active;
d.notes = c.Notes; d.notes = c.Notes;
@@ -765,6 +769,7 @@ namespace AyaNova.PlugIn.V8
#region LoanItems #region LoanItems
private async System.Threading.Tasks.Task ExportLoanItems(ProgressForm progress) private async System.Threading.Tasks.Task ExportLoanItems(ProgressForm progress)
{ {
ResetUniqueNames();
if (!progress.KeepGoing) return; if (!progress.KeepGoing) return;
var ObjectTypeName = "LoanItem"; var ObjectTypeName = "LoanItem";
var RavenObjectName = "LoanUnit"; var RavenObjectName = "LoanUnit";
@@ -787,7 +792,7 @@ namespace AyaNova.PlugIn.V8
var ObjectTID = new TypeAndID(RootObjectTypes.LoanItem, c.ID); var ObjectTID = new TypeAndID(RootObjectTypes.LoanItem, c.ID);
dynamic d = new JObject(); dynamic d = new JObject();
d.name = c.Name; d.name = GetUniqueName(c.Name);
progress.Op(ObjectTypeName + " " + d.name); progress.Op(ObjectTypeName + " " + d.name);
d.active = c.Active; d.active = c.Active;
d.notes = c.Notes; d.notes = c.Notes;
@@ -841,6 +846,7 @@ namespace AyaNova.PlugIn.V8
#region Parts #region Parts
private async System.Threading.Tasks.Task ExportParts(ProgressForm progress) private async System.Threading.Tasks.Task ExportParts(ProgressForm progress)
{ {
ResetUniqueNames();
if (!progress.KeepGoing) return; if (!progress.KeepGoing) return;
var ObjectTypeName = "Part"; var ObjectTypeName = "Part";
var RavenObjectName = "Part"; var RavenObjectName = "Part";
@@ -864,7 +870,7 @@ namespace AyaNova.PlugIn.V8
var ObjectTID = new TypeAndID(RootObjectTypes.Part, c.ID); var ObjectTID = new TypeAndID(RootObjectTypes.Part, c.ID);
dynamic d = new JObject(); 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); progress.Op(ObjectTypeName + " " + d.name);
d.active = c.Active; d.active = c.Active;
d.notes = c.Notes; d.notes = c.Notes;
@@ -919,6 +925,7 @@ namespace AyaNova.PlugIn.V8
#region Projects #region Projects
private async System.Threading.Tasks.Task ExportProjects(ProgressForm progress) private async System.Threading.Tasks.Task ExportProjects(ProgressForm progress)
{ {
ResetUniqueNames();
if (!progress.KeepGoing) return; if (!progress.KeepGoing) return;
var ObjectTypeName = "Project"; 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 //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); var ObjectTID = new TypeAndID(RootObjectTypes.Project, c.ID);
dynamic d = new JObject(); dynamic d = new JObject();
d.name = c.Name; d.name = GetUniqueName(c.Name);
progress.Op(ObjectTypeName + " " + d.name); progress.Op(ObjectTypeName + " " + d.name);
d.active = c.Active; d.active = c.Active;
d.notes = c.Notes; d.notes = c.Notes;
@@ -1059,6 +1066,7 @@ namespace AyaNova.PlugIn.V8
#region Units #region Units
private async System.Threading.Tasks.Task ExportUnits(ProgressForm progress) private async System.Threading.Tasks.Task ExportUnits(ProgressForm progress)
{ {
ResetUniqueNames();
if (!progress.KeepGoing) return; if (!progress.KeepGoing) return;
var ObjectTypeName = "Unit"; 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 //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); var ObjectTID = new TypeAndID(RootObjectTypes.Unit, c.ID);
dynamic d = new JObject(); dynamic d = new JObject();
d.name = c.Serial; d.name = GetUniqueName(c.Serial);
progress.Op(ObjectTypeName + " " + d.name); progress.Op(ObjectTypeName + " " + d.name);
d.active = c.Active; d.active = c.Active;
d.notes = c.Notes; d.notes = c.Notes;
@@ -1135,6 +1143,7 @@ namespace AyaNova.PlugIn.V8
#region UnitModels #region UnitModels
private async System.Threading.Tasks.Task ExportUnitModels(ProgressForm progress) private async System.Threading.Tasks.Task ExportUnitModels(ProgressForm progress)
{ {
ResetUniqueNames();
if (!progress.KeepGoing) return; if (!progress.KeepGoing) return;
var ObjectTypeName = "UnitModel"; 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 //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); var ObjectTID = new TypeAndID(RootObjectTypes.UnitModel, c.ID);
dynamic d = new JObject(); dynamic d = new JObject();
d.name = c.Name; d.name = GetUniqueName(c.Name);
progress.Op(ObjectTypeName + " " + d.name); progress.Op(ObjectTypeName + " " + d.name);
d.active = c.Active; d.active = c.Active;
d.notes = c.Notes; d.notes = c.Notes;
@@ -1210,6 +1219,7 @@ namespace AyaNova.PlugIn.V8
#region Vendors #region Vendors
private async System.Threading.Tasks.Task ExportVendors(ProgressForm progress) private async System.Threading.Tasks.Task ExportVendors(ProgressForm progress)
{ {
ResetUniqueNames();
if (!progress.KeepGoing) return; if (!progress.KeepGoing) return;
var ObjectTypeName = "Vendor"; 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 //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); var ObjectTID = new TypeAndID(RootObjectTypes.Vendor, c.ID);
dynamic d = new JObject(); dynamic d = new JObject();
d.name = c.Name; d.name = GetUniqueName(c.Name);
progress.Op(ObjectTypeName + " " + d.name); progress.Op(ObjectTypeName + " " + d.name);
d.active = c.Active; d.active = c.Active;
d.notes = c.Notes; d.notes = c.Notes;
@@ -1397,6 +1407,7 @@ namespace AyaNova.PlugIn.V8
LocaleList l = LocaleList.GetList(); LocaleList l = LocaleList.GetList();
foreach (LocaleList.LocaleListInfo i in l) foreach (LocaleList.LocaleListInfo i in l)
{ {
ResetUniqueNames();
if (!progress.KeepGoing) return; if (!progress.KeepGoing) return;
LocalizedTextTable lt = LocalizedTextTable.Load(i.Locale); LocalizedTextTable lt = LocalizedTextTable.Load(i.Locale);
@@ -1439,7 +1450,7 @@ namespace AyaNova.PlugIn.V8
//MAKE A DUPLICATE //MAKE A DUPLICATE
//name like this: "My custom (Espanol)" etc one for each target stock language //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.SubOp("");
progress.Op("Exporting " + i.Locale + " to " + exportName); progress.Op("Exporting " + i.Locale + " to " + exportName);
@@ -1646,106 +1657,116 @@ namespace AyaNova.PlugIn.V8
#region Unitmodelcategories #region Unitmodelcategories
private void ExportUnitModelCategories(ProgressForm progress) private void ExportUnitModelCategories(ProgressForm progress)
{ {
ResetUniqueNames();
UnitModelCategories l = UnitModelCategories.GetItems(); UnitModelCategories l = UnitModelCategories.GetItems();
progress.Append("Compiling " + l.Count.ToString() + " Unit model categories"); 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 #endregion
#region Unitservicetypes #region Unitservicetypes
private void ExportUnitServiceTypes(ProgressForm progress) private void ExportUnitServiceTypes(ProgressForm progress)
{ {
ResetUniqueNames();
UnitServiceTypes l = UnitServiceTypes.GetItems(); UnitServiceTypes l = UnitServiceTypes.GetItems();
progress.Append("Compiling " + l.Count.ToString() + " Unit service types"); progress.Append("Compiling " + l.Count.ToString() + " Unit service types");
foreach (UnitServiceType i in l) 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 #endregion
#region WorkorderItemTypes #region WorkorderItemTypes
private void ExportWorkorderItemTypes(ProgressForm progress) private void ExportWorkorderItemTypes(ProgressForm progress)
{ {
ResetUniqueNames();
WorkorderItemTypes l = WorkorderItemTypes.GetItems(); WorkorderItemTypes l = WorkorderItemTypes.GetItems();
progress.Append("Compiling " + l.Count.ToString() + " Workorder item types"); progress.Append("Compiling " + l.Count.ToString() + " Workorder item types");
foreach (WorkorderItemType i in l) 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 #endregion
#region REGIONS #region REGIONS
private void ExportRegions(ProgressForm progress) private void ExportRegions(ProgressForm progress)
{ {
ResetUniqueNames();
RegionList l = RegionList.GetList(string.Empty); RegionList l = RegionList.GetList(string.Empty);
progress.Append("Compiling " + l.Count.ToString() + " Regions"); progress.Append("Compiling " + l.Count.ToString() + " Regions");
foreach (RegionList.RegionListInfo i in l) 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 #endregion
#region Client groups #region Client groups
private void ExportClientGroups(ProgressForm progress) private void ExportClientGroups(ProgressForm progress)
{ {
ResetUniqueNames();
ClientGroups l = ClientGroups.GetItems(); ClientGroups l = ClientGroups.GetItems();
progress.Append("Compiling " + l.Count.ToString() + " Client groups"); progress.Append("Compiling " + l.Count.ToString() + " Client groups");
foreach (ClientGroup i in l) 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 #endregion
#region Workorder categories #region Workorder categories
private void ExportWorkorderCategories(ProgressForm progress) private void ExportWorkorderCategories(ProgressForm progress)
{ {
ResetUniqueNames();
WorkorderCategories l = WorkorderCategories.GetItems(); WorkorderCategories l = WorkorderCategories.GetItems();
progress.Append("Compiling " + l.Count.ToString() + " Workorder categories"); progress.Append("Compiling " + l.Count.ToString() + " Workorder categories");
foreach (WorkorderCategory i in l) 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 #endregion
#region Part categories #region Part categories
private void ExportPartCategories(ProgressForm progress) private void ExportPartCategories(ProgressForm progress)
{ {
ResetUniqueNames();
PartCategories l = PartCategories.GetItems(); PartCategories l = PartCategories.GetItems();
progress.Append("Compiling " + l.Count.ToString() + " Part categories"); 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 #endregion
#region ScheduleableUserGroups #region ScheduleableUserGroups
private void ExportScheduleableUserGroups(ProgressForm progress) private void ExportScheduleableUserGroups(ProgressForm progress)
{ {
ResetUniqueNames();
ScheduleableUserGroupPickList pl = ScheduleableUserGroupPickList.GetList(); ScheduleableUserGroupPickList pl = ScheduleableUserGroupPickList.GetList();
progress.Append("Compiling " + pl.Count.ToString() + " Scheduleable user groups"); progress.Append("Compiling " + pl.Count.ToString() + " Scheduleable user groups");
foreach (ScheduleableUserGroupPickList.ScheduleableUserGroupPickListInfo i in pl) 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 #endregion clients
#region Dispatch zones #region Dispatch zones
private void ExportDispatchZones(ProgressForm progress) private void ExportDispatchZones(ProgressForm progress)
{ {
ResetUniqueNames();
DispatchZones l = DispatchZones.GetItems(false); DispatchZones l = DispatchZones.GetItems(false);
progress.Append("Compiling " + l.Count.ToString() + " Dispatch zones"); progress.Append("Compiling " + l.Count.ToString() + " Dispatch zones");
foreach (DispatchZone i in l) 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 #endregion
private void ExportUserSkills(ProgressForm progress) private void ExportUserSkills(ProgressForm progress)
{ {
ResetUniqueNames();
UserSkills l = UserSkills.GetItems(); UserSkills l = UserSkills.GetItems();
progress.Append("Compiling " + l.Count.ToString() + " User skills"); progress.Append("Compiling " + l.Count.ToString() + " User skills");
foreach (UserSkill i in l) 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) private void ExportUserCertifications(ProgressForm progress)
{ {
ResetUniqueNames();
UserCertifications l = UserCertifications.GetItems(); UserCertifications l = UserCertifications.GetItems();
progress.Append("Compiling " + l.Count.ToString() + " User certifications"); progress.Append("Compiling " + l.Count.ToString() + " User certifications");
foreach (UserCertification i in l) 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 #endregion TAG ITEMS