diff --git a/devdocs/todo.txt b/devdocs/todo.txt
index 44f6e4e4..dd3a382a 100644
--- a/devdocs/todo.txt
+++ b/devdocs/todo.txt
@@ -19,6 +19,11 @@ TODO: REFACTOR GetNoLogAsync function is used in many places redundantly when th
TODO: REFACTOR biz objects have two creates, an async and sync one, WTF is that about? See if can make it just one async version.
- https://docs.microsoft.com/en-us/aspnet/core/performance/performance-best-practices?view=aspnetcore-3.1
+
+TODO: License.cs using httpclient directly albeit trying to do it right`
+ - Change to use httpclientfactory injected service:
+ - https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-3.1
+
TODO: Need route to gather all object role rights in a format useful to display in UI so that a biz manager can see at a glance the rights for different roles to objects
- This way it's dynamic and picked up from the code itself which is always the source of truth so no need to put in the manual
- Would likely want to display multiple ways: for a specific object or role or selected user maybe too in the user info form ("effective roles")
diff --git a/server/AyaNova/Controllers/LicenseController.cs b/server/AyaNova/Controllers/LicenseController.cs
index df33edd0..61208146 100644
--- a/server/AyaNova/Controllers/LicenseController.cs
+++ b/server/AyaNova/Controllers/LicenseController.cs
@@ -98,7 +98,7 @@ namespace AyaNova.Api.Controllers
try
{
- AyaNova.Core.License.Fetch(serverState, ct, log);
+ AyaNova.Core.License.FetchKeyAsync(serverState, ct, log);
}
catch (Exception ex)
{
@@ -166,7 +166,7 @@ namespace AyaNova.Api.Controllers
}
//Send the request to RockFish here (or at least start the job to do it in which case return Accepted instead of no content and update comment above)
- var ret = Core.License.RequestTrial(requestData.EmailAddress, requestData.RegisteredTo, log);
+ var ret = Core.License.RequestTrialAsync(requestData.EmailAddress, requestData.RegisteredTo, log);
//Log
EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.License, AyaEvent.LicenseTrialRequest), ct);
diff --git a/server/AyaNova/Startup.cs b/server/AyaNova/Startup.cs
index ed7413da..d28f2224 100644
--- a/server/AyaNova/Startup.cs
+++ b/server/AyaNova/Startup.cs
@@ -435,7 +435,7 @@ namespace AyaNova
DbUtil.CheckFingerPrint(AySchema.EXPECTED_COLUMN_COUNT, AySchema.EXPECTED_INDEX_COUNT, _newLog);
//Initialize license
- AyaNova.Core.License.Initialize(apiServerState, dbContext, _newLog);
+ AyaNova.Core.License.InitializeAsync(apiServerState, dbContext, _newLog);
//Ensure locales are present, not missing any keys and that there is a server default locale that exists
LocaleBiz lb = new LocaleBiz(dbContext, 1, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, AuthorizationRoles.OpsAdminFull);
@@ -447,7 +447,7 @@ namespace AyaNova
//TESTING
if (TESTING_REFRESH_DB)
{
- AyaNova.Core.License.Fetch(apiServerState, dbContext, _newLog);
+ AyaNova.Core.License.FetchKeyAsync(apiServerState, dbContext, _newLog);
//NOTE: For unit testing make sure the time zone in util is set to the same figure as here to ensure list filter by date tests will work because server is on same page as user in terms of time
Util.Seeder.SeedDatabase(Util.Seeder.SeedLevel.SmallOneManShopTrialDataSet, -7);//#############################################################################################
}
diff --git a/server/AyaNova/util/License.cs b/server/AyaNova/util/License.cs
index ae31167a..3d8f0286 100644
--- a/server/AyaNova/util/License.cs
+++ b/server/AyaNova/util/License.cs
@@ -339,7 +339,7 @@ namespace AyaNova.Core
/// Request a key
///
/// Result string
- internal static string RequestTrial(string email, string regto, ILogger log)
+ internal static async Task RequestTrialAsync(string email, string regto, ILogger log)
{
//BEFORE_RELEASE: DO THE FOLLOWING BEFORE RELEASE:
//TODO: TESTING REMOVE BEFORE RELEASE
@@ -361,7 +361,7 @@ namespace AyaNova.Core
string sUrl = $"{LICENSE_SERVER_URL}rvr" + q.ToQueryString();
try
{
- var res = _Client.GetStringAsync(sUrl).Result;
+ var res = await _Client.GetStringAsync(sUrl);
return res;
}
catch (Exception ex)
@@ -382,7 +382,7 @@ namespace AyaNova.Core
/// Fetch a key, validate it and install it in the db then initialize with it
///
/// Result string
- internal static void Fetch(AyaNova.Api.ControllerHelpers.ApiServerState apiServerState, AyContext ctx, ILogger log)
+ internal static async Task FetchKeyAsync(AyaNova.Api.ControllerHelpers.ApiServerState apiServerState, AyContext ct, ILogger log)
{
log.LogDebug($"Fetching license for DBID {DbId.ToString()}");
string sUrl = $"{LICENSE_SERVER_URL}rvf/{DbId.ToString()}";
@@ -394,14 +394,14 @@ namespace AyaNova.Core
try
{
- string RawTextKeyFromRockfish = _Client.GetStringAsync(sUrl).Result;
+ string RawTextKeyFromRockfish = await _Client.GetStringAsync(sUrl);
//FUTURE: if there is any kind of error response or REASON or LicenseFetchStatus then here is
//where to deal with it
AyaNovaLicenseKey ParsedKey = Parse(RawTextKeyFromRockfish, log);
if (ParsedKey != null)
{
- Install(RawTextKeyFromRockfish, ParsedKey, apiServerState, ctx, log);
+ await InstallAsync(RawTextKeyFromRockfish, ParsedKey, apiServerState, ct, log);
}
}
catch (Exception ex)
@@ -417,14 +417,14 @@ namespace AyaNova.Core
/// Initialize the key
/// Handle if first boot scenario to tag DB ID etc
///
- internal static async Task Initialize(AyaNova.Api.ControllerHelpers.ApiServerState apiServerState, AyContext ct, ILogger log)
+ internal static async Task InitializeAsync(AyaNova.Api.ControllerHelpers.ApiServerState apiServerState, AyContext ct, ILogger log)
{
log.LogDebug("Initializing license");
try
{
//Fetch key from db as no tracking so doesn't hang round if need to immediately clear and then re-add the key
- Models.License ldb = ct.License.AsNoTracking().SingleOrDefault();
+ Models.License ldb = await ct.License.AsNoTracking().SingleOrDefaultAsync();
//Non existent license should restrict server to ops routes only with closed API
if (ldb == null)
@@ -508,7 +508,7 @@ namespace AyaNova.Core
///
/// Install key to db
///
- private static async Task Install(string RawTextNewKey, AyaNovaLicenseKey ParsedNewKey, AyaNova.Api.ControllerHelpers.ApiServerState apiServerState, AyContext ct, ILogger log)
+ private static async Task InstallAsync(string RawTextNewKey, AyaNovaLicenseKey ParsedNewKey, AyaNova.Api.ControllerHelpers.ApiServerState apiServerState, AyContext ct, ILogger log)
{
try
{
@@ -547,7 +547,7 @@ namespace AyaNova.Core
}
finally
{
- await Initialize(apiServerState, ct, log);
+ await InitializeAsync(apiServerState, ct, log);
}
return true;
}