This commit is contained in:
2020-01-27 23:15:45 +00:00
parent f26ed45908
commit 633c5e6811

View File

@@ -47,13 +47,13 @@ namespace AyaNova.Util
try try
{ {
LogStatusAsync(JobId, LogJob, log, $"SEEDER: Seeding data level is {slevel.ToString()}, time zone offset is {timeZoneOffset.ToString()}"); await LogStatusAsync(JobId, LogJob, log, $"SEEDER: Seeding data level is {slevel.ToString()}, time zone offset is {timeZoneOffset.ToString()}");
//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)
{ {
var msg = "This database has a registered license key so it can't be seeded"; var msg = "This database has a registered license key so it can't be seeded";
LogStatusAsync(JobId, LogJob, log, msg); await LogStatusAsync(JobId, LogJob, log, msg);
throw new System.NotSupportedException(msg); throw new System.NotSupportedException(msg);
} }
@@ -61,22 +61,22 @@ namespace AyaNova.Util
if (timeZoneOffset > 14 || timeZoneOffset < (-12)) if (timeZoneOffset > 14 || timeZoneOffset < (-12))
{ {
var msg = $"Time zone offset \"{timeZoneOffset.ToString()}\" is not valid"; var msg = $"Time zone offset \"{timeZoneOffset.ToString()}\" is not valid";
LogStatusAsync(JobId, LogJob, log, msg); await LogStatusAsync(JobId, LogJob, log, msg);
throw new System.NotSupportedException(msg); throw new System.NotSupportedException(msg);
} }
apiServerState.SetOpsOnly("Seeding database"); apiServerState.SetOpsOnly("Seeding database");
//Erase all the data except for the license, schema and the manager user //Erase all the data except for the license, schema and the manager user
DbUtil.EmptyBizDataFromDatabaseForSeedingOrImportingAsync(log); await DbUtil.EmptyBizDataFromDatabaseForSeedingOrImportingAsync(log);
//Set the time zone of the manager account //Set the time zone of the manager account
using (var cct = ServiceProviderProvider.DBContext) using (var cct = ServiceProviderProvider.DBContext)
{ {
var mgr = cct.UserOptions.FirstAsync(m => m.Id == 1).Result; var mgr = await cct.UserOptions.FirstAsync(m => m.Id == 1);
mgr.TimeZoneOffset = timeZoneOffset; mgr.TimeZoneOffset = timeZoneOffset;
cct.SaveChanges(); await cct.SaveChangesAsync();
} }
@@ -132,13 +132,13 @@ namespace AyaNova.Util
//Create and save to db //Create and save to db
using (var cct = ServiceProviderProvider.DBContext) using (var cct = ServiceProviderProvider.DBContext)
{ {
FormCustomBiz.GetBizInternal(cct).CreateAsync(fc).Wait(); await FormCustomBiz.GetBizInternal(cct).CreateAsync(fc);
} }
} }
//Seed special test data for integration testing //Seed special test data for integration testing
//log.LogInformation("Seeding known users"); //log.LogInformation("Seeding known users");
SeedKnownUsersAsync(log, timeZoneOffset); await SeedKnownUsersAsync(log, timeZoneOffset);
//log.LogInformation("Seeding all other data"); //log.LogInformation("Seeding all other data");
switch (slevel) switch (slevel)
@@ -148,27 +148,26 @@ namespace AyaNova.Util
#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
//PERF //PERF
LogStatusAsync(JobId, LogJob, log, $"Seeding SMALL number of user(s)...."); await LogStatusAsync(JobId, LogJob, log, $"Seeding SMALL number of user(s)....");
var watch = new Stopwatch(); var watch = new Stopwatch();
watch.Start(); watch.Start();
//Generate owner and lead tech //Generate owner and lead tech
GenSeedUserAsync(log, 1, AuthorizationRoles.BizAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.OpsAdminFull, UserType.Schedulable, timeZoneOffset); await GenSeedUserAsync(log, 1, AuthorizationRoles.BizAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.OpsAdminFull, UserType.Schedulable, timeZoneOffset);
//Generate one office person / secretary //Generate one office person / secretary
GenSeedUserAsync(log, 1, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.AccountingFull, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 1, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.AccountingFull, UserType.NonSchedulable, timeZoneOffset);
//PERF //PERF
watch.Stop(); watch.Stop();
LogStatusAsync(JobId, LogJob, log, $"{SeededUserCount} Users seeded in {watch.ElapsedMilliseconds} ms"); await LogStatusAsync(JobId, LogJob, log, $"{SeededUserCount} Users seeded in {watch.ElapsedMilliseconds} ms");
//100 widgets //100 widgets
watch = new Stopwatch(); watch = new Stopwatch();
watch.Start(); watch.Start();
//await GenSeedWidgetAsync(log, 100); await GenSeedWidgetAsync(log, 100);
GenSeedWidgetAsync(log, 100);
//PERF //PERF
watch.Stop(); watch.Stop();
LogStatusAsync(JobId, LogJob, log, $"100 Widgets seeded in {watch.ElapsedMilliseconds} ms"); await LogStatusAsync(JobId, LogJob, log, $"100 Widgets seeded in {watch.ElapsedMilliseconds} ms");
#endregion gensmall #endregion gensmall
} }
@@ -179,58 +178,58 @@ namespace AyaNova.Util
//This is for a typical AyaNova medium busy shop //This is for a typical AyaNova medium busy shop
//has one location, many techs and full staff for each department //has one location, many techs and full staff for each department
//PERF //PERF
LogStatusAsync(JobId, LogJob, log, $"Seeding MEDIUM number of user(s)...."); await LogStatusAsync(JobId, LogJob, log, $"Seeding MEDIUM number of user(s)....");
var watch = new Stopwatch(); var watch = new Stopwatch();
watch.Start(); watch.Start();
//One IT administrator, can change ops but nothing else //One IT administrator, can change ops but nothing else
GenSeedUserAsync(log, 1, AuthorizationRoles.OpsAdminFull, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 1, AuthorizationRoles.OpsAdminFull, UserType.NonSchedulable, timeZoneOffset);
//One business administrator, can view ops issues //One business administrator, can view ops issues
GenSeedUserAsync(log, 1, AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 1, AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable, timeZoneOffset);
//One owner who doesn't control anything but views stuff //One owner who doesn't control anything but views stuff
GenSeedUserAsync(log, 1, AuthorizationRoles.BizAdminLimited | AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited | AuthorizationRoles.SalesLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 1, AuthorizationRoles.BizAdminLimited | AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited | AuthorizationRoles.SalesLimited, UserType.NonSchedulable, timeZoneOffset);
//20 techs //20 techs
GenSeedUserAsync(log, 20, AuthorizationRoles.TechFull | AuthorizationRoles.DispatchLimited, UserType.Schedulable, timeZoneOffset); await GenSeedUserAsync(log, 20, AuthorizationRoles.TechFull | AuthorizationRoles.DispatchLimited, UserType.Schedulable, timeZoneOffset);
//2 subcontractors //2 subcontractors
GenSeedUserAsync(log, 2, AuthorizationRoles.SubContractorFull, UserType.Subcontractor, timeZoneOffset); await GenSeedUserAsync(log, 2, AuthorizationRoles.SubContractorFull, UserType.Subcontractor, timeZoneOffset);
//3 generic office people people //3 generic office people people
GenSeedUserAsync(log, 3, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 3, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable, timeZoneOffset);
//2 Full sales people //2 Full sales people
GenSeedUserAsync(log, 2, AuthorizationRoles.SalesFull, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 2, AuthorizationRoles.SalesFull, UserType.NonSchedulable, timeZoneOffset);
//1 dispatch manager //1 dispatch manager
GenSeedUserAsync(log, 1, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 1, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable, timeZoneOffset);
//1 Inventory manager //1 Inventory manager
GenSeedUserAsync(log, 1, AuthorizationRoles.InventoryFull | AuthorizationRoles.DispatchLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 1, AuthorizationRoles.InventoryFull | AuthorizationRoles.DispatchLimited, UserType.NonSchedulable, timeZoneOffset);
//1 accountant / bookkeeper //1 accountant / bookkeeper
GenSeedUserAsync(log, 1, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 1, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited, UserType.NonSchedulable, timeZoneOffset);
//10 full on customer users //10 full on customer users
GenSeedUserAsync(log, 10, AuthorizationRoles.CustomerLimited, UserType.Customer, timeZoneOffset); await GenSeedUserAsync(log, 10, AuthorizationRoles.CustomerLimited, UserType.Customer, timeZoneOffset);
//10 limited customer users //10 limited customer users
GenSeedUserAsync(log, 10, AuthorizationRoles.CustomerLimited, UserType.Customer, timeZoneOffset); await GenSeedUserAsync(log, 10, AuthorizationRoles.CustomerLimited, UserType.Customer, timeZoneOffset);
//PERF //PERF
watch.Stop(); watch.Stop();
LogStatusAsync(JobId, LogJob, log, $"{SeededUserCount} Users seeded in {watch.ElapsedMilliseconds} ms"); await LogStatusAsync(JobId, LogJob, log, $"{SeededUserCount} Users seeded in {watch.ElapsedMilliseconds} ms");
//500 widgets //500 widgets
LogStatusAsync(JobId, LogJob, log, $"Seeding 500 Widgets...."); await LogStatusAsync(JobId, LogJob, log, $"Seeding 500 Widgets....");
watch = new Stopwatch(); watch = new Stopwatch();
watch.Start(); watch.Start();
//await GenSeedWidgetAsync(log, 500); //await GenSeedWidgetAsync(log, 500);
GenSeedWidgetAsync(log, 500); await GenSeedWidgetAsync(log, 500);
//PERF //PERF
watch.Stop(); watch.Stop();
LogStatusAsync(JobId, LogJob, log, $"500 Widgets seeded in {watch.ElapsedMilliseconds} ms"); await LogStatusAsync(JobId, LogJob, log, $"500 Widgets seeded in {watch.ElapsedMilliseconds} ms");
#endregion genmedium #endregion genmedium
} }
@@ -242,72 +241,72 @@ namespace AyaNova.Util
//Each location has a full staff and corporate head office has an overarching staff member in charge of each location //Each location has a full staff and corporate head office has an overarching staff member in charge of each location
//PERF //PERF
LogStatusAsync(JobId, LogJob, log, $"Seeding LARGE number of user(s)...."); await LogStatusAsync(JobId, LogJob, log, $"Seeding LARGE number of user(s)....");
var watch = new Stopwatch(); var watch = new Stopwatch();
watch.Start(); watch.Start();
//IT administrator, can change ops but nothing else //IT administrator, can change ops but nothing else
GenSeedUserAsync(log, 2, AuthorizationRoles.OpsAdminFull, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 2, AuthorizationRoles.OpsAdminFull, UserType.NonSchedulable, timeZoneOffset);
//business administrator, can view ops issues //business administrator, can view ops issues
GenSeedUserAsync(log, 2, AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 2, AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable, timeZoneOffset);
//owner / upper management who doesn't control anything but views stuff //owner / upper management who doesn't control anything but views stuff
GenSeedUserAsync(log, 5, AuthorizationRoles.BizAdminLimited | AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 5, AuthorizationRoles.BizAdminLimited | AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable, timeZoneOffset);
//100 techs //100 techs
GenSeedUserAsync(log, 100, AuthorizationRoles.TechFull | AuthorizationRoles.DispatchLimited, UserType.Schedulable, timeZoneOffset); await GenSeedUserAsync(log, 100, AuthorizationRoles.TechFull | AuthorizationRoles.DispatchLimited, UserType.Schedulable, timeZoneOffset);
//limited techs //limited techs
GenSeedUserAsync(log, 50, AuthorizationRoles.TechLimited | AuthorizationRoles.DispatchLimited, UserType.Schedulable, timeZoneOffset); await GenSeedUserAsync(log, 50, AuthorizationRoles.TechLimited | AuthorizationRoles.DispatchLimited, UserType.Schedulable, timeZoneOffset);
//20 subcontractors //20 subcontractors
GenSeedUserAsync(log, 20, AuthorizationRoles.SubContractorFull, UserType.Subcontractor, timeZoneOffset); await GenSeedUserAsync(log, 20, AuthorizationRoles.SubContractorFull, UserType.Subcontractor, timeZoneOffset);
//10 limited subcontractors //10 limited subcontractors
GenSeedUserAsync(log, 10, AuthorizationRoles.SubContractorLimited, UserType.Subcontractor, timeZoneOffset); await GenSeedUserAsync(log, 10, AuthorizationRoles.SubContractorLimited, UserType.Subcontractor, timeZoneOffset);
//30 generic office people people //30 generic office people people
GenSeedUserAsync(log, 30, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 30, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable, timeZoneOffset);
//10 Full sales people //10 Full sales people
GenSeedUserAsync(log, 10, AuthorizationRoles.SalesFull, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 10, AuthorizationRoles.SalesFull, UserType.NonSchedulable, timeZoneOffset);
//5 Limited sales people //5 Limited sales people
GenSeedUserAsync(log, 5, AuthorizationRoles.SalesLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 5, AuthorizationRoles.SalesLimited, UserType.NonSchedulable, timeZoneOffset);
//5 dispatch manager //5 dispatch manager
GenSeedUserAsync(log, 5, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 5, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable, timeZoneOffset);
//5 Inventory manager //5 Inventory manager
GenSeedUserAsync(log, 5, AuthorizationRoles.InventoryFull | AuthorizationRoles.DispatchLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 5, AuthorizationRoles.InventoryFull | AuthorizationRoles.DispatchLimited, UserType.NonSchedulable, timeZoneOffset);
//10 Inventory manager assistants //10 Inventory manager assistants
GenSeedUserAsync(log, 5, AuthorizationRoles.InventoryLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 5, AuthorizationRoles.InventoryLimited, UserType.NonSchedulable, timeZoneOffset);
//5 accountant / bookkeeper //5 accountant / bookkeeper
GenSeedUserAsync(log, 5, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 5, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited, UserType.NonSchedulable, timeZoneOffset);
//100 full on customer users //100 full on customer users
GenSeedUserAsync(log, 20, AuthorizationRoles.CustomerFull, UserType.Customer, timeZoneOffset); await GenSeedUserAsync(log, 20, AuthorizationRoles.CustomerFull, UserType.Customer, timeZoneOffset);
//100 limited customer users //100 limited customer users
GenSeedUserAsync(log, 20, AuthorizationRoles.CustomerLimited, UserType.Customer, timeZoneOffset); await GenSeedUserAsync(log, 20, AuthorizationRoles.CustomerLimited, UserType.Customer, timeZoneOffset);
//PERF //PERF
watch.Stop(); watch.Stop();
LogStatusAsync(JobId, LogJob, log, $"{SeededUserCount} Users seeded in {watch.ElapsedMilliseconds} ms"); await LogStatusAsync(JobId, LogJob, log, $"{SeededUserCount} Users seeded in {watch.ElapsedMilliseconds} ms");
//5000 widgets //5000 widgets
LogStatusAsync(JobId, LogJob, log, $"Seeding 5,000 Widgets...."); await LogStatusAsync(JobId, LogJob, log, $"Seeding 5,000 Widgets....");
watch = new Stopwatch(); watch = new Stopwatch();
watch.Start(); watch.Start();
//await GenSeedWidgetAsync(log, 5000); //await GenSeedWidgetAsync(log, 5000);
GenSeedWidgetAsync(log, 5000); await GenSeedWidgetAsync(log, 5000);
//PERF //PERF
watch.Stop(); watch.Stop();
LogStatusAsync(JobId, LogJob, log, $"5k Widgets seeded in {watch.ElapsedMilliseconds} ms"); await LogStatusAsync(JobId, LogJob, log, $"5k Widgets seeded in {watch.ElapsedMilliseconds} ms");
#endregion genlarge #endregion genlarge
} }
break; break;
@@ -319,82 +318,82 @@ namespace AyaNova.Util
//It is acceptable for this seeding to take many hours as it would normally be used rarely //It is acceptable for this seeding to take many hours as it would normally be used rarely
//PERF //PERF
LogStatusAsync(JobId, LogJob, log, $"Seeding HUGE number of user(s)...."); await LogStatusAsync(JobId, LogJob, log, $"Seeding HUGE number of user(s)....");
var watch = new Stopwatch(); var watch = new Stopwatch();
watch.Start(); watch.Start();
//IT administrator, can change ops but nothing else //IT administrator, can change ops but nothing else
GenSeedUserAsync(log, 10, AuthorizationRoles.OpsAdminFull, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 10, AuthorizationRoles.OpsAdminFull, UserType.NonSchedulable, timeZoneOffset);
//business administrator, can view ops issues //business administrator, can view ops issues
GenSeedUserAsync(log, 10, AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 10, AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable, timeZoneOffset);
//owner / upper management who doesn't control anything but views stuff //owner / upper management who doesn't control anything but views stuff
GenSeedUserAsync(log, 20, AuthorizationRoles.BizAdminLimited | AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 20, AuthorizationRoles.BizAdminLimited | AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable, timeZoneOffset);
//regular techs //regular techs
GenSeedUserAsync(log, 500, AuthorizationRoles.TechFull | AuthorizationRoles.DispatchLimited, UserType.Schedulable, timeZoneOffset); await GenSeedUserAsync(log, 500, AuthorizationRoles.TechFull | AuthorizationRoles.DispatchLimited, UserType.Schedulable, timeZoneOffset);
//limited techs //limited techs
GenSeedUserAsync(log, 200, AuthorizationRoles.TechLimited | AuthorizationRoles.DispatchLimited, UserType.Schedulable, timeZoneOffset); await GenSeedUserAsync(log, 200, AuthorizationRoles.TechLimited | AuthorizationRoles.DispatchLimited, UserType.Schedulable, timeZoneOffset);
//subcontractors //subcontractors
GenSeedUserAsync(log, 80, AuthorizationRoles.SubContractorFull, UserType.Subcontractor, timeZoneOffset); await GenSeedUserAsync(log, 80, AuthorizationRoles.SubContractorFull, UserType.Subcontractor, timeZoneOffset);
//limited subcontractors //limited subcontractors
GenSeedUserAsync(log, 40, AuthorizationRoles.SubContractorLimited, UserType.Subcontractor, timeZoneOffset); await GenSeedUserAsync(log, 40, AuthorizationRoles.SubContractorLimited, UserType.Subcontractor, timeZoneOffset);
//generic office people people //generic office people people
GenSeedUserAsync(log, 200, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 200, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable, timeZoneOffset);
//20 Full sales people //20 Full sales people
GenSeedUserAsync(log, 20, AuthorizationRoles.SalesFull, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 20, AuthorizationRoles.SalesFull, UserType.NonSchedulable, timeZoneOffset);
//10 Limited sales people //10 Limited sales people
GenSeedUserAsync(log, 10, AuthorizationRoles.SalesLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 10, AuthorizationRoles.SalesLimited, UserType.NonSchedulable, timeZoneOffset);
//dispatch manager //dispatch manager
GenSeedUserAsync(log, 20, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 20, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable, timeZoneOffset);
//Inventory manager //Inventory manager
GenSeedUserAsync(log, 40, AuthorizationRoles.InventoryFull | AuthorizationRoles.DispatchLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 40, AuthorizationRoles.InventoryFull | AuthorizationRoles.DispatchLimited, UserType.NonSchedulable, timeZoneOffset);
//Inventory manager assistants //Inventory manager assistants
GenSeedUserAsync(log, 20, AuthorizationRoles.InventoryLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 20, AuthorizationRoles.InventoryLimited, UserType.NonSchedulable, timeZoneOffset);
//accountant / bookkeeper //accountant / bookkeeper
GenSeedUserAsync(log, 20, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited, UserType.NonSchedulable, timeZoneOffset); await GenSeedUserAsync(log, 20, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited, UserType.NonSchedulable, timeZoneOffset);
//full on customer users //full on customer users
GenSeedUserAsync(log, 200, AuthorizationRoles.CustomerFull, UserType.Customer, timeZoneOffset); await GenSeedUserAsync(log, 200, AuthorizationRoles.CustomerFull, UserType.Customer, timeZoneOffset);
//limited customer users //limited customer users
GenSeedUserAsync(log, 50, AuthorizationRoles.CustomerLimited, UserType.Customer, timeZoneOffset); await GenSeedUserAsync(log, 50, AuthorizationRoles.CustomerLimited, UserType.Customer, timeZoneOffset);
//PERF //PERF
watch.Stop(); watch.Stop();
LogStatusAsync(JobId, LogJob, log, $"{SeededUserCount} Users seeded in {watch.ElapsedMilliseconds} ms"); await LogStatusAsync(JobId, LogJob, log, $"{SeededUserCount} Users seeded in {watch.ElapsedMilliseconds} ms");
//20000 widgets //20000 widgets
LogStatusAsync(JobId, LogJob, log, $"Seeding 20,000 Widgets...."); await LogStatusAsync(JobId, LogJob, log, $"Seeding 20,000 Widgets....");
watch = new Stopwatch(); watch = new Stopwatch();
watch.Start(); watch.Start();
//await GenSeedWidgetAsync(log, 20000); //await GenSeedWidgetAsync(log, 20000);
GenSeedWidgetAsync(log, 20000); await GenSeedWidgetAsync(log, 20000);
watch.Stop(); watch.Stop();
LogStatusAsync(JobId, LogJob, log, $"20k Widgets seeded in {watch.ElapsedMilliseconds} ms"); await LogStatusAsync(JobId, LogJob, log, $"20k Widgets seeded in {watch.ElapsedMilliseconds} ms");
#endregion genhuge #endregion genhuge
} }
break; break;
} }
LogStatusAsync(JobId, LogJob, log, "Seeding completed successfully"); await LogStatusAsync(JobId, LogJob, log, "Seeding completed successfully");
} }
catch (Exception ex) catch (Exception ex)
{ {
log.LogError(ex, "Seeder:SeedDatabase error during ops"); log.LogError(ex, "Seeder:SeedDatabase error during ops");
if (LogJob) if (LogJob)
JobsBiz.LogJobAsync(JobId, $"Seeder:SeedDatabase error during ops\r\n{ex.Message}"); await JobsBiz.LogJobAsync(JobId, $"Seeder:SeedDatabase error during ops\r\n{ex.Message}");
throw ex; throw ex;
} }
finally finally