This commit is contained in:
2020-06-10 14:40:12 +00:00
parent 7ffee42684
commit ff20c44710
5 changed files with 71 additions and 17 deletions

View File

@@ -30,6 +30,9 @@ namespace AyaNova.Core
// private const string LICENSE_SERVER_URL = "https://rockfish.ayanova.com/";
private const string LICENSE_SERVER_URL = "http://localhost:3001/";
//Unlicensed token
private const string UNLICENSED_TOKEN = "UNLICENSED";
//Scheduleable users
private const string SERVICE_TECHS_FEATURE_NAME = "ServiceTechs";
@@ -70,10 +73,26 @@ namespace AyaNova.Core
//DTO object for parsed key
internal class AyaNovaLicenseKey
{
// Return a license state enumeration value
// 0 = No license at all of any kind
// 1 = trial license key
// 2 = purchased license key
// 3 = purchased but expired key (license itself is expired, not the maintenance, that's seperate)
// Note: this has nothing to do with whether there is an active license or not, merely that it's of a type
// this is so client can display appropriate UI
public enum LicenseStatus
{
NONE = 0,
ActiveTrial = 1,
ExpiredTrial = 2,
ActivePurchased = 3,
ExpiredPurchased = 4
}
public AyaNovaLicenseKey()
{
Features = new List<LicenseFeature>();
RegisteredTo = "UNLICENSED";
RegisteredTo = UNLICENSED_TOKEN;
Id = RegisteredTo;
}
@@ -130,9 +149,27 @@ namespace AyaNova.Core
return false;
}
public LicenseStatus Status
{
get
{
if (string.IsNullOrWhiteSpace(RegisteredTo) || RegisteredTo == UNLICENSED_TOKEN)
return LicenseStatus.NONE;
if (TrialLicense && !LicenseExpired)
return LicenseStatus.ActiveTrial;
if (TrialLicense && LicenseExpired)
return LicenseStatus.ExpiredTrial;
if (!TrialLicense && !LicenseExpired)
return LicenseStatus.ActivePurchased;
if (!TrialLicense && LicenseExpired)
return LicenseStatus.ExpiredPurchased;
throw new System.Exception("License::Status - unable to determine license status");
}
}
//Has any kind of valid license that is active
//used for auth route checking to allow for fixing this issue
public bool IsLicensed
public bool KeyDoesNotNeedAttention
{
get
{
@@ -141,6 +178,7 @@ namespace AyaNova.Core
}
public bool IsEmpty
{
get
@@ -257,7 +295,7 @@ namespace AyaNova.Core
if (ActiveKey.IsEmpty)
{
sb.AppendLine("UNLICENSED");
sb.AppendLine(UNLICENSED_TOKEN);
sb.AppendLine($"DB ID: {DbId}");
}
else