This commit is contained in:
@@ -59,7 +59,7 @@ namespace AyaNova.Biz
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//CREATE
|
||||
//
|
||||
internal async Task<WorkOrder> WorkOrderCreateAsync(WorkOrder newObject)
|
||||
internal async Task<WorkOrder> WorkOrderCreateAsync(WorkOrder newObject, bool populateViz = true)
|
||||
{
|
||||
await WorkOrderValidateAsync(newObject, null);
|
||||
if (HasErrors)
|
||||
@@ -92,8 +92,8 @@ namespace AyaNova.Biz
|
||||
}
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
|
||||
await WorkOrderPopulateVizFields(newObject, true);//doing this here ahead of notification because notification may require the viz field lookup anyway and afaict no harm in it
|
||||
if (populateViz)
|
||||
await WorkOrderPopulateVizFields(newObject, true);
|
||||
await WorkOrderHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
||||
return newObject;
|
||||
}
|
||||
@@ -2925,7 +2925,7 @@ namespace AyaNova.Biz
|
||||
if (o.VendorSentViaId != null)
|
||||
o.VendorSentViaViz = await ct.Vendor.AsNoTracking().Where(x => x.Id == o.VendorSentViaId).Select(x => x.Name).FirstOrDefaultAsync();
|
||||
|
||||
TaxCode Tax = null;
|
||||
TaxCode Tax = null;
|
||||
if (o.TaxCodeId != null)
|
||||
Tax = await ct.TaxCode.AsNoTracking().FirstOrDefaultAsync(z => z.Id == o.TaxCodeId);
|
||||
if (Tax != null)
|
||||
@@ -2934,7 +2934,7 @@ namespace AyaNova.Biz
|
||||
|
||||
o.CostViz = o.ShippingCost + o.RepairCost;
|
||||
o.PriceViz = o.ShippingPrice + o.RepairPrice;
|
||||
|
||||
|
||||
//Currently not contract discounted so no further calcs need apply to priceViz
|
||||
|
||||
//Calculate totals and taxes
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace AyaNova.Util
|
||||
{
|
||||
@@ -60,10 +62,10 @@ namespace AyaNova.Util
|
||||
return DateToDisplay.ToLocalTime().ToString("g");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
/// <summary>
|
||||
/// Returns current date/time in sortable format
|
||||
///(used for duplicate names by stringUtil and others)
|
||||
///(used for duplicate names by stringUtil and others)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string SortableShortCurrentDateTimeValue
|
||||
@@ -77,18 +79,49 @@ namespace AyaNova.Util
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// returns passed in date as a string format ISO8661 UTC date (no conversion of date is done, it's assumed to be in UTC already)
|
||||
/// </summary>
|
||||
/// <param name="DateToDisplay"></param>
|
||||
/// <returns></returns>
|
||||
public static string UniversalISO8661Format(DateTime DateToDisplay)
|
||||
{
|
||||
DateTime dtUTC=new DateTime(DateToDisplay.Ticks, DateTimeKind.Utc);
|
||||
DateTime dtUTC = new DateTime(DateToDisplay.Ticks, DateTimeKind.Utc);
|
||||
return dtUTC.ToString("o");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// returns passed in timespan to human readable format
|
||||
/// </summary>
|
||||
/// <param name="timeSpan"></param>
|
||||
/// <returns></returns>
|
||||
public static string FormatTimeSpan(TimeSpan timeSpan)
|
||||
{
|
||||
Func<Tuple<int, string>, string> tupleFormatter = t => $"{t.Item1} {t.Item2}{(t.Item1 == 1 ? string.Empty : "s")}";
|
||||
var components = new List<Tuple<int, string>>
|
||||
{
|
||||
Tuple.Create((int) timeSpan.TotalDays, "day"),
|
||||
Tuple.Create(timeSpan.Hours, "hour"),
|
||||
Tuple.Create(timeSpan.Minutes, "minute"),
|
||||
Tuple.Create(timeSpan.Seconds, "second"),
|
||||
};
|
||||
|
||||
components.RemoveAll(i => i.Item1 == 0);
|
||||
|
||||
string extra = "";
|
||||
|
||||
if (components.Count > 1)
|
||||
{
|
||||
var finalComponent = components[components.Count - 1];
|
||||
components.RemoveAt(components.Count - 1);
|
||||
extra = $" and {tupleFormatter(finalComponent)}";
|
||||
}
|
||||
|
||||
return $"{string.Join(", ", components.Select(tupleFormatter))}{extra}";
|
||||
}
|
||||
|
||||
|
||||
}//eoc
|
||||
|
||||
}//eons
|
||||
@@ -365,6 +365,7 @@ namespace AyaNova.Util
|
||||
await EraseTableAsync("aworkordertemplate", conn);
|
||||
//---
|
||||
|
||||
|
||||
await EraseTableAsync("afileattachment", conn);
|
||||
await EraseTableAsync("acustomerservicerequest", conn);
|
||||
await EraseTableAsync("awidget", conn);
|
||||
@@ -424,6 +425,9 @@ namespace AyaNova.Util
|
||||
await EraseTableAsync("aservicebank", conn);
|
||||
|
||||
await EraseTableAsync("aworkorderstatus", conn);
|
||||
await EraseTableAsync("aworkorderitemstatus", conn);
|
||||
await EraseTableAsync("aworkorderitempriority", conn);
|
||||
await EraseTableAsync("ataskgroup", conn);//items cascade
|
||||
|
||||
|
||||
//after cleanup
|
||||
|
||||
@@ -247,7 +247,7 @@ namespace AyaNova.Util
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
await LogStatusAsync(JobId, LogJob, log, $"Small level sample data seeded in {watch.ElapsedMilliseconds} ms");
|
||||
await LogStatusAsync(JobId, LogJob, log, "Small level sample data seeded in " + AyaNova.Util.DateUtil.FormatTimeSpan(watch.Elapsed));
|
||||
|
||||
#endregion gensmall
|
||||
}
|
||||
@@ -302,7 +302,7 @@ namespace AyaNova.Util
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
await LogStatusAsync(JobId, LogJob, log, $"MEDIUM level sample data seeded in {watch.ElapsedMilliseconds} ms");
|
||||
await LogStatusAsync(JobId, LogJob, log, "MEDIUM level sample data seeded in " + AyaNova.Util.DateUtil.FormatTimeSpan(watch.Elapsed));
|
||||
|
||||
#endregion genmedium
|
||||
}
|
||||
@@ -367,7 +367,7 @@ namespace AyaNova.Util
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
await LogStatusAsync(JobId, LogJob, log, $"LARGE level sample data seeded in {watch.ElapsedMilliseconds} ms");
|
||||
await LogStatusAsync(JobId, LogJob, log, "LARGE level sample data seeded in " + AyaNova.Util.DateUtil.FormatTimeSpan(watch.Elapsed));
|
||||
#endregion genlarge
|
||||
}
|
||||
break;
|
||||
@@ -428,12 +428,12 @@ namespace AyaNova.Util
|
||||
await SeedPartWarehouseAsync(log, 20);
|
||||
await SeedPartAsync(log, 500, 20);
|
||||
await SeedPartAssemblyAsync(log, 5);
|
||||
await SeedPurchaseOrderAsync(log, 200);
|
||||
await SeedPurchaseOrderAsync(log, 200);
|
||||
await SeedWorkOrderAsync(log, 200);
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
await LogStatusAsync(JobId, LogJob, log, $"HUGE level sample data seeded in {watch.ElapsedMilliseconds} ms");
|
||||
await LogStatusAsync(JobId, LogJob, log, "HUGE level sample data seeded in " + AyaNova.Util.DateUtil.FormatTimeSpan(watch.Elapsed));
|
||||
#endregion genhuge
|
||||
}
|
||||
break;
|
||||
@@ -2893,7 +2893,7 @@ namespace AyaNova.Util
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct);
|
||||
var NewObject = await biz.WorkOrderCreateAsync(o);
|
||||
var NewObject = await biz.WorkOrderCreateAsync(o, false);
|
||||
TotalSeededWorkOrders++;
|
||||
if (NewObject == null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user