diff --git a/server/AyaNova/biz/PMBiz.cs b/server/AyaNova/biz/PMBiz.cs index c8643aa6..e0e56dcd 100644 --- a/server/AyaNova/biz/PMBiz.cs +++ b/server/AyaNova/biz/PMBiz.cs @@ -1554,7 +1554,7 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); //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); @@ -1909,7 +1909,7 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); //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); @@ -2297,7 +2297,7 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); //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); @@ -2701,7 +2701,7 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); //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); @@ -3046,7 +3046,7 @@ namespace AyaNova.Biz return false; } //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); @@ -3472,7 +3472,7 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); //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); @@ -3743,7 +3743,7 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); //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); @@ -4024,7 +4024,7 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); //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); @@ -4408,7 +4408,7 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); //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); if (parentTransaction == null) await transaction.CommitAsync(); diff --git a/server/AyaNova/biz/QuoteBiz.cs b/server/AyaNova/biz/QuoteBiz.cs index d6876557..d64878f8 100644 --- a/server/AyaNova/biz/QuoteBiz.cs +++ b/server/AyaNova/biz/QuoteBiz.cs @@ -850,7 +850,7 @@ namespace AyaNova.Biz //this may turn out to be the pattern for most biz object types but keeping it seperate allows for custom usage from time to time return await GetReportData(dataListSelectedRequest); } - + //////////////////////////////////////////////////////////////////////////////////////////////// //JOB / OPERATIONS @@ -993,7 +993,7 @@ namespace AyaNova.Biz qoute.LastStatusId = newObject.QuoteStatusId; await ct.SaveChangesAsync(); 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; } } @@ -1077,202 +1077,202 @@ namespace AyaNova.Biz - //////////////////////////////////////////////////////////////////////////////////////////////// - // NOTIFICATION PROCESSING - // - public async Task StateHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null) - { + // //////////////////////////////////////////////////////////////////////////////////////////////// + // // NOTIFICATION PROCESSING + // // + // public async Task StateHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null) + // { - ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger(); - if (ServerBootConfig.SEEDING) return; - log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]"); + // ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger(); + // if (ServerBootConfig.SEEDING) return; + // 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 - await Task.CompletedTask; - // QuoteState oProposed = (QuoteState)proposedObj; + // //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; + // // 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(); - // QuoteStatus wos = await ct.QuoteStatus.AsNoTracking().FirstOrDefaultAsync(x => x.Id == oProposed.QuoteStatusId); - // //for notification purposes because has no name / tags field itself - // oProposed.Name = WorkorderInfo.Serial.ToString(); - // oProposed.Tags = WorkorderInfo.Tags; + // // 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); + // // //for notification purposes because has no name / tags field itself + // // oProposed.Name = WorkorderInfo.Serial.ToString(); + // // oProposed.Tags = WorkorderInfo.Tags; - // //STANDARD EVENTS FOR ALL OBJECTS - // //NONE: state notifications are specific and not the same as for general objects so don't process standard events + // // //STANDARD EVENTS FOR ALL OBJECTS + // // //NONE: state notifications are specific and not the same as for general objects so don't process standard events - // //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 - // //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 + // // //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 + // // //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 - // //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 - // //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. - // //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 + // // //## DELETED EVENTS + // // //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. + // // //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.WorkorderCompletedStatusOverdue); - // // await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, o.Id, NotifyEventType.WorkorderStatusAge); + // // // 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.WorkorderStatusAge); - // //## CREATED (this is the only possible notification CREATION ayaEvent type for a quote state as they are create only) - // if (ayaEvent == AyaEvent.Created) - // { - // //# STATUS CHANGE (create new status) - // { - // //Conditions: must match specific status id value and also tags below - // //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(); - // foreach (var sub in subs) - // { - // //not for inactive users - // if (!await UserBiz.UserIsActive(sub.UserId)) continue; + // // //## CREATED (this is the only possible notification CREATION ayaEvent type for a quote state as they are create only) + // // if (ayaEvent == AyaEvent.Created) + // // { + // // //# STATUS CHANGE (create new status) + // // { + // // //Conditions: must match specific status id value and also tags below + // // //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(); + // // foreach (var sub in subs) + // // { + // // //not for inactive users + // // if (!await UserBiz.UserIsActive(sub.UserId)) continue; - // //Tag match? (will be true if no sub tags so always safe to call this) - // if (NotifyEventHelper.ObjectHasAllSubscriptionTags(WorkorderInfo.Tags, sub.Tags)) - // { - // NotifyEvent n = new NotifyEvent() - // { - // EventType = NotifyEventType.WorkorderStatusChange, - // UserId = sub.UserId, - // AyaType = AyaType.Quote, - // ObjectId = oProposed.QuoteId, - // NotifySubscriptionId = sub.Id, - // Name = $"{WorkorderInfo.Serial.ToString()} - {wos.Name}" - // }; - // await ct.NotifyEvent.AddAsync(n); - // log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]"); - // await ct.SaveChangesAsync(); - // } - // } - // }//quote status change event + // // //Tag match? (will be true if no sub tags so always safe to call this) + // // if (NotifyEventHelper.ObjectHasAllSubscriptionTags(WorkorderInfo.Tags, sub.Tags)) + // // { + // // NotifyEvent n = new NotifyEvent() + // // { + // // EventType = NotifyEventType.WorkorderStatusChange, + // // UserId = sub.UserId, + // // AyaType = AyaType.Quote, + // // ObjectId = oProposed.QuoteId, + // // NotifySubscriptionId = sub.Id, + // // Name = $"{WorkorderInfo.Serial.ToString()} - {wos.Name}" + // // }; + // // await ct.NotifyEvent.AddAsync(n); + // // log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]"); + // // await ct.SaveChangesAsync(); + // // } + // // } + // // }//quote status change event - // //# 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 - // //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); - // var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.WorkorderStatusAge && z.IdValue == oProposed.QuoteStatusId).ToListAsync(); - // foreach (var sub in subs) - // { - // //not for inactive users - // if (!await UserBiz.UserIsActive(sub.UserId)) continue; + // // //# 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 + // // //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); + // // var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.WorkorderStatusAge && z.IdValue == oProposed.QuoteStatusId).ToListAsync(); + // // foreach (var sub in subs) + // // { + // // //not for inactive users + // // 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) - // if (NotifyEventHelper.ObjectHasAllSubscriptionTags(WorkorderInfo.Tags, sub.Tags)) - // { - // NotifyEvent n = new NotifyEvent() - // { - // EventType = NotifyEventType.WorkorderStatusAge, - // UserId = sub.UserId, - // AyaType = AyaType.Quote, - // ObjectId = oProposed.QuoteId, - // NotifySubscriptionId = sub.Id, - // Name = $"{WorkorderInfo.Serial.ToString()} - {wos.Name}" - // }; - // await ct.NotifyEvent.AddAsync(n); - // log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]"); - // await ct.SaveChangesAsync(); - // } - // } - // }//quote status change event + // // //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)) + // // { + // // NotifyEvent n = new NotifyEvent() + // // { + // // EventType = NotifyEventType.WorkorderStatusAge, + // // UserId = sub.UserId, + // // AyaType = AyaType.Quote, + // // ObjectId = oProposed.QuoteId, + // // NotifySubscriptionId = sub.Id, + // // Name = $"{WorkorderInfo.Serial.ToString()} - {wos.Name}" + // // }; + // // await ct.NotifyEvent.AddAsync(n); + // // log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]"); + // // await ct.SaveChangesAsync(); + // // } + // // } + // // }//quote status change event - // //# 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 - // //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 + // // //# 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 + // // //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? - // //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 - // //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 + // // //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. + // // //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 - // if (wos.Completed) - // { - // //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); - // } - // }//quote complete by overdue change event + // // if (wos.Completed) + // // { + // // //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); + // // } + // // }//quote complete by overdue change event - // //# WorkorderCompleted - Customer AND User but customer only notifies if it's their quote - // { - // if (wos.Completed) - // { - // //look for potential subscribers - // var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.WorkorderCompleted).ToListAsync(); - // foreach (var sub in subs) - // { - // //not for inactive users - // if (!await UserBiz.UserIsActive(sub.UserId)) continue; + // // //# WorkorderCompleted - Customer AND User but customer only notifies if it's their quote + // // { + // // if (wos.Completed) + // // { + // // //look for potential subscribers + // // var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.WorkorderCompleted).ToListAsync(); + // // foreach (var sub in subs) + // // { + // // //not for inactive users + // // if (!await UserBiz.UserIsActive(sub.UserId)) continue; - // //Customer User? - // 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) - // { - // //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(); + // // if (UserInfo.UserType == UserType.Customer || UserInfo.UserType == UserType.HeadOffice) + // // { + // // //CUSTOMER USER - // //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; + // // //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; - // 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? - // if (!customerUserRights.NotifyWOCompleted) continue; + // // //Are they allowed right now to use this type of notification? + // // if (!customerUserRights.NotifyWOCompleted) continue; - // //is this their related work order? - // 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 - // if (UserInfo.HeadOfficeId == null) continue;//can't match any head office so no need to go further + // // //is this their related work order? + // // 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 + // // 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) - // 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 (UserInfo.HeadOfficeId != CustomerInfo.HeadOfficeId) continue; - // } - // } - // else - // { - // //INSIDE USER - // //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 - // if (!NotifyEventHelper.ObjectHasAllSubscriptionTags(WorkorderInfo.Tags, sub.Tags)) continue; - // } + // // //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(); + // // if (!CustomerInfo.BillHeadOffice) continue;//can't possibly match so no need to go further + // // if (UserInfo.HeadOfficeId != CustomerInfo.HeadOfficeId) continue; + // // } + // // } + // // else + // // { + // // //INSIDE USER + // // //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 + // // if (!NotifyEventHelper.ObjectHasAllSubscriptionTags(WorkorderInfo.Tags, sub.Tags)) continue; + // // } - // //Ok, we're here so it must be ok to notify user - // NotifyEvent n = new NotifyEvent() - // { - // EventType = NotifyEventType.WorkorderCompleted, - // UserId = sub.UserId, - // AyaType = AyaType.Quote, - // ObjectId = oProposed.QuoteId, - // NotifySubscriptionId = sub.Id, - // Name = $"{WorkorderInfo.Serial.ToString()}" - // }; - // await ct.NotifyEvent.AddAsync(n); - // log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]"); - // await ct.SaveChangesAsync(); - // } - // } - // }//WorkorderCompleted - // } + // // //Ok, we're here so it must be ok to notify user + // // NotifyEvent n = new NotifyEvent() + // // { + // // EventType = NotifyEventType.WorkorderCompleted, + // // UserId = sub.UserId, + // // AyaType = AyaType.Quote, + // // ObjectId = oProposed.QuoteId, + // // NotifySubscriptionId = sub.Id, + // // Name = $"{WorkorderInfo.Serial.ToString()}" + // // }; + // // await ct.NotifyEvent.AddAsync(n); + // // log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]"); + // // await ct.SaveChangesAsync(); + // // } + // // } + // // }//WorkorderCompleted + // // } - }//end of process notifications + // }//end of process notifications #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 ItemSearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await ItemHandlePotentialNotificationEvent(AyaEvent.Created, newObject); await ItemPopulateVizFields(newObject, false); + await ItemHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -1398,8 +1398,8 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, putObject.Id, AyaType.QuoteItem, AyaEvent.Modified), ct); await ItemSearchIndexAsync(putObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags); - await ItemHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); await ItemPopulateVizFields(putObject, false); + await ItemHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); return putObject; } @@ -1673,9 +1673,8 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await ExpenseSearchIndexAsync(newObject, true); - - await ExpenseHandlePotentialNotificationEvent(AyaEvent.Created, newObject); await ExpensePopulateVizFields(newObject); + await ExpenseHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -1732,8 +1731,8 @@ namespace AyaNova.Biz } await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, putObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await ExpenseSearchIndexAsync(putObject, false); - await ExpenseHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); await ExpensePopulateVizFields(putObject); + await ExpenseHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); return putObject; } @@ -1753,10 +1752,10 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); //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); - - + + if (parentTransaction == null) await transaction.CommitAsync(); await ExpenseHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); @@ -2039,17 +2038,13 @@ namespace AyaNova.Biz if (HasErrors) return null; else - { - - + { await ct.QuoteItemLabor.AddAsync(newObject); await ct.SaveChangesAsync(); - await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await LaborSearchIndexAsync(newObject, true); - - await LaborHandlePotentialNotificationEvent(AyaEvent.Created, newObject); await LaborPopulateVizFields(newObject); + await LaborHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -2106,9 +2101,8 @@ namespace AyaNova.Biz } await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await LaborSearchIndexAsync(putObject, false); - - await LaborHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); await LaborPopulateVizFields(putObject); + await LaborHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); return putObject; } @@ -2128,10 +2122,10 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); //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); - - + + if (parentTransaction == null) await transaction.CommitAsync(); await LaborHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); @@ -2357,7 +2351,7 @@ namespace AyaNova.Biz RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);//note: this is passed only to add errors //validate custom fields - + } } @@ -2448,9 +2442,8 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await LoanSearchIndexAsync(newObject, true); - - await LoanHandlePotentialNotificationEvent(AyaEvent.Created, newObject); await LoanPopulateVizFields(newObject); + await LoanHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -2504,9 +2497,8 @@ namespace AyaNova.Biz } await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await LoanSearchIndexAsync(putObject, false); - - await LoanHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); await LoanPopulateVizFields(putObject); + await LoanHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); return putObject; } @@ -2526,10 +2518,10 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); //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); - - + + if (parentTransaction == null) await transaction.CommitAsync(); await LoanHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); @@ -2761,7 +2753,7 @@ namespace AyaNova.Biz RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);//note: this is passed only to add errors //validate custom fields - + } } @@ -2854,15 +2846,12 @@ namespace AyaNova.Biz return null; else { - // newObject.Tags = TagBiz.NormalizeTags(newObject.Tags); - await ct.QuoteItemOutsideService.AddAsync(newObject); await ct.SaveChangesAsync(); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await OutsideServiceSearchIndexAsync(newObject, true); - - await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Created, newObject); await OutsideServicePopulateVizFields(newObject); + await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -2914,10 +2903,8 @@ namespace AyaNova.Biz } await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, putObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await OutsideServiceSearchIndexAsync(putObject, false); - - - await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); await OutsideServicePopulateVizFields(putObject); + await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); return putObject; } @@ -2937,10 +2924,9 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); //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); - - + if (parentTransaction == null) await transaction.CommitAsync(); await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); @@ -3087,7 +3073,7 @@ namespace AyaNova.Biz RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);//note: this is passed only to add errors //validate custom fields - + } } @@ -3180,8 +3166,8 @@ namespace AyaNova.Biz else { await PartBizActionsAsync(AyaEvent.Created, newObject, null, null); - - + + await ct.QuoteItemPart.AddAsync(newObject); await ct.SaveChangesAsync(); if (HasErrors) @@ -3192,8 +3178,8 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await PartSearchIndexAsync(newObject, true); await transaction.CommitAsync(); - await PartPopulateVizFields(newObject); + await PartHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -3232,9 +3218,6 @@ namespace AyaNova.Biz return null; } - - - await PartValidateAsync(putObject, dbObject); if (HasErrors) return 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 PartSearchIndexAsync(putObject, false); - - await PartHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); await transaction.CommitAsync(); await PartPopulateVizFields(putObject); + await PartHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); return putObject; } } @@ -3288,10 +3270,8 @@ namespace AyaNova.Biz return false; } //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); - - if (parentTransaction == null) await transaction.CommitAsync(); await PartHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); @@ -3557,7 +3537,7 @@ namespace AyaNova.Biz RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);//note: this is passed only to add errors //validate custom fields - + } } @@ -3645,15 +3625,11 @@ namespace AyaNova.Biz return null; else { - - await ct.QuoteItemScheduledUser.AddAsync(newObject); await ct.SaveChangesAsync(); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); - - - await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Created, newObject); await ScheduledUserPopulateVizFields(newObject); + await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -3687,9 +3663,6 @@ namespace AyaNova.Biz AddError(ApiErrorCode.CONCURRENCY_CONFLICT); return null; } - - - await ScheduledUserValidateAsync(putObject, dbObject); if (HasErrors) return null; ct.Replace(dbObject, putObject); @@ -3706,10 +3679,8 @@ namespace AyaNova.Biz return null; } await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, putObject.AyaType, AyaEvent.Modified), ct); - - - await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); await ScheduledUserPopulateVizFields(putObject); + await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); return putObject; } @@ -3729,10 +3700,8 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); //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); - - if (parentTransaction == null) await transaction.CommitAsync(); await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); @@ -3814,29 +3783,6 @@ namespace AyaNova.Biz if (proposedObj.StartDate > proposedObj.StopDate) 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? var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(z => z.FormKey == AyaType.QuoteItemScheduledUser.ToString()); if (FormCustomization != null) @@ -3847,7 +3793,7 @@ namespace AyaNova.Biz RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);//note: this is passed only to add errors //validate custom fields - + } } @@ -3931,15 +3877,13 @@ namespace AyaNova.Biz if (HasErrors) return null; else - { - + { await ct.QuoteItemTask.AddAsync(newObject); await ct.SaveChangesAsync(); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await TaskSearchIndexAsync(newObject, true); - - await TaskHandlePotentialNotificationEvent(AyaEvent.Created, newObject); await TaskPopulateVizFields(newObject); + await TaskHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -3971,8 +3915,6 @@ namespace AyaNova.Biz AddError(ApiErrorCode.CONCURRENCY_CONFLICT); return null; } - - await TaskValidateAsync(putObject, dbObject); if (HasErrors) return null; 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 TaskSearchIndexAsync(dbObject, false); - - await TaskHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); await TaskPopulateVizFields(putObject); + await TaskHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); return putObject; } @@ -4012,10 +3953,8 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); //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); - - if (parentTransaction == null) await transaction.CommitAsync(); await TaskHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); @@ -4065,9 +4004,7 @@ namespace AyaNova.Biz StringUtil.TrimTypeName(typeof(WorkorderItemTaskCompletionType).ToString()), UserTranslationId, CurrentUserRoles); - 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 } - //Check state if updatable right now if (!isNew) { @@ -4124,7 +4060,6 @@ namespace AyaNova.Biz if (currentObj.Sequence != proposedObj.Sequence) AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "Sequence"); } - if (string.IsNullOrWhiteSpace(proposedObj.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 //validate custom fields - } } @@ -4226,8 +4160,8 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await TravelSearchIndexAsync(newObject, true); - await TravelHandlePotentialNotificationEvent(AyaEvent.Created, newObject); await TravelPopulateVizFields(newObject); + await TravelHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -4282,7 +4216,7 @@ namespace AyaNova.Biz } await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await TravelSearchIndexAsync(putObject, false); - + await TravelHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); await TravelPopulateVizFields(putObject); return putObject; @@ -4304,10 +4238,10 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); //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); - - + + if (parentTransaction == null) await transaction.CommitAsync(); await TravelHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); @@ -4518,7 +4452,7 @@ namespace AyaNova.Biz RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);//note: this is passed only to add errors //validate custom fields - + } } @@ -4605,7 +4539,7 @@ namespace AyaNova.Biz if (HasErrors) return null; else - { + { newObject.Tags = TagBiz.NormalizeTags(newObject.Tags); newObject.CustomFields = JsonUtil.CompactJson(newObject.CustomFields); await ct.QuoteItemUnit.AddAsync(newObject); @@ -4694,7 +4628,7 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); //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); if (parentTransaction == null) await transaction.CommitAsync(); @@ -4774,7 +4708,7 @@ namespace AyaNova.Biz { //skip validation if seeding // if (ServerBootConfig.SEEDING) return; - + //run validation and biz rules bool isNew = currentObj == null; diff --git a/server/AyaNova/biz/WorkOrderBiz.cs b/server/AyaNova/biz/WorkOrderBiz.cs index 3884a428..d8cd1312 100644 --- a/server/AyaNova/biz/WorkOrderBiz.cs +++ b/server/AyaNova/biz/WorkOrderBiz.cs @@ -163,15 +163,13 @@ namespace AyaNova.Biz await transaction.CommitAsync(); if (populateViz) await WorkOrderPopulateVizFields(newObject, true, false); - - await WorkOrderHandlePotentialNotificationEvent(AyaEvent.Created, newObject); - if (newObject.GenCopyAttachmentsFrom != null && !newObject.GenCopyAttachmentsFrom.IsEmpty) { //copy attachment from existing object await AttachmentBiz.DuplicateAttachments(newObject.GenCopyAttachmentsFrom, new AyaTypeId(AyaType.WorkOrder, newObject.Id), ct); newObject.GenCopyAttachmentsFrom = null;//so it doesn't get returned } + await WorkOrderHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -4032,6 +4030,7 @@ namespace AyaNova.Biz await transaction.CommitAsync(); await PartPopulateVizFields(newObject); + await PartHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -4097,10 +4096,9 @@ namespace AyaNova.Biz } await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, putObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await PartSearchIndexAsync(putObject, false); - - await PartHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); await transaction.CommitAsync(); await PartPopulateVizFields(putObject); + await PartHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); return putObject; } }