This commit is contained in:
2020-07-01 18:14:57 +00:00
parent 78598688ac
commit cd16d4acbf
2 changed files with 59 additions and 15 deletions

View File

@@ -48,7 +48,7 @@ namespace AyaNova.Api.Controllers
/// <param name="enumkey">The key name of the enumerated type</param> /// <param name="enumkey">The key name of the enumerated type</param>
/// <returns>List</returns> /// <returns>List</returns>
[HttpGet("list/{enumkey}")] [HttpGet("list/{enumkey}")]
public ActionResult GetList([FromRoute]string enumkey) public ActionResult GetList([FromRoute] string enumkey)
{ {
if (serverState.IsClosed) if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
@@ -148,10 +148,45 @@ namespace AyaNova.Api.Controllers
ReturnList.Add(new NameIdItem() { Name = LT["UserTypeUtility"], Id = (long)UserType.Utility }); ReturnList.Add(new NameIdItem() { Name = LT["UserTypeUtility"], Id = (long)UserType.Utility });
ReturnList.Add(new NameIdItem() { Name = LT["UserTypeServiceContractor"], Id = (long)UserType.ServiceContractor }); ReturnList.Add(new NameIdItem() { Name = LT["UserTypeServiceContractor"], Id = (long)UserType.ServiceContractor });
} }
else if (keyNameInLowerCase == StringUtil.TrimTypeName(typeof(AyaEvent).ToString()).ToLowerInvariant())
{
TranslationKeysToFetch.Add("EventDeleted");
TranslationKeysToFetch.Add("EventCreated");
TranslationKeysToFetch.Add("EventRetrieved");
TranslationKeysToFetch.Add("EventModified");
TranslationKeysToFetch.Add("EventAttachmentCreate");
TranslationKeysToFetch.Add("EventAttachmentDelete");
TranslationKeysToFetch.Add("EventAttachmentDownload");
TranslationKeysToFetch.Add("EventLicenseFetch");
TranslationKeysToFetch.Add("EventLicenseTrialRequest");
TranslationKeysToFetch.Add("EventServerStateChange");
TranslationKeysToFetch.Add("EventSeedDatabase");
TranslationKeysToFetch.Add("EventAttachmentModified");
TranslationKeysToFetch.Add("AdminEraseDatabase");
TranslationKeysToFetch.Add("EventResetSerial");
TranslationKeysToFetch.Add("EventUtilityFileDownload");
var LT = TranslationBiz.GetSubsetStaticAsync(TranslationKeysToFetch, TranslationId).Result;
ReturnList.Add(new NameIdItem() { Name = LT["EventDeleted"], Id = (long)AyaEvent.Deleted });
ReturnList.Add(new NameIdItem() { Name = LT["EventCreated"], Id = (long)AyaEvent.Created });
ReturnList.Add(new NameIdItem() { Name = LT["EventRetrieved"], Id = (long)AyaEvent.Retrieved });
ReturnList.Add(new NameIdItem() { Name = LT["EventModified"], Id = (long)AyaEvent.Modified });
ReturnList.Add(new NameIdItem() { Name = LT["EventAttachmentCreate"], Id = (long)AyaEvent.AttachmentCreate });
ReturnList.Add(new NameIdItem() { Name = LT["EventAttachmentDelete"], Id = (long)AyaEvent.AttachmentDelete });
ReturnList.Add(new NameIdItem() { Name = LT["EventAttachmentDownload"], Id = (long)AyaEvent.AttachmentDownload });
ReturnList.Add(new NameIdItem() { Name = LT["EventLicenseFetch"], Id = (long)AyaEvent.LicenseFetch });
ReturnList.Add(new NameIdItem() { Name = LT["EventLicenseTrialRequest"], Id = (long)AyaEvent.LicenseTrialRequest });
ReturnList.Add(new NameIdItem() { Name = LT["EventServerStateChange"], Id = (long)AyaEvent.ServerStateChange });
ReturnList.Add(new NameIdItem() { Name = LT["EventSeedDatabase"], Id = (long)AyaEvent.SeedDatabase });
ReturnList.Add(new NameIdItem() { Name = LT["EventAttachmentModified"], Id = (long)AyaEvent.AttachmentModified });
ReturnList.Add(new NameIdItem() { Name = LT["AdminEraseDatabase"], Id = (long)AyaEvent.EraseAllData });
ReturnList.Add(new NameIdItem() { Name = LT["EventResetSerial"], Id = (long)AyaEvent.ResetSerial });
ReturnList.Add(new NameIdItem() { Name = LT["EventUtilityFileDownload"], Id = (long)AyaEvent.UtilityFileDownload });
}
else if (keyNameInLowerCase == StringUtil.TrimTypeName(typeof(AuthorizationRoles).ToString()).ToLowerInvariant()) else if (keyNameInLowerCase == StringUtil.TrimTypeName(typeof(AuthorizationRoles).ToString()).ToLowerInvariant())
{ {
// TranslationKeysToFetch.Add("AuthorizationRoleNoRole"); // TranslationKeysToFetch.Add("AuthorizationRoleNoRole");
TranslationKeysToFetch.Add("AuthorizationRoleBizAdminLimited"); TranslationKeysToFetch.Add("AuthorizationRoleBizAdminLimited");
TranslationKeysToFetch.Add("AuthorizationRoleBizAdminFull"); TranslationKeysToFetch.Add("AuthorizationRoleBizAdminFull");
TranslationKeysToFetch.Add("AuthorizationRoleDispatchLimited"); TranslationKeysToFetch.Add("AuthorizationRoleDispatchLimited");
@@ -169,10 +204,10 @@ namespace AyaNova.Api.Controllers
TranslationKeysToFetch.Add("AuthorizationRoleOpsAdminFull"); TranslationKeysToFetch.Add("AuthorizationRoleOpsAdminFull");
TranslationKeysToFetch.Add("AuthorizationRoleSalesLimited"); TranslationKeysToFetch.Add("AuthorizationRoleSalesLimited");
TranslationKeysToFetch.Add("AuthorizationRoleSalesFull"); TranslationKeysToFetch.Add("AuthorizationRoleSalesFull");
// TranslationKeysToFetch.Add("AuthorizationRoleAll"); // TranslationKeysToFetch.Add("AuthorizationRoleAll");
var LT = TranslationBiz.GetSubsetStaticAsync(TranslationKeysToFetch, TranslationId).Result; var LT = TranslationBiz.GetSubsetStaticAsync(TranslationKeysToFetch, TranslationId).Result;
// ReturnList.Add(new NameIdItem() { Name = LT["AuthorizationRoleNoRole"], Id = (long)AuthorizationRoles.NoRole }); // ReturnList.Add(new NameIdItem() { Name = LT["AuthorizationRoleNoRole"], Id = (long)AuthorizationRoles.NoRole });
ReturnList.Add(new NameIdItem() { Name = LT["AuthorizationRoleBizAdminLimited"], Id = (long)AuthorizationRoles.BizAdminLimited }); ReturnList.Add(new NameIdItem() { Name = LT["AuthorizationRoleBizAdminLimited"], Id = (long)AuthorizationRoles.BizAdminLimited });
ReturnList.Add(new NameIdItem() { Name = LT["AuthorizationRoleBizAdminFull"], Id = (long)AuthorizationRoles.BizAdminFull }); ReturnList.Add(new NameIdItem() { Name = LT["AuthorizationRoleBizAdminFull"], Id = (long)AuthorizationRoles.BizAdminFull });
ReturnList.Add(new NameIdItem() { Name = LT["AuthorizationRoleDispatchLimited"], Id = (long)AuthorizationRoles.DispatchLimited }); ReturnList.Add(new NameIdItem() { Name = LT["AuthorizationRoleDispatchLimited"], Id = (long)AuthorizationRoles.DispatchLimited });
@@ -190,7 +225,7 @@ namespace AyaNova.Api.Controllers
ReturnList.Add(new NameIdItem() { Name = LT["AuthorizationRoleOpsAdminFull"], Id = (long)AuthorizationRoles.OpsAdminFull }); ReturnList.Add(new NameIdItem() { Name = LT["AuthorizationRoleOpsAdminFull"], Id = (long)AuthorizationRoles.OpsAdminFull });
ReturnList.Add(new NameIdItem() { Name = LT["AuthorizationRoleSalesLimited"], Id = (long)AuthorizationRoles.SalesLimited }); ReturnList.Add(new NameIdItem() { Name = LT["AuthorizationRoleSalesLimited"], Id = (long)AuthorizationRoles.SalesLimited });
ReturnList.Add(new NameIdItem() { Name = LT["AuthorizationRoleSalesFull"], Id = (long)AuthorizationRoles.SalesFull }); ReturnList.Add(new NameIdItem() { Name = LT["AuthorizationRoleSalesFull"], Id = (long)AuthorizationRoles.SalesFull });
// ReturnList.Add(new NameIdItem() { Name = LT["AuthorizationRoleAll"], Id = (long)AuthorizationRoles.All }); // ReturnList.Add(new NameIdItem() { Name = LT["AuthorizationRoleAll"], Id = (long)AuthorizationRoles.All });
} }
else else

View File

@@ -25,22 +25,22 @@ namespace AyaNova.Util
public static class Level public static class Level
{ {
public enum SeedLevel { NotValid, SmallOneManShopTrialDataSet, MediumLocalServiceCompanyTrialDataSet, LargeCorporateMultiRegionalTrialDataSet, HugeForLoadTest }; public enum SeedLevel { NotValid, Small, Medium, Large, Huge };
public static SeedLevel StringToSeedLevel(string size) public static SeedLevel StringToSeedLevel(string size)
{ {
switch (size.ToLowerInvariant()) switch (size.ToLowerInvariant())
{ {
case "small": case "small":
return SeedLevel.SmallOneManShopTrialDataSet; return SeedLevel.Small;
case "medium": case "medium":
return SeedLevel.MediumLocalServiceCompanyTrialDataSet; return SeedLevel.Medium;
case "large": case "large":
return SeedLevel.LargeCorporateMultiRegionalTrialDataSet; return SeedLevel.Large;
case "huge": case "huge":
return SeedLevel.HugeForLoadTest; return SeedLevel.Huge;
default: default:
return SeedLevel.NotValid; return SeedLevel.NotValid;
@@ -73,7 +73,8 @@ namespace AyaNova.Util
try try
{ {
await LogStatusAsync(JobId, LogJob, log, $"Seeding data, level {slevel.ToString()}, time zone offset {timeZoneOffset.ToString()}"); var StatusMsg = $"Seeding data, level {slevel.ToString()}, time zone offset {timeZoneOffset.ToString()}";
await LogStatusAsync(JobId, LogJob, log, StatusMsg);
//Only allow this in a trial database //Only allow this in a trial database
if (!AyaNova.Core.License.ActiveKey.TrialLicense) if (!AyaNova.Core.License.ActiveKey.TrialLicense)
@@ -95,6 +96,14 @@ namespace AyaNova.Util
apiServerState.SetOpsOnly("Seeding database"); apiServerState.SetOpsOnly("Seeding database");
//Erase all the data except for the license, schema and the SuperUser //Erase all the data except for the license, schema and the SuperUser
await DbUtil.EmptyBizDataFromDatabaseForSeedingOrImportingAsync(log); await DbUtil.EmptyBizDataFromDatabaseForSeedingOrImportingAsync(log);
//Event log erase and seeding
using (var ct = ServiceProviderProvider.DBContext)
{
await EventLogProcessor.LogEventToDatabaseAsync(new Event(1, 0, AyaType.Global, AyaEvent.EraseAllData, "(seeding preparation)"), ct);
await EventLogProcessor.LogEventToDatabaseAsync(new Event(1, 0, AyaType.Global, AyaEvent.SeedDatabase, StatusMsg), ct);
}
apiServerState.SetOpsOnly("Seeding database with sample data"); apiServerState.SetOpsOnly("Seeding database with sample data");
@@ -193,7 +202,7 @@ namespace AyaNova.Util
//log.LogInformation("Seeding all other data"); //log.LogInformation("Seeding all other data");
switch (slevel) switch (slevel)
{ {
case Level.SeedLevel.SmallOneManShopTrialDataSet: case Level.SeedLevel.Small:
{ {
#region GenSmall #region GenSmall
//This is for a busy but one man shop with a single office person handling stuff back at the shop //This is for a busy but one man shop with a single office person handling stuff back at the shop
@@ -222,7 +231,7 @@ namespace AyaNova.Util
#endregion gensmall #endregion gensmall
} }
break; break;
case Level.SeedLevel.MediumLocalServiceCompanyTrialDataSet: case Level.SeedLevel.Medium:
{ {
#region GenMedium #region GenMedium
//This is for a typical AyaNova medium busy shop //This is for a typical AyaNova medium busy shop
@@ -284,7 +293,7 @@ namespace AyaNova.Util
#endregion genmedium #endregion genmedium
} }
break; break;
case Level.SeedLevel.LargeCorporateMultiRegionalTrialDataSet: case Level.SeedLevel.Large:
{ {
#region GenLarge #region GenLarge
//this is a large corporation with multiple branches in multiple locations all in the same country //this is a large corporation with multiple branches in multiple locations all in the same country
@@ -361,7 +370,7 @@ namespace AyaNova.Util
} }
break; break;
case Level.SeedLevel.HugeForLoadTest: case Level.SeedLevel.Huge:
{ {
#region GenHuge #region GenHuge
//this is the HUGE dataset for load and other testing //this is the HUGE dataset for load and other testing