This commit is contained in:
@@ -5196,7 +5196,7 @@ namespace AyaNova.Biz
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Process generation of pms to workorders
|
||||
//
|
||||
internal static async Task Generate(AyContext ct, ILogger log)
|
||||
internal static async Task GenerateAsync(AyContext ct, ILogger log)
|
||||
{
|
||||
#if (DEBUG)
|
||||
log.LogInformation("PMBiz - Generating");
|
||||
@@ -5216,7 +5216,28 @@ namespace AyaNova.Biz
|
||||
#if (DEBUG)
|
||||
log.LogInformation($"PMBiz - processing pm id {pmid}");
|
||||
#endif
|
||||
var p = await ct.PM.Where(x => x.Id == pmid).FirstOrDefaultAsync();
|
||||
var p = await ct.PM.AsSplitQuery()
|
||||
.Include(w => w.Items.OrderBy(item => item.Sequence))
|
||||
.ThenInclude(wi => wi.Expenses)
|
||||
.Include(w => w.Items)
|
||||
.ThenInclude(wi => wi.Labors)
|
||||
.Include(w => w.Items)
|
||||
.ThenInclude(wi => wi.Loans)
|
||||
.Include(w => w.Items)
|
||||
.ThenInclude(wi => wi.Parts)
|
||||
.Include(w => w.Items)
|
||||
.ThenInclude(wi => wi.ScheduledUsers)
|
||||
.Include(w => w.Items)
|
||||
.ThenInclude(wi => wi.Tasks.OrderBy(t => t.Sequence))
|
||||
.Include(w => w.Items)
|
||||
.ThenInclude(wi => wi.Travels)
|
||||
.Include(w => w.Items)
|
||||
.ThenInclude(wi => wi.Units)
|
||||
.Include(w => w.Items)
|
||||
.ThenInclude(wi => wi.OutsideServices)
|
||||
.SingleOrDefaultAsync(z => z.Id == pmid);
|
||||
|
||||
|
||||
if (p == null)
|
||||
{
|
||||
log.LogError($"PMBiz - PM was not fetchable when attempting to process PM id: {pmid}, deleted during processing?");
|
||||
@@ -5301,6 +5322,9 @@ namespace AyaNova.Biz
|
||||
try
|
||||
{
|
||||
await ct.SaveChangesAsync();
|
||||
#if (DEBUG)
|
||||
log.LogInformation($"PMBiz::GenerateAsync updated PM after successful generation {p.Serial}");
|
||||
#endif
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -5323,9 +5347,7 @@ namespace AyaNova.Biz
|
||||
|
||||
internal static async Task<bool> NewServiceWorkOrderFromPMAsync(PM p, AyContext ct, ILogger log)
|
||||
{
|
||||
|
||||
WorkOrder wo = new WorkOrder();
|
||||
|
||||
wo.Address = p.Address;
|
||||
wo.City = p.City;
|
||||
//o.CompleteByDate=??
|
||||
@@ -5520,6 +5542,9 @@ namespace AyaNova.Biz
|
||||
//todo: NOTIFY FAIL
|
||||
return false;
|
||||
}
|
||||
#if (DEBUG)
|
||||
log.LogInformation($"PMBiz::NewServiceWorkOrderFromPMAsync created new workorder {NewObject.Serial}");
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user