This commit is contained in:
@@ -211,7 +211,7 @@ namespace AyaNova.Util
|
|||||||
await LogStatusAsync(JobId, LogJob, log, $"Seeding SMALL sample data....");
|
await LogStatusAsync(JobId, LogJob, log, $"Seeding SMALL sample data....");
|
||||||
var watch = new Stopwatch();
|
var watch = new Stopwatch();
|
||||||
watch.Start();
|
watch.Start();
|
||||||
|
|
||||||
//Generate owner and lead tech
|
//Generate owner and lead tech
|
||||||
await SeedUserAsync(log, 1, AuthorizationRoles.BizAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.OpsAdminFull, UserType.Service);
|
await SeedUserAsync(log, 1, AuthorizationRoles.BizAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.OpsAdminFull, UserType.Service);
|
||||||
//Generate one office person / secretary
|
//Generate one office person / secretary
|
||||||
@@ -225,7 +225,8 @@ namespace AyaNova.Util
|
|||||||
await SeedTravelRateAsync(log, 3);
|
await SeedTravelRateAsync(log, 3);
|
||||||
await SeedUnitModelAsync(log, 10);
|
await SeedUnitModelAsync(log, 10);
|
||||||
await SeedUnitAsync(log, 500);//5 times the customers or 5 units per customer
|
await SeedUnitAsync(log, 500);//5 times the customers or 5 units per customer
|
||||||
await SeedLoanLoanUnitAsync(log,5);
|
await SeedLoanLoanUnitAsync(log, 5);
|
||||||
|
await SeedCustomerServiceRequestAsync(log, 5);
|
||||||
|
|
||||||
//PERF
|
//PERF
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
@@ -274,7 +275,8 @@ namespace AyaNova.Util
|
|||||||
await SeedTravelRateAsync(log, 5);
|
await SeedTravelRateAsync(log, 5);
|
||||||
await SeedUnitModelAsync(log, 25);
|
await SeedUnitModelAsync(log, 25);
|
||||||
await SeedUnitAsync(log, 2500);//5 times the customers or 5 units per customer
|
await SeedUnitAsync(log, 2500);//5 times the customers or 5 units per customer
|
||||||
await SeedLoanLoanUnitAsync(log,10);
|
await SeedLoanLoanUnitAsync(log, 10);
|
||||||
|
await SeedCustomerServiceRequestAsync(log, 10);
|
||||||
|
|
||||||
//PERF
|
//PERF
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
@@ -318,7 +320,7 @@ namespace AyaNova.Util
|
|||||||
//5 dispatch manager
|
//5 dispatch manager
|
||||||
await SeedUserAsync(log, 5, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryLimited, UserType.NotService);
|
await SeedUserAsync(log, 5, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryLimited, UserType.NotService);
|
||||||
//5 Inventory manager
|
//5 Inventory manager
|
||||||
await SeedUserAsync(log, 5, AuthorizationRoles.InventoryFull | AuthorizationRoles.DispatchLimited, UserType.NotService);
|
await SeedUserAsync(log, 5, AuthorizationRoles.InventoryFull | AuthorizationRoles.DispatchLimited, UserType.NotService);
|
||||||
//10 Inventory manager assistants
|
//10 Inventory manager assistants
|
||||||
await SeedUserAsync(log, 5, AuthorizationRoles.InventoryLimited, UserType.NotService);
|
await SeedUserAsync(log, 5, AuthorizationRoles.InventoryLimited, UserType.NotService);
|
||||||
//5 accountant / bookkeeper
|
//5 accountant / bookkeeper
|
||||||
@@ -333,7 +335,8 @@ namespace AyaNova.Util
|
|||||||
await SeedTravelRateAsync(log, 10);
|
await SeedTravelRateAsync(log, 10);
|
||||||
await SeedUnitModelAsync(log, 30);
|
await SeedUnitModelAsync(log, 30);
|
||||||
await SeedUnitAsync(log, 25000);//5 times the customers or 5 units per customer
|
await SeedUnitAsync(log, 25000);//5 times the customers or 5 units per customer
|
||||||
await SeedLoanLoanUnitAsync(log,15);
|
await SeedLoanLoanUnitAsync(log, 15);
|
||||||
|
await SeedCustomerServiceRequestAsync(log, 15);
|
||||||
|
|
||||||
//PERF
|
//PERF
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
@@ -394,6 +397,7 @@ namespace AyaNova.Util
|
|||||||
await SeedUnitModelAsync(log, 40);
|
await SeedUnitModelAsync(log, 40);
|
||||||
await SeedUnitAsync(log, 100000);//5 times the customers or 5 units per customer
|
await SeedUnitAsync(log, 100000);//5 times the customers or 5 units per customer
|
||||||
await SeedLoanLoanUnitAsync(log, 20);
|
await SeedLoanLoanUnitAsync(log, 20);
|
||||||
|
await SeedCustomerServiceRequestAsync(log, 20);
|
||||||
|
|
||||||
//PERF
|
//PERF
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
@@ -786,7 +790,7 @@ namespace AyaNova.Util
|
|||||||
public HashSet<string> HashUserNames = new HashSet<string>();
|
public HashSet<string> HashUserNames = new HashSet<string>();
|
||||||
private int TotalSeededUsers = 0;
|
private int TotalSeededUsers = 0;
|
||||||
|
|
||||||
public async Task SeedUserAsync(
|
public async Task<long> SeedUserAsync(
|
||||||
ILogger log, int count, AuthorizationRoles roles, UserType userType,
|
ILogger log, int count, AuthorizationRoles roles, UserType userType,
|
||||||
bool active = true, string login = null, string password = null,
|
bool active = true, string login = null, string password = null,
|
||||||
long translationId = 0, List<string> tags = null,
|
long translationId = 0, List<string> tags = null,
|
||||||
@@ -796,7 +800,8 @@ namespace AyaNova.Util
|
|||||||
if (translationId == 0)
|
if (translationId == 0)
|
||||||
translationId = ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID;
|
translationId = ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID;
|
||||||
|
|
||||||
|
//to return for code that creates a single user and needs the id
|
||||||
|
long LastSeededUserId = 0;
|
||||||
|
|
||||||
for (int x = 0; x < count; x++)
|
for (int x = 0; x < count; x++)
|
||||||
{
|
{
|
||||||
@@ -860,9 +865,10 @@ namespace AyaNova.Util
|
|||||||
log.LogError($"Seeder::SeedUser error creating {u.Name}\r\n" + biz.GetErrorsAsString());
|
log.LogError($"Seeder::SeedUser error creating {u.Name}\r\n" + biz.GetErrorsAsString());
|
||||||
throw new System.Exception("Seeder::SeedUser error creating user\r\n" + biz.GetErrorsAsString());
|
throw new System.Exception("Seeder::SeedUser error creating user\r\n" + biz.GetErrorsAsString());
|
||||||
}
|
}
|
||||||
|
LastSeededUserId = NewObject.Id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return LastSeededUserId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1415,7 +1421,7 @@ namespace AyaNova.Util
|
|||||||
o.RateWeek = o.RateHour * 36.8m;
|
o.RateWeek = o.RateHour * 36.8m;
|
||||||
o.RateMonth = o.RateHour * 21 * 8;
|
o.RateMonth = o.RateHour * 21 * 8;
|
||||||
o.RateYear = o.RateHour * 36.8m * 52;
|
o.RateYear = o.RateHour * 36.8m * 52;
|
||||||
o.DefaultRate=Fake.Random.Enum<LoanUnitRateUnit>();
|
o.DefaultRate = Fake.Random.Enum<LoanUnitRateUnit>();
|
||||||
|
|
||||||
|
|
||||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||||
@@ -1434,6 +1440,45 @@ namespace AyaNova.Util
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
//CUSTOMERSERVICEREQUEST
|
||||||
|
//
|
||||||
|
public async Task SeedCustomerServiceRequestAsync(ILogger log, int count)
|
||||||
|
{
|
||||||
|
DateTime seedStartWindow = DateTime.Now.AddYears(-1);
|
||||||
|
DateTime seedEndWindow = DateTime.Now.AddMonths(-11);
|
||||||
|
|
||||||
|
for (int x = 0; x < count; x++)
|
||||||
|
{
|
||||||
|
CustomerServiceRequest o = new CustomerServiceRequest();
|
||||||
|
|
||||||
|
o.Name = Fake.Hacker.Phrase();
|
||||||
|
o.Notes = Fake.Lorem.Sentence();
|
||||||
|
o.Tags = RandomTags();
|
||||||
|
o.DateRequested = Fake.Date.Between(seedStartWindow, seedEndWindow).ToUniversalTime();
|
||||||
|
o.CustomerId = Fake.Random.Long(1, TotalSeededCustomers);
|
||||||
|
o.RequestedByUserId = await SeedUserAsync(log, 1, AuthorizationRoles.CustomerFull, UserType.Customer, true, null, null, 0, null, null, o.CustomerId, null);
|
||||||
|
o.Status = CustomerServiceRequestStatus.Open;
|
||||||
|
o.Priority = Fake.Random.Enum<CustomerServiceRequestPriority>();
|
||||||
|
o.CustomerReferenceNumber = Fake.Finance.Account();
|
||||||
|
|
||||||
|
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||||
|
{
|
||||||
|
CustomerServiceRequestBiz biz = CustomerServiceRequestBiz.GetBiz(ct);
|
||||||
|
var NewObject = await biz.CreateAsync(o);
|
||||||
|
if (NewObject == null)
|
||||||
|
{
|
||||||
|
var err = $"Seeder::SeedCustomerServiceRequest error creating {o.Name}\r\n{biz.GetErrorsAsString()}";
|
||||||
|
log.LogError(err);
|
||||||
|
throw new System.Exception(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
}//eoc
|
}//eoc
|
||||||
|
|||||||
Reference in New Issue
Block a user