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

@@ -25,22 +25,22 @@ namespace AyaNova.Util
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)
{
switch (size.ToLowerInvariant())
{
case "small":
return SeedLevel.SmallOneManShopTrialDataSet;
return SeedLevel.Small;
case "medium":
return SeedLevel.MediumLocalServiceCompanyTrialDataSet;
return SeedLevel.Medium;
case "large":
return SeedLevel.LargeCorporateMultiRegionalTrialDataSet;
return SeedLevel.Large;
case "huge":
return SeedLevel.HugeForLoadTest;
return SeedLevel.Huge;
default:
return SeedLevel.NotValid;
@@ -73,7 +73,8 @@ namespace AyaNova.Util
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
if (!AyaNova.Core.License.ActiveKey.TrialLicense)
@@ -95,6 +96,14 @@ namespace AyaNova.Util
apiServerState.SetOpsOnly("Seeding database");
//Erase all the data except for the license, schema and the SuperUser
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");
@@ -193,7 +202,7 @@ namespace AyaNova.Util
//log.LogInformation("Seeding all other data");
switch (slevel)
{
case Level.SeedLevel.SmallOneManShopTrialDataSet:
case Level.SeedLevel.Small:
{
#region GenSmall
//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
}
break;
case Level.SeedLevel.MediumLocalServiceCompanyTrialDataSet:
case Level.SeedLevel.Medium:
{
#region GenMedium
//This is for a typical AyaNova medium busy shop
@@ -284,7 +293,7 @@ namespace AyaNova.Util
#endregion genmedium
}
break;
case Level.SeedLevel.LargeCorporateMultiRegionalTrialDataSet:
case Level.SeedLevel.Large:
{
#region GenLarge
//this is a large corporation with multiple branches in multiple locations all in the same country
@@ -361,7 +370,7 @@ namespace AyaNova.Util
}
break;
case Level.SeedLevel.HugeForLoadTest:
case Level.SeedLevel.Huge:
{
#region GenHuge
//this is the HUGE dataset for load and other testing