This commit is contained in:
2021-02-12 21:30:34 +00:00
parent fa4978f148
commit 11963cb994
2 changed files with 55 additions and 23 deletions

View File

@@ -35,7 +35,7 @@ namespace AyaNova.PlugIn.V8
public string PluginVersion public string PluginVersion
{ {
get { return "7.6.1-alpha.101"; } get { return "7.6.1-alpha.104"; }
} }
public string About public string About
@@ -419,6 +419,32 @@ namespace AyaNova.PlugIn.V8
UsedNames.Clear(); UsedNames.Clear();
} }
List<string> UsedUserNames = new List<string>();
long LUniqueUserName = 1;
private string GetUniqueUserName(string tryName)
{
string retName = tryName;
do
{
if (!UsedUserNames.Contains(retName))
{
UsedUserNames.Add(retName);
return retName;
}
retName = util.UniqueNameBuilder(tryName, LUniqueUserName++, 255);
} while (true);
}
private void ResetUniqueUserNames()
{
LUniqueUserName = 1;
UsedUserNames.Clear();
}
#region Users #region Users
private async System.Threading.Tasks.Task ExportStaffUsers(ProgressForm progress) private async System.Threading.Tasks.Task ExportStaffUsers(ProgressForm progress)
@@ -501,7 +527,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 = GetUniqueUserName(c.FirstName + " " + c.LastName);
if (IsDuplicatev7v8IdMapItem(c.ID, c.FirstName + " " + c.LastName, progress)) continue; if (IsDuplicatev7v8IdMapItem(c.ID, c.FirstName + " " + c.LastName, progress)) continue;
progress.Op("User " + d.name); progress.Op("User " + d.name);
//throw new System.Exception("TODO: UserTypes sb done differently now to align"); //throw new System.Exception("TODO: UserTypes sb done differently now to align");
@@ -660,7 +686,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 = GetUniqueUserName(c.FirstName + " " + c.LastName);
if (IsDuplicatev7v8IdMapItem(c.ID, c.FirstName + " " + c.LastName, progress)) continue; if (IsDuplicatev7v8IdMapItem(c.ID, c.FirstName + " " + c.LastName, progress)) continue;
progress.Op("User " + d.name); progress.Op("User " + d.name);
//throw new System.Exception("TODO: UserTypes sb done differently now to align"); //throw new System.Exception("TODO: UserTypes sb done differently now to align");
@@ -971,7 +997,7 @@ namespace AyaNova.PlugIn.V8
//-------------------------------- //--------------------------------
d = new JObject(); d = new JObject();
d.name = GetUniqueName(c.Contact); d.name = GetUniqueUserName(c.Contact);
progress.Op("Contact " + d.name); progress.Op("Contact " + d.name);
d.userType = RavenUserType.Customer; d.userType = RavenUserType.Customer;
@@ -1181,7 +1207,7 @@ namespace AyaNova.PlugIn.V8
//-------------------------------- //--------------------------------
d = new JObject(); d = new JObject();
d.name = GetUniqueName(c.Contact); d.name = GetUniqueUserName(c.Contact);
progress.Op("Contact " + d.name); progress.Op("Contact " + d.name);
d.userType = RavenUserType.HeadOffice; d.userType = RavenUserType.HeadOffice;
@@ -1405,7 +1431,7 @@ namespace AyaNova.PlugIn.V8
progress.Append("Exporting " + pl.Count.ToString() + " " + ObjectTypeName + "s"); progress.Append("Exporting " + pl.Count.ToString() + " " + ObjectTypeName + "s");
//cache unit of measures //cache unit of measures
UnitOfMeasurePickList umpl=UnitOfMeasurePickList.GetList(false); UnitOfMeasurePickList umpl = UnitOfMeasurePickList.GetList(false);
foreach (PartPickList.PartPickListInfo i in pl) foreach (PartPickList.PartPickListInfo i in pl)
{ {
@@ -1420,7 +1446,8 @@ namespace AyaNova.PlugIn.V8
if (IsDuplicatev7v8IdMapItem(c.ID, c.PartNumber, progress)) continue; if (IsDuplicatev7v8IdMapItem(c.ID, c.PartNumber, progress)) continue;
progress.Op(ObjectTypeName + " " + d.partNumber + " " + d.name); progress.Op(ObjectTypeName + " " + d.partNumber + " " + d.name);
d.name = c.Name; d.name = c.Name;
d.partNumber = c.PartNumber;
d.partNumber = GetUniqueName(c.PartNumber);
d.manufacturerId = Getv7v8IdMapNullOk(c.ManufacturerID); d.manufacturerId = Getv7v8IdMapNullOk(c.ManufacturerID);
d.manufacturerNumber = c.ManufacturerNumber; d.manufacturerNumber = c.ManufacturerNumber;
d.wholeSalerId = Getv7v8IdMapNullOk(c.WholesalerID); d.wholeSalerId = Getv7v8IdMapNullOk(c.WholesalerID);
@@ -1781,6 +1808,9 @@ namespace AyaNova.PlugIn.V8
PickListAutoComplete pl = PickListAutoComplete.GetList("**", "unitmodel"); PickListAutoComplete pl = PickListAutoComplete.GetList("**", "unitmodel");
progress.Append("Exporting " + pl.Count.ToString() + " " + ObjectTypeName + "s"); progress.Append("Exporting " + pl.Count.ToString() + " " + ObjectTypeName + "s");
//model number and vendorid must be unique
List<string> UnqNumberVendorId = new List<string>();
foreach (PickListAutoComplete.PickListAutoCompleteInfo i in pl) foreach (PickListAutoComplete.PickListAutoCompleteInfo i in pl)
{ {
if (!progress.KeepGoing) return; if (!progress.KeepGoing) return;
@@ -1792,18 +1822,18 @@ namespace AyaNova.PlugIn.V8
dynamic d = new JObject(); dynamic d = new JObject();
//neither name nor number are unique at either end by intention
d.name = c.Name; d.name = c.Name;
progress.Op(ObjectTypeName + " " + d.name); progress.Op(ObjectTypeName + " " + d.name);
if (string.IsNullOrWhiteSpace(c.ModelNumber)) string tempModelNumber = c.ModelNumber;
{ if (string.IsNullOrWhiteSpace(tempModelNumber))
d.number = "0"; tempModelNumber = "0";//was not required in v7, is required in v8
}
else //UNIT MODEL NUMBER and VENDOR ID combo must be unique!!
{ //this ensures that by appending a extra number character that is unique then removing the vendorid from the start
d.number = c.ModelNumber; //resulting in a unique name/vendorid combo
} d.number = GetUniqueName(c.VendorID.ToString() + tempModelNumber).Replace(c.VendorID.ToString(), "");
d.active = c.Active; d.active = c.Active;
d.notes = c.Notes; d.notes = c.Notes;
if (c.VendorID != Guid.Empty) if (c.VendorID != Guid.Empty)
@@ -2765,9 +2795,9 @@ namespace AyaNova.PlugIn.V8
LocalizedTextTable lt = LocalizedTextTable.Load(i.Locale); LocalizedTextTable lt = LocalizedTextTable.Load(i.Locale);
progress.Op("Checking if locale " + i.Locale + " is customized"); progress.Op("Checking if locale " + i.Locale + " is customized");
//#if(DEBUG) //#if(DEBUG)
// continue; // continue;
//#endif //#endif
if (!util.LocaleIsCustomized(i.Locale, lt, progress)) continue; if (!util.LocaleIsCustomized(i.Locale, lt, progress)) continue;
////calculate hash ////calculate hash
//List<string> allStrings = new List<string>(); //List<string> allStrings = new List<string>();

View File

@@ -165,7 +165,9 @@ namespace AyaNova.PlugIn.V8
var responseAsString = await response.Content.ReadAsStringAsync(); var responseAsString = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode) if (!response.IsSuccessStatusCode)
{ {
throw new Exception("POST error, route: " + route + "\n" + responseAsString + "\n" + response.ReasonPhrase); if (string.IsNullOrWhiteSpace(postJson))
postJson = "n/a";
throw new Exception("POST error, route: " + route + "\n" + responseAsString + "\n" + response.ReasonPhrase + "\nOBJECT:\n" + postJson);
} }
else else
return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) }; return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) };
@@ -244,8 +246,8 @@ namespace AyaNova.PlugIn.V8
d.ayId = RavenId; d.ayId = RavenId;
d.creator = RavenCreatorId; d.creator = RavenCreatorId;
d.modifier = RavenModifierId; d.modifier = RavenModifierId;
d.created = DateToV8(sCreated,true); d.created = DateToV8(sCreated, true);
d.modified = DateToV8(sModified,true); d.modified = DateToV8(sModified, true);
await PostAsync("event-log/v7", d.ToString()); await PostAsync("event-log/v7", d.ToString());
} }