This commit is contained in:
@@ -225,6 +225,11 @@ namespace AyaNova.Util
|
||||
//CUSTOMERS
|
||||
await GenSeedCustomerAsync(log, 100);
|
||||
|
||||
//HEAD-OFFICES
|
||||
await GenSeedHeadOfficeAsync(log, 2);
|
||||
|
||||
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
await LogStatusAsync(JobId, LogJob, log, $"Small level sample data seeded in {watch.ElapsedMilliseconds} ms");
|
||||
@@ -280,6 +285,9 @@ namespace AyaNova.Util
|
||||
//CUSTOMERS
|
||||
await GenSeedCustomerAsync(log, 500);
|
||||
|
||||
//HEAD-OFFICES
|
||||
await GenSeedHeadOfficeAsync(log, 4);
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
await LogStatusAsync(JobId, LogJob, log, $"MEDIUM level sample data seeded in {watch.ElapsedMilliseconds} ms");
|
||||
@@ -351,6 +359,9 @@ namespace AyaNova.Util
|
||||
//CUSTOMERS
|
||||
await GenSeedCustomerAsync(log, 5000);
|
||||
|
||||
//HEAD-OFFICES
|
||||
await GenSeedHeadOfficeAsync(log, 8);
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
await LogStatusAsync(JobId, LogJob, log, $"LARGE level sample data seeded in {watch.ElapsedMilliseconds} ms");
|
||||
@@ -422,6 +433,9 @@ namespace AyaNova.Util
|
||||
//CUSTOMERS
|
||||
await GenSeedCustomerAsync(log, 20000);
|
||||
|
||||
//HEAD-OFFICES
|
||||
await GenSeedHeadOfficeAsync(log, 16);
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
await LogStatusAsync(JobId, LogJob, log, $"HUGE level sample data seeded in {watch.ElapsedMilliseconds} ms");
|
||||
@@ -637,7 +651,7 @@ namespace AyaNova.Util
|
||||
var NewObject = await Biz.CreateAsync(u);
|
||||
if (NewObject == null)
|
||||
{
|
||||
log.LogError($"Seeder::GenSeedUser error creating user {u.Name}\r\n" + Biz.GetErrorsAsString());
|
||||
log.LogError($"Seeder::GenSeedUser error creating {u.Name}\r\n" + Biz.GetErrorsAsString());
|
||||
throw new System.Exception("Seeder::GenSeedUser error creating user\r\n" + Biz.GetErrorsAsString());
|
||||
}
|
||||
}
|
||||
@@ -692,7 +706,7 @@ namespace AyaNova.Util
|
||||
var NewObject = await biz.CreateAsync(o);
|
||||
if (NewObject == null)
|
||||
{
|
||||
log.LogError($"Seeder::GenSeedWidget error creating widget {o.Name}\r\n" + biz.GetErrorsAsString());
|
||||
log.LogError($"Seeder::GenSeedWidget error creating {o.Name}\r\n" + biz.GetErrorsAsString());
|
||||
throw new System.Exception("Seeder::GenSeedWidget error creating widget\r\n" + biz.GetErrorsAsString());
|
||||
}
|
||||
}
|
||||
@@ -706,7 +720,7 @@ namespace AyaNova.Util
|
||||
//////////////////////////////////////////////////////
|
||||
//CUSTOMER
|
||||
//
|
||||
public async Task GenSeedCustomerAsync(ILogger log, int count)
|
||||
public async Task GenSeedCustomerAsync(ILogger log, int count, long? headOfficeId = null)
|
||||
{
|
||||
|
||||
DateTime seedStartWindow = DateTime.Now.AddYears(-1);
|
||||
@@ -733,6 +747,12 @@ namespace AyaNova.Util
|
||||
o.WebAddress = Fake.Internet.Url();
|
||||
o.EmailAddress = Fake.Internet.ExampleEmail();
|
||||
|
||||
if (headOfficeId != null)
|
||||
{
|
||||
o.HeadOfficeId = headOfficeId;
|
||||
o.BillHeadOffice = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//This seems wrong to do in a loop but is 4 times faster this way ?!?
|
||||
@@ -743,7 +763,7 @@ namespace AyaNova.Util
|
||||
|
||||
if (NewObject == null)
|
||||
{
|
||||
var err = $"Seeder::GenSeedCustomer error creating customer {o.Name}\r\n{biz.GetErrorsAsString()}";
|
||||
var err = $"Seeder::GenSeedCustomer error creating {o.Name}\r\n{biz.GetErrorsAsString()}";
|
||||
log.LogError(err);
|
||||
throw new System.Exception(err);
|
||||
}
|
||||
@@ -756,6 +776,58 @@ namespace AyaNova.Util
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
//HEADOFFICE
|
||||
//
|
||||
public async Task GenSeedHeadOfficeAsync(ILogger log, int count)
|
||||
{
|
||||
|
||||
DateTime seedStartWindow = DateTime.Now.AddYears(-1);
|
||||
DateTime seedEndWindow = DateTime.Now.AddYears(1);
|
||||
for (int x = 0; x < count; x++)
|
||||
{
|
||||
HeadOffice o = new HeadOffice();
|
||||
o.Name = Uniquify(Fake.Company.CompanyName());
|
||||
o.Active = true;
|
||||
o.Notes = Fake.Company.CatchPhrase();
|
||||
o.Tags = RandomTags();
|
||||
|
||||
o.AccountNumber = Fake.Finance.Account();
|
||||
o.Latitude = (decimal)Fake.Address.Latitude();
|
||||
o.Longitude = (decimal)Fake.Address.Longitude();
|
||||
o.Address = Fake.Address.StreetAddress();
|
||||
o.City = Fake.Address.City();
|
||||
o.Region = Fake.Address.State();
|
||||
o.Country = Fake.Address.Country();
|
||||
|
||||
o.Phone1 = Fake.Phone.PhoneNumber();
|
||||
o.Phone2 = Fake.Phone.PhoneNumber();
|
||||
o.Phone3 = Fake.Phone.PhoneNumber();
|
||||
o.WebAddress = Fake.Internet.Url();
|
||||
o.EmailAddress = Fake.Internet.ExampleEmail();
|
||||
|
||||
|
||||
|
||||
//This seems wrong to do in a loop but is 4 times faster this way ?!?
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
HeadOfficeBiz biz = HeadOfficeBiz.GetBiz(ct);
|
||||
var NewObject = await biz.CreateAsync(o);
|
||||
|
||||
if (NewObject == null)
|
||||
{
|
||||
var err = $"Seeder::GenSeedHeadOffice error creating {o.Name}\r\n{biz.GetErrorsAsString()}";
|
||||
log.LogError(err);
|
||||
throw new System.Exception(err);
|
||||
}
|
||||
//HeadOffice contacts
|
||||
await GenSeedUserAsync(log, 1, AuthorizationRoles.CustomerFull, UserType.HeadOffice, true, null, null, 0, null, null, null, NewObject.Id);
|
||||
//HeadOffice Customer
|
||||
await GenSeedCustomerAsync(log, 1, NewObject.Id);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Reference in New Issue
Block a user