From 6a520b3e13f581c27665fd73414d31b69809b620 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 15 Oct 2021 15:29:56 +0000 Subject: [PATCH] seeder changes to accommodate truly huge generation --- .../Example Units Per Customer .ayrt | 1 + server/AyaNova/util/Seeder.cs | 71 +++++++++++-------- 2 files changed, 41 insertions(+), 31 deletions(-) create mode 100644 server/AyaNova/resource/rpt/stock-report-templates/Example Units Per Customer .ayrt diff --git a/server/AyaNova/resource/rpt/stock-report-templates/Example Units Per Customer .ayrt b/server/AyaNova/resource/rpt/stock-report-templates/Example Units Per Customer .ayrt new file mode 100644 index 00000000..65205246 --- /dev/null +++ b/server/AyaNova/resource/rpt/stock-report-templates/Example Units Per Customer .ayrt @@ -0,0 +1 @@ +{"Name":"Example Units Per Customer ","Active":true,"Notes":"Uses built in Helper ayGroupByKey ","Roles":50554,"AType":31,"IncludeWoItemDescendants":false,"Template":"\n\n\t
\t \n\t\t \n \t\t\n\n \n \n \n \n \t\n \n \n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t \n \n \n \t\t\n \t\n \t\t\n \n \n {{#each ayReportData}}\n \n \n\t\t\t \n\t\t\t \n \n\t\t {{#each items}}\n\t\t \n\t\t\t \n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t \n \n\t\t\t{{/each}}\n\t\t\t\n\t\t\t \n \n \t {{/each}}\n \n
Units per Customer
 
CustomerSerial NumberUnit ModelLast Closed Service DateLast Closed WONotes
 
{{group}}# of units for {{group}}: {{count}}
 {{Serial}}{{UnitModelViz}}{{ayDate LastCompletedServiceDateViz}}{{LastCompletedWorkOrderViz}}{{Notes}}
 
\n\n\n \n\t
\n\n","Style":".singlePage\n{\npage-break-after: always;\n}\n\ntable { \n font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;\n border-collapse: collapse;\n white-space: pre-wrap;\n width: 100%;\n table-layout: fixed;\n }\n\nthead {\n display: table-header-group; /* so as to print the table-header on all subsequent pages */\n}\n\n.heading {\n border-style: solid;\n border-width: 1pt;\n border-color: #e8e5e5; \n margin: 10pt;\n background-color: #e8e5e5;\n padding: 5pt; \n font-size: 14pt; \n text-align: center;\n} \n\n.bodyhead {\n border-style: solid;\n border-width: 1pt;\n border-color: #e8e5e5; \n margin: 10pt;\n background-color: #e8e5e5;\n font-size: 12pt; \n}\n\n\n.rightlean {\n text-align: right;\n}\n.leftlean {\n text-align: left;\n}\n.centerlean {\n text-align: center;\n}\ntbody tr:nth-child(even) {\n font-size: 9pt;\n background-color: lightgray; /* MUST checkmark Print background in PDF Options for this to show */\n height: 50px;\n overflow-wrap: break-word;\n} \ntbody tr:nth-child(odd) {\n font-size: 9pt;\n background-color: lightgoldenrodyellow; /* MUST checkmark Print background in PDF Options for this to show */\n height: 50px;\n overflow-wrap: break-word;\n} \n\n\ntfoot {\n /* display: table-footer-group; uncomment to print the table-footer on all pages, not just last page - */\n page-break-inside: avoid;\n /* position: fixed; uncommenting position: will force footer to bottom BUT then leftlean and rightlean don't work AND tbody overwrites */\n \n bottom: 0;\n width: 100%;\n border-top: 1px solid black; \n}\n\n\n.fontgreen {\n color: green;\n}\n.fontblue {\n color: blue;\n}\n.fontred {\n color:red;\n}\n\n","JsPrerender":"async function ayPrepareData(reportData) {\n\n //send the raw report data to the groupByKey function which will return a new array grouped by the key name provided\n reportData.ayReportData = ayGroupByKey(reportData.ayReportData, 'CustomerViz')\n\n //return the data into the pipeline to send to the report template\n return reportData;\n}\n\n","JsHelpers":"//Register custom Handlebars helpers here to use in your report script\n//https://handlebarsjs.com/guide/#custom-helpers\nHandlebars.registerHelper('loud', function (aString) {\n return aString.toUpperCase()\n})","RenderType":0,"HeaderTemplate":"    (set in report template's PDF Options) Printed date: ","FooterTemplate":"  (set in report template's PDF Options showing x of ALL pages printed)  Page  of ","DisplayHeaderFooter":true,"PaperFormat":10,"Landscape":true,"MarginOptionsBottom":"10mm","MarginOptionsLeft":"10mm","MarginOptionsRight":"10mm","MarginOptionsTop":"10mm","PageRanges":null,"PreferCSSPageSize":false,"PrintBackground":true,"Scale":1.00000} \ No newline at end of file diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs index 59dc178b..1f9145eb 100644 --- a/server/AyaNova/util/Seeder.cs +++ b/server/AyaNova/util/Seeder.cs @@ -230,8 +230,8 @@ namespace AyaNova.Util await SeedUserAsync(log, 1, AuthorizationRoles.Service | AuthorizationRoles.Inventory | AuthorizationRoles.Accounting, UserType.NotService); await SeedVendorAsync(log, 10); await SeedUnitModelAsync(log, 10); - await SeedCustomerAsync(log, 25); - await SeedHeadOfficeAsync(log, 10); + await SeedCustomerAsync(log, 25, slevel); + await SeedHeadOfficeAsync(log, 10, slevel); await SeedVendorAsync(log, 10); await SeedProjectAsync(log, 3); await SeedServiceRateAsync(log, 5); @@ -288,8 +288,8 @@ namespace AyaNova.Util await SeedVendorAsync(log, 50); await SeedUnitModelAsync(log, 20); - await SeedCustomerAsync(log, 500); - await SeedHeadOfficeAsync(log, 20); + await SeedCustomerAsync(log, 500, slevel); + await SeedHeadOfficeAsync(log, 20, slevel); await SeedProjectAsync(log, 5); await SeedServiceRateAsync(log, 10); @@ -356,8 +356,8 @@ namespace AyaNova.Util await SeedVendorAsync(log, 100); await SeedUnitModelAsync(log, 40); - await SeedCustomerAsync(log, 1000); - await SeedHeadOfficeAsync(log, 40); + await SeedCustomerAsync(log, 1000, slevel); + await SeedHeadOfficeAsync(log, 40, slevel); await SeedProjectAsync(log, 10); await SeedServiceRateAsync(log, 20); @@ -401,7 +401,7 @@ namespace AyaNova.Util //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); //regular techs - await SeedUserAsync(log, 500, AuthorizationRoles.Tech | AuthorizationRoles.ServiceRestricted, UserType.Service); + await SeedUserAsync(log, 1000, AuthorizationRoles.Tech | AuthorizationRoles.ServiceRestricted, UserType.Service); //Restricted techs await SeedUserAsync(log, 200, AuthorizationRoles.TechRestricted | AuthorizationRoles.ServiceRestricted, UserType.Service); //subcontractors @@ -409,9 +409,9 @@ namespace AyaNova.Util //Restricted subcontractors await SeedUserAsync(log, 40, AuthorizationRoles.SubContractorRestricted, UserType.ServiceContractor); //generic office people people - await SeedUserAsync(log, 200, AuthorizationRoles.ServiceRestricted | AuthorizationRoles.InventoryRestricted, UserType.NotService); + await SeedUserAsync(log, 500, AuthorizationRoles.ServiceRestricted | AuthorizationRoles.InventoryRestricted, UserType.NotService); //20 Full sales people - await SeedUserAsync(log, 20, AuthorizationRoles.Sales, UserType.NotService); + await SeedUserAsync(log, 60, AuthorizationRoles.Sales, UserType.NotService); //10 Restricted sales people await SeedUserAsync(log, 10, AuthorizationRoles.SalesRestricted, UserType.NotService); //Service manager @@ -423,25 +423,25 @@ namespace AyaNova.Util //accountant / bookkeeper await SeedUserAsync(log, 20, AuthorizationRoles.Accounting | AuthorizationRoles.BizAdminRestricted, UserType.NotService); - await SeedVendorAsync(log, 500); - await SeedUnitModelAsync(log, 200); - await SeedCustomerAsync(log, 10000); - await SeedHeadOfficeAsync(log, 200); + await SeedVendorAsync(log, 5000); + await SeedUnitModelAsync(log, 400); + await SeedCustomerAsync(log, 30000, slevel); + await SeedHeadOfficeAsync(log, 500, slevel); - await SeedProjectAsync(log, 20); - await SeedServiceRateAsync(log, 100); - await SeedTravelRateAsync(log, 50); + await SeedProjectAsync(log, 1000); + await SeedServiceRateAsync(log, 200); + await SeedTravelRateAsync(log, 100); //await SeedUnitAsync(log, 25000); - await SeedLoanLoanUnitAsync(log, 100); - await SeedCustomerServiceRequestAsync(log, 100); - await SeedPartWarehouseAsync(log, 100); - await SeedPartAsync(log, 1000, 3000); - await SeedPartAssemblyAsync(log, 25); - await SeedPurchaseOrderAsync(log, 250); - await SeedQuoteAsync(log, 5); - await SeedPMAsync(log, 3); - await SeedWorkOrderAsync(log, 20000);//was 1000 + await SeedLoanLoanUnitAsync(log, 200); + await SeedCustomerServiceRequestAsync(log, 200); + await SeedPartWarehouseAsync(log, 200); + await SeedPartAsync(log, 10000, 6000); + await SeedPartAssemblyAsync(log, 500); + await SeedPurchaseOrderAsync(log, 1000); + await SeedQuoteAsync(log, 1000); + await SeedPMAsync(log, 1000); + await SeedWorkOrderAsync(log, 100000);//was 1000 //PERF watch.Stop(); @@ -1788,7 +1788,7 @@ namespace AyaNova.Util ////////////////////////////////////////////////////// //CUSTOMER // - public async Task SeedCustomerAsync(ILogger log, int count, long? headOfficeId = null) + public async Task SeedCustomerAsync(ILogger log, int count, Level.SeedLevel slevel, long? headOfficeId = null) { for (int x = 0; x < count; x++) @@ -1851,8 +1851,17 @@ namespace AyaNova.Util if (Fake.Random.Number(9) == 4) await SeedUserAsync(log, 1, AuthorizationRoles.Customer, UserType.Customer, true, null, null, 0, null, null, NewObject.Id, null); - //5 units per customer - await SeedUnitAsync(log, 20, NewObject.Id);//5 times the customers or 5 units per customer + switch (slevel) + { + case Level.SeedLevel.Small: + case Level.SeedLevel.Large: + case Level.SeedLevel.Medium: + await SeedUnitAsync(log, 20, NewObject.Id); + break; + case Level.SeedLevel.Huge: + await SeedUnitAsync(log, 100, NewObject.Id); + break; + } } } } @@ -1862,7 +1871,7 @@ namespace AyaNova.Util ////////////////////////////////////////////////////// //HEADOFFICE // - public async Task SeedHeadOfficeAsync(ILogger log, int count) + public async Task SeedHeadOfficeAsync(ILogger log, int count, Level.SeedLevel slevel) { for (int x = 0; x < count; x++) @@ -1916,7 +1925,7 @@ namespace AyaNova.Util //HeadOffice contacts await SeedUserAsync(log, 1, AuthorizationRoles.Customer, UserType.HeadOffice, true, null, null, 0, null, null, null, NewObject.Id); //HeadOffice Customer - await SeedCustomerAsync(log, 2, NewObject.Id); + await SeedCustomerAsync(log, 2,slevel, NewObject.Id); } } @@ -2146,7 +2155,7 @@ namespace AyaNova.Util o.Name = $"{Fake.Vehicle.Model()} {Fake.Commerce.Categories(1)[0]} - {Fake.Finance.Account(6)}"; } while (!HashUnitModelNames.Add(o.Name)); - + o.Active = true; o.Notes = Fake.Lorem.Sentence();