This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);//#############################################################################################
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ namespace AyaNova.Core
|
||||
/// Request a key
|
||||
/// </summary>
|
||||
/// <returns>Result string</returns>
|
||||
internal static string RequestTrial(string email, string regto, ILogger log)
|
||||
internal static async Task<string> 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
|
||||
/// </summary>
|
||||
/// <returns>Result string</returns>
|
||||
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
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Install key to db
|
||||
/// </summary>
|
||||
private static async Task<bool> Install(string RawTextNewKey, AyaNovaLicenseKey ParsedNewKey, AyaNova.Api.ControllerHelpers.ApiServerState apiServerState, AyContext ct, ILogger log)
|
||||
private static async Task<bool> 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user