From 8a9970d346fc1291c75275c4ed49fa10b25efdfd Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 10 Jan 2023 01:33:52 +0000 Subject: [PATCH] --- server/biz/GlobalBizSettingsBiz.cs | 29 +++++++++++++++++--- server/biz/LicenseBiz.cs | 40 +++++++++++++++++++++++++++- server/models/TrialLicenseRequest.cs | 2 +- todo.txt | 2 +- 4 files changed, 66 insertions(+), 7 deletions(-) diff --git a/server/biz/GlobalBizSettingsBiz.cs b/server/biz/GlobalBizSettingsBiz.cs index a409664..b13038f 100644 --- a/server/biz/GlobalBizSettingsBiz.cs +++ b/server/biz/GlobalBizSettingsBiz.cs @@ -676,6 +676,9 @@ namespace Sockeye.Biz l.TrialMode = true; l.Key = sKey; + //get number of users count and features etc + LicenseBiz.ParseKeySetDTOFields(l); + //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); @@ -707,12 +710,30 @@ namespace Sockeye.Biz 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; + //workaround sketchy old testing licenses + if (l.PGroup == ProductGroup.RavenSubscription) + { + if (l.MaxDataGB == null || l.MaxDataGB == 0) + l.MaxDataGB = 20; + + if (l.CustomerUsers == null || l.CustomerUsers == 0) + l.CustomerUsers = 250; + + + } + + + LicenseBiz lbiz = LicenseBiz.GetBiz(ct); var newLicenseObject = await lbiz.CreateAsync(l, true); + +#if (DEBUG) if (newLicenseObject == null) - ; - else - TrialKeyId = newLicenseObject.Id; + { + System.Diagnostics.Debugger.Break(); + } +#endif + TrialKeyId = newLicenseObject.Id; } } @@ -730,7 +751,7 @@ namespace Sockeye.Biz tlr.Processed = DateUtil.EpochToDateNullIsNull(jTrialRequestItem["dtProcessed"].Value()); tlr.Status = (TrialRequestStatus)jTrialRequestItem["status"].Value(); tlr.RejectReason = jTrialRequestItem["rejectReason"].Value(); - tlr.KeyId = TrialKeyId; + tlr.LicenseId = TrialKeyId; var biz = TrialLicenseRequestBiz.GetBiz(ct); await biz.CreateAsync(tlr); } diff --git a/server/biz/LicenseBiz.cs b/server/biz/LicenseBiz.cs index a57fd7d..cc509c6 100644 --- a/server/biz/LicenseBiz.cs +++ b/server/biz/LicenseBiz.cs @@ -401,9 +401,43 @@ namespace Sockeye.Biz "Count": 20 } ] + + + + "Key": { + "LicenseFormat": "8", + "Id": "00-1593712003", + "RegisteredTo": "Test corporation", + "DBID": "mRntGkdwvYCDOAOroCQpB5Elbct09iNIS7lcU7QgRCY=", + "LicenseExpiration": "2020-08-16T17:46:43.6261717Z", + "MaintenanceExpiration": "2020-08-16T17:46:43.6261717Z", + "Features": [ + { + "Name": "TrialMode" + }, + { + "Name": "ServiceMode" + }, + { + "Name": "Accounting" + }, + { + "Name": "ServiceTechs", + "Count": 1000 + } + ] +} +} */ string keyNoWS = System.Text.RegularExpressions.Regex.Replace(StringUtil.Extract(l.Key, "[KEY", "KEY]").Trim(), "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1"); var jKey = JObject.Parse(keyNoWS); + +// #if (DEBUG) +// if (jKey["Key"]["DBID"].Value() == "mRntGkdwvYCDOAOroCQpB5Elbct09iNIS7lcU7QgRCY=") +// System.Diagnostics.Debugger.Break(); +// #endif + + var jaFeatures = (JArray)jKey.SelectToken("Key.Features"); for (int x = 0; x < jaFeatures.Count; x++) { @@ -417,7 +451,7 @@ namespace Sockeye.Biz if (jFeature["Count"] != null) count = jFeature["Count"].Value(); - if (feature == "ActiveInternalUsers") + if (feature == "ActiveInternalUsers" || feature == "ServiceTechs")//at one point early in testing was ServiceTechs kept for import from rockfish l.Users = count; if (feature == "ActiveCustomerUsers") @@ -429,6 +463,10 @@ namespace Sockeye.Biz } } +#if (DEBUG) + if (l.Users == 0) + System.Diagnostics.Debugger.Break(); +#endif return l; } diff --git a/server/models/TrialLicenseRequest.cs b/server/models/TrialLicenseRequest.cs index 5c0664e..3d84ebe 100644 --- a/server/models/TrialLicenseRequest.cs +++ b/server/models/TrialLicenseRequest.cs @@ -29,7 +29,7 @@ namespace Sockeye.Models public DateTime? Processed { get; set; } public TrialRequestStatus Status { get; set; } = TrialRequestStatus.New; public string RejectReason { get; set; } - public long? KeyId { get; set; } + public long? LicenseId { get; set; } [Required] public ProductGroup PGroup { get; set; } public List Tags { get; set; } diff --git a/todo.txt b/todo.txt index 3fe2c5b..54b3f2b 100644 --- a/todo.txt +++ b/todo.txt @@ -7,7 +7,7 @@ Import fixup, list fixup, ui fixup Basically, want only one place for a license to exist and that's in license table trial requests just drive the process, dont' actually cotnain a license anymore - +pgsql.PostgresException : 42703: column "keyid" of relation "atriallicenserequest" does not exist ------