This commit is contained in:
2020-06-18 21:54:11 +00:00
parent 40b705b75a
commit bec40e92fd
3 changed files with 24 additions and 14 deletions

View File

@@ -704,19 +704,19 @@ namespace AyaNova.Core
throw new ApplicationException("E1020 - Can't install a trial key into a non empty AyaNova database. Erase the database first.");
}
//TODO: TECHCOUNT - new license causes exceeding count?
if (await AyaNova.Biz.UserBiz.ActiveCountAsync() > ParsedNewKey.GetLicenseFeature(SERVICE_TECHS_FEATURE_NAME).Count)
//TODO: TECHCOUNT - new license causes exceeding count?
long NewTechCount = ParsedNewKey.GetLicenseFeature(SERVICE_TECHS_FEATURE_NAME).Count;
if (await AyaNova.Biz.UserBiz.ActiveCountAsync() > NewTechCount)
{
//Ok, the easy thing to do here is just set all techs inactive, but
//a trickier but probably better thing to do is set just enough techs inactive and choose them based
//on the oldest last login datetime first
throw new ApplicationException("E1020 - Can't install key, too many active techs and / or subcontractors in database. Deactivate enough to install key.");
//attempt to set enough of the eldest last login techs to inactive
await AyaNova.Biz.UserBiz.DeActivateExcessiveTechs(NewTechCount, log);
if (await AyaNova.Biz.UserBiz.ActiveCountAsync() > NewTechCount)
throw new ApplicationException("E1020 - Can't install key, too many active techs and / or subcontractors in database. Deactivate enough to install key.");
}
//Update current license
CurrentInDbKeyRecord.Key = RawTextNewKey;
//LOOKAT: reason, resultcode etc
//There is similar block related to this in ayschema for db schema version 8
await ct.SaveChangesAsync();
}
catch (Exception ex)