More subscription stuff
This commit is contained in:
@@ -74,7 +74,13 @@ namespace rockfishCore.Controllers
|
||||
|
||||
|
||||
//if there is an active trial for this db then can't do this they must request we re-release it or completely zap the database instead
|
||||
var MustBeOlderThan = DateUtil.DateToEpoch(DateTime.Now.AddDays((RavenKeyFactory.TRIAL_PERIOD_DAYS * -1)));
|
||||
long MustBeOlderThan = 0;
|
||||
if (r.Perpetual)
|
||||
MustBeOlderThan = DateUtil.DateToEpoch(DateTime.Now.AddDays((RavenKeyFactory.PERPETUAL_TRIAL_PERIOD_DAYS * -1)));
|
||||
else
|
||||
MustBeOlderThan = DateUtil.DateToEpoch(DateTime.Now.AddHours((RavenKeyFactory.SUBSCRIPTION_TRIAL_PERIOD_HOURS * -1)));
|
||||
|
||||
|
||||
if (await ct.TrialRequest.Where(z => z.DbId == r.DbId && z.DtProcessed != null && z.DtProcessed > MustBeOlderThan).AnyAsync())
|
||||
{
|
||||
return BadRequest("E1000 - Can't trial; there is already an active trial license issued for this database Id");
|
||||
@@ -86,7 +92,7 @@ namespace rockfishCore.Controllers
|
||||
NewRequest.DbId = r.DbId;
|
||||
NewRequest.CompanyName = r.Company;
|
||||
NewRequest.ContactName = r.Contact;
|
||||
NewRequest.Perpetual=r.Perpetual;
|
||||
NewRequest.Perpetual = r.Perpetual;
|
||||
await ct.TrialRequest.AddAsync(NewRequest);
|
||||
await ct.SaveChangesAsync();
|
||||
NewRequest.EmailConfirmCode = NewRequest.Id.ToString() + FetchKeyCode.generate();
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ app.ravLicense = (function () {
|
||||
} else {
|
||||
if (!$("#licenseExpires").prop("checked")) {
|
||||
alert(
|
||||
"Subscriptin licenses MUST have a license expiry, can not process"
|
||||
"Subscription licenses MUST have a license expiry, can not process"
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user