This commit is contained in:
2023-01-10 00:44:33 +00:00
parent c4b6f5e1d2
commit 8467470c1d
4 changed files with 65 additions and 36 deletions

View File

@@ -476,6 +476,7 @@ namespace Sockeye.Biz
}
*/
var l = new License();
l.Active = true;
l.RegTo = jLicense["regTo"].Value<string>();
//try to match customer; rockfish didn't track customer id in the license so this is a bit wishy washy
@@ -489,6 +490,9 @@ namespace Sockeye.Biz
var KeyText = jLicense["key"].Value<string>();
l.Key = KeyText;
LicenseBiz.ParseKeySetDTOFields(l);
if (KeyText.Contains("AyaNovaLicenseKey"))
{
//v7 key
@@ -548,8 +552,8 @@ namespace Sockeye.Biz
if (jKey["AyaNovaLicenseKey"]["LockDate"] != null)
l.LicenseExpire = jKey["AyaNovaLicenseKey"]["LockDate"].Value<DateTime>().ToUniversalTime();
l.MaintenanceExpire = jKey["AyaNovaLicenseKey"]["Expires"].Value<DateTime>().ToUniversalTime();
//l.Users=jKey["AyaNovaLicenseKey"]["TotalScheduleableUsers"].Value<int>();
l.PGroup = ProductGroup.AyaNova7;
l.FetchCode = jLicense["code"].Value<string>();
l.Tags.Add("v7");
@@ -572,6 +576,7 @@ namespace Sockeye.Biz
l.LicenseExpire = jKey["AyaNovaLiteLicenseKey"]["LockDate"].Value<DateTime>().ToUniversalTime();
l.MaintenanceExpire = jKey["AyaNovaLiteLicenseKey"]["Expires"].Value<DateTime>().ToUniversalTime();
l.PGroup = ProductGroup.AyaNova7;
l.FetchCode = jLicense["code"].Value<string>();
l.Tags.Add("v7");
@@ -615,7 +620,7 @@ namespace Sockeye.Biz
l.Created = (DateTime)DateUtil.EpochToDateNullIsNull(jLicense["dtcreated"].Value<long>());
l.FetchedOn = DateUtil.EpochToDateNullIsNull(jLicense["dtfetched"].Value<long?>());
l.FetchEmail = jLicense["email"].Value<string>();
l.Key = jLicense["key"].Value<string>();
// l.Key = jLicense["key"].Value<string>();
l.Active = true;//active here means it's been fully prepared and is viable for use, all prior licenses fit this description so all are active
l.NotificationSent = true;
@@ -662,31 +667,54 @@ namespace Sockeye.Biz
//Save Key first then can set keyid on tlr
long? TrialKeyId = null;
{
License l = new License();
l.TrialMode = true;
l.Key = jTrialRequestItem["key"].Value<string>();
string sKey = jTrialRequestItem["key"].Value<string>();
if (!string.IsNullOrWhiteSpace(sKey))
{
License l = new License();
l.TrialMode = true;
//Parse key as we need the expiry dates and they are only stored in the key not the trial request
string keyNoWS = System.Text.RegularExpressions.Regex.Replace(StringUtil.Extract(l.Key, "[KEY", "KEY]").Trim(), "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1");
var jKey = JObject.Parse(keyNoWS);
l.DbId = jKey["Key"]["DBID"].Value<string>();
l.LicenseExpire = jKey["Key"]["LicenseExpiration"].Value<DateTime>().ToUniversalTime();
if ((bool?)jKey["Key"]["Perpetual"] ?? true)
l.PGroup = ProductGroup.RavenPerpetual;
else
l.PGroup = ProductGroup.RavenSubscription;
l.MaintenanceExpire = jKey["Key"]["MaintenanceExpiration"].Value<DateTime>().ToUniversalTime();
l.Tags.Add("raven");
l.Tags.Add("trial");
l.Created = DateUtil.EpochToDateNullIsMin(jTrialRequestItem["dtProcessed"].Value<long>());
l.FetchedOn = DateUtil.EpochToDateNullIsNull(jTrialRequestItem["dtFetched"].Value<long?>());
l.FetchEmail = jTrialRequestItem["email"].Value<string>();
l.Key = sKey;
//Parse key as we need the expiry dates and they are only stored in the key not the trial request
string keyNoWS = System.Text.RegularExpressions.Regex.Replace(StringUtil.Extract(l.Key, "[KEY", "KEY]").Trim(), "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1");
var jKey = JObject.Parse(keyNoWS);
l.Active = true;//active here means it's been fully prepared and is viable for use, all prior licenses fit this description so all are active
l.NotificationSent = true;
LicenseBiz lbiz = LicenseBiz.GetBiz(ct);
await lbiz.CreateAsync(l, true);
l.RegTo = jKey["Key"]["RegisteredTo"].Value<string>();
//try to match customer; rockfish didn't track customer id in the license so this is a bit wishy washy
Customer cust = null;
cust = await ct.Customer.AsNoTracking().FirstOrDefaultAsync(z => z.Name == l.RegTo);
if (cust == null)//email?
cust = await ct.Customer.AsNoTracking().FirstOrDefaultAsync(z => z.EmailAddress.Contains(jTrialRequestItem["email"].Value<string>()));
if (cust != null)
l.CustomerId = cust.Id;
l.DbId = jKey["Key"]["DBID"].Value<string>();
l.LicenseExpire = jKey["Key"]["LicenseExpiration"].Value<DateTime>().ToUniversalTime();
if ((bool?)jKey["Key"]["Perpetual"] ?? true)
l.PGroup = ProductGroup.RavenPerpetual;
else
l.PGroup = ProductGroup.RavenSubscription;
l.MaintenanceExpire = jKey["Key"]["MaintenanceExpiration"].Value<DateTime>().ToUniversalTime();
l.Tags.Add("raven");
l.Tags.Add("trial");
l.Created = DateUtil.EpochToDateNullIsMin(jTrialRequestItem["dtProcessed"].Value<long>());
l.FetchedOn = DateUtil.EpochToDateNullIsNull(jTrialRequestItem["dtFetched"].Value<long?>());
l.FetchEmail = jTrialRequestItem["email"].Value<string>();
l.Active = true;//active here means it's been fully prepared and is viable for use, all prior licenses fit this description so all are active
l.NotificationSent = true;
LicenseBiz lbiz = LicenseBiz.GetBiz(ct);
var newLicenseObject = await lbiz.CreateAsync(l, true);
if (newLicenseObject == null)
;
else
TrialKeyId = newLicenseObject.Id;
}
}
{
@@ -702,7 +730,7 @@ namespace Sockeye.Biz
tlr.Processed = DateUtil.EpochToDateNullIsNull(jTrialRequestItem["dtProcessed"].Value<long?>());
tlr.Status = (TrialRequestStatus)jTrialRequestItem["status"].Value<int>();
tlr.RejectReason = jTrialRequestItem["rejectReason"].Value<string>();
tlr.KeyId = TrialKeyId;
var biz = TrialLicenseRequestBiz.GetBiz(ct);
await biz.CreateAsync(tlr);
}

View File

@@ -78,7 +78,7 @@ namespace Sockeye.Biz
#region PARSE KEY SET DTO FIELDS
//Read the license key text, parse it and set the dto fields accordingly
internal License ParseKeySetDTOFields(License l)
public static License ParseKeySetDTOFields(License l)
{
if (l == null || string.IsNullOrWhiteSpace(l.Key))
@@ -411,11 +411,12 @@ namespace Sockeye.Biz
var feature = jFeature["Name"].Value<string>();
int count = 0;
if (feature != "TrialMode")
count = jFeature["Count"].Value<int>();
else
if (feature == "TrialMode")
l.TrialMode = true;
if (jFeature["Count"] != null)
count = jFeature["Count"].Value<int>();
if (feature == "ActiveInternalUsers")
l.Users = count;
@@ -600,14 +601,15 @@ namespace Sockeye.Biz
bool isNew = currentObj == null;
//fetched keys are never editable, must be duped if re-issue
if (currentObj.FetchedOn != null)
//I'LL PROBABLY NEED TO CHANGE THIS LATER FOR SOME REASON BUT FOR NOW IT'S DEFENSIVE
if (!isNew && currentObj.FetchedOn != null)
{
AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "generalerror", "Fetched, not changeable, duplicate instead");
return;
}
//MISC product group is not valid for keys
if (currentObj.PGroup == ProductGroup.Misc)
if (proposedObj.PGroup == ProductGroup.Misc)
{
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "pGroup");
return;

View File

@@ -195,7 +195,6 @@ namespace Sockeye.Biz
.AddText(obj.Email)
.AddText(obj.EmailConfirmCode)
.AddText(obj.RejectReason)
.AddText(obj.Key)
.AddText(obj.Tags);
}

View File

@@ -22,16 +22,16 @@ namespace Sockeye.Util
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImportingAsync WHEN NEW TABLES ADDED!!!!
private const int DESIRED_SCHEMA_LEVEL = 17;
internal const long EXPECTED_COLUMN_COUNT = 504;
internal const long EXPECTED_COLUMN_COUNT = 505;
internal const long EXPECTED_INDEX_COUNT = 74;
internal const long EXPECTED_CHECK_CONSTRAINTS = 240;
internal const long EXPECTED_FOREIGN_KEY_CONSTRAINTS = 32;
internal const long EXPECTED_CHECK_CONSTRAINTS = 242;
internal const long EXPECTED_FOREIGN_KEY_CONSTRAINTS = 33;
internal const long EXPECTED_VIEWS = 0;
internal const long EXPECTED_ROUTINES = 2;
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImportingAsync WHEN NEW TABLES ADDED!!!!
///////////////////////////////////////// C504:I74:CC241:FC32:V0:R2)
///////////////////////////////////////// (C505:I74:CC242:FC33:V0:R2)
/*
MAXIMUM POSTGRES OBJECT NAME LENGTH: 63 CHARACTERS