This commit is contained in:
@@ -208,26 +208,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
|
||||||
await LogStatusAsync(JobId, LogJob, log, $"Seeding SMALL number of user(s)....");
|
await LogStatusAsync(JobId, LogJob, log, $"Seeding SMALL sample data....");
|
||||||
var watch = new Stopwatch();
|
var watch = new Stopwatch();
|
||||||
watch.Start();
|
watch.Start();
|
||||||
|
|
||||||
|
//USERS
|
||||||
//Generate owner and lead tech
|
//Generate owner and lead tech
|
||||||
await GenSeedUserAsync(log, 1, AuthorizationRoles.BizAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.OpsAdminFull, UserType.Service);
|
await GenSeedUserAsync(log, 1, AuthorizationRoles.BizAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.OpsAdminFull, UserType.Service);
|
||||||
|
|
||||||
//Generate one office person / secretary
|
//Generate one office person / secretary
|
||||||
await GenSeedUserAsync(log, 1, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.AccountingFull, UserType.NotService);
|
await GenSeedUserAsync(log, 1, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.AccountingFull, UserType.NotService);
|
||||||
//PERF
|
|
||||||
watch.Stop();
|
|
||||||
await LogStatusAsync(JobId, LogJob, log, $"{SeededUserCount} Users seeded in {watch.ElapsedMilliseconds} ms");
|
|
||||||
|
|
||||||
|
//WIDGET
|
||||||
//100 widgets
|
|
||||||
watch = new Stopwatch();
|
|
||||||
watch.Start();
|
|
||||||
await GenSeedWidgetAsync(log, 100);
|
await GenSeedWidgetAsync(log, 100);
|
||||||
|
|
||||||
|
//CUSTOMERS
|
||||||
|
await GenSeedCustomerAsync(log, 100);
|
||||||
|
|
||||||
//PERF
|
//PERF
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
await LogStatusAsync(JobId, LogJob, log, $"100 Widgets seeded in {watch.ElapsedMilliseconds} ms");
|
await LogStatusAsync(JobId, LogJob, log, $"Small level sample data seeded in {watch.ElapsedMilliseconds} ms");
|
||||||
|
|
||||||
#endregion gensmall
|
#endregion gensmall
|
||||||
}
|
}
|
||||||
@@ -238,9 +238,11 @@ 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
|
||||||
await LogStatusAsync(JobId, LogJob, log, $"Seeding MEDIUM number of user(s)....");
|
await LogStatusAsync(JobId, LogJob, log, $"Seeding MEDIUM sample data....");
|
||||||
var watch = new Stopwatch();
|
var watch = new Stopwatch();
|
||||||
watch.Start();
|
watch.Start();
|
||||||
|
|
||||||
|
//USERS
|
||||||
//One IT administrator, can change ops but nothing else
|
//One IT administrator, can change ops but nothing else
|
||||||
await GenSeedUserAsync(log, 1, AuthorizationRoles.OpsAdminFull, UserType.NotService);
|
await GenSeedUserAsync(log, 1, AuthorizationRoles.OpsAdminFull, UserType.NotService);
|
||||||
|
|
||||||
@@ -276,20 +278,16 @@ namespace AyaNova.Util
|
|||||||
|
|
||||||
//10 limited customer users
|
//10 limited customer users
|
||||||
await GenSeedUserAsync(log, 10, AuthorizationRoles.CustomerLimited, UserType.Customer);
|
await GenSeedUserAsync(log, 10, AuthorizationRoles.CustomerLimited, UserType.Customer);
|
||||||
//PERF
|
|
||||||
watch.Stop();
|
//WIDGETS
|
||||||
await LogStatusAsync(JobId, LogJob, log, $"{SeededUserCount} Users seeded in {watch.ElapsedMilliseconds} ms");
|
|
||||||
|
|
||||||
//500 widgets
|
|
||||||
await LogStatusAsync(JobId, LogJob, log, $"Seeding 500 Widgets....");
|
|
||||||
watch = new Stopwatch();
|
|
||||||
watch.Start();
|
|
||||||
|
|
||||||
//await GenSeedWidgetAsync(log, 500);
|
|
||||||
await GenSeedWidgetAsync(log, 500);
|
await GenSeedWidgetAsync(log, 500);
|
||||||
|
|
||||||
|
//CUSTOMERS
|
||||||
|
await GenSeedCustomerAsync(log, 500);
|
||||||
|
|
||||||
//PERF
|
//PERF
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
await LogStatusAsync(JobId, LogJob, log, $"500 Widgets seeded in {watch.ElapsedMilliseconds} ms");
|
await LogStatusAsync(JobId, LogJob, log, $"MEDIUM level sample data seeded in {watch.ElapsedMilliseconds} ms");
|
||||||
|
|
||||||
#endregion genmedium
|
#endregion genmedium
|
||||||
}
|
}
|
||||||
@@ -301,10 +299,12 @@ 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
|
||||||
await LogStatusAsync(JobId, LogJob, log, $"Seeding LARGE number of user(s)....");
|
await LogStatusAsync(JobId, LogJob, log, $"Seeding LARGE sample data....");
|
||||||
var watch = new Stopwatch();
|
var watch = new Stopwatch();
|
||||||
watch.Start();
|
watch.Start();
|
||||||
|
|
||||||
|
|
||||||
|
//USERS
|
||||||
//IT administrator, can change ops but nothing else
|
//IT administrator, can change ops but nothing else
|
||||||
await GenSeedUserAsync(log, 2, AuthorizationRoles.OpsAdminFull, UserType.NotService);
|
await GenSeedUserAsync(log, 2, AuthorizationRoles.OpsAdminFull, UserType.NotService);
|
||||||
|
|
||||||
@@ -353,20 +353,16 @@ namespace AyaNova.Util
|
|||||||
//100 limited customer users
|
//100 limited customer users
|
||||||
await GenSeedUserAsync(log, 20, AuthorizationRoles.CustomerLimited, UserType.Customer);
|
await GenSeedUserAsync(log, 20, AuthorizationRoles.CustomerLimited, UserType.Customer);
|
||||||
|
|
||||||
//PERF
|
|
||||||
watch.Stop();
|
|
||||||
await LogStatusAsync(JobId, LogJob, log, $"{SeededUserCount} Users seeded in {watch.ElapsedMilliseconds} ms");
|
|
||||||
|
|
||||||
//5000 widgets
|
//WIDGETS
|
||||||
await LogStatusAsync(JobId, LogJob, log, $"Seeding 5,000 Widgets....");
|
|
||||||
watch = new Stopwatch();
|
|
||||||
watch.Start();
|
|
||||||
//await GenSeedWidgetAsync(log, 5000);
|
|
||||||
await GenSeedWidgetAsync(log, 5000);
|
await GenSeedWidgetAsync(log, 5000);
|
||||||
|
|
||||||
|
//CUSTOMERS
|
||||||
|
await GenSeedCustomerAsync(log, 5000);
|
||||||
|
|
||||||
//PERF
|
//PERF
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
await LogStatusAsync(JobId, LogJob, log, $"5k Widgets seeded in {watch.ElapsedMilliseconds} ms");
|
await LogStatusAsync(JobId, LogJob, log, $"LARGE level sample data seeded in {watch.ElapsedMilliseconds} ms");
|
||||||
#endregion genlarge
|
#endregion genlarge
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -377,11 +373,13 @@ namespace AyaNova.Util
|
|||||||
//this is the HUGE dataset for load and other testing
|
//this is the HUGE dataset for load and other testing
|
||||||
//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
|
||||||
await LogStatusAsync(JobId, LogJob, log, $"Seeding HUGE number of user(s)....");
|
await LogStatusAsync(JobId, LogJob, log, $"Seeding HUGE sample data....");
|
||||||
var watch = new Stopwatch();
|
var watch = new Stopwatch();
|
||||||
watch.Start();
|
watch.Start();
|
||||||
|
|
||||||
|
|
||||||
|
//USERS
|
||||||
//IT administrator, can change ops but nothing else
|
//IT administrator, can change ops but nothing else
|
||||||
await GenSeedUserAsync(log, 10, AuthorizationRoles.OpsAdminFull, UserType.NotService);
|
await GenSeedUserAsync(log, 10, AuthorizationRoles.OpsAdminFull, UserType.NotService);
|
||||||
|
|
||||||
@@ -430,18 +428,16 @@ namespace AyaNova.Util
|
|||||||
//limited customer users
|
//limited customer users
|
||||||
await GenSeedUserAsync(log, 50, AuthorizationRoles.CustomerLimited, UserType.Customer);
|
await GenSeedUserAsync(log, 50, AuthorizationRoles.CustomerLimited, UserType.Customer);
|
||||||
|
|
||||||
|
|
||||||
|
//WIDGETS
|
||||||
|
await GenSeedWidgetAsync(log, 20000);
|
||||||
|
|
||||||
|
//CUSTOMERS
|
||||||
|
await GenSeedCustomerAsync(log, 20000);
|
||||||
|
|
||||||
//PERF
|
//PERF
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
await LogStatusAsync(JobId, LogJob, log, $"{SeededUserCount} Users seeded in {watch.ElapsedMilliseconds} ms");
|
await LogStatusAsync(JobId, LogJob, log, $"HUGE level sample data seeded in {watch.ElapsedMilliseconds} ms");
|
||||||
|
|
||||||
//20000 widgets
|
|
||||||
await LogStatusAsync(JobId, LogJob, log, $"Seeding 20,000 Widgets....");
|
|
||||||
watch = new Stopwatch();
|
|
||||||
watch.Start();
|
|
||||||
//await GenSeedWidgetAsync(log, 20000);
|
|
||||||
await GenSeedWidgetAsync(log, 20000);
|
|
||||||
watch.Stop();
|
|
||||||
await LogStatusAsync(JobId, LogJob, log, $"20k Widgets seeded in {watch.ElapsedMilliseconds} ms");
|
|
||||||
#endregion genhuge
|
#endregion genhuge
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -709,6 +705,45 @@ namespace AyaNova.Util
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
//CUSTOMER
|
||||||
|
//
|
||||||
|
public async Task GenSeedCustomerAsync(ILogger log, int count)
|
||||||
|
{
|
||||||
|
|
||||||
|
DateTime seedStartWindow = DateTime.Now.AddYears(-1);
|
||||||
|
DateTime seedEndWindow = DateTime.Now.AddYears(1);
|
||||||
|
for (int x = 0; x < count; x++)
|
||||||
|
{
|
||||||
|
Customer o = new Customer();
|
||||||
|
o.Name = Uniquify(Fake.Company.CompanyName());
|
||||||
|
o.Active = true;
|
||||||
|
o.Notes = Fake.Company.CatchPhrase();
|
||||||
|
o.Tags = RandomTags();
|
||||||
|
|
||||||
|
//This seems wrong to do in a loop but is 4 times faster this way ?!?
|
||||||
|
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||||
|
{
|
||||||
|
CustomerBiz biz = CustomerBiz.GetBiz(ct);
|
||||||
|
var NewObject = await biz.CreateAsync(o);
|
||||||
|
if (NewObject == null)
|
||||||
|
{
|
||||||
|
var err = $"Seeder::GenSeedCustomer error creating customer {o.Name}\r\n{biz.GetErrorsAsString()}";
|
||||||
|
log.LogError(err);
|
||||||
|
throw new System.Exception(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
}//eoc
|
}//eoc
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user