seed data sane levels and distribution of workorders and other data
This commit is contained in:
@@ -246,7 +246,7 @@ namespace AyaNova.Util
|
||||
await SeedPurchaseOrderAsync(log, 10);
|
||||
await SeedQuoteAsync(log, 5);
|
||||
await SeedPMAsync(log, 3);
|
||||
await SeedWorkOrderAsync(log, 100);
|
||||
await SeedWorkOrderAsync(log, 450, slevel);
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
@@ -304,7 +304,7 @@ namespace AyaNova.Util
|
||||
await SeedPurchaseOrderAsync(log, 30);
|
||||
await SeedQuoteAsync(log, 5);
|
||||
await SeedPMAsync(log, 3);
|
||||
await SeedWorkOrderAsync(log, 200);
|
||||
await SeedWorkOrderAsync(log, 900, slevel);
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
@@ -372,7 +372,7 @@ namespace AyaNova.Util
|
||||
await SeedPurchaseOrderAsync(log, 50);
|
||||
await SeedQuoteAsync(log, 5);
|
||||
await SeedPMAsync(log, 3);
|
||||
await SeedWorkOrderAsync(log, 300);
|
||||
await SeedWorkOrderAsync(log, 1800, slevel);
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
@@ -400,14 +400,21 @@ namespace AyaNova.Util
|
||||
await SeedUserAsync(log, 10, AuthorizationRoles.BizAdmin | AuthorizationRoles.OpsAdminRestricted, UserType.NotService);
|
||||
//owner / upper management who doesn't control anything but views stuff
|
||||
await SeedUserAsync(log, 20, AuthorizationRoles.BizAdminRestricted | AuthorizationRoles.ServiceRestricted | AuthorizationRoles.InventoryRestricted | AuthorizationRoles.OpsAdminRestricted, UserType.NotService);
|
||||
|
||||
////////////////////////////////////////////////
|
||||
//TECHS (LICENSE CONSUMERS)
|
||||
//trial license allows 1000
|
||||
//
|
||||
//regular techs
|
||||
await SeedUserAsync(log, 1000, AuthorizationRoles.Tech | AuthorizationRoles.ServiceRestricted, UserType.Service);
|
||||
await SeedUserAsync(log, 675, AuthorizationRoles.Tech | AuthorizationRoles.ServiceRestricted, UserType.Service);
|
||||
//Restricted techs
|
||||
await SeedUserAsync(log, 200, AuthorizationRoles.TechRestricted | AuthorizationRoles.ServiceRestricted, UserType.Service);
|
||||
//subcontractors
|
||||
await SeedUserAsync(log, 80, AuthorizationRoles.SubContractor, UserType.ServiceContractor);
|
||||
//Restricted subcontractors
|
||||
await SeedUserAsync(log, 40, AuthorizationRoles.SubContractorRestricted, UserType.ServiceContractor);
|
||||
///////////////////////////////////////////
|
||||
|
||||
//generic office people people
|
||||
await SeedUserAsync(log, 500, AuthorizationRoles.ServiceRestricted | AuthorizationRoles.InventoryRestricted, UserType.NotService);
|
||||
//20 Full sales people
|
||||
@@ -431,7 +438,7 @@ namespace AyaNova.Util
|
||||
await SeedProjectAsync(log, 1000);
|
||||
await SeedServiceRateAsync(log, 200);
|
||||
await SeedTravelRateAsync(log, 100);
|
||||
|
||||
|
||||
await SeedLoanLoanUnitAsync(log, 200);
|
||||
await SeedCustomerServiceRequestAsync(log, 200);
|
||||
await SeedPartWarehouseAsync(log, 200);
|
||||
@@ -439,8 +446,8 @@ namespace AyaNova.Util
|
||||
await SeedPartAssemblyAsync(log, 500);
|
||||
await SeedPurchaseOrderAsync(log, 1000);
|
||||
await SeedQuoteAsync(log, 1000);
|
||||
await SeedPMAsync(log, 1000);
|
||||
await SeedWorkOrderAsync(log, 1000);
|
||||
await SeedPMAsync(log, 3);//DO NOT want too many of these as they affect performance
|
||||
await SeedWorkOrderAsync(log, 3600, slevel);
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
@@ -2734,10 +2741,39 @@ namespace AyaNova.Util
|
||||
//////////////////////////////////////////////////////
|
||||
//WORK ORDER
|
||||
//
|
||||
public async Task SeedWorkOrderAsync(ILogger log, int count)
|
||||
public async Task SeedWorkOrderAsync(ILogger log, int count, Level.SeedLevel seedLevel)
|
||||
{
|
||||
DateTime seedStartWindow = DateTime.UtcNow.AddMonths(-3);
|
||||
DateTime seedEndWindow = DateTime.UtcNow.AddMonths(3);
|
||||
//Goal is 5 workorders per day for each level and window
|
||||
//accepting that some days will have way more and some none, it's ok
|
||||
//need a very large window for huge level seeding
|
||||
|
||||
//small defaults
|
||||
int PastMonthsToSeed = 2;
|
||||
int woItemCount = 4;
|
||||
int woItemUnitCount = 2;
|
||||
|
||||
switch (seedLevel)
|
||||
{
|
||||
case Level.SeedLevel.Medium:
|
||||
PastMonthsToSeed = 5;
|
||||
woItemCount = 3;
|
||||
woItemUnitCount = 1;
|
||||
break;
|
||||
case Level.SeedLevel.Large:
|
||||
PastMonthsToSeed = 11;
|
||||
woItemCount = 2;
|
||||
|
||||
woItemUnitCount = 1;
|
||||
break;
|
||||
case Level.SeedLevel.Huge:
|
||||
PastMonthsToSeed = 23;
|
||||
woItemCount = 1;
|
||||
woItemUnitCount = 1;
|
||||
break;
|
||||
|
||||
}
|
||||
DateTime seedStartWindow = DateTime.UtcNow.AddMonths(-PastMonthsToSeed);//goes back based on seed level
|
||||
DateTime seedEndWindow = DateTime.UtcNow.AddMonths(1);//always one month from now
|
||||
|
||||
for (int x = 0; x < count; x++)
|
||||
{
|
||||
@@ -2792,7 +2828,7 @@ namespace AyaNova.Util
|
||||
o.InternalReferenceNumber = "irf-" + Fake.Finance.Account(4);
|
||||
o.ServiceDate = woDate;
|
||||
|
||||
int woItemCount = Fake.Random.Int(1, 4);
|
||||
|
||||
for (int y = 0; y < woItemCount; y++)
|
||||
{
|
||||
var woItem = new WorkOrderItem()
|
||||
@@ -2805,20 +2841,16 @@ namespace AyaNova.Util
|
||||
WorkOrderItemStatusId = Fake.Random.Long(1, 3)//there are 3 different sample woitem status
|
||||
};
|
||||
|
||||
//UNITS
|
||||
var woItemUnit = new WorkOrderItemUnit()
|
||||
//UNITS
|
||||
for (int a = 0; a < woItemUnitCount; a++)
|
||||
{
|
||||
UnitId = GetRandomUnitForCustomer(o.CustomerId),
|
||||
Notes = Fake.Lorem.Sentence()
|
||||
};
|
||||
woItem.Units.Add(woItemUnit);
|
||||
|
||||
woItemUnit = new WorkOrderItemUnit()
|
||||
{
|
||||
UnitId = GetRandomUnitForCustomer(o.CustomerId),
|
||||
Notes = Fake.Lorem.Sentence()
|
||||
};
|
||||
woItem.Units.Add(woItemUnit);
|
||||
var woItemUnit = new WorkOrderItemUnit()
|
||||
{
|
||||
UnitId = GetRandomUnitForCustomer(o.CustomerId),
|
||||
Notes = Fake.Lorem.Sentence(3)
|
||||
};
|
||||
woItem.Units.Add(woItemUnit);
|
||||
}
|
||||
|
||||
//SCHEDULED USERS
|
||||
//not realistic, just to fill schedule forms with a nice even distribution
|
||||
|
||||
Reference in New Issue
Block a user