This commit is contained in:
@@ -240,6 +240,7 @@ namespace AyaNova.Util
|
||||
await SeedPartWarehouseAsync(log, 5);
|
||||
await SeedPartAsync(log, 50);
|
||||
await SeedPartAssemblyAsync(log, 5);
|
||||
await SeedPurchaseOrderAsync(log, 10);
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
@@ -293,6 +294,7 @@ namespace AyaNova.Util
|
||||
await SeedPartWarehouseAsync(log, 10);
|
||||
await SeedPartAsync(log, 100);
|
||||
await SeedPartAssemblyAsync(log, 5);
|
||||
await SeedPurchaseOrderAsync(log, 15);
|
||||
|
||||
|
||||
//PERF
|
||||
@@ -357,6 +359,7 @@ namespace AyaNova.Util
|
||||
await SeedPartWarehouseAsync(log, 15);
|
||||
await SeedPartAsync(log, 200);
|
||||
await SeedPartAssemblyAsync(log, 5);
|
||||
await SeedPurchaseOrderAsync(log, 25);
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
@@ -421,6 +424,7 @@ namespace AyaNova.Util
|
||||
await SeedPartWarehouseAsync(log, 20);
|
||||
await SeedPartAsync(log, 500);
|
||||
await SeedPartAssemblyAsync(log, 5);
|
||||
await SeedPurchaseOrderAsync(log, 50);
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
@@ -573,7 +577,7 @@ namespace AyaNova.Util
|
||||
ho.Phone2 = Fake.Phone.PhoneNumber();
|
||||
ho.Phone3 = Fake.Phone.PhoneNumber();
|
||||
ho.WebAddress = Fake.Internet.Protocol() + "://example." + Fake.Internet.DomainSuffix();
|
||||
|
||||
|
||||
ho.EmailAddress = Fake.Internet.ExampleEmail();
|
||||
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
@@ -1685,7 +1689,63 @@ namespace AyaNova.Util
|
||||
}
|
||||
|
||||
|
||||
private int TotalSeededPurchaseOrders = 0;
|
||||
//////////////////////////////////////////////////////
|
||||
//PURCHASE ORDER
|
||||
//
|
||||
public async Task SeedPurchaseOrderAsync(ILogger log, int count)
|
||||
{
|
||||
DateTime seedStartWindow = DateTime.Now.AddYears(-1);
|
||||
DateTime seedEndWindow = DateTime.Now.AddMonths(-11);
|
||||
for (int x = 0; x < count; x++)
|
||||
{
|
||||
PurchaseOrder o = new PurchaseOrder();
|
||||
var poDate = Fake.Date.Between(seedStartWindow, seedEndWindow);
|
||||
o.OrderedDate = poDate.ToUniversalTime();
|
||||
o.ExpectedReceiveDate = poDate.AddDays(5).ToUniversalTime();
|
||||
o.Status = PurchaseOrderStatus.ClosedFullReceived;
|
||||
o.Notes = Fake.Lorem.Sentence();
|
||||
o.Tags = RandomTags();
|
||||
|
||||
List<long> partsAdded = new List<long>();
|
||||
int partCount = Fake.Random.Int(1, 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);
|
||||
var qty = Fake.Random.Int(1, 100);
|
||||
o.Items.Add(new PurchaseOrderItem()
|
||||
{
|
||||
PartId = partId,
|
||||
PartWarehouseId = Fake.Random.Long(1, 3),
|
||||
QuantityOrdered = qty,
|
||||
QuantityReceived = qty,
|
||||
PurchaseOrderCost = 10,
|
||||
ReceivedCost = 10,
|
||||
ReceivedDate = o.ExpectedReceiveDate
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//This seems wrong to do in a loop but is 4 times faster this way ?!?
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
PurchaseOrderBiz biz = PurchaseOrderBiz.GetBiz(ct);
|
||||
var NewObject = await biz.CreateAsync(o);
|
||||
TotalSeededPurchaseOrders++;
|
||||
if (NewObject == null)
|
||||
{
|
||||
var err = $"Seeder::SeedPurchaseOrder error creating {o.Serial}\r\n{biz.GetErrorsAsString()}";
|
||||
log.LogError(err);
|
||||
throw new System.Exception(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user