diff --git a/server/biz/GlobalBizSettingsBiz.cs b/server/biz/GlobalBizSettingsBiz.cs index 6c7289f..2490db8 100644 --- a/server/biz/GlobalBizSettingsBiz.cs +++ b/server/biz/GlobalBizSettingsBiz.cs @@ -566,7 +566,7 @@ namespace Sockeye.Biz */ string keyNoWS = System.Text.RegularExpressions.Regex.Replace(StringUtil.Extract(KeyText, "[KEY", "KEY]").Trim(), "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1"); var jKey = JObject.Parse(keyNoWS); - //In v7 the license expires is an optional property set called "LockDate" + //In v7 the license expires is an optional property set called "LockDate" l.LicenseExpire = null; if (jKey["AyaNovaLiteLicenseKey"]["LockDate"] != null) l.LicenseExpire = jKey["AyaNovaLiteLicenseKey"]["LockDate"].Value().ToUniversalTime(); @@ -618,7 +618,7 @@ namespace Sockeye.Biz l.Key = jLicense["key"].Value(); 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 biz = LicenseBiz.GetBiz(ct); await biz.CreateAsync(l); diff --git a/server/biz/LicenseBiz.cs b/server/biz/LicenseBiz.cs index a063464..3852486 100644 --- a/server/biz/LicenseBiz.cs +++ b/server/biz/LicenseBiz.cs @@ -50,8 +50,6 @@ namespace Sockeye.Biz { await GenerateKey(newObject); if (HasErrors) return null; - - newObject.Tags = TagBiz.NormalizeTags(newObject.Tags); await ct.License.AddAsync(newObject); await ct.SaveChangesAsync(); @@ -487,22 +485,24 @@ namespace Sockeye.Biz internal async Task GenerateKey(License l) { - if(l.CustomerId!=null){ - l.CustomerViz=await ct.Customer.AsNoTracking().Where(x => x.Id == l.CustomerId).Select(x => x.Name).FirstOrDefaultAsync(); + if (l.CustomerId != null) + { + l.CustomerViz = await ct.Customer.AsNoTracking().Where(x => x.Id == l.CustomerId).Select(x => x.Name).FirstOrDefaultAsync(); } - - switch(l.PGroup){ - case ProductGroup.RavenPerpetual: + + switch (l.PGroup) + { + case ProductGroup.RavenPerpetual: case ProductGroup.RavenSubscription: - { - RavenKeyFactory.GenerateAndSetRavenKey(l); - } - break; + { + RavenKeyFactory.GenerateAndSetRavenKey(l); + } + break; case ProductGroup.AyaNova7: - { - KeyFactory.GenerateAndSetV7Key(l); - } - break; + { + KeyFactory.GenerateAndSetV7Key(l); + } + break; } } diff --git a/server/models/License.cs b/server/models/License.cs index e8b9572..fa81034 100644 --- a/server/models/License.cs +++ b/server/models/License.cs @@ -17,6 +17,7 @@ namespace Sockeye.Models public DateTime Created { get; set; } public bool Active { get; set; }//active licenses can be fetched by customer, inactive means still putting together or it's been kiboshed + public bool NotificationSent { get; set; } public long? CustomerId { get; set; } [NotMapped] public string CustomerViz { get; set; } @@ -32,13 +33,15 @@ namespace Sockeye.Models public DateTime? LicenseExpire { get; set; } public DateTime MaintenanceExpire { get; set; } + public bool TrialMode { get; set; } = false;//v8 indicates it was requested by user as trial request or manually created as a trial request in UI + //v8 dto props [NotMapped] public int? CustomerUsers { get; set; }//v8 - subscription only [NotMapped] public int? MaxDataGB { get; set; }//v8 - subscription only - [NotMapped] - public bool TrialMode { get; set; } = false;//v8 indicates it was requested by user as trial request or manually created as a trial request in UI + + //shared dto props [NotMapped] public int Users { get; set; }//v7 scheduled users, v8 internal users diff --git a/server/models/TrialLicenseRequest.cs b/server/models/TrialLicenseRequest.cs index e90d8ad..5c0664e 100644 --- a/server/models/TrialLicenseRequest.cs +++ b/server/models/TrialLicenseRequest.cs @@ -29,9 +29,9 @@ namespace Sockeye.Models public DateTime? Processed { get; set; } public TrialRequestStatus Status { get; set; } = TrialRequestStatus.New; public string RejectReason { get; set; } - public string Key { get; set; } - public DateTime? FetchedOn { get; set; } - public bool Perpetual { get; set; } = false; + public long? KeyId { get; set; } + [Required] + public ProductGroup PGroup { get; set; } public List Tags { get; set; } //workaround for notification diff --git a/server/util/AySchema.cs b/server/util/AySchema.cs index ad3b150..ef7a650 100644 --- a/server/util/AySchema.cs +++ b/server/util/AySchema.cs @@ -875,14 +875,15 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); await ExecQueryAsync("CREATE TABLE alicense (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, created TIMESTAMPTZ NOT NULL, active BOOL NOT NULL DEFAULT false, " + "customerid BIGINT REFERENCES acustomer(id), pgroup INTEGER NOT NULL DEFAULT 0, regto TEXT NOT NULL, key TEXT, fetchcode TEXT, fetchemail TEXT, " - + "fetchedon TIMESTAMPTZ, dbid TEXT, licenseexpire TIMESTAMPTZ, maintenanceexpire TIMESTAMPTZ NOT NULL, " + + "fetchedon TIMESTAMPTZ, dbid TEXT, licenseexpire TIMESTAMPTZ, maintenanceexpire TIMESTAMPTZ NOT NULL, notificationsent BOOL NOT NULL DEFAULT false, " + + "trialmode BOOL NOT NULL DEFAULT false, " + "wiki TEXT, tags VARCHAR(255) ARRAY )"); await ExecQueryAsync("CREATE TABLE atriallicenserequest (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, dbid TEXT NOT NULL, companyname TEXT NOT NULL, " + "contactname TEXT NOT NULL, email TEXT NOT NULL, emailconfirmcode TEXT NOT NULL, emailvalidated BOOL DEFAULT false, " - + "requested TIMESTAMPTZ NOT NULL, processed TIMESTAMPTZ, status INTEGER NOT NULL DEFAULT 0, rejectreason TEXT, key TEXT, " - + "fetchedon TIMESTAMPTZ, perpetual BOOL DEFAULT false NOT NULL, tags VARCHAR(255) ARRAY )"); + + "requested TIMESTAMPTZ NOT NULL, processed TIMESTAMPTZ, status INTEGER NOT NULL DEFAULT 0, rejectreason TEXT, licenseid BIGINT REFERENCES alicense(id), " + + "pgroup INTEGER NOT NULL DEFAULT 0, tags VARCHAR(255) ARRAY )"); await ExecQueryAsync("CREATE TABLE asubscriptionserver (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, active BOOL NOT NULL DEFAULT true, created TIMESTAMPTZ NOT NULL, " @@ -923,6 +924,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseFetchedOn', 'Fetched date' FROM atranslation t where t.baselanguage = 'en'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseDBID', 'DBID' FROM atranslation t where t.baselanguage = 'en'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseMaintenanceExpire', 'Maintenance expires' FROM atranslation t where t.baselanguage = 'en'"); + await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'NotificationSent', 'Notification sent' FROM atranslation t where t.baselanguage = 'en'"); //spanish translations await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseList', 'Licenses' FROM atranslation t where t.baselanguage = 'es'"); @@ -933,6 +935,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseFetchedOn', 'Fetched date' FROM atranslation t where t.baselanguage = 'es'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseDBID', 'DBID' FROM atranslation t where t.baselanguage = 'es'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseMaintenanceExpire', 'Maintenance expires' FROM atranslation t where t.baselanguage = 'es'"); + await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'NotificationSent', 'Notification sent' FROM atranslation t where t.baselanguage = 'es'"); //french translations await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseList', 'Licenses' FROM atranslation t where t.baselanguage = 'fr'"); @@ -943,6 +946,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseFetchedOn', 'Fetched date' FROM atranslation t where t.baselanguage = 'fr'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseDBID', 'DBID' FROM atranslation t where t.baselanguage = 'fr'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseMaintenanceExpire', 'Maintenance expires' FROM atranslation t where t.baselanguage = 'fr'"); + await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'NotificationSent', 'Notification sent' FROM atranslation t where t.baselanguage = 'es'"); //german translations await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseList', 'Licenses' FROM atranslation t where t.baselanguage = 'de'"); @@ -953,6 +957,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseFetchedOn', 'Fetched date' FROM atranslation t where t.baselanguage = 'de'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseDBID', 'DBID' FROM atranslation t where t.baselanguage = 'de'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseMaintenanceExpire', 'Maintenance expires' FROM atranslation t where t.baselanguage = 'de'"); + await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'NotificationSent', 'Notification sent' FROM atranslation t where t.baselanguage = 'es'"); #endregion license @@ -968,8 +973,6 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestProcessed', 'Processed' FROM atranslation t where t.baselanguage = 'en'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestStatus', 'Status' FROM atranslation t where t.baselanguage = 'en'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestRejectReason', 'Reject reason' FROM atranslation t where t.baselanguage = 'en'"); - await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestFetchedOn', 'Fetched' FROM atranslation t where t.baselanguage = 'en'"); - await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestPerpetual', 'Perpetual' FROM atranslation t where t.baselanguage = 'en'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialRequestStatusNew', 'New' FROM atranslation t where t.baselanguage = 'en'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialRequestStatusApproved', 'Approved' FROM atranslation t where t.baselanguage = 'en'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialRequestStatusRejected', 'Rejected' FROM atranslation t where t.baselanguage = 'en'"); @@ -985,8 +988,6 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestProcessed', 'Processed' FROM atranslation t where t.baselanguage = 'es'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestStatus', 'Status' FROM atranslation t where t.baselanguage = 'es'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestRejectReason', 'Reject reason' FROM atranslation t where t.baselanguage = 'es'"); - await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestFetchedOn', 'Fetched' FROM atranslation t where t.baselanguage = 'es'"); - await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestPerpetual', 'Perpetual' FROM atranslation t where t.baselanguage = 'es'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialRequestStatusNew', 'New' FROM atranslation t where t.baselanguage = 'es'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialRequestStatusApproved', 'Approved' FROM atranslation t where t.baselanguage = 'es'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialRequestStatusRejected', 'Rejected' FROM atranslation t where t.baselanguage = 'es'"); @@ -1002,8 +1003,6 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestProcessed', 'Processed' FROM atranslation t where t.baselanguage = 'fr'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestStatus', 'Status' FROM atranslation t where t.baselanguage = 'fr'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestRejectReason', 'Reject reason' FROM atranslation t where t.baselanguage = 'fr'"); - await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestFetchedOn', 'Fetched' FROM atranslation t where t.baselanguage = 'fr'"); - await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestPerpetual', 'Perpetual' FROM atranslation t where t.baselanguage = 'fr'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialRequestStatusNew', 'New' FROM atranslation t where t.baselanguage = 'fr'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialRequestStatusApproved', 'Approved' FROM atranslation t where t.baselanguage = 'fr'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialRequestStatusRejected', 'Rejected' FROM atranslation t where t.baselanguage = 'fr'"); @@ -1019,8 +1018,6 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestProcessed', 'Processed' FROM atranslation t where t.baselanguage = 'de'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestStatus', 'Status' FROM atranslation t where t.baselanguage = 'de'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestRejectReason', 'Reject reason' FROM atranslation t where t.baselanguage = 'de'"); - await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestFetchedOn', 'Fetched' FROM atranslation t where t.baselanguage = 'de'"); - await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestPerpetual', 'Perpetual' FROM atranslation t where t.baselanguage = 'de'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialRequestStatusNew', 'New' FROM atranslation t where t.baselanguage = 'de'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialRequestStatusApproved', 'Approved' FROM atranslation t where t.baselanguage = 'de'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialRequestStatusRejected', 'Rejected' FROM atranslation t where t.baselanguage = 'de'"); diff --git a/todo.txt b/todo.txt index 1bde6aa..3fe2c5b 100644 --- a/todo.txt +++ b/todo.txt @@ -1,6 +1,16 @@ LICENSE NOTES +Move license from trialrequest to license object and set the linking id of the license on the request +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 + + + +------ + Sockeye should generate a license on a sale receipt, maybe after a slight delay. Generated license should be in the list of licenses but have a unfulfilled status of some kind so it's ready for me to visually see purchases applicable and confirm approve and send it with one click but it's not doing it itself.