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

@@ -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)
{