This commit is contained in:
@@ -148,8 +148,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="requestData"></param>
|
/// <param name="requestData"></param>
|
||||||
/// <returns>HTTP 204 No Content result code on success or fail code with explanation</returns>
|
/// <returns>HTTP 204 No Content result code on success or fail code with explanation</returns>
|
||||||
[HttpPost("trialrequest")]
|
[HttpPost("trialRequest")]
|
||||||
public async Task<IActionResult> RequestTrial([FromBody] dtoRequestTrial requestData)
|
public async Task<IActionResult> RequestTrial([FromBody] RequestTrial trialRequest)
|
||||||
{
|
{
|
||||||
if (serverState.IsClosed)
|
if (serverState.IsClosed)
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
@@ -175,7 +175,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)
|
//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 = await Core.License.RequestTrialAsync(requestData.EmailAddress, requestData.RegisteredTo, log);
|
var ret = await Core.License.RequestTrialAsync(trialRequest, log);
|
||||||
|
|
||||||
//Log
|
//Log
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.License, AyaEvent.LicenseTrialRequest), ct);
|
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.License, AyaEvent.LicenseTrialRequest), ct);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
//JSON KEY
|
//JSON KEY
|
||||||
using Org.BouncyCastle.Security;
|
using Org.BouncyCastle.Security;
|
||||||
using Org.BouncyCastle.OpenSsl;
|
using Org.BouncyCastle.OpenSsl;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -27,8 +28,11 @@ namespace AyaNova.Core
|
|||||||
{
|
{
|
||||||
|
|
||||||
//License server address
|
//License server address
|
||||||
// private const string LICENSE_SERVER_URL = "https://rockfish.ayanova.com/";
|
#if (DEBUG)
|
||||||
private const string LICENSE_SERVER_URL = "http://localhost:3001/";
|
private const string LICENSE_SERVER_URL = "http://localhost:3001/";
|
||||||
|
#else
|
||||||
|
private const string LICENSE_SERVER_URL = "https://rockfish.ayanova.com/";
|
||||||
|
#endif
|
||||||
|
|
||||||
//Unlicensed token
|
//Unlicensed token
|
||||||
private const string UNLICENSED_TOKEN = "UNLICENSED";
|
private const string UNLICENSED_TOKEN = "UNLICENSED";
|
||||||
@@ -436,20 +440,28 @@ namespace AyaNova.Core
|
|||||||
/// Request a key
|
/// Request a key
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Result string</returns>
|
/// <returns>Result string</returns>
|
||||||
internal static async Task<string> RequestTrialAsync(string email, string regto, ILogger log)
|
internal static async Task<string> RequestTrialAsync(RequestTrial trialRequest, ILogger log)
|
||||||
{
|
{
|
||||||
|
|
||||||
Microsoft.AspNetCore.Http.Extensions.QueryBuilder q = new Microsoft.AspNetCore.Http.Extensions.QueryBuilder();
|
Microsoft.AspNetCore.Http.Extensions.QueryBuilder q = new Microsoft.AspNetCore.Http.Extensions.QueryBuilder();
|
||||||
q.Add("dbid", LicenseDbId.ToString());
|
trialRequest.DbId = ServerDbId;
|
||||||
q.Add("email", email);
|
|
||||||
q.Add("regto", regto);
|
|
||||||
|
|
||||||
log.LogDebug($"Requesting trial license for DBID {LicenseDbId.ToString()}");
|
log.LogDebug($"Requesting trial license for DBID {LicenseDbId.ToString()}");
|
||||||
string sUrl = $"{LICENSE_SERVER_URL}rvr" + q.ToQueryString();
|
string sUrl = $"{LICENSE_SERVER_URL}rvr" + q.ToQueryString();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var res = await ServiceProviderProvider.HttpClientFactory.CreateClient().GetStringAsync(sUrl);
|
// var content = new StringContent(jsonObject.ToString(), Encoding.UTF8, "application/json");
|
||||||
return res;
|
// var result = client.PostAsync(url, content).Result;
|
||||||
|
|
||||||
|
var content = new StringContent(JsonConvert.SerializeObject(trialRequest), Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
|
var client = ServiceProviderProvider.HttpClientFactory.CreateClient();
|
||||||
|
var res = await client.PostAsync(sUrl, content);
|
||||||
|
if (res.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
return "ok";
|
||||||
|
}
|
||||||
|
else return res.Content.ToString();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -478,7 +490,7 @@ namespace AyaNova.Core
|
|||||||
//FUTURE: if there is any kind of error response or REASON or LicenseFetchStatus then here is
|
//FUTURE: if there is any kind of error response or REASON or LicenseFetchStatus then here is
|
||||||
//where to deal with it
|
//where to deal with it
|
||||||
//todo: key should hang off json data object as text version of key
|
//todo: key should hang off json data object as text version of key
|
||||||
//that way we can put other objects on the data return object
|
//that way we can put other objects on the data return object
|
||||||
|
|
||||||
AyaNovaLicenseKey ParsedKey = Parse(RawTextKeyFromRockfish, log);
|
AyaNovaLicenseKey ParsedKey = Parse(RawTextKeyFromRockfish, log);
|
||||||
if (ParsedKey != null)
|
if (ParsedKey != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user