diff --git a/server/AyaNova/biz/UserBiz.cs b/server/AyaNova/biz/UserBiz.cs index 2273ebf3..9654d3a4 100644 --- a/server/AyaNova/biz/UserBiz.cs +++ b/server/AyaNova/biz/UserBiz.cs @@ -38,7 +38,7 @@ namespace AyaNova.Biz } //This is where SUBSCRIPTION active internal (non customer) license consumers are accounted for - internal static async Task ActiveInsideUserCountAsync() + internal static async Task ActiveInternalUserCountAsync() { using (AyContext ct = ServiceProviderProvider.DBContext) { @@ -757,7 +757,7 @@ namespace AyaNova.Biz //Yes, it might be affected depending on things long CurrentActiveCount = await UserBiz.ActiveTechUserCountAsync(); HERE - long LicensedUserCount = AyaNova.Core.License.ActiveKey.ActiveNumber; + long LicensedUserCount = AyaNova.Core.License.ActiveKey.ActiveTechsCount; if (isNew) { diff --git a/server/AyaNova/generator/CoreJobSweeper.cs b/server/AyaNova/generator/CoreJobSweeper.cs index e0ce7103..c7d3efe6 100644 --- a/server/AyaNova/generator/CoreJobSweeper.cs +++ b/server/AyaNova/generator/CoreJobSweeper.cs @@ -57,7 +57,7 @@ namespace AyaNova.Biz await SweepInternalJobsLogsAsync(ct, dtDeleteCutoff); //Stealthy check of user count exceeded - if (await UserBiz.ActiveTechUserCountAsync() > AyaNova.Core.License.ActiveKey.ActiveNumber) + if (await UserBiz.ActiveTechUserCountAsync() > AyaNova.Core.License.ActiveKey.ActiveTechsCount) { HERE //WARNING: DO not change the text of this message without also diff --git a/server/AyaNova/util/License.cs b/server/AyaNova/util/License.cs index d40cc09f..f13e78a8 100644 --- a/server/AyaNova/util/License.cs +++ b/server/AyaNova/util/License.cs @@ -138,7 +138,7 @@ namespace AyaNova.Core return null; } - public long ActiveNumber + public long ActiveTechsCount { get { @@ -146,6 +146,22 @@ namespace AyaNova.Core } } + public long ActiveInternalUsersCount + { + get + { + return GetLicenseFeature(ACTIVE_INTERNAL_USERS_FEATURE_NAME).Count; + } + } + + public long ActiveCustomerContactUsersCount + { + get + { + return GetLicenseFeature(ACTIVE_CUSTOMER_USERS_FEATURE_NAME).Count; + } + } + /// /// Check for the existance of license feature /// @@ -758,8 +774,27 @@ namespace AyaNova.Core return; } -HERE - //Has someone been trying funny business with the active techs in the db? +#if (SUBSCRIPTION_BUILD) + + if (await AyaNova.Biz.UserBiz.ActiveInternalUserCountAsync() > _ActiveLicense.ActiveInternalUsersCount) + { + var msg = $"E1020 - Active internal staff User count exceeded licensed capacity"; + apiServerState.SetSystemLock(msg); + log.LogCritical(msg); + return; + } + + + if (await AyaNova.Biz.UserBiz.ActiveCustomerContactUserCountAsync() > _ActiveLicense.ActiveCustomerContactUsersCount) + { + var msg = $"E1020 - Active Customer Contact User count exceeded licensed capacity"; + apiServerState.SetSystemLock(msg); + log.LogCritical(msg); + return; + } + + +#else if (await AyaNova.Biz.UserBiz.ActiveTechUserCountAsync() > _ActiveLicense.ActiveNumber) { var msg = $"E1020 - Active count exceeded capacity"; @@ -767,6 +802,9 @@ HERE log.LogCritical(msg); return; } +#endif + //Has someone been trying funny business with the active techs in the db? + //Key is ok, might not have been on first boot so check and clear if locked //This works for now because system lock only means license lock