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 SeedPurchaseOrderAsync(log, 10);
|
||||||
await SeedQuoteAsync(log, 5);
|
await SeedQuoteAsync(log, 5);
|
||||||
await SeedPMAsync(log, 3);
|
await SeedPMAsync(log, 3);
|
||||||
await SeedWorkOrderAsync(log, 100);
|
await SeedWorkOrderAsync(log, 450, slevel);
|
||||||
|
|
||||||
//PERF
|
//PERF
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
@@ -304,7 +304,7 @@ namespace AyaNova.Util
|
|||||||
await SeedPurchaseOrderAsync(log, 30);
|
await SeedPurchaseOrderAsync(log, 30);
|
||||||
await SeedQuoteAsync(log, 5);
|
await SeedQuoteAsync(log, 5);
|
||||||
await SeedPMAsync(log, 3);
|
await SeedPMAsync(log, 3);
|
||||||
await SeedWorkOrderAsync(log, 200);
|
await SeedWorkOrderAsync(log, 900, slevel);
|
||||||
|
|
||||||
//PERF
|
//PERF
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
@@ -372,7 +372,7 @@ namespace AyaNova.Util
|
|||||||
await SeedPurchaseOrderAsync(log, 50);
|
await SeedPurchaseOrderAsync(log, 50);
|
||||||
await SeedQuoteAsync(log, 5);
|
await SeedQuoteAsync(log, 5);
|
||||||
await SeedPMAsync(log, 3);
|
await SeedPMAsync(log, 3);
|
||||||
await SeedWorkOrderAsync(log, 300);
|
await SeedWorkOrderAsync(log, 1800, slevel);
|
||||||
|
|
||||||
//PERF
|
//PERF
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
@@ -400,14 +400,21 @@ namespace AyaNova.Util
|
|||||||
await SeedUserAsync(log, 10, AuthorizationRoles.BizAdmin | AuthorizationRoles.OpsAdminRestricted, UserType.NotService);
|
await SeedUserAsync(log, 10, AuthorizationRoles.BizAdmin | AuthorizationRoles.OpsAdminRestricted, UserType.NotService);
|
||||||
//owner / upper management who doesn't control anything but views stuff
|
//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);
|
await SeedUserAsync(log, 20, AuthorizationRoles.BizAdminRestricted | AuthorizationRoles.ServiceRestricted | AuthorizationRoles.InventoryRestricted | AuthorizationRoles.OpsAdminRestricted, UserType.NotService);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////
|
||||||
|
//TECHS (LICENSE CONSUMERS)
|
||||||
|
//trial license allows 1000
|
||||||
|
//
|
||||||
//regular techs
|
//regular techs
|
||||||
await SeedUserAsync(log, 1000, AuthorizationRoles.Tech | AuthorizationRoles.ServiceRestricted, UserType.Service);
|
await SeedUserAsync(log, 675, AuthorizationRoles.Tech | AuthorizationRoles.ServiceRestricted, UserType.Service);
|
||||||
//Restricted techs
|
//Restricted techs
|
||||||
await SeedUserAsync(log, 200, AuthorizationRoles.TechRestricted | AuthorizationRoles.ServiceRestricted, UserType.Service);
|
await SeedUserAsync(log, 200, AuthorizationRoles.TechRestricted | AuthorizationRoles.ServiceRestricted, UserType.Service);
|
||||||
//subcontractors
|
//subcontractors
|
||||||
await SeedUserAsync(log, 80, AuthorizationRoles.SubContractor, UserType.ServiceContractor);
|
await SeedUserAsync(log, 80, AuthorizationRoles.SubContractor, UserType.ServiceContractor);
|
||||||
//Restricted subcontractors
|
//Restricted subcontractors
|
||||||
await SeedUserAsync(log, 40, AuthorizationRoles.SubContractorRestricted, UserType.ServiceContractor);
|
await SeedUserAsync(log, 40, AuthorizationRoles.SubContractorRestricted, UserType.ServiceContractor);
|
||||||
|
///////////////////////////////////////////
|
||||||
|
|
||||||
//generic office people people
|
//generic office people people
|
||||||
await SeedUserAsync(log, 500, AuthorizationRoles.ServiceRestricted | AuthorizationRoles.InventoryRestricted, UserType.NotService);
|
await SeedUserAsync(log, 500, AuthorizationRoles.ServiceRestricted | AuthorizationRoles.InventoryRestricted, UserType.NotService);
|
||||||
//20 Full sales people
|
//20 Full sales people
|
||||||
@@ -439,8 +446,8 @@ namespace AyaNova.Util
|
|||||||
await SeedPartAssemblyAsync(log, 500);
|
await SeedPartAssemblyAsync(log, 500);
|
||||||
await SeedPurchaseOrderAsync(log, 1000);
|
await SeedPurchaseOrderAsync(log, 1000);
|
||||||
await SeedQuoteAsync(log, 1000);
|
await SeedQuoteAsync(log, 1000);
|
||||||
await SeedPMAsync(log, 1000);
|
await SeedPMAsync(log, 3);//DO NOT want too many of these as they affect performance
|
||||||
await SeedWorkOrderAsync(log, 1000);
|
await SeedWorkOrderAsync(log, 3600, slevel);
|
||||||
|
|
||||||
//PERF
|
//PERF
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
@@ -2734,10 +2741,39 @@ namespace AyaNova.Util
|
|||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
//WORK ORDER
|
//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);
|
//Goal is 5 workorders per day for each level and window
|
||||||
DateTime seedEndWindow = DateTime.UtcNow.AddMonths(3);
|
//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++)
|
for (int x = 0; x < count; x++)
|
||||||
{
|
{
|
||||||
@@ -2792,7 +2828,7 @@ namespace AyaNova.Util
|
|||||||
o.InternalReferenceNumber = "irf-" + Fake.Finance.Account(4);
|
o.InternalReferenceNumber = "irf-" + Fake.Finance.Account(4);
|
||||||
o.ServiceDate = woDate;
|
o.ServiceDate = woDate;
|
||||||
|
|
||||||
int woItemCount = Fake.Random.Int(1, 4);
|
|
||||||
for (int y = 0; y < woItemCount; y++)
|
for (int y = 0; y < woItemCount; y++)
|
||||||
{
|
{
|
||||||
var woItem = new WorkOrderItem()
|
var woItem = new WorkOrderItem()
|
||||||
@@ -2806,19 +2842,15 @@ namespace AyaNova.Util
|
|||||||
};
|
};
|
||||||
|
|
||||||
//UNITS
|
//UNITS
|
||||||
var woItemUnit = new WorkOrderItemUnit()
|
for (int a = 0; a < woItemUnitCount; a++)
|
||||||
{
|
{
|
||||||
UnitId = GetRandomUnitForCustomer(o.CustomerId),
|
var woItemUnit = new WorkOrderItemUnit()
|
||||||
Notes = Fake.Lorem.Sentence()
|
{
|
||||||
};
|
UnitId = GetRandomUnitForCustomer(o.CustomerId),
|
||||||
woItem.Units.Add(woItemUnit);
|
Notes = Fake.Lorem.Sentence(3)
|
||||||
|
};
|
||||||
woItemUnit = new WorkOrderItemUnit()
|
woItem.Units.Add(woItemUnit);
|
||||||
{
|
}
|
||||||
UnitId = GetRandomUnitForCustomer(o.CustomerId),
|
|
||||||
Notes = Fake.Lorem.Sentence()
|
|
||||||
};
|
|
||||||
woItem.Units.Add(woItemUnit);
|
|
||||||
|
|
||||||
//SCHEDULED USERS
|
//SCHEDULED USERS
|
||||||
//not realistic, just to fill schedule forms with a nice even distribution
|
//not realistic, just to fill schedule forms with a nice even distribution
|
||||||
|
|||||||
Reference in New Issue
Block a user