This commit is contained in:
2020-05-05 18:35:49 +00:00
parent 5773a3f42d
commit 20926758b3
2 changed files with 123 additions and 24 deletions

View File

@@ -174,6 +174,18 @@ namespace AyaNova.PlugIn.V8
else Map.Add(v7id, v8id); else Map.Add(v7id, v8id);
} }
private bool IsDuplicateMapItem(Guid v7id, string name, ProgressForm progress)
{
if (Map.ContainsKey(v7id))
{
progress.Append("DUPLICATE: " + name + " - has duplicate ID, not exported");
return true;
}
return false;
}
private long SafeGetUserMap(Guid id) private long SafeGetUserMap(Guid id)
{ {
if (!Map.ContainsKey(id)) return 1;//1=raven administrator account if (!Map.ContainsKey(id)) return 1;//1=raven administrator account
@@ -213,12 +225,15 @@ namespace AyaNova.PlugIn.V8
/* /*
TODO: TODO:
Add dupe check for v7 id as there should be none, but seeing dupes in some db's
still determining if real dupe or different records
Only compare original locale keys for hash not ones added in schema updates or dropped Only compare original locale keys for hash not ones added in schema updates or dropped
Need more detail when fails on release mode, right now no idea what actually happened Need more detail when fails on release mode, right now no idea what actually happened
I'd like to see a full log sent to the server on fail I'd like to see a full log sent to the server on fail
not sure, would be a *lot* of data potentially to gather all this eating up memory
keep a record of every op/subop etc in progress, on fail push out that list with the keep a record of every op/subop etc in progress, on fail push out that list with the
exception to somewhere on the server, maybe as an attachment for the manager user? exception to somewhere on the server, maybe as an attachment for the manager user?
so can view in detail remote users export issues so can view in detail remote users export issues
@@ -425,11 +440,13 @@ namespace AyaNova.PlugIn.V8
if (i.ID == User.AdministratorID) continue; if (i.ID == User.AdministratorID) continue;
User c = User.GetItem(i.ID); User c = User.GetItem(i.ID);
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);
if (IsDuplicateMapItem(c.ID, c.FirstName+" " + c.LastName, progress)) continue;
progress.Op("User " + d.name); progress.Op("User " + d.name);
d.userType = (int)c.UserType; d.userType = (int)c.UserType;
@@ -568,6 +585,7 @@ namespace AyaNova.PlugIn.V8
dynamic d = new JObject(); dynamic d = new JObject();
d.name = GetUniqueName(c.Name); d.name = GetUniqueName(c.Name);
if (IsDuplicateMapItem(c.ID,c.Name, progress)) continue;
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;
@@ -650,6 +668,7 @@ namespace AyaNova.PlugIn.V8
dynamic d = new JObject(); dynamic d = new JObject();
d.name = GetUniqueName(c.Name); d.name = GetUniqueName(c.Name);
if (IsDuplicateMapItem(c.ID, c.Name, progress)) continue;
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;
@@ -730,6 +749,7 @@ namespace AyaNova.PlugIn.V8
dynamic d = new JObject(); dynamic d = new JObject();
d.name = GetUniqueName(c.Name); d.name = GetUniqueName(c.Name);
if (IsDuplicateMapItem(c.ID, c.Name, progress)) continue;
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;
@@ -810,6 +830,7 @@ namespace AyaNova.PlugIn.V8
dynamic d = new JObject(); dynamic d = new JObject();
d.name = GetUniqueName(c.Name); d.name = GetUniqueName(c.Name);
if (IsDuplicateMapItem(c.ID, c.Name, progress)) continue;
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;
@@ -890,6 +911,7 @@ namespace AyaNova.PlugIn.V8
dynamic d = new JObject(); dynamic d = new JObject();
d.name = GetUniqueName(i.DisplayName(AyaBizUtils.GlobalSettings.DefaultPartDisplayFormat));//todo: temporary for testing d.name = GetUniqueName(i.DisplayName(AyaBizUtils.GlobalSettings.DefaultPartDisplayFormat));//todo: temporary for testing
if (IsDuplicateMapItem(c.ID, c.Name, progress)) continue;
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;
@@ -969,6 +991,7 @@ namespace AyaNova.PlugIn.V8
dynamic d = new JObject(); dynamic d = new JObject();
d.name = GetUniqueName(c.Name); d.name = GetUniqueName(c.Name);
if (IsDuplicateMapItem(c.ID, c.Name, progress)) continue;
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;
@@ -1046,6 +1069,7 @@ namespace AyaNova.PlugIn.V8
dynamic d = new JObject(); dynamic d = new JObject();
d.name = c.PONumber.ToString(); d.name = c.PONumber.ToString();
if (IsDuplicateMapItem(c.ID, i.LT_PurchaseOrder_Label_PONumber.Display, progress)) continue;
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;
@@ -1115,6 +1139,7 @@ namespace AyaNova.PlugIn.V8
dynamic d = new JObject(); dynamic d = new JObject();
d.name = GetUniqueName(c.Serial); d.name = GetUniqueName(c.Serial);
if (IsDuplicateMapItem(c.ID, c.Serial, progress)) continue;
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;
@@ -1196,6 +1221,7 @@ namespace AyaNova.PlugIn.V8
dynamic d = new JObject(); dynamic d = new JObject();
d.name = GetUniqueName(c.Name); d.name = GetUniqueName(c.Name);
if (IsDuplicateMapItem(c.ID, c.Name, progress)) continue;
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;
@@ -1274,6 +1300,7 @@ namespace AyaNova.PlugIn.V8
dynamic d = new JObject(); dynamic d = new JObject();
d.name = GetUniqueName(c.Name); d.name = GetUniqueName(c.Name);
if (IsDuplicateMapItem(c.ID, c.Name, progress)) continue;
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;
@@ -1350,6 +1377,7 @@ namespace AyaNova.PlugIn.V8
tags.Add(ImportTag); tags.Add(ImportTag);
Workorder c = Workorder.GetItem(i.LT_O_Workorder.Value); Workorder c = Workorder.GetItem(i.LT_O_Workorder.Value);
if (IsDuplicateMapItem(c.ID, c.WorkorderService.ServiceNumber.ToString(), progress)) continue;
var ObjectTID = new TypeAndID(RootObjectTypes.WorkorderService, c.ID); var ObjectTID = new TypeAndID(RootObjectTypes.WorkorderService, c.ID);
//make one on the server to update //make one on the server to update
var rMainObject = await util.PostAsync(RavenObjectName + "/Create?serial=" + c.WorkorderService.ServiceNumber); var rMainObject = await util.PostAsync(RavenObjectName + "/Create?serial=" + c.WorkorderService.ServiceNumber);
@@ -1433,6 +1461,7 @@ namespace AyaNova.PlugIn.V8
tags.Add(ImportTag); tags.Add(ImportTag);
Workorder c = Workorder.GetItem(i.LT_O_WorkorderQuote.Value); Workorder c = Workorder.GetItem(i.LT_O_WorkorderQuote.Value);
if (IsDuplicateMapItem(c.ID, c.WorkorderQuote.QuoteNumber.ToString(), progress)) continue;
var ObjectTID = new TypeAndID(RootObjectTypes.WorkorderQuote, c.ID); var ObjectTID = new TypeAndID(RootObjectTypes.WorkorderQuote, c.ID);
//make one on the server to update //make one on the server to update
var rMainObject = await util.PostAsync(RavenObjectName + "/Create?serial=" + c.WorkorderQuote.QuoteNumber); var rMainObject = await util.PostAsync(RavenObjectName + "/Create?serial=" + c.WorkorderQuote.QuoteNumber);
@@ -1516,6 +1545,7 @@ namespace AyaNova.PlugIn.V8
tags.Add(ImportTag); tags.Add(ImportTag);
Workorder c = Workorder.GetItem(i.LT_O_WorkorderPreventiveMaintenance.Value); Workorder c = Workorder.GetItem(i.LT_O_WorkorderPreventiveMaintenance.Value);
if (IsDuplicateMapItem(c.ID, c.WorkorderPreventiveMaintenance.PreventiveMaintenanceNumber.ToString(), progress)) continue;
var ObjectTID = new TypeAndID(RootObjectTypes.WorkorderPreventiveMaintenance, c.ID); var ObjectTID = new TypeAndID(RootObjectTypes.WorkorderPreventiveMaintenance, c.ID);
//make one on the server to update //make one on the server to update
var rMainObject = await util.PostAsync(RavenObjectName + "/Create?serial=" + c.WorkorderPreventiveMaintenance.PreventiveMaintenanceNumber); var rMainObject = await util.PostAsync(RavenObjectName + "/Create?serial=" + c.WorkorderPreventiveMaintenance.PreventiveMaintenanceNumber);
@@ -1581,21 +1611,30 @@ namespace AyaNova.PlugIn.V8
progress.Op("Start Locales export"); progress.Op("Start Locales export");
progress.SubOp(""); progress.SubOp("");
progress.Append("Exporting customized Locales"); progress.Append("Exporting customized Locales");
//checksum locales ////checksum locales
//if a recognized checksum then don't import because it means it wasn't modified from stock ////if a recognized checksum then don't import because it means it wasn't modified from stock
/* ///*
Stock fresh trial db (fb) values: // Stock fresh trial db (fb) values:
Locale: Custom English hash code: 740187325 // Locale Custom English [signature: -1965948581]
Locale: Deutsch hash code: -257973661 // Locale Deutsch [signature: -564065723]
Locale: English hash code: 740187325 // Locale English [signature: -1965948581]
Locale: Español hash code: -373723947 // Locale Español [signature: -1122936791]
Locale: Français hash code: -224208815 // Locale Français [signature: -679171126]
*/
List<int> StockLocaleHashes = new List<int>(); //Do not use these keys in hash calculation which were added / modified during various schema updates
StockLocaleHashes.Add(-257973661); // Global.Label.UseInventory.Description
StockLocaleHashes.Add(740187325); // Locale.Label.LocaleFile
StockLocaleHashes.Add(-373723947); // UnitNameDisplayFormats.Label.ModelSerial
StockLocaleHashes.Add(-224208815); // UnitNameDisplayFormats.Label.SerialModel
// UnitNameDisplayFormats.Label.SerialModelVendor
// UnitNameDisplayFormats.Label.VendorModelSerial
// O.PartBin
//*/
//List<int> StockLocaleHashes = new List<int>();
//StockLocaleHashes.Add(-1965948581);
//StockLocaleHashes.Add(-564065723);
//StockLocaleHashes.Add(-1122936791);
//StockLocaleHashes.Add(-679171126);
//Get a list of RAVEN translations and ID's //Get a list of RAVEN translations and ID's
var a = await util.GetAsync("Translation/List"); var a = await util.GetAsync("Translation/List");
@@ -1611,14 +1650,25 @@ 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");
//calculate hash if (!util.LocaleIsCustomized(i.Locale, lt, progress)) continue;
List<string> allStrings = new List<string>(); ////calculate hash
foreach (var entry in lt.LT) //List<string> allStrings = new List<string>();
allStrings.Add(entry.Value); //foreach (var entry in lt.LT)
int CurrentLocaleHash = util.GetOrderIndependentHashCode<string>(allStrings); //{
allStrings.Clear(); // if(entry.Key=="Global.Label.UseInventory.Description") continue;
if (StockLocaleHashes.Contains(CurrentLocaleHash)) continue; // if(entry.Key=="Locale.Label.LocaleFile") continue;
progress.Append("Locale " + i.Locale + " is customized [signature: "+CurrentLocaleHash.ToString()+"]; exporting"); // if(entry.Key=="UnitNameDisplayFormats.Label.ModelSerial") continue;
// if(entry.Key=="UnitNameDisplayFormats.Label.SerialModel") continue;
// if(entry.Key=="UnitNameDisplayFormats.Label.SerialModelVendor") continue;
// if(entry.Key=="UnitNameDisplayFormats.Label.VendorModelSerial") continue;
// if (entry.Key == "O.PartBin") continue;
// allStrings.Add(entry.Value);
//}
//int CurrentLocaleHash = util.GetOrderIndependentHashCode<string>(allStrings);
//allStrings.Clear();
//if (StockLocaleHashes.Contains(CurrentLocaleHash)) continue;
//progress.Append("Locale " + i.Locale + " is customized [signature: "+CurrentLocaleHash.ToString()+"]; exporting");
//collection to hold items sent to server //collection to hold items sent to server
List<UpdateTranslationItem> exportItems = new List<UpdateTranslationItem>(); List<UpdateTranslationItem> exportItems = new List<UpdateTranslationItem>();
@@ -2132,7 +2182,7 @@ namespace AyaNova.PlugIn.V8
if (af == null) continue; if (af == null) continue;
progress.SubOp("Wikifile: \"" + af.Name + "\" " + AyaBizUtils.FileSizeDisplay((decimal)af.FileSize)); progress.SubOp("Wikifile: \"" + af.Name + "\" " + AyaBizUtils.FileSizeDisplay((decimal)af.FileSize));
if (IsDuplicateMapItem(i.LT_O_AyaFile.Value, i.LT_O_AyaFile.Display, progress)) continue;
//Compile the FileData property //Compile the FileData property
var sDate = i.LT_Common_Label_Created.ToString(); var sDate = i.LT_Common_Label_Created.ToString();
DateTimeOffset dtLastModified = DateTime.UtcNow; DateTimeOffset dtLastModified = DateTime.UtcNow;

View File

@@ -492,6 +492,55 @@ namespace AyaNova.PlugIn.V8
public static bool LocaleIsCustomized(string localeName, GZTW.AyaNova.BLL.LocalizedTextTable lt, ProgressForm progress)
{
//checksum locales
//if a recognized checksum then don't import because it means it wasn't modified from stock
/*
Stock fresh trial db (fb) values:
Locale Custom English is customized [signature: -2007218741] exporting
Locale Deutsch is customized [signature: -605335883] exporting
Locale English is customized [signature: -2007218741] exporting
Locale Español is customized [signature: -1164206951] exporting
Locale Français is customized [signature: -720441286] exporting
Do not use these keys in hash calculation which were added / modified during various schema updates
Global.Label.UseInventory.Description
Locale.Label.LocaleFile
UnitNameDisplayFormats.Label.ModelSerial
UnitNameDisplayFormats.Label.SerialModel
UnitNameDisplayFormats.Label.SerialModelVendor
UnitNameDisplayFormats.Label.VendorModelSerial
O.PartBin
*/
List<int> StockLocaleHashes = new List<int>();
StockLocaleHashes.Add(-605335883);
StockLocaleHashes.Add(-2007218741);
StockLocaleHashes.Add(-1164206951);
StockLocaleHashes.Add(-720441286);
//calculate hash
List<string> allStrings = new List<string>();
foreach (var entry in lt.LT)
{
if (entry.Key == "Global.Label.UseInventory.Description") continue;
if (entry.Key == "Locale.Label.LocaleFile") continue;
if (entry.Key == "UnitNameDisplayFormats.Label.ModelSerial") continue;
if (entry.Key == "UnitNameDisplayFormats.Label.SerialModel") continue;
if (entry.Key == "UnitNameDisplayFormats.Label.SerialModelVendor") continue;
if (entry.Key == "UnitNameDisplayFormats.Label.VendorModelSerial") continue;
if (entry.Key == "O.PartBin") continue;
if (entry.Key == "UI.Label.CurrentUserName") continue;
allStrings.Add(entry.Value);
}
int CurrentLocaleHash = GetOrderIndependentHashCode<string>(allStrings);
if (StockLocaleHashes.Contains(CurrentLocaleHash)) return false;
progress.Append("Locale " + localeName + " is customized [signature: " + CurrentLocaleHash.ToString() + "] exporting");
return true;
}
public static int GetOrderIndependentHashCode<T>(IEnumerable<T> source) public static int GetOrderIndependentHashCode<T>(IEnumerable<T> source)
{ {