This commit is contained in:
@@ -199,7 +199,16 @@ namespace AyaNova.Util
|
||||
//Seed special test data for integration testing
|
||||
//log.LogInformation("Seeding known users");
|
||||
await SeedKnownObjectsAsync(log);
|
||||
/*
|
||||
|
||||
███████╗███████╗███████╗██████╗ █████╗ ██╗ ██╗ ████████╗██╗ ██╗███████╗ ████████╗██╗ ██╗██╗███╗ ██╗ ██████╗ ███████╗
|
||||
██╔════╝██╔════╝██╔════╝██╔══██╗ ██╔══██╗██║ ██║ ╚══██╔══╝██║ ██║██╔════╝ ╚══██╔══╝██║ ██║██║████╗ ██║██╔════╝ ██╔════╝
|
||||
███████╗█████╗ █████╗ ██║ ██║ ███████║██║ ██║ ██║ ███████║█████╗ ██║ ███████║██║██╔██╗ ██║██║ ███╗███████╗
|
||||
╚════██║██╔══╝ ██╔══╝ ██║ ██║ ██╔══██║██║ ██║ ██║ ██╔══██║██╔══╝ ██║ ██╔══██║██║██║╚██╗██║██║ ██║╚════██║
|
||||
███████║███████╗███████╗██████╔╝ ██║ ██║███████╗███████╗ ██║ ██║ ██║███████╗ ██║ ██║ ██║██║██║ ╚████║╚██████╔╝███████║
|
||||
╚══════╝╚══════╝╚══════╝╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝
|
||||
|
||||
*/
|
||||
//log.LogInformation("Seeding all other data");
|
||||
switch (slevel)
|
||||
{
|
||||
@@ -227,6 +236,7 @@ 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 SeedPartWarehouseAsync(log, 5);
|
||||
await SeedPartAsync(log, 50);
|
||||
await SeedPartAssemblyAsync(log, 5);
|
||||
|
||||
@@ -279,6 +289,7 @@ 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 SeedPartWarehouseAsync(log, 10);
|
||||
await SeedPartAsync(log, 100);
|
||||
await SeedPartAssemblyAsync(log, 5);
|
||||
|
||||
@@ -342,6 +353,7 @@ 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 SeedPartWarehouseAsync(log, 15);
|
||||
await SeedPartAsync(log, 200);
|
||||
await SeedPartAssemblyAsync(log, 5);
|
||||
|
||||
@@ -405,6 +417,7 @@ 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 SeedPartWarehouseAsync(log, 20);
|
||||
await SeedPartAsync(log, 500);
|
||||
await SeedPartAssemblyAsync(log, 5);
|
||||
|
||||
@@ -1488,6 +1501,42 @@ namespace AyaNova.Util
|
||||
}
|
||||
|
||||
|
||||
public HashSet<string> HashPartWarehouseNames = new HashSet<string>();
|
||||
private int TotalSeededPartWarehouses = 1;//Default warehouse is already present
|
||||
//////////////////////////////////////////////////////
|
||||
//PARTWAREHOUSE
|
||||
//
|
||||
public async Task SeedPartWarehouseAsync(ILogger log, int count)
|
||||
{
|
||||
for (int x = 0; x < count; x++)
|
||||
{
|
||||
PartWarehouse o = new PartWarehouse();
|
||||
do
|
||||
{
|
||||
o.Name = $"WHS- {Fake.Address.StreetName()}";
|
||||
} while (!HashPartWarehouseNames.Add(o.Name));
|
||||
|
||||
o.Active = true;
|
||||
o.Notes = Fake.Lorem.Sentence();
|
||||
o.Tags = RandomTags();
|
||||
|
||||
|
||||
//This seems wrong to do in a loop but is 4 times faster this way ?!?
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
PartWarehouseBiz biz = PartWarehouseBiz.GetBiz(ct);
|
||||
var NewObject = await biz.CreateAsync(o);
|
||||
TotalSeededPartWarehouses++;
|
||||
if (NewObject == null)
|
||||
{
|
||||
var err = $"Seeder::SeedPartWarehouse error creating {o.Name}\r\n{biz.GetErrorsAsString()}";
|
||||
log.LogError(err);
|
||||
throw new System.Exception(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public HashSet<string> HashPartNumbers = new HashSet<string>();
|
||||
@@ -1556,22 +1605,28 @@ namespace AyaNova.Util
|
||||
OpeningInventoryLevel += Fake.Random.Number(1, 1000);
|
||||
PartInventory partInventory = null;
|
||||
|
||||
//add opening inventory
|
||||
partInventory = await PartInventoryBizNess.CreateAsync(new dtPartInventory() { PartId = NewObject.Id, PartWarehouseId = 1, Quantity = OpeningInventoryLevel, Description = "New part opening inventory" });
|
||||
|
||||
//make two adjustments to have some testing data
|
||||
if (partInventory != null)
|
||||
partInventory = await PartInventoryBizNess.CreateAsync(new dtPartInventory() { PartId = NewObject.Id, PartWarehouseId = 1, Quantity = -1, Description = "example adjustment" });
|
||||
|
||||
if (partInventory != null)
|
||||
partInventory = await PartInventoryBizNess.CreateAsync(new dtPartInventory() { PartId = NewObject.Id, PartWarehouseId = 1, Quantity = Fake.Random.Number(1, 100), Description = "example adjustment" });
|
||||
|
||||
|
||||
if (partInventory == null)
|
||||
//Add inventory into multiple warehouses for testing
|
||||
for (int y = 0; y < 3; y++)
|
||||
{
|
||||
var err = $"Seeder::SeedPart - error creating {o.PartNumber} INVENTORY \r\n{PartInventoryBizNess.GetErrorsAsString()}";
|
||||
log.LogError(err);
|
||||
throw new System.Exception(err);
|
||||
int WarehouseNumber=y+1;
|
||||
|
||||
//add opening inventory
|
||||
partInventory = await PartInventoryBizNess.CreateAsync(new dtPartInventory() { PartId = NewObject.Id, PartWarehouseId = WarehouseNumber, Quantity = OpeningInventoryLevel, Description = "New part opening inventory" });
|
||||
|
||||
//make two adjustments to have some testing data
|
||||
if (partInventory != null)
|
||||
partInventory = await PartInventoryBizNess.CreateAsync(new dtPartInventory() { PartId = NewObject.Id, PartWarehouseId = WarehouseNumber, Quantity = -1, Description = "example adjustment" });
|
||||
|
||||
if (partInventory != null)
|
||||
partInventory = await PartInventoryBizNess.CreateAsync(new dtPartInventory() { PartId = NewObject.Id, PartWarehouseId = WarehouseNumber, Quantity = Fake.Random.Number(1, 100), Description = "example adjustment" });
|
||||
|
||||
|
||||
if (partInventory == null)
|
||||
{
|
||||
var err = $"Seeder::SeedPart - error creating {o.PartNumber} INVENTORY \r\n{PartInventoryBizNess.GetErrorsAsString()}";
|
||||
log.LogError(err);
|
||||
throw new System.Exception(err);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user