This commit is contained in:
2021-07-28 17:19:17 +00:00
parent b11491af66
commit 8440a4b132

View File

@@ -244,9 +244,10 @@ namespace AyaNova.Util
await SeedPartWarehouseAsync(log, 5); await SeedPartWarehouseAsync(log, 5);
await SeedPartAsync(log, 20, 100); await SeedPartAsync(log, 20, 100);
await SeedPartAssemblyAsync(log, 5); await SeedPartAssemblyAsync(log, 5);
await SeedPurchaseOrderAsync(log, 20); await SeedPurchaseOrderAsync(log, 10);
await SeedQuoteAsync(log, 5); await SeedQuoteAsync(log, 5);
await SeedWorkOrderAsync(log, 25); await SeedPMAsync(log, 3);
await SeedWorkOrderAsync(log, 10);
//PERF //PERF
watch.Stop(); watch.Stop();
@@ -304,6 +305,7 @@ namespace AyaNova.Util
await SeedPartAssemblyAsync(log, 5); await SeedPartAssemblyAsync(log, 5);
await SeedPurchaseOrderAsync(log, 30); await SeedPurchaseOrderAsync(log, 30);
await SeedQuoteAsync(log, 5); await SeedQuoteAsync(log, 5);
await SeedPMAsync(log, 3);
await SeedWorkOrderAsync(log, 75); await SeedWorkOrderAsync(log, 75);
//PERF //PERF
@@ -372,6 +374,7 @@ namespace AyaNova.Util
await SeedPartAssemblyAsync(log, 5); await SeedPartAssemblyAsync(log, 5);
await SeedPurchaseOrderAsync(log, 50); await SeedPurchaseOrderAsync(log, 50);
await SeedQuoteAsync(log, 5); await SeedQuoteAsync(log, 5);
await SeedPMAsync(log, 3);
await SeedWorkOrderAsync(log, 150); await SeedWorkOrderAsync(log, 150);
//PERF //PERF
@@ -441,6 +444,7 @@ namespace AyaNova.Util
await SeedPartAssemblyAsync(log, 25); await SeedPartAssemblyAsync(log, 25);
await SeedPurchaseOrderAsync(log, 250); await SeedPurchaseOrderAsync(log, 250);
await SeedQuoteAsync(log, 5); await SeedQuoteAsync(log, 5);
await SeedPMAsync(log, 3);
await SeedWorkOrderAsync(log, 300); await SeedWorkOrderAsync(log, 300);
//PERF //PERF
@@ -3697,15 +3701,15 @@ namespace AyaNova.Util
o.CustomerId = GetRandomCustomerId();//Fake.Random.Long(1, TotalSeededCustomers); o.CustomerId = GetRandomCustomerId();//Fake.Random.Long(1, TotalSeededCustomers);
//------ //------
o.StopGeneratingDate=woDate.AddYears(1); o.StopGeneratingDate = woDate.AddYears(1);
o.ExcludeDaysOfWeek= new bool[]{true,true,true,true,true,false,false};//Monday to Sunday (0-6 index) o.ExcludeDaysOfWeek = new bool[] { true, true, true, true, true, false, false };//Monday to Sunday (0-6 index)
o.Active=true; o.Active = true;
o.NextServiceDate=woDate.AddDays(1); o.NextServiceDate = woDate.AddDays(1);
o.RepeatInterval=1; o.RepeatInterval = 1;
o.RepeatUnit= PMTimeUnit.Months; o.RepeatUnit = PMTimeUnit.Months;
o.GenerateBeforeInterval=3; o.GenerateBeforeInterval = 3;
o.GenerateBeforeUnit=PMTimeUnit.Days; o.GenerateBeforeUnit = PMTimeUnit.Days;
//------ //------
@@ -3730,24 +3734,24 @@ namespace AyaNova.Util
o.PostCode = head.PostCode; o.PostCode = head.PostCode;
} }
else else
{ {
o.PostAddress = cust.PostAddress; o.PostAddress = cust.PostAddress;
o.PostCity = cust.PostCity; o.PostCity = cust.PostCity;
o.PostRegion = cust.PostRegion; o.PostRegion = cust.PostRegion;
o.PostCountry = cust.PostCountry; o.PostCountry = cust.PostCountry;
o.PostCode = cust.PostCode; o.PostCode = cust.PostCode;
} }
} }
o.CustomerReferenceNumber = "crf-" + Fake.Finance.Account(4); o.CustomerReferenceNumber = "crf-" + Fake.Finance.Account(4);
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, 2); int woItemCount = Fake.Random.Int(1, 2);
for (int y = 0; y < woItemCount; y++) for (int y = 0; y < woItemCount; y++)
{ {
var woItem = new PMItem() var woItem = new PMItem()
{ {
Sequence = y + 1, Sequence = y + 1,
@@ -4053,13 +4057,13 @@ for (int y = 0; y < woItemCount; y++)
woItem.OutsideServices.Add(woItemOutsideService); woItem.OutsideServices.Add(woItemOutsideService);
o.Items.Add(woItem); o.Items.Add(woItem);
} }
//This seems wrong to do in a loop but is 4 times faster this way ?!? //This seems wrong to do in a loop but is 4 times faster this way ?!?
using (AyContext ct = ServiceProviderProvider.DBContext) using (AyContext ct = ServiceProviderProvider.DBContext)
{ {
PMBiz biz = PMBiz.GetBiz(ct); PMBiz biz = PMBiz.GetBiz(ct);
var NewObject = await biz.PMCreateAsync(o, false); var NewObject = await biz.PMCreateAsync(o, false);
TotalSeededPMs++; TotalSeededPMs++;
@@ -4069,7 +4073,7 @@ using (AyContext ct = ServiceProviderProvider.DBContext)
log.LogError(err); log.LogError(err);
throw new System.Exception(err); throw new System.Exception(err);
} }
} }
} }
} }
@@ -4079,22 +4083,22 @@ using (AyContext ct = ServiceProviderProvider.DBContext)
private long GetRandomUnitForCustomer(long customerId) private long GetRandomUnitForCustomer(long customerId)
{ {
var l = CustomerUnits.Where(x => x.Key == customerId).FirstOrDefault();//Fake.Random.Long(1, TotalSeededUnits); var l = CustomerUnits.Where(x => x.Key == customerId).FirstOrDefault();//Fake.Random.Long(1, TotalSeededUnits);
var numUnits = l.Value.Count(); var numUnits = l.Value.Count();
//because faker values are INCLUSIVE and this is going to be used as an index on an array need to -1 each end of the range //because faker values are INCLUSIVE and this is going to be used as an index on an array need to -1 each end of the range
var i = Fake.Random.Int(0, numUnits - 1); var i = Fake.Random.Int(0, numUnits - 1);
return l.Value[i]; return l.Value[i];
} }
private long GetRandomCustomerId() private long GetRandomCustomerId()
{ {
//return any random customer except for the shadow unit one //return any random customer except for the shadow unit one
long ret = KnownCustomerForShadownUnitsId; long ret = KnownCustomerForShadownUnitsId;
while (ret == KnownCustomerForShadownUnitsId) while (ret == KnownCustomerForShadownUnitsId)
ret = Fake.Random.Long(1, TotalSeededCustomers); ret = Fake.Random.Long(1, TotalSeededCustomers);
return ret; return ret;
} }
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////