This commit is contained in:
2021-08-05 22:13:04 +00:00
parent 37a8c57ac6
commit 163d4a40a8
3 changed files with 222 additions and 290 deletions

View File

@@ -1554,7 +1554,7 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
//Log event //Log event
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.PMItemId.ToString(), ct);//Fix?? await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
@@ -1909,7 +1909,7 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
//Log event //Log event
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.PMItemId.ToString(), ct);//Fix?? await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
@@ -2297,7 +2297,7 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
//Log event //Log event
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.PMItemId.ToString(), ct);//Fix?? await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
@@ -2701,7 +2701,7 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
//Log event //Log event
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.PMItemId.ToString(), ct);//Fix?? await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
@@ -3046,7 +3046,7 @@ namespace AyaNova.Biz
return false; return false;
} }
//Log event //Log event
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.PMItemId.ToString(), ct);//Fix?? await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
@@ -3472,7 +3472,7 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
//Log event //Log event
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.PMItemId.ToString(), ct);//Fix?? await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
@@ -3743,7 +3743,7 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
//Log event //Log event
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.PMItemId.ToString(), ct);//Fix?? await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
@@ -4024,7 +4024,7 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
//Log event //Log event
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.PMItemId.ToString(), ct); await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
@@ -4408,7 +4408,7 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
//Log event //Log event
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.PMItemId.ToString(), ct);//Fix?? await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "pmitem:" + dbObject.PMItemId.ToString(), ct);//Fix??
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
if (parentTransaction == null) if (parentTransaction == null)
await transaction.CommitAsync(); await transaction.CommitAsync();

View File

@@ -993,7 +993,7 @@ namespace AyaNova.Biz
qoute.LastStatusId = newObject.QuoteStatusId; qoute.LastStatusId = newObject.QuoteStatusId;
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, AyaType.QuoteStatus, AyaEvent.Created), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, AyaType.QuoteStatus, AyaEvent.Created), ct);
await StateHandlePotentialNotificationEvent(AyaEvent.Created, newObject); //await StateHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
return newObject; return newObject;
} }
} }
@@ -1077,202 +1077,202 @@ namespace AyaNova.Biz
//////////////////////////////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////////////////////////////////
// NOTIFICATION PROCESSING // // NOTIFICATION PROCESSING
// // //
public async Task StateHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null) // public async Task StateHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
{ // {
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<QuoteBiz>(); // ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<QuoteBiz>();
if (ServerBootConfig.SEEDING) return; // if (ServerBootConfig.SEEDING) return;
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]"); // log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
bool isNew = currentObj == null; // bool isNew = currentObj == null;
//currently no quote state notifications but may well be in future so this saves changing a bunch of shit if necessary later // //currently no quote state notifications but may well be in future so this saves changing a bunch of shit if necessary later
await Task.CompletedTask; // await Task.CompletedTask;
// QuoteState oProposed = (QuoteState)proposedObj; // // QuoteState oProposed = (QuoteState)proposedObj;
// var WorkorderInfo = await ct.Quote.AsNoTracking().Where(x => x.Id == oProposed.QuoteId).Select(x => new { x.Serial, x.Tags, x.CustomerId }).FirstOrDefaultAsync(); // // var WorkorderInfo = await ct.Quote.AsNoTracking().Where(x => x.Id == oProposed.QuoteId).Select(x => new { x.Serial, x.Tags, x.CustomerId }).FirstOrDefaultAsync();
// QuoteStatus wos = await ct.QuoteStatus.AsNoTracking().FirstOrDefaultAsync(x => x.Id == oProposed.QuoteStatusId); // // QuoteStatus wos = await ct.QuoteStatus.AsNoTracking().FirstOrDefaultAsync(x => x.Id == oProposed.QuoteStatusId);
// //for notification purposes because has no name / tags field itself // // //for notification purposes because has no name / tags field itself
// oProposed.Name = WorkorderInfo.Serial.ToString(); // // oProposed.Name = WorkorderInfo.Serial.ToString();
// oProposed.Tags = WorkorderInfo.Tags; // // oProposed.Tags = WorkorderInfo.Tags;
// //STANDARD EVENTS FOR ALL OBJECTS // // //STANDARD EVENTS FOR ALL OBJECTS
// //NONE: state notifications are specific and not the same as for general objects so don't process standard events // // //NONE: state notifications are specific and not the same as for general objects so don't process standard events
// //SPECIFIC EVENTS FOR THIS OBJECT // // //SPECIFIC EVENTS FOR THIS OBJECT
// //WorkorderStatusChange = 4,//*Workorder object, any NEW status set. Conditions: specific status ID value only (no generic any status allowed), Workorder TAGS // // //WorkorderStatusChange = 4,//*Workorder object, any NEW status set. Conditions: specific status ID value only (no generic any status allowed), Workorder TAGS
// //WorkorderCompletedStatusOverdue = 15,//* Workorder object not set to a "Completed" flagged quote status type in selected time span from creation of workorderWorkorderSetToCompletedStatus // // //WorkorderCompletedStatusOverdue = 15,//* Workorder object not set to a "Completed" flagged quote status type in selected time span from creation of workorderWorkorderSetToCompletedStatus
// //WorkorderStatusAge = 24,//* Workorder STATUS unchanged for set time (stuck in state), conditional on: Duration (how long stuck), exact status selected IdValue, Tags. Advance notice can NOT be set // // //WorkorderStatusAge = 24,//* Workorder STATUS unchanged for set time (stuck in state), conditional on: Duration (how long stuck), exact status selected IdValue, Tags. Advance notice can NOT be set
// //NOTE: ID, state notifications are for the Workorder, not the state itself unlike other objects, so use the WO type and ID here for all notifications // // //NOTE: ID, state notifications are for the Workorder, not the state itself unlike other objects, so use the WO type and ID here for all notifications
// //## DELETED EVENTS // // //## DELETED EVENTS
// //A state cannot be deleted so nothing to handle that is required // // //A state cannot be deleted so nothing to handle that is required
// //a quote CAN be deleted and it will automatically remove all events for it so also no need to remove time delayed status events either if wo is deleted. // // //a quote CAN be deleted and it will automatically remove all events for it so also no need to remove time delayed status events either if wo is deleted.
// //so in essence there is nothing to be done regarding deleted events with states in a blanket way, however specific events below may remove them as appropriate // // //so in essence there is nothing to be done regarding deleted events with states in a blanket way, however specific events below may remove them as appropriate
// // await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, o.Id, NotifyEventType.WorkorderStatusChange); // // // await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, o.Id, NotifyEventType.WorkorderStatusChange);
// // await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, o.Id, NotifyEventType.WorkorderCompletedStatusOverdue); // // // await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, o.Id, NotifyEventType.WorkorderCompletedStatusOverdue);
// // await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, o.Id, NotifyEventType.WorkorderStatusAge); // // // await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, o.Id, NotifyEventType.WorkorderStatusAge);
// //## CREATED (this is the only possible notification CREATION ayaEvent type for a quote state as they are create only) // // //## CREATED (this is the only possible notification CREATION ayaEvent type for a quote state as they are create only)
// if (ayaEvent == AyaEvent.Created) // // if (ayaEvent == AyaEvent.Created)
// { // // {
// //# STATUS CHANGE (create new status) // // //# STATUS CHANGE (create new status)
// { // // {
// //Conditions: must match specific status id value and also tags below // // //Conditions: must match specific status id value and also tags below
// //delivery is immediate so no need to remove old ones of this kind // // //delivery is immediate so no need to remove old ones of this kind
// var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.WorkorderStatusChange && z.IdValue == oProposed.QuoteStatusId).ToListAsync(); // // var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.WorkorderStatusChange && z.IdValue == oProposed.QuoteStatusId).ToListAsync();
// foreach (var sub in subs) // // foreach (var sub in subs)
// { // // {
// //not for inactive users // // //not for inactive users
// if (!await UserBiz.UserIsActive(sub.UserId)) continue; // // if (!await UserBiz.UserIsActive(sub.UserId)) continue;
// //Tag match? (will be true if no sub tags so always safe to call this) // // //Tag match? (will be true if no sub tags so always safe to call this)
// if (NotifyEventHelper.ObjectHasAllSubscriptionTags(WorkorderInfo.Tags, sub.Tags)) // // if (NotifyEventHelper.ObjectHasAllSubscriptionTags(WorkorderInfo.Tags, sub.Tags))
// { // // {
// NotifyEvent n = new NotifyEvent() // // NotifyEvent n = new NotifyEvent()
// { // // {
// EventType = NotifyEventType.WorkorderStatusChange, // // EventType = NotifyEventType.WorkorderStatusChange,
// UserId = sub.UserId, // // UserId = sub.UserId,
// AyaType = AyaType.Quote, // // AyaType = AyaType.Quote,
// ObjectId = oProposed.QuoteId, // // ObjectId = oProposed.QuoteId,
// NotifySubscriptionId = sub.Id, // // NotifySubscriptionId = sub.Id,
// Name = $"{WorkorderInfo.Serial.ToString()} - {wos.Name}" // // Name = $"{WorkorderInfo.Serial.ToString()} - {wos.Name}"
// }; // // };
// await ct.NotifyEvent.AddAsync(n); // // await ct.NotifyEvent.AddAsync(n);
// log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]"); // // log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
// await ct.SaveChangesAsync(); // // await ct.SaveChangesAsync();
// } // // }
// } // // }
// }//quote status change event // // }//quote status change event
// //# STATUS AGE // // //# STATUS AGE
// { // // {
// //WorkorderStatusAge = 24,//* Workorder STATUS unchanged for set time (stuck in state), conditional on: Duration (how long stuck), exact status selected IdValue, Tags. Advance notice can NOT be set // // //WorkorderStatusAge = 24,//* Workorder STATUS unchanged for set time (stuck in state), conditional on: Duration (how long stuck), exact status selected IdValue, Tags. Advance notice can NOT be set
// //Always clear any old ones for this object as they are all irrelevant the moment the state has changed: // // //Always clear any old ones for this object as they are all irrelevant the moment the state has changed:
// await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, proposedObj.Id, NotifyEventType.WorkorderStatusAge); // // await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, proposedObj.Id, NotifyEventType.WorkorderStatusAge);
// var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.WorkorderStatusAge && z.IdValue == oProposed.QuoteStatusId).ToListAsync(); // // var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.WorkorderStatusAge && z.IdValue == oProposed.QuoteStatusId).ToListAsync();
// foreach (var sub in subs) // // foreach (var sub in subs)
// { // // {
// //not for inactive users // // //not for inactive users
// if (!await UserBiz.UserIsActive(sub.UserId)) continue; // // if (!await UserBiz.UserIsActive(sub.UserId)) continue;
// //Quote Tag match? (Not State, state has no tags, will be true if no sub tags so always safe to call this) // // //Quote Tag match? (Not State, state has no tags, will be true if no sub tags so always safe to call this)
// if (NotifyEventHelper.ObjectHasAllSubscriptionTags(WorkorderInfo.Tags, sub.Tags)) // // if (NotifyEventHelper.ObjectHasAllSubscriptionTags(WorkorderInfo.Tags, sub.Tags))
// { // // {
// NotifyEvent n = new NotifyEvent() // // NotifyEvent n = new NotifyEvent()
// { // // {
// EventType = NotifyEventType.WorkorderStatusAge, // // EventType = NotifyEventType.WorkorderStatusAge,
// UserId = sub.UserId, // // UserId = sub.UserId,
// AyaType = AyaType.Quote, // // AyaType = AyaType.Quote,
// ObjectId = oProposed.QuoteId, // // ObjectId = oProposed.QuoteId,
// NotifySubscriptionId = sub.Id, // // NotifySubscriptionId = sub.Id,
// Name = $"{WorkorderInfo.Serial.ToString()} - {wos.Name}" // // Name = $"{WorkorderInfo.Serial.ToString()} - {wos.Name}"
// }; // // };
// await ct.NotifyEvent.AddAsync(n); // // await ct.NotifyEvent.AddAsync(n);
// log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]"); // // log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
// await ct.SaveChangesAsync(); // // await ct.SaveChangesAsync();
// } // // }
// } // // }
// }//quote status change event // // }//quote status change event
// //# COMPLETE BY OVERDUE // // //# COMPLETE BY OVERDUE
// { // // {
// //NOTE: the initial notification is created by the Workorder Header notification as it's where this time delayed notification is first generated // // //NOTE: the initial notification is created by the Workorder Header notification as it's where this time delayed notification is first generated
// //the only job here in state notification is to remove any prior finish overdue notifications waiting if a new state is selected that is a completed state // // //the only job here in state notification is to remove any prior finish overdue notifications waiting if a new state is selected that is a completed state
// //NOTE ABOUT RE-OPEN DECISION ON HOW THIS WORKS: // // //NOTE ABOUT RE-OPEN DECISION ON HOW THIS WORKS:
// //what though if it's not a Completed status, then I guess don't remove it, but what if it *was* a Completed status and it's change to a non Completed? // // //what though if it's not a Completed status, then I guess don't remove it, but what if it *was* a Completed status and it's change to a non Completed?
// //that, in essence re-opens it so it's not Completed at that point. // // //that, in essence re-opens it so it's not Completed at that point.
// //My decision on this june 2021 is that a work order Completed status notification is satisifed the moment it's saved with a Completed status // // //My decision on this june 2021 is that a work order Completed status notification is satisifed the moment it's saved with a Completed status
// //and nothing afterwards restarts that process so if a person sets closed status then sets open status again no new Completed overdue notification will be generated // // //and nothing afterwards restarts that process so if a person sets closed status then sets open status again no new Completed overdue notification will be generated
// if (wos.Completed) // // if (wos.Completed)
// { // // {
// //Workorder was just set to a completed status so remove any notify events lurking to deliver for overdue // // //Workorder was just set to a completed status so remove any notify events lurking to deliver for overdue
// await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, oProposed.QuoteId, NotifyEventType.WorkorderCompletedStatusOverdue); // // await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, oProposed.QuoteId, NotifyEventType.WorkorderCompletedStatusOverdue);
// } // // }
// }//quote complete by overdue change event // // }//quote complete by overdue change event
// //# WorkorderCompleted - Customer AND User but customer only notifies if it's their quote // // //# WorkorderCompleted - Customer AND User but customer only notifies if it's their quote
// { // // {
// if (wos.Completed) // // if (wos.Completed)
// { // // {
// //look for potential subscribers // // //look for potential subscribers
// var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.WorkorderCompleted).ToListAsync(); // // var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.WorkorderCompleted).ToListAsync();
// foreach (var sub in subs) // // foreach (var sub in subs)
// { // // {
// //not for inactive users // // //not for inactive users
// if (!await UserBiz.UserIsActive(sub.UserId)) continue; // // if (!await UserBiz.UserIsActive(sub.UserId)) continue;
// //Customer User? // // //Customer User?
// var UserInfo = await ct.User.AsNoTracking().Where(x => x.Id == sub.UserId).Select(x => new { x.CustomerId, x.UserType, x.HeadOfficeId }).FirstOrDefaultAsync(); // // var UserInfo = await ct.User.AsNoTracking().Where(x => x.Id == sub.UserId).Select(x => new { x.CustomerId, x.UserType, x.HeadOfficeId }).FirstOrDefaultAsync();
// if (UserInfo.UserType == UserType.Customer || UserInfo.UserType == UserType.HeadOffice) // // if (UserInfo.UserType == UserType.Customer || UserInfo.UserType == UserType.HeadOffice)
// { // // {
// //CUSTOMER USER // // //CUSTOMER USER
// //Quick short circuit: if quote doesn't have a customer id then it's not going to match no matter what // // //Quick short circuit: if quote doesn't have a customer id then it's not going to match no matter what
// if (WorkorderInfo.CustomerId == 0) continue; // // if (WorkorderInfo.CustomerId == 0) continue;
// var customerUserRights = await UserBiz.CustomerUserEffectiveRightsAsync(sub.UserId); // // var customerUserRights = await UserBiz.CustomerUserEffectiveRightsAsync(sub.UserId);
// //Are they allowed right now to use this type of notification? // // //Are they allowed right now to use this type of notification?
// if (!customerUserRights.NotifyWOCompleted) continue; // // if (!customerUserRights.NotifyWOCompleted) continue;
// //is this their related work order? // // //is this their related work order?
// if (UserInfo.CustomerId != WorkorderInfo.CustomerId) // // if (UserInfo.CustomerId != WorkorderInfo.CustomerId)
// { // // {
// //not the same customer but might be a head office user and this is one of their customers so check for that // // //not the same customer but might be a head office user and this is one of their customers so check for that
// if (UserInfo.HeadOfficeId == null) continue;//can't match any head office so no need to go further // // if (UserInfo.HeadOfficeId == null) continue;//can't match any head office so no need to go further
// //see if quote customer's head office is the same id as the user's headofficeid (note that a customer user with the same head office as a *different* customer quote doesn't qualify) // // //see if quote customer's head office is the same id as the user's headofficeid (note that a customer user with the same head office as a *different* customer quote doesn't qualify)
// var CustomerInfo = await ct.Customer.AsNoTracking().Where(x => x.Id == WorkorderInfo.CustomerId).Select(x => new { x.HeadOfficeId, x.BillHeadOffice }).FirstOrDefaultAsync(); // // var CustomerInfo = await ct.Customer.AsNoTracking().Where(x => x.Id == WorkorderInfo.CustomerId).Select(x => new { x.HeadOfficeId, x.BillHeadOffice }).FirstOrDefaultAsync();
// if (!CustomerInfo.BillHeadOffice) continue;//can't possibly match so no need to go further // // if (!CustomerInfo.BillHeadOffice) continue;//can't possibly match so no need to go further
// if (UserInfo.HeadOfficeId != CustomerInfo.HeadOfficeId) continue; // // if (UserInfo.HeadOfficeId != CustomerInfo.HeadOfficeId) continue;
// } // // }
// } // // }
// else // // else
// { // // {
// //INSIDE USER // // //INSIDE USER
// //Tag match? (will be true if no sub tags so always safe to call this) // // //Tag match? (will be true if no sub tags so always safe to call this)
// //check early to avoid cost of fetching and calculating total if unnecessary // // //check early to avoid cost of fetching and calculating total if unnecessary
// if (!NotifyEventHelper.ObjectHasAllSubscriptionTags(WorkorderInfo.Tags, sub.Tags)) continue; // // if (!NotifyEventHelper.ObjectHasAllSubscriptionTags(WorkorderInfo.Tags, sub.Tags)) continue;
// } // // }
// //Ok, we're here so it must be ok to notify user // // //Ok, we're here so it must be ok to notify user
// NotifyEvent n = new NotifyEvent() // // NotifyEvent n = new NotifyEvent()
// { // // {
// EventType = NotifyEventType.WorkorderCompleted, // // EventType = NotifyEventType.WorkorderCompleted,
// UserId = sub.UserId, // // UserId = sub.UserId,
// AyaType = AyaType.Quote, // // AyaType = AyaType.Quote,
// ObjectId = oProposed.QuoteId, // // ObjectId = oProposed.QuoteId,
// NotifySubscriptionId = sub.Id, // // NotifySubscriptionId = sub.Id,
// Name = $"{WorkorderInfo.Serial.ToString()}" // // Name = $"{WorkorderInfo.Serial.ToString()}"
// }; // // };
// await ct.NotifyEvent.AddAsync(n); // // await ct.NotifyEvent.AddAsync(n);
// log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]"); // // log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
// await ct.SaveChangesAsync(); // // await ct.SaveChangesAsync();
// } // // }
// } // // }
// }//WorkorderCompleted // // }//WorkorderCompleted
// } // // }
}//end of process notifications // }//end of process notifications
#endregion work order STATE level #endregion work order STATE level
@@ -1311,8 +1311,8 @@ namespace AyaNova.Biz
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, AyaType.QuoteItem, AyaEvent.Created), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, AyaType.QuoteItem, AyaEvent.Created), ct);
await ItemSearchIndexAsync(newObject, true); await ItemSearchIndexAsync(newObject, true);
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
await ItemHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
await ItemPopulateVizFields(newObject, false); await ItemPopulateVizFields(newObject, false);
await ItemHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
return newObject; return newObject;
} }
} }
@@ -1398,8 +1398,8 @@ namespace AyaNova.Biz
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, putObject.Id, AyaType.QuoteItem, AyaEvent.Modified), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, putObject.Id, AyaType.QuoteItem, AyaEvent.Modified), ct);
await ItemSearchIndexAsync(putObject, false); await ItemSearchIndexAsync(putObject, false);
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags);
await ItemHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
await ItemPopulateVizFields(putObject, false); await ItemPopulateVizFields(putObject, false);
await ItemHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
return putObject; return putObject;
} }
@@ -1673,9 +1673,8 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct);
await ExpenseSearchIndexAsync(newObject, true); await ExpenseSearchIndexAsync(newObject, true);
await ExpenseHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
await ExpensePopulateVizFields(newObject); await ExpensePopulateVizFields(newObject);
await ExpenseHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
return newObject; return newObject;
} }
} }
@@ -1732,8 +1731,8 @@ namespace AyaNova.Biz
} }
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, putObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, putObject.Id, putObject.AyaType, AyaEvent.Modified), ct);
await ExpenseSearchIndexAsync(putObject, false); await ExpenseSearchIndexAsync(putObject, false);
await ExpenseHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
await ExpensePopulateVizFields(putObject); await ExpensePopulateVizFields(putObject);
await ExpenseHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
return putObject; return putObject;
} }
@@ -1753,7 +1752,7 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
//Log event //Log event
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix?? await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
@@ -2040,16 +2039,12 @@ namespace AyaNova.Biz
return null; return null;
else else
{ {
await ct.QuoteItemLabor.AddAsync(newObject); await ct.QuoteItemLabor.AddAsync(newObject);
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct);
await LaborSearchIndexAsync(newObject, true); await LaborSearchIndexAsync(newObject, true);
await LaborHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
await LaborPopulateVizFields(newObject); await LaborPopulateVizFields(newObject);
await LaborHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
return newObject; return newObject;
} }
} }
@@ -2106,9 +2101,8 @@ namespace AyaNova.Biz
} }
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, putObject.AyaType, AyaEvent.Modified), ct);
await LaborSearchIndexAsync(putObject, false); await LaborSearchIndexAsync(putObject, false);
await LaborHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
await LaborPopulateVizFields(putObject); await LaborPopulateVizFields(putObject);
await LaborHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
return putObject; return putObject;
} }
@@ -2128,7 +2122,7 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
//Log event //Log event
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix?? await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
@@ -2448,9 +2442,8 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct);
await LoanSearchIndexAsync(newObject, true); await LoanSearchIndexAsync(newObject, true);
await LoanHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
await LoanPopulateVizFields(newObject); await LoanPopulateVizFields(newObject);
await LoanHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
return newObject; return newObject;
} }
} }
@@ -2504,9 +2497,8 @@ namespace AyaNova.Biz
} }
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, putObject.AyaType, AyaEvent.Modified), ct);
await LoanSearchIndexAsync(putObject, false); await LoanSearchIndexAsync(putObject, false);
await LoanHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
await LoanPopulateVizFields(putObject); await LoanPopulateVizFields(putObject);
await LoanHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
return putObject; return putObject;
} }
@@ -2526,7 +2518,7 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
//Log event //Log event
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix?? await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
@@ -2854,15 +2846,12 @@ namespace AyaNova.Biz
return null; return null;
else else
{ {
// newObject.Tags = TagBiz.NormalizeTags(newObject.Tags);
await ct.QuoteItemOutsideService.AddAsync(newObject); await ct.QuoteItemOutsideService.AddAsync(newObject);
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct);
await OutsideServiceSearchIndexAsync(newObject, true); await OutsideServiceSearchIndexAsync(newObject, true);
await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
await OutsideServicePopulateVizFields(newObject); await OutsideServicePopulateVizFields(newObject);
await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
return newObject; return newObject;
} }
} }
@@ -2914,10 +2903,8 @@ namespace AyaNova.Biz
} }
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, putObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, putObject.Id, putObject.AyaType, AyaEvent.Modified), ct);
await OutsideServiceSearchIndexAsync(putObject, false); await OutsideServiceSearchIndexAsync(putObject, false);
await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
await OutsideServicePopulateVizFields(putObject); await OutsideServicePopulateVizFields(putObject);
await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
return putObject; return putObject;
} }
@@ -2937,10 +2924,9 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
//Log event //Log event
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix?? await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
if (parentTransaction == null) if (parentTransaction == null)
await transaction.CommitAsync(); await transaction.CommitAsync();
await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
@@ -3192,8 +3178,8 @@ namespace AyaNova.Biz
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct);
await PartSearchIndexAsync(newObject, true); await PartSearchIndexAsync(newObject, true);
await transaction.CommitAsync(); await transaction.CommitAsync();
await PartPopulateVizFields(newObject); await PartPopulateVizFields(newObject);
await PartHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
return newObject; return newObject;
} }
} }
@@ -3232,9 +3218,6 @@ namespace AyaNova.Biz
return null; return null;
} }
await PartValidateAsync(putObject, dbObject); await PartValidateAsync(putObject, dbObject);
if (HasErrors) return null; if (HasErrors) return null;
await PartBizActionsAsync(AyaEvent.Modified, putObject, dbObject, null); await PartBizActionsAsync(AyaEvent.Modified, putObject, dbObject, null);
@@ -3258,10 +3241,9 @@ namespace AyaNova.Biz
} }
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, putObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, putObject.Id, putObject.AyaType, AyaEvent.Modified), ct);
await PartSearchIndexAsync(putObject, false); await PartSearchIndexAsync(putObject, false);
await PartHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
await transaction.CommitAsync(); await transaction.CommitAsync();
await PartPopulateVizFields(putObject); await PartPopulateVizFields(putObject);
await PartHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
return putObject; return putObject;
} }
} }
@@ -3288,10 +3270,8 @@ namespace AyaNova.Biz
return false; return false;
} }
//Log event //Log event
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix?? await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
if (parentTransaction == null) if (parentTransaction == null)
await transaction.CommitAsync(); await transaction.CommitAsync();
await PartHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); await PartHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
@@ -3645,15 +3625,11 @@ namespace AyaNova.Biz
return null; return null;
else else
{ {
await ct.QuoteItemScheduledUser.AddAsync(newObject); await ct.QuoteItemScheduledUser.AddAsync(newObject);
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct);
await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
await ScheduledUserPopulateVizFields(newObject); await ScheduledUserPopulateVizFields(newObject);
await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
return newObject; return newObject;
} }
} }
@@ -3687,9 +3663,6 @@ namespace AyaNova.Biz
AddError(ApiErrorCode.CONCURRENCY_CONFLICT); AddError(ApiErrorCode.CONCURRENCY_CONFLICT);
return null; return null;
} }
await ScheduledUserValidateAsync(putObject, dbObject); await ScheduledUserValidateAsync(putObject, dbObject);
if (HasErrors) return null; if (HasErrors) return null;
ct.Replace(dbObject, putObject); ct.Replace(dbObject, putObject);
@@ -3706,10 +3679,8 @@ namespace AyaNova.Biz
return null; return null;
} }
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, putObject.AyaType, AyaEvent.Modified), ct);
await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
await ScheduledUserPopulateVizFields(putObject); await ScheduledUserPopulateVizFields(putObject);
await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
return putObject; return putObject;
} }
@@ -3729,10 +3700,8 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
//Log event //Log event
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix?? await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
if (parentTransaction == null) if (parentTransaction == null)
await transaction.CommitAsync(); await transaction.CommitAsync();
await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
@@ -3814,29 +3783,6 @@ namespace AyaNova.Biz
if (proposedObj.StartDate > proposedObj.StopDate) if (proposedObj.StartDate > proposedObj.StopDate)
AddError(ApiErrorCode.VALIDATION_STARTDATE_AFTER_ENDDATE, "StartDate"); AddError(ApiErrorCode.VALIDATION_STARTDATE_AFTER_ENDDATE, "StartDate");
//For now decision is to not check for sched conflicts on pm as it's not a work order yet anyway
// //Scheduling conflict?
// if (!AyaNova.Util.ServerGlobalBizSettings.Cache.AllowScheduleConflicts
// && proposedObj.UserId != null
// && proposedObj.StartDate != null
// && proposedObj.StopDate != null
// && (isNew
// || (proposedObj.StartDate != currentObj.StartDate)
// || (proposedObj.StopDate != currentObj.StopDate)
// || (proposedObj.UserId != currentObj.UserId)
// ))
// {
// if (await ct.QuoteItemScheduledUser.AnyAsync(x => x.Id != proposedObj.Id
// && x.UserId == proposedObj.UserId
// && x.StartDate <= proposedObj.StopDate
// && proposedObj.StartDate <= x.StopDate))
// {
// AddError(ApiErrorCode.VALIDATION_FAILED, "StartDate", await Translate("ScheduleConflict"));
// AddError(ApiErrorCode.VALIDATION_FAILED, "StopDate", await Translate("ScheduleConflict"));
// }
// }
//Any form customizations to validate? //Any form customizations to validate?
var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(z => z.FormKey == AyaType.QuoteItemScheduledUser.ToString()); var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(z => z.FormKey == AyaType.QuoteItemScheduledUser.ToString());
if (FormCustomization != null) if (FormCustomization != null)
@@ -3932,14 +3878,12 @@ namespace AyaNova.Biz
return null; return null;
else else
{ {
await ct.QuoteItemTask.AddAsync(newObject); await ct.QuoteItemTask.AddAsync(newObject);
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct);
await TaskSearchIndexAsync(newObject, true); await TaskSearchIndexAsync(newObject, true);
await TaskHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
await TaskPopulateVizFields(newObject); await TaskPopulateVizFields(newObject);
await TaskHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
return newObject; return newObject;
} }
} }
@@ -3971,8 +3915,6 @@ namespace AyaNova.Biz
AddError(ApiErrorCode.CONCURRENCY_CONFLICT); AddError(ApiErrorCode.CONCURRENCY_CONFLICT);
return null; return null;
} }
await TaskValidateAsync(putObject, dbObject); await TaskValidateAsync(putObject, dbObject);
if (HasErrors) return null; if (HasErrors) return null;
ct.Replace(dbObject, putObject); ct.Replace(dbObject, putObject);
@@ -3990,9 +3932,8 @@ namespace AyaNova.Biz
} }
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, putObject.AyaType, AyaEvent.Modified), ct);
await TaskSearchIndexAsync(dbObject, false); await TaskSearchIndexAsync(dbObject, false);
await TaskHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
await TaskPopulateVizFields(putObject); await TaskPopulateVizFields(putObject);
await TaskHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
return putObject; return putObject;
} }
@@ -4012,10 +3953,8 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
//Log event //Log event
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix?? await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
if (parentTransaction == null) if (parentTransaction == null)
await transaction.CommitAsync(); await transaction.CommitAsync();
await TaskHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); await TaskHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
@@ -4065,9 +4004,7 @@ namespace AyaNova.Biz
StringUtil.TrimTypeName(typeof(WorkorderItemTaskCompletionType).ToString()), StringUtil.TrimTypeName(typeof(WorkorderItemTaskCompletionType).ToString()),
UserTranslationId, UserTranslationId,
CurrentUserRoles); CurrentUserRoles);
o.StatusViz = taskCompletionTypeEnumList.Where(x => x.Id == (long)o.Status).Select(x => x.Name).First(); o.StatusViz = taskCompletionTypeEnumList.Where(x => x.Id == (long)o.Status).Select(x => x.Name).First();
} }
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
@@ -4092,7 +4029,6 @@ namespace AyaNova.Biz
return;//this is a completely disqualifying error return;//this is a completely disqualifying error
} }
//Check state if updatable right now //Check state if updatable right now
if (!isNew) if (!isNew)
{ {
@@ -4124,7 +4060,6 @@ namespace AyaNova.Biz
if (currentObj.Sequence != proposedObj.Sequence) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Sequence"); if (currentObj.Sequence != proposedObj.Sequence) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Sequence");
} }
if (string.IsNullOrWhiteSpace(proposedObj.Task)) if (string.IsNullOrWhiteSpace(proposedObj.Task))
AddError(ApiErrorCode.VALIDATION_REQUIRED, "Task"); AddError(ApiErrorCode.VALIDATION_REQUIRED, "Task");
@@ -4138,7 +4073,6 @@ namespace AyaNova.Biz
RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);//note: this is passed only to add errors RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);//note: this is passed only to add errors
//validate custom fields //validate custom fields
} }
} }
@@ -4226,8 +4160,8 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct);
await TravelSearchIndexAsync(newObject, true); await TravelSearchIndexAsync(newObject, true);
await TravelHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
await TravelPopulateVizFields(newObject); await TravelPopulateVizFields(newObject);
await TravelHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
return newObject; return newObject;
} }
} }
@@ -4304,7 +4238,7 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
//Log event //Log event
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.QuoteItemId.ToString(), ct); await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
@@ -4694,7 +4628,7 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
//Log event //Log event
await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix?? await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "quoteitem:" + dbObject.QuoteItemId.ToString(), ct);//Fix??
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct);
if (parentTransaction == null) if (parentTransaction == null)
await transaction.CommitAsync(); await transaction.CommitAsync();

View File

@@ -163,15 +163,13 @@ namespace AyaNova.Biz
await transaction.CommitAsync(); await transaction.CommitAsync();
if (populateViz) if (populateViz)
await WorkOrderPopulateVizFields(newObject, true, false); await WorkOrderPopulateVizFields(newObject, true, false);
await WorkOrderHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
if (newObject.GenCopyAttachmentsFrom != null && !newObject.GenCopyAttachmentsFrom.IsEmpty) if (newObject.GenCopyAttachmentsFrom != null && !newObject.GenCopyAttachmentsFrom.IsEmpty)
{ {
//copy attachment from existing object //copy attachment from existing object
await AttachmentBiz.DuplicateAttachments(newObject.GenCopyAttachmentsFrom, new AyaTypeId(AyaType.WorkOrder, newObject.Id), ct); await AttachmentBiz.DuplicateAttachments(newObject.GenCopyAttachmentsFrom, new AyaTypeId(AyaType.WorkOrder, newObject.Id), ct);
newObject.GenCopyAttachmentsFrom = null;//so it doesn't get returned newObject.GenCopyAttachmentsFrom = null;//so it doesn't get returned
} }
await WorkOrderHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
return newObject; return newObject;
} }
} }
@@ -4032,6 +4030,7 @@ namespace AyaNova.Biz
await transaction.CommitAsync(); await transaction.CommitAsync();
await PartPopulateVizFields(newObject); await PartPopulateVizFields(newObject);
await PartHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
return newObject; return newObject;
} }
} }
@@ -4097,10 +4096,9 @@ namespace AyaNova.Biz
} }
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, putObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, putObject.Id, putObject.AyaType, AyaEvent.Modified), ct);
await PartSearchIndexAsync(putObject, false); await PartSearchIndexAsync(putObject, false);
await PartHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
await transaction.CommitAsync(); await transaction.CommitAsync();
await PartPopulateVizFields(putObject); await PartPopulateVizFields(putObject);
await PartHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
return putObject; return putObject;
} }
} }