From bc1c5fcc7b7cf0b4ff67c12dac94f3fc6d464be6 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 10 Jul 2020 17:33:24 +0000 Subject: [PATCH] --- .vscode/launch.json | 2 +- .../AyaNova/Controllers/NotifyController.cs | 2 +- server/AyaNova/Startup.cs | 7 ++--- server/AyaNova/util/License.cs | 28 +++++++++++++------ 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 396abc9b..bcfc56be 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -50,7 +50,7 @@ "AYANOVA_USE_URLS": "http://*:7575;", "AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles", "AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles", - "AYANOVA_SERVER_TEST_MODE":"false", + "AYANOVA_SERVER_TEST_MODE":"true", "AYANOVA_SERVER_TEST_MODE_SEEDLEVEL":"small", "AYANOVA_SERVER_TEST_MODE_TZ_OFFSET":"-7", "AYANOVA_BACKUP_PG_DUMP_PATH":"C:\\data\\code\\PostgreSQLPortable_12.0\\App\\PgSQL\\bin\\" diff --git a/server/AyaNova/Controllers/NotifyController.cs b/server/AyaNova/Controllers/NotifyController.cs index 500e9816..34fbede3 100644 --- a/server/AyaNova/Controllers/NotifyController.cs +++ b/server/AyaNova/Controllers/NotifyController.cs @@ -63,7 +63,7 @@ namespace AyaNova.Api.Controllers if (serverState.IsClosed) return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); System.Random rnd = new System.Random(); - + int RandomNewCount = rnd.Next(20); return Ok(ApiOkResponse.Response(RandomNewCount)); } diff --git a/server/AyaNova/Startup.cs b/server/AyaNova/Startup.cs index f84e358f..451f9d86 100644 --- a/server/AyaNova/Startup.cs +++ b/server/AyaNova/Startup.cs @@ -547,10 +547,7 @@ namespace AyaNova _newLog.LogDebug("DB schema check"); AySchema.CheckAndUpdateAsync(dbContext, _newLog).Wait(); -// #if (DEBUG) -// System.Diagnostics.Debugger.Log(1, "BOOT", "Startup.cs -> RE-PRIMING TRANSLATIONS"); -// AyaNova.Biz.PrimeData.RePrimeTranslations().Wait(); -// #endif + //Check database integrity _newLog.LogDebug("DB integrity check"); @@ -575,7 +572,7 @@ namespace AyaNova if (ServerBootConfig.AYANOVA_SERVER_TEST_MODE) { _newLog.LogInformation($"Server test mode seeding, level is {ServerBootConfig.AYANOVA_SERVER_TEST_MODE_SEEDLEVEL}, tz offset is {ServerBootConfig.AYANOVA_SERVER_TEST_MODE_TZ_OFFSET}"); - AyaNova.Core.License.FetchKeyAsync(apiServerState, dbContext, _newLog, true).Wait(); + AyaNova.Core.License.FetchKeyAsync(apiServerState, dbContext, _newLog, true, true).Wait(); //NOTE: For unit testing make sure the time zone is same as tester to ensure list filter by date tests will work because server is on same page as user in terms of time var seed = new Util.Seeder(); seed.SeedDatabaseAsync(Seeder.Level.StringToSeedLevel(ServerBootConfig.AYANOVA_SERVER_TEST_MODE_SEEDLEVEL), ServerBootConfig.AYANOVA_SERVER_TEST_MODE_TZ_OFFSET).Wait(); diff --git a/server/AyaNova/util/License.cs b/server/AyaNova/util/License.cs index 44987d6f..dbeda22a 100644 --- a/server/AyaNova/util/License.cs +++ b/server/AyaNova/util/License.cs @@ -29,14 +29,13 @@ namespace AyaNova.Core { //License server address - private const string LICENSE_SERVER_URL = "https://rockfish.ayanova.com/"; + // private const string LICENSE_SERVER_URL = "https://rockfish.ayanova.com/"; -// #if (DEBUG) - //IF TESTING LOCAL DEV ROCKFISH: -// private const string LICENSE_SERVER_URL = "http://localhost:3001/"; -// #else -// private const string LICENSE_SERVER_URL = "https://rockfish.ayanova.com/"; -// #endif + #if (DEBUG) + private const string LICENSE_SERVER_URL = "http://localhost:3001/"; + #else + private const string LICENSE_SERVER_URL = "https://rockfish.ayanova.com/"; + #endif //Unlicensed token private const string UNLICENSED_TOKEN = "UNLICENSED"; @@ -492,7 +491,11 @@ namespace AyaNova.Core /// Fetch a key, validate it and install it in the db then initialize with it /// /// Result string - internal static async Task FetchKeyAsync(AyaNova.Api.ControllerHelpers.ApiServerState apiServerState, AyContext ct, ILogger log, bool calledFromInternalJob) +#if (DEBUG) + internal static async Task FetchKeyAsync(AyaNova.Api.ControllerHelpers.ApiServerState apiServerState, AyContext ct, ILogger log, bool calledFromInternalJob, bool devTestTrial=false) +#else + internal static async Task FetchKeyAsync(AyaNova.Api.ControllerHelpers.ApiServerState apiServerState, AyContext ct, ILogger log, bool calledFromInternalJob) +#endif { if (calledFromInternalJob) log.LogTrace($"Fetching license for DBID {LicenseDbId} (called by job)"); @@ -500,7 +503,16 @@ namespace AyaNova.Core log.LogInformation($"Fetching license for DBID {LicenseDbId}"); var FetchRequest = new dtoFetchRequest() { DbId = LicenseDbId }; +#if (DEBUG) string sUrl = $"{LICENSE_SERVER_URL}rvf"; + if (devTestTrial) + { + sUrl += "?dtt=true";//signal to rockfish to provide a key immediately for dev testing + } +#else + string sUrl = $"{LICENSE_SERVER_URL}rvf"; +#endif + try { // string ResponseText = await ServiceProviderProvider.HttpClientFactory.CreateClient().GetStringAsync(sUrl);