More subscription stuff

This commit is contained in:
2022-08-26 23:01:19 +00:00
parent adcc07c8b9
commit c9adfbb656
3 changed files with 71 additions and 27 deletions

View File

@@ -38,7 +38,9 @@ namespace rockfishCore.Util
//Key generator controller
public static class RavenKeyFactory
{
public const int TRIAL_PERIOD_DAYS = 5;
public const int PERPETUAL_TRIAL_PERIOD_DAYS = 5;
public const int SUBSCRIPTION_TRIAL_PERIOD_HOURS = 48;
//Unlicensed token
private const string UNLICENSED_TOKEN = "UNLICENSED";
@@ -46,9 +48,16 @@ namespace rockfishCore.Util
//REVOKED token
public const string REVOKED_TOKEN = "REVOKED";
//FEATURE NAMES
//Scheduleable users
private const string SERVICE_TECHS_FEATURE_NAME = "ServiceTechs";
//LICENSE USER COUNT FEATURES
//PERPETUAL Scheduleable users
private const string ACTIVE_SERVICE_TECHS_FEATURE_NAME = "ServiceTechs";
//SUBSCRIPTION
private const string ACTIVE_INTERNAL_USERS_FEATURE_NAME = "ActiveInternalUsers";
private const string ACTIVE_CUSTOMER_USERS_FEATURE_NAME = "ActiveCustomerUsers";
//Add-on's / integrations
//This feature name means it's a trial key
@@ -104,7 +113,7 @@ namespace rockfishCore.Util
continue;
}
if (f.Feature == SERVICE_TECHS_FEATURE_NAME)
if (f.Feature == ACTIVE_SERVICE_TECHS_FEATURE_NAME)
{
sb.AppendLine($"Scheduleable resources: {f.Count}");
continue;
@@ -237,17 +246,61 @@ namespace rockfishCore.Util
k.RegisteredTo = CompanyName;
k.DbId = dbid;
k.Perpetual = Perpetual;
//trial period time limit
k.MaintenanceExpiration = k.LicenseExpiration = DateTime.UtcNow.AddDays(TRIAL_PERIOD_DAYS);
//flag as trial key not regular key
k.Features.Add(new LicenseFeature() { Feature = TRIAL_FEATURE_NAME, Count = 0 });
//add every possible feature
k.Features.Add(new LicenseFeature() { Feature = SERVICE_TECHS_FEATURE_NAME, Count = 100 });
if (Perpetual)
{
//trial period time limit
k.MaintenanceExpiration = k.LicenseExpiration = DateTime.UtcNow.AddDays(PERPETUAL_TRIAL_PERIOD_DAYS);
//enough techs to easily cover huge amounts of seeding (it's actually only 15 at the moment but you never know this is some buffer)
k.Features.Add(new LicenseFeature() { Feature = ACTIVE_SERVICE_TECHS_FEATURE_NAME, Count = 250 });
}
else
{
//SUBSCRIPTION
//trial period time limit
k.MaintenanceExpiration = k.LicenseExpiration = DateTime.UtcNow.AddHours(SUBSCRIPTION_TRIAL_PERIOD_HOURS);
//20k customer contacts will cover huge seeding level easily
//5k inside staff users will cover huge seeding level easily
k.Features.Add(new LicenseFeature() { Feature = ACTIVE_INTERNAL_USERS_FEATURE_NAME, Count = 5000 });
k.Features.Add(new LicenseFeature() { Feature = ACTIVE_CUSTOMER_USERS_FEATURE_NAME, Count = 20000 });
}
return GenerateRavenKey(k);
}
//TESTING ONLY this is for development purposes only
//No external usage
public static string GetRavenTestKey(string dbid, bool Perpetual)
{
//Build a sample test key, sign it and return it
AyaNovaLicenseKey k = new AyaNovaLicenseKey();
k.LicenseFormat = "8";
k.RegisteredTo = "GZ TestCo Inc.";
k.DbId = dbid;
k.Perpetual = Perpetual;
if (Perpetual)
{
k.MaintenanceExpiration = k.LicenseExpiration = DateTime.UtcNow.AddDays(PERPETUAL_TRIAL_PERIOD_DAYS);
k.Features.Add(new LicenseFeature() { Feature = ACTIVE_SERVICE_TECHS_FEATURE_NAME, Count = 250 });
}
else
{
//SUBSCRIPTION
k.MaintenanceExpiration = k.LicenseExpiration = DateTime.UtcNow.AddHours(SUBSCRIPTION_TRIAL_PERIOD_HOURS);
//20k customer contacts will cover huge seeding level easily
//5k inside staff users will cover huge seeding level easily
k.Features.Add(new LicenseFeature() { Feature = ACTIVE_INTERNAL_USERS_FEATURE_NAME, Count = 5000 });
k.Features.Add(new LicenseFeature() { Feature = ACTIVE_CUSTOMER_USERS_FEATURE_NAME, Count = 20000 });
}
k.Features.Add(new LicenseFeature() { Feature = TRIAL_FEATURE_NAME, Count = 0 });
return GenerateRavenKey(k);
}
/// <summary>
@@ -414,22 +467,7 @@ oArP0E2Vbow3JMxq/oeXmHbrLMLQfYyXwFmciLFigOtkd45bfHdrbA==
//this is for development purposes only
//No external usage
public static string GetRavenTestKey(string dbid, bool Perpetual)
{
//Build a sample test key, sign it and return it
AyaNovaLicenseKey k = new AyaNovaLicenseKey();
k.LicenseFormat = "8";
k.RegisteredTo = "GZ TestCo Inc.";
k.DbId = dbid;
k.Perpetual = Perpetual;
k.Features.Add(new LicenseFeature() { Feature = SERVICE_TECHS_FEATURE_NAME, Count = 100 });
k.MaintenanceExpiration = k.LicenseExpiration = DateTime.UtcNow.AddDays(TRIAL_PERIOD_DAYS);
k.Features.Add(new LicenseFeature() { Feature = TRIAL_FEATURE_NAME, Count = 0 });
return GenerateRavenKey(k);
}
//eoc
}