This commit is contained in:
2022-08-23 17:04:03 +00:00
parent 0016204582
commit ae3d576d40
2 changed files with 29 additions and 22 deletions

View File

@@ -56,14 +56,34 @@ namespace AyaNova.Biz
dtDeleteCutoff = DateTime.UtcNow - INTERNAL_JOBS_LOGS_DELETE_AFTER_THIS_TIMESPAN;
await SweepInternalJobsLogsAsync(ct, dtDeleteCutoff);
//Stealthy check of user count exceeded
if (await UserBiz.ActiveTechUserCountAsync() > AyaNova.Core.License.ActiveKey.ActiveTechsCount)
//In flight check of user count exceeded in case someone meddled in the DB Directly
#if (SUBSCRIPTION_BUILD)
if (await AyaNova.Biz.UserBiz.ActiveInternalUserCountAsync() > AyaNova.Core.License.ActiveKey.ActiveInternalUsersCount)
{
var msg = $"{AyaNova.Core.License.SERVER_STATE_LOCKOUT_DUE_TO_LICENSE_EXCEEDED_CAPACITY_ERROR} (internal staff User count)";
AyaNova.Util.ServiceProviderProvider.ServerState.SetSystemLock(msg);
log.LogCritical(msg);
return;
}
if (await AyaNova.Biz.UserBiz.ActiveCustomerContactUserCountAsync() > AyaNova.Core.License.ActiveKey.ActiveCustomerContactUsersCount)
{
var msg = $"{AyaNova.Core.License.SERVER_STATE_LOCKOUT_DUE_TO_LICENSE_EXCEEDED_CAPACITY_ERROR} (Customer Contact User count)";
AyaNova.Util.ServiceProviderProvider.ServerState.SetSystemLock(msg);
log.LogCritical(msg);
return;
}
#else
if (await UserBiz.ActiveTechUserCountAsync() > AyaNova.Core.License.ActiveKey.ActiveTechsCount)
{
//Warning: magic string, do not change this, triggers special login procedures to fix license issue
AyaNova.Util.ServiceProviderProvider.ServerState.SetSystemLock(AyaNova.Core.License.SERVER_STATE_LOCKOUT_DUE_TO_LICENSE_EXCEEDED_CAPACITY_ERROR);
log.LogCritical(AyaNova.Core.License.SERVER_STATE_LOCKOUT_DUE_TO_LICENSE_EXCEEDED_CAPACITY_ERROR);
return;
}
#endif
}
lastSweep = DateTime.UtcNow;