This commit is contained in:
2020-01-27 21:40:15 +00:00
parent 693ddb6b4b
commit 3c9a6c8ea6
4 changed files with 18 additions and 13 deletions

View File

@@ -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;
}