This commit is contained in:
@@ -227,6 +227,8 @@ namespace AyaNova.Util
|
||||
await SeedUnitAsync(log, 500);//5 times the customers or 5 units per customer
|
||||
await SeedLoanLoanUnitAsync(log, 5);
|
||||
await SeedCustomerServiceRequestAsync(log, 5);
|
||||
await SeedPartAsync(log, 50);
|
||||
await SeedPartAssemblyAsync(log, 5);
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
@@ -277,6 +279,9 @@ namespace AyaNova.Util
|
||||
await SeedUnitAsync(log, 2500);//5 times the customers or 5 units per customer
|
||||
await SeedLoanLoanUnitAsync(log, 10);
|
||||
await SeedCustomerServiceRequestAsync(log, 10);
|
||||
await SeedPartAsync(log, 100);
|
||||
await SeedPartAssemblyAsync(log, 5);
|
||||
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
@@ -337,6 +342,8 @@ namespace AyaNova.Util
|
||||
await SeedUnitAsync(log, 25000);//5 times the customers or 5 units per customer
|
||||
await SeedLoanLoanUnitAsync(log, 15);
|
||||
await SeedCustomerServiceRequestAsync(log, 15);
|
||||
await SeedPartAsync(log, 200);
|
||||
await SeedPartAssemblyAsync(log, 5);
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
@@ -398,6 +405,8 @@ namespace AyaNova.Util
|
||||
await SeedUnitAsync(log, 100000);//5 times the customers or 5 units per customer
|
||||
await SeedLoanLoanUnitAsync(log, 20);
|
||||
await SeedCustomerServiceRequestAsync(log, 20);
|
||||
await SeedPartAsync(log, 500);
|
||||
await SeedPartAssemblyAsync(log, 5);
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
@@ -1523,7 +1532,7 @@ namespace AyaNova.Util
|
||||
TotalSeededParts++;
|
||||
if (NewObject == null)
|
||||
{
|
||||
var err = $"Seeder::SeedPart error creating {o.Name}\r\n{biz.GetErrorsAsString()}";
|
||||
var err = $"Seeder::SeedPart error creating {o.PartNumber}\r\n{biz.GetErrorsAsString()}";
|
||||
log.LogError(err);
|
||||
throw new System.Exception(err);
|
||||
}
|
||||
@@ -1532,10 +1541,54 @@ namespace AyaNova.Util
|
||||
}
|
||||
|
||||
|
||||
public HashSet<string> HashPartAssemblyNames = new HashSet<string>();
|
||||
private int TotalSeededPartAssemblies = 0;
|
||||
//////////////////////////////////////////////////////
|
||||
//PARTASSEMBLY
|
||||
//
|
||||
public async Task SeedPartAssemblyAsync(ILogger log, int count)
|
||||
{
|
||||
for (int x = 0; x < count; x++)
|
||||
{
|
||||
PartAssembly o = new PartAssembly();
|
||||
List<long> partsAdded = new List<long>();
|
||||
do
|
||||
{
|
||||
o.Name = "asm" + Fake.Finance.Account(4);
|
||||
} while (!HashPartAssemblyNames.Add(o.Name));
|
||||
|
||||
//SEED PARTASSEMBLY
|
||||
o.Active = true;
|
||||
o.Notes = Fake.Lorem.Sentence();
|
||||
o.Tags = RandomTags();
|
||||
int partCount = Fake.Random.Int(2, 5);
|
||||
for (int y = 0; y < partCount; y++)
|
||||
{
|
||||
long partId = 0;
|
||||
do
|
||||
{
|
||||
partId = Fake.Random.Long(1, TotalSeededParts);
|
||||
} while (partsAdded.Contains(partId));
|
||||
partsAdded.Add(partId);
|
||||
o.Items.Add(new PartAssemblyItem() { PartId = partId });
|
||||
}
|
||||
|
||||
|
||||
//This seems wrong to do in a loop but is 4 times faster this way ?!?
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
PartAssemblyBiz biz = PartAssemblyBiz.GetBiz(ct);
|
||||
var NewObject = await biz.CreateAsync(o);
|
||||
TotalSeededPartAssemblies++;
|
||||
if (NewObject == null)
|
||||
{
|
||||
var err = $"Seeder::SeedPartAssembly error creating {o.Name}\r\n{biz.GetErrorsAsString()}";
|
||||
log.LogError(err);
|
||||
throw new System.Exception(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user