From 52428ef5cf3a5ae8f252fb3a619274407e1cae25 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 19 Oct 2021 20:00:57 +0000 Subject: [PATCH] Changed Seeding for Units to be fewer per customer and cleanup needless allocation within unit generation --- server/AyaNova/util/Seeder.cs | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs index 61ece08d..31ec3641 100644 --- a/server/AyaNova/util/Seeder.cs +++ b/server/AyaNova/util/Seeder.cs @@ -228,8 +228,8 @@ namespace AyaNova.Util await SeedUserAsync(log, 1, AuthorizationRoles.BizAdmin | AuthorizationRoles.Service | AuthorizationRoles.Inventory | AuthorizationRoles.OpsAdmin, UserType.Service); //Generate one office person / secretary await SeedUserAsync(log, 1, AuthorizationRoles.Service | AuthorizationRoles.Inventory | AuthorizationRoles.Accounting, UserType.NotService); - - //2 other techs (must always be enough to have no dupes per workorder) + + //2 other techs (must always be enough to have no dupes per workorder) await SeedUserAsync(log, 2, AuthorizationRoles.Tech | AuthorizationRoles.ServiceRestricted, UserType.Service); await SeedVendorAsync(log, 10); @@ -273,18 +273,18 @@ namespace AyaNova.Util await SeedUserAsync(log, 1, AuthorizationRoles.BizAdmin | AuthorizationRoles.OpsAdminRestricted, UserType.NotService); //One owner who doesn't control anything but views stuff await SeedUserAsync(log, 1, AuthorizationRoles.BizAdminRestricted | AuthorizationRoles.ServiceRestricted | AuthorizationRoles.InventoryRestricted | AuthorizationRoles.OpsAdminRestricted | AuthorizationRoles.SalesRestricted, UserType.NotService); - //////////////////////////////////////////////// + //////////////////////////////////////////////// //TECHS (LICENSE CONSUMERS) //trial license allows 1000 // //regular techs await SeedUserAsync(log, 5, AuthorizationRoles.Tech | AuthorizationRoles.ServiceRestricted, UserType.Service); //Restricted techs - // await SeedUserAsync(log, 2, AuthorizationRoles.TechRestricted | AuthorizationRoles.ServiceRestricted, UserType.Service); + // await SeedUserAsync(log, 2, AuthorizationRoles.TechRestricted | AuthorizationRoles.ServiceRestricted, UserType.Service); //subcontractors await SeedUserAsync(log, 1, AuthorizationRoles.SubContractor, UserType.ServiceContractor); //Restricted subcontractors - // await SeedUserAsync(log, 1, AuthorizationRoles.SubContractorRestricted, UserType.ServiceContractor); + // await SeedUserAsync(log, 1, AuthorizationRoles.SubContractorRestricted, UserType.ServiceContractor); /////////////////////////////////////////// //3 generic office people people await SeedUserAsync(log, 3, AuthorizationRoles.ServiceRestricted | AuthorizationRoles.InventoryRestricted, UserType.NotService); @@ -342,8 +342,8 @@ namespace AyaNova.Util await SeedUserAsync(log, 2, AuthorizationRoles.BizAdmin | AuthorizationRoles.OpsAdminRestricted, UserType.NotService); //owner / upper management who doesn't control anything but views stuff await SeedUserAsync(log, 5, AuthorizationRoles.BizAdminRestricted | AuthorizationRoles.ServiceRestricted | AuthorizationRoles.InventoryRestricted | AuthorizationRoles.OpsAdminRestricted, UserType.NotService); - - //////////////////////////////////////////////// + + //////////////////////////////////////////////// //TECHS (LICENSE CONSUMERS) //trial license allows 1000 // @@ -356,7 +356,7 @@ namespace AyaNova.Util //Restricted subcontractors await SeedUserAsync(log, 1, AuthorizationRoles.SubContractorRestricted, UserType.ServiceContractor); /////////////////////////////////////////// - + //30 generic office people people await SeedUserAsync(log, 30, AuthorizationRoles.ServiceRestricted | AuthorizationRoles.InventoryRestricted, UserType.NotService); //10 Full sales people @@ -1878,12 +1878,14 @@ namespace AyaNova.Util switch (slevel) { case Level.SeedLevel.Small: + await SeedUnitAsync(log, 2, NewObject.Id); + break; case Level.SeedLevel.Large: case Level.SeedLevel.Medium: - await SeedUnitAsync(log, 20, NewObject.Id); + await SeedUnitAsync(log, 5, NewObject.Id); break; case Level.SeedLevel.Huge: - await SeedUnitAsync(log, 100, NewObject.Id); + await SeedUnitAsync(log, 10, NewObject.Id); break; } } @@ -2213,6 +2215,8 @@ namespace AyaNova.Util public HashSet HashUnitNames = new HashSet(); //private int TotalSeededUnits = 0; private Dictionary> CustomerUnits = new Dictionary>(); + public int[] WarrantyMonths = new[] { 1, 6, 12, 24, 36 }; + public string[] WarrantyTerms = new[] { "Parts only", "Parts and service", "Service only", "Shipping parts and service", "First month parts and service here; after is depot only" }; ////////////////////////////////////////////////////// //UNIT @@ -2221,8 +2225,6 @@ namespace AyaNova.Util { DateTime seedStartWindow = DateTime.Now.AddYears(-10); DateTime seedEndWindow = DateTime.Now.AddYears(1); - var WarrantyMonths = new[] { 1, 6, 12, 24, 36 }; - var WarrantyTerms = new[] { "Parts only", "Parts and service", "Service only", "Shipping parts and service", "First month parts and service here; after is depot only" }; List unitsAddedThisRun = new List(); for (int x = 0; x < count; x++) { @@ -2846,7 +2848,7 @@ namespace AyaNova.Util o.InternalReferenceNumber = "irf-" + Fake.Finance.Account(4); o.ServiceDate = woDate; - var actualWorkorderItemCount=Fake.Random.Int(1,MaximumWorkOrderItemCount); + var actualWorkorderItemCount = Fake.Random.Int(1, MaximumWorkOrderItemCount); for (int y = 0; y < actualWorkorderItemCount; y++) { var woItem = new WorkOrderItem() @@ -2871,12 +2873,12 @@ namespace AyaNova.Util } //SCHEDULED USERS - var actualScheduledUserCount=Fake.Random.Int(1,2); + var actualScheduledUserCount = Fake.Random.Int(1, 2); for (int a = 0; a < actualScheduledUserCount; a++) { var randomStart = Fake.Random.Int(0, 5); var randomHours = Fake.Random.Int(1, 4); - // var randomDays = Fake.Random.Int(0, 3); + // var randomDays = Fake.Random.Int(0, 3); var randomStop = randomStart + randomHours; var woItemScheduledUser = new WorkOrderItemScheduledUser() { @@ -3262,7 +3264,7 @@ namespace AyaNova.Util } } - //All wo ending status + //All wo ending status //if it's in the past tag it with a completed type status if (isPast) {