From 5b7c8390669ef936db6ca3b9a72839891145fd17 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 19 Dec 2018 22:22:17 +0000 Subject: [PATCH] --- .vscode/launch.json | 4 ++-- devdocs/todo.txt | 17 +++++++++++++++++ server/AyaNova/Startup.cs | 2 +- server/AyaNova/biz/PrimeData.cs | 28 +++++++++++----------------- server/AyaNova/util/AySchema.cs | 14 +++++++++++--- 5 files changed, 42 insertions(+), 23 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index d95867a5..49c9bd20 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -31,8 +31,8 @@ }, "env": { "ASPNETCORE_ENVIRONMENT": "Development", - //"AYANOVA_LOG_LEVEL": "Info", - "AYANOVA_LOG_LEVEL": "Debug", + "AYANOVA_LOG_LEVEL": "Info", + //"AYANOVA_LOG_LEVEL": "Debug", "AYANOVA_DEFAULT_LANGUAGE": "en", //LOCALE MUST BE en for Integration TESTING //"AYANOVA_PERMANENTLY_ERASE_DATABASE": "true", diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 399d6ce4..b182c049 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -83,6 +83,23 @@ TODO SERVER STUFF - Boot server and seed with debug log turned on, - see what is being tracked by EF that doesn't need to, seems some of that shit is being tracked. + - Microsoft.EntityFrameworkCore.ChangeTracking|DetectChanges starting + + 2018-12-19 12:19:44.9942|DEBUG|Microsoft.EntityFrameworkCore.ChangeTracking|'AyContext' generated temporary value '-9223372036854774807' for the 'Id' property of new 'Locale' entity. + 2018-12-19 12:19:45.0490|DEBUG|Microsoft.EntityFrameworkCore.ChangeTracking|Context 'Locale' started tracking '{Id: -9223372036854774807}' entity with key 'AyContext'. + ... + 2018-12-19 12:19:49.2317|DEBUG|Microsoft.EntityFrameworkCore.ChangeTracking|Foreign key property 'LocaleItem.LocaleId' detected as changed from '-9223372036854774807' to '1' for entity with key '{Id: -9223372036854774080}'. + 2018-12-19 12:19:49.2317|DEBUG|Microsoft.EntityFrameworkCore.ChangeTracking|Foreign key property 'LocaleItem.LocaleId' detected as changed from '-9223372036854774807' to '1' for entity with key '{Id: -9223372036854774079}'. + 2018-12-19 12:19:49.2317|DEBUG|Microsoft.EntityFrameworkCore.ChangeTracking|Foreign key property 'LocaleItem.LocaleId' detected as changed from '-9223372036854774807' to '1' for entity with key '{Id: -9223372036854774078}'. + ... + 2018-12-19 12:19:52.2781|DEBUG|Microsoft.EntityFrameworkCore.ChangeTracking|The 'LocaleItem' entity with key '{Id: 1129}' tracked by 'AyContext' changed from 'Added' to 'Unchanged'. +2018-12-19 12:19:52.2781|DEBUG|Microsoft.EntityFrameworkCore.ChangeTracking|The 'LocaleItem' entity with key '{Id: 1128}' tracked by 'AyContext' changed from 'Added' to 'Unchanged'. +2018-12-19 12:19:52.2781|DEBUG|Microsoft.EntityFrameworkCore.ChangeTracking|The 'LocaleItem' entity with key '{Id: 1127}' tracked by 'AyContext' changed from 'Added' to 'Unchanged'. +2018-12-19 12:19:52.2781|DEBUG|Microsoft.EntityFrameworkCore.ChangeTracking|The 'LocaleItem' entity with key '{Id: 1126}' tracked by 'AyContext' changed from 'Added' to 'Unchanged'. +... + + + - See what warnings are displayed about sql usage - Docs: pagingOptions, sort and filter need to be documented for API diff --git a/server/AyaNova/Startup.cs b/server/AyaNova/Startup.cs index a9392ce7..39914acc 100644 --- a/server/AyaNova/Startup.cs +++ b/server/AyaNova/Startup.cs @@ -98,7 +98,7 @@ namespace AyaNova bool LOG_SENSITIVE_DATA = false; #if (DEBUG) - LOG_SENSITIVE_DATA = true; + //LOG_SENSITIVE_DATA = true; #endif diff --git a/server/AyaNova/biz/PrimeData.cs b/server/AyaNova/biz/PrimeData.cs index 9d5aafbd..ce736361 100644 --- a/server/AyaNova/biz/PrimeData.cs +++ b/server/AyaNova/biz/PrimeData.cs @@ -12,14 +12,6 @@ namespace AyaNova.Biz //Prime the database with initial, minimum required data to boot and do things (manager account, locales) public static class PrimeData { - // private readonly AyContext ct; - // private readonly ILogger log; - - // public PrimeData(AyContext dbcontext, ILogger logger) - // { - // ct = dbcontext; - // log = logger; - // } /// /// Prime the database with manager account @@ -49,8 +41,9 @@ namespace AyaNova.Biz /// Prime the locales /// This may be called before there are any users on a fresh db boot /// - public static void PrimeLocales(AyContext ct) - { + public static void PrimeLocales() + {// + //Read in each stock locale from a text file and then create them in the DB var ResourceFolderPath = Path.Combine(ServerBootConfig.AYANOVA_CONTENT_ROOT_PATH, "resource"); @@ -60,20 +53,21 @@ namespace AyaNova.Biz } - ImportLocale(ct, ResourceFolderPath, "en"); - ImportLocale(ct, ResourceFolderPath, "es"); - ImportLocale(ct, ResourceFolderPath, "fr"); - ImportLocale(ct, ResourceFolderPath, "de"); + ImportLocale(ResourceFolderPath, "en"); + ImportLocale(ResourceFolderPath, "es"); + ImportLocale(ResourceFolderPath, "fr"); + ImportLocale(ResourceFolderPath, "de"); //Ensure locales are present, not missing any keys and that there is a server default locale that exists - //LocaleBiz lb = new LocaleBiz(ct, AuthorizationRoles.OpsAdminFull); - LocaleBiz lb = LocaleBiz.GetBizInternal(ct, 1, AuthorizationRoles.OpsAdminFull); + + LocaleBiz lb = LocaleBiz.GetBizInternal(ServiceProviderProvider.DBContext, 1, AuthorizationRoles.OpsAdminFull); lb.ValidateLocales(); } - private static void ImportLocale(AyContext ct, string resourceFolderPath, string localeCode) + private static void ImportLocale(string resourceFolderPath, string localeCode) { + AyContext ct = ServiceProviderProvider.DBContext; var LocalePath = Path.Combine(resourceFolderPath, $"{localeCode}.json"); if (!File.Exists(LocalePath)) { diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 4e4a428a..133816e1 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -20,7 +20,7 @@ namespace AyaNova.Util /////////// CHANGE THIS ON NEW SCHEMA UPDATE //////////////////// //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!! - private const int DESIRED_SCHEMA_LEVEL = 8; + private const int DESIRED_SCHEMA_LEVEL = 9; internal const long EXPECTED_COLUMN_COUNT = 98; internal const long EXPECTED_INDEX_COUNT = 22; @@ -160,7 +160,7 @@ namespace AyaNova.Util exec("CREATE INDEX alocaleitem_localeid_key_display_idx ON alocaleitem (localeid,key, display)"); //Load the default LOCALES - AyaNova.Biz.PrimeData.PrimeLocales(ct); + AyaNova.Biz.PrimeData.PrimeLocales(); //Add user table @@ -306,7 +306,7 @@ namespace AyaNova.Util } - ////////////////////////////////////////////////// + ////////////////////////////////////////////////// // TAGS repository if (currentSchema < 9) { @@ -316,6 +316,14 @@ namespace AyaNova.Util } + + + //MAKE SURE THE DESIRED SCHEMA WAS SET PROPERLY + if (currentSchema > DESIRED_SCHEMA_LEVEL) + throw new ArgumentOutOfRangeException("AySchema::DesiredSchemaLevel WASN'T SET PROPERLY"); + + + //######################################### //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!