This commit is contained in:
@@ -77,8 +77,11 @@ namespace AyaNova.Api.Controllers
|
|||||||
case "large":
|
case "large":
|
||||||
seedLevel = Seeder.SeedLevel.LargeCorporateMultiRegionalTrialDataSet;
|
seedLevel = Seeder.SeedLevel.LargeCorporateMultiRegionalTrialDataSet;
|
||||||
break;
|
break;
|
||||||
|
case "huge":
|
||||||
|
seedLevel = Seeder.SeedLevel.HugeForLoadTest;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.NOT_FOUND, "size", "Valid values are \"small\", \"medium\", \"large\""));
|
return BadRequest(new ApiErrorResponse(ApiErrorCode.NOT_FOUND, "size", "Valid values are \"small\", \"medium\", \"large\", \"huge\""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace AyaNova.Util
|
|||||||
public static class Seeder
|
public static class Seeder
|
||||||
{
|
{
|
||||||
|
|
||||||
public enum SeedLevel { SmallOneManShopTrialDataSet, MediumLocalServiceCompanyTrialDataSet, LargeCorporateMultiRegionalTrialDataSet };
|
public enum SeedLevel { SmallOneManShopTrialDataSet, MediumLocalServiceCompanyTrialDataSet, LargeCorporateMultiRegionalTrialDataSet, HugeForLoadTest };
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
@@ -53,135 +53,203 @@ namespace AyaNova.Util
|
|||||||
//log.LogInformation("Seeding all other data");
|
//log.LogInformation("Seeding all other data");
|
||||||
switch (slevel)
|
switch (slevel)
|
||||||
{
|
{
|
||||||
|
|
||||||
//This is for a busy but one man shop with a single office person handling stuff back at the shop
|
|
||||||
case SeedLevel.SmallOneManShopTrialDataSet:
|
case SeedLevel.SmallOneManShopTrialDataSet:
|
||||||
//Generate owner and lead tech
|
|
||||||
GenSeedUser(log, 1, AuthorizationRoles.BizAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.OpsAdminFull, UserType.Schedulable);
|
|
||||||
|
|
||||||
//Generate one office person / secretary
|
|
||||||
GenSeedUser(log, 1, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.AccountingFull, UserType.NonSchedulable);
|
|
||||||
|
|
||||||
//200 widgets
|
|
||||||
GenSeedWidget(log, 200);
|
|
||||||
|
|
||||||
break;
|
|
||||||
//This is for a typical AyaNova medium busy shop
|
|
||||||
//has one location, many techs and full staff for each department
|
|
||||||
case SeedLevel.MediumLocalServiceCompanyTrialDataSet:
|
|
||||||
|
|
||||||
//One IT administrator, can change ops but nothing else
|
|
||||||
GenSeedUser(log, 1, AuthorizationRoles.OpsAdminFull, UserType.NonSchedulable);
|
|
||||||
|
|
||||||
//One business administrator, can view ops issues
|
|
||||||
GenSeedUser(log, 1, AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable);
|
|
||||||
|
|
||||||
//One owner who doesn't control anything but views stuff
|
|
||||||
GenSeedUser(log, 1, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable);
|
|
||||||
|
|
||||||
//20 techs
|
|
||||||
GenSeedUser(log, 20, AuthorizationRoles.TechFull | AuthorizationRoles.DispatchLimited, UserType.Schedulable);
|
|
||||||
|
|
||||||
//2 subcontractors
|
|
||||||
GenSeedUser(log, 2, AuthorizationRoles.SubContractorFull, UserType.Subcontractor);
|
|
||||||
|
|
||||||
//3 sales / generic office people people
|
|
||||||
GenSeedUser(log, 3, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable);
|
|
||||||
|
|
||||||
//1 dispatch manager
|
|
||||||
GenSeedUser(log, 1, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable);
|
|
||||||
|
|
||||||
//1 Inventory manager
|
|
||||||
GenSeedUser(log, 1, AuthorizationRoles.InventoryFull | AuthorizationRoles.DispatchLimited, UserType.NonSchedulable);
|
|
||||||
|
|
||||||
//1 accountant / bookkeeper
|
|
||||||
GenSeedUser(log, 1, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited, UserType.NonSchedulable);
|
|
||||||
|
|
||||||
//10 full on client users
|
|
||||||
GenSeedUser(log, 10, AuthorizationRoles.ClientLimited, UserType.Client);
|
|
||||||
|
|
||||||
//10 limited client users
|
|
||||||
GenSeedUser(log, 10, AuthorizationRoles.ClientLimited, UserType.Client);
|
|
||||||
|
|
||||||
//2000 widgets
|
|
||||||
GenSeedWidget(log, 2000);
|
|
||||||
|
|
||||||
break;
|
|
||||||
//this is a large corporation with multiple branches in multiple locations all in the same country
|
|
||||||
//Each location has a full staff and corporate head office has an overarching staff member in charge of each location
|
|
||||||
case SeedLevel.LargeCorporateMultiRegionalTrialDataSet:
|
|
||||||
|
|
||||||
//PERF
|
|
||||||
log.LogInformation($"Seeding user(s)....");
|
|
||||||
var watch = new Stopwatch();
|
|
||||||
watch.Start();
|
|
||||||
|
|
||||||
//IT administrator, can change ops but nothing else
|
|
||||||
GenSeedUser(log, 2, AuthorizationRoles.OpsAdminFull, UserType.NonSchedulable);
|
|
||||||
|
|
||||||
//business administrator, can view ops issues
|
|
||||||
GenSeedUser(log, 2, AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable);
|
|
||||||
|
|
||||||
//owner / upper management who doesn't control anything but views stuff
|
|
||||||
GenSeedUser(log, 5, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable);
|
|
||||||
|
|
||||||
//techs
|
|
||||||
//GenSeedUser(log, 100, AuthorizationRoles.TechFull | AuthorizationRoles.DispatchLimited, UserType.Schedulable);
|
|
||||||
for (int i = 0; i < 20; i++)
|
|
||||||
{
|
{
|
||||||
GenSeedUser(log, 5, AuthorizationRoles.TechFull | AuthorizationRoles.DispatchLimited, UserType.Schedulable);
|
//This is for a busy but one man shop with a single office person handling stuff back at the shop
|
||||||
|
|
||||||
|
//Generate owner and lead tech
|
||||||
|
GenSeedUser(log, 1, AuthorizationRoles.BizAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.OpsAdminFull, UserType.Schedulable);
|
||||||
|
|
||||||
|
//Generate one office person / secretary
|
||||||
|
GenSeedUser(log, 1, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.AccountingFull, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//100 widgets
|
||||||
|
GenSeedWidget(log, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//limited techs
|
|
||||||
GenSeedUser(log, 50, AuthorizationRoles.TechLimited | AuthorizationRoles.DispatchLimited, UserType.Schedulable);
|
|
||||||
|
|
||||||
//20 subcontractors
|
|
||||||
GenSeedUser(log, 20, AuthorizationRoles.SubContractorFull, UserType.Subcontractor);
|
|
||||||
|
|
||||||
//10 limited subcontractors
|
|
||||||
GenSeedUser(log, 10, AuthorizationRoles.SubContractorLimited, UserType.Subcontractor);
|
|
||||||
|
|
||||||
//30 sales / generic office people people
|
|
||||||
GenSeedUser(log, 30, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable);
|
|
||||||
|
|
||||||
//5 dispatch manager
|
|
||||||
GenSeedUser(log, 5, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable);
|
|
||||||
|
|
||||||
//5 Inventory manager
|
|
||||||
GenSeedUser(log, 5, AuthorizationRoles.InventoryFull | AuthorizationRoles.DispatchLimited, UserType.NonSchedulable);
|
|
||||||
|
|
||||||
//10 Inventory manager assistants
|
|
||||||
GenSeedUser(log, 5, AuthorizationRoles.InventoryLimited, UserType.NonSchedulable);
|
|
||||||
|
|
||||||
//5 accountant / bookkeeper
|
|
||||||
GenSeedUser(log, 5, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited, UserType.NonSchedulable);
|
|
||||||
|
|
||||||
//100 full on client users
|
|
||||||
GenSeedUser(log, 20, AuthorizationRoles.ClientFull, UserType.Client);
|
|
||||||
|
|
||||||
//100 limited client users
|
|
||||||
GenSeedUser(log, 20, AuthorizationRoles.ClientLimited, UserType.Client);
|
|
||||||
|
|
||||||
//PERF
|
|
||||||
watch.Stop();
|
|
||||||
log.LogInformation($"Users seeded in {watch.ElapsedMilliseconds} ms");
|
|
||||||
|
|
||||||
|
|
||||||
//20000 widgets
|
|
||||||
log.LogInformation($"Seeding Widgets....");
|
|
||||||
watch = new Stopwatch();
|
|
||||||
watch.Start();
|
|
||||||
GenSeedWidget(log, 20000);
|
|
||||||
// for (int i = 0; i < 400; i++)
|
|
||||||
// {
|
|
||||||
// GenSeedWidget(log, 50);
|
|
||||||
// }
|
|
||||||
//PERF
|
|
||||||
watch.Stop();
|
|
||||||
log.LogInformation($"Widgets seeded in {watch.ElapsedMilliseconds} ms");
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
case SeedLevel.MediumLocalServiceCompanyTrialDataSet:
|
||||||
|
{
|
||||||
|
//This is for a typical AyaNova medium busy shop
|
||||||
|
//has one location, many techs and full staff for each department
|
||||||
|
|
||||||
|
//One IT administrator, can change ops but nothing else
|
||||||
|
GenSeedUser(log, 1, AuthorizationRoles.OpsAdminFull, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//One business administrator, can view ops issues
|
||||||
|
GenSeedUser(log, 1, AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//One owner who doesn't control anything but views stuff
|
||||||
|
GenSeedUser(log, 1, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//20 techs
|
||||||
|
GenSeedUser(log, 20, AuthorizationRoles.TechFull | AuthorizationRoles.DispatchLimited, UserType.Schedulable);
|
||||||
|
|
||||||
|
//2 subcontractors
|
||||||
|
GenSeedUser(log, 2, AuthorizationRoles.SubContractorFull, UserType.Subcontractor);
|
||||||
|
|
||||||
|
//3 sales / generic office people people
|
||||||
|
GenSeedUser(log, 3, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//1 dispatch manager
|
||||||
|
GenSeedUser(log, 1, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//1 Inventory manager
|
||||||
|
GenSeedUser(log, 1, AuthorizationRoles.InventoryFull | AuthorizationRoles.DispatchLimited, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//1 accountant / bookkeeper
|
||||||
|
GenSeedUser(log, 1, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//10 full on client users
|
||||||
|
GenSeedUser(log, 10, AuthorizationRoles.ClientLimited, UserType.Client);
|
||||||
|
|
||||||
|
//10 limited client users
|
||||||
|
GenSeedUser(log, 10, AuthorizationRoles.ClientLimited, UserType.Client);
|
||||||
|
|
||||||
|
//500 widgets
|
||||||
|
GenSeedWidget(log, 500);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SeedLevel.LargeCorporateMultiRegionalTrialDataSet:
|
||||||
|
{
|
||||||
|
//this is a large corporation with multiple branches in multiple locations all in the same country
|
||||||
|
//Each location has a full staff and corporate head office has an overarching staff member in charge of each location
|
||||||
|
|
||||||
|
//PERF
|
||||||
|
log.LogInformation($"Seeding user(s)....");
|
||||||
|
var watch = new Stopwatch();
|
||||||
|
watch.Start();
|
||||||
|
|
||||||
|
//IT administrator, can change ops but nothing else
|
||||||
|
GenSeedUser(log, 2, AuthorizationRoles.OpsAdminFull, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//business administrator, can view ops issues
|
||||||
|
GenSeedUser(log, 2, AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//owner / upper management who doesn't control anything but views stuff
|
||||||
|
GenSeedUser(log, 5, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//100 techs
|
||||||
|
GenSeedUser(log, 100, AuthorizationRoles.TechFull | AuthorizationRoles.DispatchLimited, UserType.Schedulable);
|
||||||
|
|
||||||
|
//limited techs
|
||||||
|
GenSeedUser(log, 50, AuthorizationRoles.TechLimited | AuthorizationRoles.DispatchLimited, UserType.Schedulable);
|
||||||
|
|
||||||
|
//20 subcontractors
|
||||||
|
GenSeedUser(log, 20, AuthorizationRoles.SubContractorFull, UserType.Subcontractor);
|
||||||
|
|
||||||
|
//10 limited subcontractors
|
||||||
|
GenSeedUser(log, 10, AuthorizationRoles.SubContractorLimited, UserType.Subcontractor);
|
||||||
|
|
||||||
|
//30 sales / generic office people people
|
||||||
|
GenSeedUser(log, 30, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//5 dispatch manager
|
||||||
|
GenSeedUser(log, 5, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//5 Inventory manager
|
||||||
|
GenSeedUser(log, 5, AuthorizationRoles.InventoryFull | AuthorizationRoles.DispatchLimited, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//10 Inventory manager assistants
|
||||||
|
GenSeedUser(log, 5, AuthorizationRoles.InventoryLimited, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//5 accountant / bookkeeper
|
||||||
|
GenSeedUser(log, 5, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//100 full on client users
|
||||||
|
GenSeedUser(log, 20, AuthorizationRoles.ClientFull, UserType.Client);
|
||||||
|
|
||||||
|
//100 limited client users
|
||||||
|
GenSeedUser(log, 20, AuthorizationRoles.ClientLimited, UserType.Client);
|
||||||
|
|
||||||
|
//PERF
|
||||||
|
watch.Stop();
|
||||||
|
log.LogInformation($"Users seeded in {watch.ElapsedMilliseconds} ms");
|
||||||
|
|
||||||
|
|
||||||
|
//5000 widgets
|
||||||
|
|
||||||
|
log.LogInformation($"Seeding 5000 Widgets....");
|
||||||
|
watch = new Stopwatch();
|
||||||
|
watch.Start();
|
||||||
|
GenSeedWidget(log, 5000);
|
||||||
|
|
||||||
|
//PERF
|
||||||
|
watch.Stop();
|
||||||
|
log.LogInformation($"Widgets seeded in {watch.ElapsedMilliseconds} ms");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SeedLevel.HugeForLoadTest:
|
||||||
|
{
|
||||||
|
//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
|
||||||
|
|
||||||
|
//PERF
|
||||||
|
log.LogInformation($"Seeding user(s)....");
|
||||||
|
var watch = new Stopwatch();
|
||||||
|
watch.Start();
|
||||||
|
|
||||||
|
//IT administrator, can change ops but nothing else
|
||||||
|
GenSeedUser(log, 10, AuthorizationRoles.OpsAdminFull, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//business administrator, can view ops issues
|
||||||
|
GenSeedUser(log, 10, AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//owner / upper management who doesn't control anything but views stuff
|
||||||
|
GenSeedUser(log, 20, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//regular techs
|
||||||
|
GenSeedUser(log, 500, AuthorizationRoles.TechFull | AuthorizationRoles.DispatchLimited, UserType.Schedulable);
|
||||||
|
|
||||||
|
//limited techs
|
||||||
|
GenSeedUser(log, 200, AuthorizationRoles.TechLimited | AuthorizationRoles.DispatchLimited, UserType.Schedulable);
|
||||||
|
|
||||||
|
//subcontractors
|
||||||
|
GenSeedUser(log, 80, AuthorizationRoles.SubContractorFull, UserType.Subcontractor);
|
||||||
|
|
||||||
|
//limited subcontractors
|
||||||
|
GenSeedUser(log, 40, AuthorizationRoles.SubContractorLimited, UserType.Subcontractor);
|
||||||
|
|
||||||
|
//120 sales / generic office people people
|
||||||
|
GenSeedUser(log, 30, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//5 dispatch manager
|
||||||
|
GenSeedUser(log, 5, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//5 Inventory manager
|
||||||
|
GenSeedUser(log, 5, AuthorizationRoles.InventoryFull | AuthorizationRoles.DispatchLimited, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//10 Inventory manager assistants
|
||||||
|
GenSeedUser(log, 5, AuthorizationRoles.InventoryLimited, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//5 accountant / bookkeeper
|
||||||
|
GenSeedUser(log, 5, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited, UserType.NonSchedulable);
|
||||||
|
|
||||||
|
//100 full on client users
|
||||||
|
GenSeedUser(log, 20, AuthorizationRoles.ClientFull, UserType.Client);
|
||||||
|
|
||||||
|
//100 limited client users
|
||||||
|
GenSeedUser(log, 20, AuthorizationRoles.ClientLimited, UserType.Client);
|
||||||
|
|
||||||
|
//PERF
|
||||||
|
watch.Stop();
|
||||||
|
log.LogInformation($"Users seeded in {watch.ElapsedMilliseconds} ms");
|
||||||
|
|
||||||
|
|
||||||
|
//20000 widgets
|
||||||
|
log.LogInformation($"Seeding 20,000 Widgets....");
|
||||||
|
watch = new Stopwatch();
|
||||||
|
watch.Start();
|
||||||
|
for (int i = 0; i < 800; i++)
|
||||||
|
{
|
||||||
|
GenSeedWidget(log, 25);
|
||||||
|
}
|
||||||
|
//PERF
|
||||||
|
watch.Stop();
|
||||||
|
log.LogInformation($"Widgets seeded in {watch.ElapsedMilliseconds} ms");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.LogInformation("Seeding completed successfully");
|
log.LogInformation("Seeding completed successfully");
|
||||||
@@ -276,12 +344,9 @@ namespace AyaNova.Util
|
|||||||
|
|
||||||
public static void GenSeedUser(ILogger log, int count, AuthorizationRoles roles, UserType userType, bool active = true, string login = null, string password = null)
|
public static void GenSeedUser(ILogger log, int count, AuthorizationRoles roles, UserType userType, bool active = true, string login = null, string password = null)
|
||||||
{
|
{
|
||||||
// log.LogInformation($"Seeding {count.ToString()} user(s)");
|
|
||||||
//var watch = new Stopwatch();
|
|
||||||
//watch.Start();
|
|
||||||
|
|
||||||
|
|
||||||
UserBiz Biz = UserBiz.GetBizInternal(ServiceProviderProvider.DBContext);
|
UserBiz Biz = UserBiz.GetBizInternal(ServiceProviderProvider.DBContext);
|
||||||
|
|
||||||
//allow creation of not entirely ready users (missing client id or subcontractor vendor id etc)
|
//allow creation of not entirely ready users (missing client id or subcontractor vendor id etc)
|
||||||
Biz.SeedOrImportRelaxedRulesMode = true;
|
Biz.SeedOrImportRelaxedRulesMode = true;
|
||||||
|
|
||||||
@@ -292,7 +357,6 @@ namespace AyaNova.Util
|
|||||||
u.OwnerId = 1;
|
u.OwnerId = 1;
|
||||||
var p = new Bogus.Person();
|
var p = new Bogus.Person();
|
||||||
u.Name = Uniquify(p.FullName);
|
u.Name = Uniquify(p.FullName);
|
||||||
// u.Salt = Hasher.GenerateSalt();
|
|
||||||
if (login != null)
|
if (login != null)
|
||||||
{
|
{
|
||||||
u.Login = login;
|
u.Login = login;
|
||||||
@@ -302,9 +366,9 @@ namespace AyaNova.Util
|
|||||||
u.Login = p.FirstName;
|
u.Login = p.FirstName;
|
||||||
|
|
||||||
if (password != null)
|
if (password != null)
|
||||||
u.Password = password;//u.Password = Hasher.hash(u.Salt, password);
|
u.Password = password;
|
||||||
else
|
else
|
||||||
u.Password = u.Login;//u.Password = Hasher.hash(u.Salt, u.Login);
|
u.Password = u.Login;
|
||||||
u.Roles = roles;
|
u.Roles = roles;
|
||||||
u.LocaleId = ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;
|
u.LocaleId = ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;
|
||||||
u.UserType = userType;
|
u.UserType = userType;
|
||||||
@@ -314,21 +378,13 @@ namespace AyaNova.Util
|
|||||||
u.UserOptions = new UserOptions(1);
|
u.UserOptions = new UserOptions(1);
|
||||||
u.UserOptions.EmailAddress = p.Email.Replace("gmail.com", "helloayanova.com").Replace("hotmail.com", "helloayanova.com").Replace("yahoo.com", "helloayanova.com");
|
u.UserOptions.EmailAddress = p.Email.Replace("gmail.com", "helloayanova.com").Replace("hotmail.com", "helloayanova.com").Replace("yahoo.com", "helloayanova.com");
|
||||||
|
|
||||||
|
var NewObject = Biz.Create(ServiceProviderProvider.DBContext, u);
|
||||||
//Re-instantiating the biz object in the loop speeds it up probably due to db context losing changes to track from before
|
|
||||||
// UserBiz Biz = UserBiz.GetBizInternal(ServiceProviderProvider.DBContext);
|
|
||||||
// //allow creation of not entirely ready users (missing client id or subcontractor vendor id etc)
|
|
||||||
// Biz.SeedOrImportRelaxedRulesMode = true;
|
|
||||||
|
|
||||||
var NewObject = Biz.Create(ServiceProviderProvider.DBContext, u);//sync version faster than async one
|
|
||||||
if (NewObject == null)
|
if (NewObject == null)
|
||||||
{
|
{
|
||||||
log.LogError($"Seeder::GenSeedUser error creating user {u.Name}\r\n" + Biz.GetErrorsAsString());
|
log.LogError($"Seeder::GenSeedUser error creating user {u.Name}\r\n" + Biz.GetErrorsAsString());
|
||||||
throw new System.Exception("Seeder::GenSeedUser error creating user\r\n" + Biz.GetErrorsAsString());
|
throw new System.Exception("Seeder::GenSeedUser error creating user\r\n" + Biz.GetErrorsAsString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// watch.Stop();
|
|
||||||
// log.LogInformation($"{count.ToString()} user(s) seeded in {watch.ElapsedMilliseconds} ms");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
@@ -336,11 +392,6 @@ namespace AyaNova.Util
|
|||||||
//
|
//
|
||||||
public static void GenSeedWidget(ILogger log, int count)
|
public static void GenSeedWidget(ILogger log, int count)
|
||||||
{
|
{
|
||||||
log.LogInformation($"Seeding {count.ToString()} Widget(s)");
|
|
||||||
var watch = new Stopwatch();
|
|
||||||
watch.Start();
|
|
||||||
//get a context just for this op to save memory on changetracking
|
|
||||||
//AyContext ct = ServiceProviderProvider.DBContext;
|
|
||||||
WidgetBiz Biz = WidgetBiz.GetBizInternal(ServiceProviderProvider.DBContext);
|
WidgetBiz Biz = WidgetBiz.GetBizInternal(ServiceProviderProvider.DBContext);
|
||||||
var f = new Bogus.Faker();
|
var f = new Bogus.Faker();
|
||||||
for (int x = 0; x < count; x++)
|
for (int x = 0; x < count; x++)
|
||||||
@@ -362,8 +413,7 @@ namespace AyaNova.Util
|
|||||||
throw new System.Exception("Seeder::GenSeedWidget error creating widget\r\n" + Biz.GetErrorsAsString());
|
throw new System.Exception("Seeder::GenSeedWidget error creating widget\r\n" + Biz.GetErrorsAsString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
watch.Stop();
|
|
||||||
log.LogInformation($"{count.ToString()} Widget(s) seeded in {watch.ElapsedMilliseconds} ms");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}//eoc
|
}//eoc
|
||||||
|
|||||||
Reference in New Issue
Block a user