diff --git a/server/AyaNova/ControllerHelpers/ApiCustomExceptionFilter.cs b/server/AyaNova/ControllerHelpers/ApiCustomExceptionFilter.cs index d69b0dbb..51399c33 100644 --- a/server/AyaNova/ControllerHelpers/ApiCustomExceptionFilter.cs +++ b/server/AyaNova/ControllerHelpers/ApiCustomExceptionFilter.cs @@ -81,7 +81,7 @@ namespace AyaNova.Api.ControllerHelpers log.LogError(context.Exception, "Error"); //Notify ops notification issue - NotifyEventProcessor.AddOpsProblemEvent("Server API internal error, see log for more details", context.Exception).Forget();//.Wait(); + NotifyEventHelper.AddOpsProblemEvent("Server API internal error, see log for more details", context.Exception).Forget();//.Wait(); HttpResponse response = context.HttpContext.Response; response.StatusCode = (int)status; diff --git a/server/AyaNova/Controllers/AttachmentController.cs b/server/AyaNova/Controllers/AttachmentController.cs index ed7ff9b0..cd3a01bc 100644 --- a/server/AyaNova/Controllers/AttachmentController.cs +++ b/server/AyaNova/Controllers/AttachmentController.cs @@ -552,7 +552,7 @@ namespace AyaNova.Api.Controllers var errText = $"Physical file {dbObject.StoredFileName} not found despite attachment record, this file is missing"; log.LogError(errText); - await NotifyEventProcessor.AddOpsProblemEvent($"File attachment issue: {errText}"); + await NotifyEventHelper.AddOpsProblemEvent($"File attachment issue: {errText}"); return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND, null, errText)); } diff --git a/server/AyaNova/Controllers/NotifyController.cs b/server/AyaNova/Controllers/NotifyController.cs index baa96f33..e4b115bf 100644 --- a/server/AyaNova/Controllers/NotifyController.cs +++ b/server/AyaNova/Controllers/NotifyController.cs @@ -190,7 +190,7 @@ namespace AyaNova.Api.Controllers foreach (long l in notifyDirectMessage.Users) { if (l != 0) - await NotifyEventProcessor.AddGeneralNotifyEvent( + await NotifyEventHelper.AddGeneralNotifyEvent( NotifyEventType.GeneralNotification, notifyDirectMessage.Message, UserNameFromContext.Name(HttpContext.Items), null, l ); } diff --git a/server/AyaNova/biz/AttachmentBiz.cs b/server/AyaNova/biz/AttachmentBiz.cs index d312470e..88a5b458 100644 --- a/server/AyaNova/biz/AttachmentBiz.cs +++ b/server/AyaNova/biz/AttachmentBiz.cs @@ -191,7 +191,7 @@ namespace AyaNova.Biz log.LogDebug(msg); await JobsBiz.LogJobAsync(job.GId, msg); - await NotifyEventProcessor.AddOpsProblemEvent($"Attachments issue:{msg}"); + await NotifyEventHelper.AddOpsProblemEvent($"Attachments issue:{msg}"); var outList = ForeignFilesNotLikelyAttachmentsFoundInAttachmentsFolder.Take(25).ToList(); foreach (string s in outList) { diff --git a/server/AyaNova/biz/ContractBiz.cs b/server/AyaNova/biz/ContractBiz.cs index 8e9a2df4..2ca262b9 100644 --- a/server/AyaNova/biz/ContractBiz.cs +++ b/server/AyaNova/biz/ContractBiz.cs @@ -49,7 +49,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -83,7 +83,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } @@ -132,7 +132,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct); await SearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -164,7 +164,7 @@ namespace AyaNova.Biz await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); await transaction.CommitAsync(); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { diff --git a/server/AyaNova/biz/CustomerBiz.cs b/server/AyaNova/biz/CustomerBiz.cs index 03bc85d5..08182686 100644 --- a/server/AyaNova/biz/CustomerBiz.cs +++ b/server/AyaNova/biz/CustomerBiz.cs @@ -54,7 +54,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -88,7 +88,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } @@ -137,7 +137,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct); await SearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -200,7 +200,7 @@ namespace AyaNova.Biz await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); await transaction.CommitAsync(); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { diff --git a/server/AyaNova/biz/HeadOfficeBiz.cs b/server/AyaNova/biz/HeadOfficeBiz.cs index 6dd77a36..d76aece3 100644 --- a/server/AyaNova/biz/HeadOfficeBiz.cs +++ b/server/AyaNova/biz/HeadOfficeBiz.cs @@ -54,7 +54,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -88,7 +88,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } @@ -137,7 +137,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct); await SearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -185,7 +185,7 @@ namespace AyaNova.Biz await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); await transaction.CommitAsync(); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { diff --git a/server/AyaNova/biz/INotifiableObject.cs b/server/AyaNova/biz/INotifiableObject.cs new file mode 100644 index 00000000..34577a86 --- /dev/null +++ b/server/AyaNova/biz/INotifiableObject.cs @@ -0,0 +1,12 @@ +using System.Threading.Tasks; +using AyaNova.Models; +namespace AyaNova.Biz +{ + /// + /// Interface for biz objects that support notification + /// + internal interface INotifiableObject + { + Task HandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel newObject, ICoreBizObjectModel originalObject = null); + } +} \ No newline at end of file diff --git a/server/AyaNova/biz/ISearchAbleObject.cs b/server/AyaNova/biz/ISearchAbleObject.cs index 5ea94ef0..3bde15cd 100644 --- a/server/AyaNova/biz/ISearchAbleObject.cs +++ b/server/AyaNova/biz/ISearchAbleObject.cs @@ -1,4 +1,3 @@ -using AyaNova.Models; using System.Threading.Tasks; namespace AyaNova.Biz { diff --git a/server/AyaNova/biz/JobsBiz.cs b/server/AyaNova/biz/JobsBiz.cs index 020568ea..bdabee3a 100644 --- a/server/AyaNova/biz/JobsBiz.cs +++ b/server/AyaNova/biz/JobsBiz.cs @@ -267,7 +267,7 @@ namespace AyaNova.Biz { var msg = "Server::ProcessJobsAsync unexpected error during processing"; log.LogError(ex, msg); - await NotifyEventProcessor.AddOpsProblemEvent(msg, ex); + await NotifyEventHelper.AddOpsProblemEvent(msg, ex); } finally { diff --git a/server/AyaNova/biz/LoanUnitBiz.cs b/server/AyaNova/biz/LoanUnitBiz.cs index af9621aa..d7105a64 100644 --- a/server/AyaNova/biz/LoanUnitBiz.cs +++ b/server/AyaNova/biz/LoanUnitBiz.cs @@ -49,7 +49,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -83,7 +83,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } @@ -132,7 +132,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct); await SearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -164,7 +164,7 @@ namespace AyaNova.Biz await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); await transaction.CommitAsync(); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { diff --git a/server/AyaNova/biz/MemoBiz.cs b/server/AyaNova/biz/MemoBiz.cs index b496eb8c..fbf01f8a 100644 --- a/server/AyaNova/biz/MemoBiz.cs +++ b/server/AyaNova/biz/MemoBiz.cs @@ -55,7 +55,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -153,7 +153,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct); await SearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -186,7 +186,7 @@ namespace AyaNova.Biz await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); await transaction.CommitAsync(); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { diff --git a/server/AyaNova/biz/NotifyEventProcessor.cs b/server/AyaNova/biz/NotifyEventHelper.cs similarity index 85% rename from server/AyaNova/biz/NotifyEventProcessor.cs rename to server/AyaNova/biz/NotifyEventHelper.cs index f2c91669..bcf9b052 100644 --- a/server/AyaNova/biz/NotifyEventProcessor.cs +++ b/server/AyaNova/biz/NotifyEventHelper.cs @@ -14,7 +14,7 @@ using AyaNova.Models; namespace AyaNova.Biz { - internal static class NotifyEventProcessor + internal static class NotifyEventHelper { private static ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("NotifyEventProcessor"); @@ -124,17 +124,17 @@ namespace AyaNova.Biz var defaultsub = await ct.NotifySubscription.FirstOrDefaultAsync(z => z.EventType == NotifyEventType.GeneralNotification && z.UserId == userId && z.DeliveryMethod == NotifyDeliveryMethod.App); if (defaultsub == null) { - //NOTE: agevalue and advanced notice settings here will ensure that direct in app notifications with a future delivery date set in their - //notifyevent.eventdate will deliver on that date and not immediately to support all the things that are direct built in notifications + //NOTE: agevalue and advanced notice settings here will ensure that direct in app notifications with a future delivery date ("deadman" switch deliveries) set in their + //notifyevent.eventdate will deliver on that date and not immediately to support all the things that are direct built in notifications for future dates //such as for an overdue Review which doesn't have or need it's own notifyeventtype and subscription independently - defaultsub = new NotifySubscription() - { - UserId = userId, - EventType = NotifyEventType.GeneralNotification, - DeliveryMethod = NotifyDeliveryMethod.App, - AgeValue = new TimeSpan(0, 0, 1), - AdvanceNotice = new TimeSpan(0, 0, 1) - }; + defaultsub = new NotifySubscription() + { + UserId = userId, + EventType = NotifyEventType.GeneralNotification, + DeliveryMethod = NotifyDeliveryMethod.App, + AgeValue = new TimeSpan(0, 0, 1), + AdvanceNotice = new TimeSpan(0, 0, 1) + }; await ct.NotifySubscription.AddAsync(defaultsub); await ct.SaveChangesAsync(); } @@ -183,16 +183,16 @@ namespace AyaNova.Biz //set a deadman automatic internal notification if goes past due var r = (Review)newObject; - var userNotifySub = await EnsureDefaultInAppUserNotificationSubscriptionExists(r.UserId, ct); - NotifySubscription supervisorNotifySub = null; - if (r.UserId != r.AssignedByUserId) - { - supervisorNotifySub = await EnsureDefaultInAppUserNotificationSubscriptionExists(r.AssignedByUserId, ct); - } - - //it not completed yet and not overdue already (which could indicate an import or something) + //if not completed yet and not overdue already (which could indicate an import or something) if (r.CompletedDate == null && r.DueDate > DateTime.UtcNow) { + var userNotifySub = await EnsureDefaultInAppUserNotificationSubscriptionExists(r.UserId, ct); + NotifySubscription supervisorNotifySub = null; + if (r.UserId != r.AssignedByUserId) + { + supervisorNotifySub = await EnsureDefaultInAppUserNotificationSubscriptionExists(r.AssignedByUserId, ct); + } + { NotifyEvent n = new NotifyEvent() { @@ -202,7 +202,7 @@ namespace AyaNova.Biz AyaType = AyaType.Review, NotifySubscriptionId = userNotifySub.Id, Name = "LT:ReviewOverDue - " + newObject.Name, - EventDate = r.DueDate.AddMinutes(1) + EventDate = r.DueDate }; await ct.NotifyEvent.AddAsync(n); log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]"); @@ -218,7 +218,7 @@ namespace AyaNova.Biz AyaType = AyaType.Review, NotifySubscriptionId = supervisorNotifySub.Id, Name = "LT:ReviewOverDue - " + newObject.Name, - EventDate = r.DueDate.AddMinutes(1) + EventDate = r.DueDate }; await ct.NotifyEvent.AddAsync(n); log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]"); @@ -353,7 +353,7 @@ namespace AyaNova.Biz break; case AyaEvent.Modified: #region Modified processing - //######## NOTE: Any that don't deliver right away should be removed before re-inserting + //######## NOTE: be sure to remove any that are being replaced potentially //------------------------------ // AyaType Specific modified related subscriptions // @@ -361,50 +361,53 @@ namespace AyaNova.Biz { case AyaType.Review: { - //set a deadman automatic internal notification if goes past due - var r = (Review)newObject; + // //Remove prior + // await ClearPriorEventsForObject(ct, newObject.AyaType, newObject.Id, NotifyEventType.GeneralNotification);//assumes only general event for this object type is overdue here - var userNotifySub = await EnsureDefaultInAppUserNotificationSubscriptionExists(r.UserId, ct); - NotifySubscription supervisorNotifySub = null; - if (r.UserId != r.AssignedByUserId) - { - supervisorNotifySub = await EnsureDefaultInAppUserNotificationSubscriptionExists(r.AssignedByUserId, ct); - } + // //set a deadman automatic internal notification if goes past due + // var r = (Review)newObject; - //it not completed yet and not overdue already (which could indicate an import or something) - if (r.CompletedDate == null && r.DueDate > DateTime.UtcNow) - { - { - NotifyEvent n = new NotifyEvent() - { - EventType = NotifyEventType.GeneralNotification, - UserId = r.UserId, - ObjectId = newObject.Id, - AyaType = AyaType.Review, - NotifySubscriptionId = userNotifySub.Id, - Name = "LT:ReviewOverDue - " + newObject.Name, - EventDate = r.DueDate.AddMinutes(1) - }; - await ct.NotifyEvent.AddAsync(n); - log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]"); - } + // //it not completed yet and not overdue already (which could indicate an import or something) + // if (r.CompletedDate == null && r.DueDate > DateTime.UtcNow) + // { + // var userNotifySub = await EnsureDefaultInAppUserNotificationSubscriptionExists(r.UserId, ct); + // NotifySubscription supervisorNotifySub = null; + // if (r.UserId != r.AssignedByUserId) + // { + // supervisorNotifySub = await EnsureDefaultInAppUserNotificationSubscriptionExists(r.AssignedByUserId, ct); + // } - if (supervisorNotifySub != null) - { - NotifyEvent n = new NotifyEvent() - { - EventType = NotifyEventType.GeneralNotification, - UserId = r.AssignedByUserId, - ObjectId = newObject.Id, - AyaType = AyaType.Review, - NotifySubscriptionId = supervisorNotifySub.Id, - Name = "LT:ReviewOverDue - " + newObject.Name, - EventDate = r.DueDate.AddMinutes(1) - }; - await ct.NotifyEvent.AddAsync(n); - log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]"); - } - } + // { + // NotifyEvent n = new NotifyEvent() + // { + // EventType = NotifyEventType.GeneralNotification, + // UserId = r.UserId, + // ObjectId = newObject.Id, + // AyaType = AyaType.Review, + // NotifySubscriptionId = userNotifySub.Id, + // Name = "LT:ReviewOverDue - " + newObject.Name, + // EventDate = r.DueDate + // }; + // await ct.NotifyEvent.AddAsync(n); + // log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]"); + // } + + // if (supervisorNotifySub != null) + // { + // NotifyEvent n = new NotifyEvent() + // { + // EventType = NotifyEventType.GeneralNotification, + // UserId = r.AssignedByUserId, + // ObjectId = newObject.Id, + // AyaType = AyaType.Review, + // NotifySubscriptionId = supervisorNotifySub.Id, + // Name = "LT:ReviewOverDue - " + newObject.Name, + // EventDate = r.DueDate + // }; + // await ct.NotifyEvent.AddAsync(n); + // log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]"); + // } + // } } break; @@ -564,16 +567,9 @@ namespace AyaNova.Biz //------------------------------ // Delete any NotifyEvent records for this exact object - // It's gone and shouldn't have any events left for it - // NOTE: this is expected to cover all created / modified events above in terms of reversing them if they're still around for whatever reason - { - var deleteList = await ct.NotifyEvent.Where(z => z.ObjectId == newObject.Id && z.AyaType == newObject.AyaType).ToListAsync(); - if (deleteList.Count > 0) - { - ct.NotifyEvent.RemoveRange(deleteList); - SaveContext = true; - } - } + // It's gone and shouldn't have any events left for it + await ClearPriorEventsForObject(ct, newObject.AyaType, newObject.Id); + //------------------------------------------ //ObjectDeleted notification @@ -629,9 +625,31 @@ namespace AyaNova.Biz }//eom + ////////////////////////////////// + // CLEAN OUT OLD EVENTS + // + // + public static async Task ClearPriorEventsForObject(AyContext ct, AyaType ayaType, long objectId, NotifyEventType eventType) + { + var eventsToDelete = await ct.NotifyEvent.Where(z => z.AyaType == ayaType && z.ObjectId == objectId && z.EventType == eventType).ToListAsync(); + if (eventsToDelete.Count == 0) return; + ct.NotifyEvent.RemoveRange(eventsToDelete); + await ct.SaveChangesAsync(); + } + public static async Task ClearPriorEventsForObject(AyContext ct, AyaType ayaType, long objectId) + { + var eventsToDelete = await ct.NotifyEvent.Where(z => z.AyaType == ayaType && z.ObjectId == objectId).ToListAsync(); + if (eventsToDelete.Count == 0) return; + ct.NotifyEvent.RemoveRange(eventsToDelete); + await ct.SaveChangesAsync(); + } - private static bool TagsMatch(List objectTags, List subTags) + ////////////////////////////////// + // COMPARE TAGS COLLECTION + // + // + public static bool TagsMatch(List objectTags, List subTags) { //no subscription tags? Then it always will match if (subTags.Count == 0) return true; diff --git a/server/AyaNova/biz/PMTemplateBiz.cs b/server/AyaNova/biz/PMTemplateBiz.cs index 0aa40eef..e0edba99 100644 --- a/server/AyaNova/biz/PMTemplateBiz.cs +++ b/server/AyaNova/biz/PMTemplateBiz.cs @@ -57,7 +57,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -91,7 +91,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } @@ -147,7 +147,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct); await SearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -179,7 +179,7 @@ namespace AyaNova.Biz await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); await transaction.CommitAsync(); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { diff --git a/server/AyaNova/biz/PartBiz.cs b/server/AyaNova/biz/PartBiz.cs index f48b342c..3b38c5f8 100644 --- a/server/AyaNova/biz/PartBiz.cs +++ b/server/AyaNova/biz/PartBiz.cs @@ -49,7 +49,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -83,7 +83,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } @@ -132,7 +132,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct); await SearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -164,7 +164,7 @@ namespace AyaNova.Biz await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); await transaction.CommitAsync(); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { diff --git a/server/AyaNova/biz/ProjectBiz.cs b/server/AyaNova/biz/ProjectBiz.cs index aa6dd941..ddc2c2e1 100644 --- a/server/AyaNova/biz/ProjectBiz.cs +++ b/server/AyaNova/biz/ProjectBiz.cs @@ -54,7 +54,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -88,7 +88,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } @@ -137,7 +137,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct); await SearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -169,7 +169,7 @@ namespace AyaNova.Biz await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); await transaction.CommitAsync(); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { diff --git a/server/AyaNova/biz/PurchaseOrderBiz.cs b/server/AyaNova/biz/PurchaseOrderBiz.cs index 89e35b61..f230ac53 100644 --- a/server/AyaNova/biz/PurchaseOrderBiz.cs +++ b/server/AyaNova/biz/PurchaseOrderBiz.cs @@ -49,7 +49,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -83,7 +83,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } @@ -132,7 +132,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct); await SearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -162,7 +162,7 @@ namespace AyaNova.Biz await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); await transaction.CommitAsync(); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { diff --git a/server/AyaNova/biz/ReminderBiz.cs b/server/AyaNova/biz/ReminderBiz.cs index 0650a7a9..01ea8f64 100644 --- a/server/AyaNova/biz/ReminderBiz.cs +++ b/server/AyaNova/biz/ReminderBiz.cs @@ -54,7 +54,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -88,7 +88,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } @@ -137,7 +137,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct); await SearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -169,7 +169,7 @@ namespace AyaNova.Biz await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); await transaction.CommitAsync(); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { diff --git a/server/AyaNova/biz/ReviewBiz.cs b/server/AyaNova/biz/ReviewBiz.cs index dd5c074a..9c0c43a9 100644 --- a/server/AyaNova/biz/ReviewBiz.cs +++ b/server/AyaNova/biz/ReviewBiz.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; using System.Linq; using AyaNova.Util; using AyaNova.Api.ControllerHelpers; @@ -11,7 +12,7 @@ using Newtonsoft.Json; namespace AyaNova.Biz { - internal class ReviewBiz : BizObject, IJobObject, ISearchAbleObject, IReportAbleObject, IExportAbleObject, IImportAbleObject + internal class ReviewBiz : BizObject, IJobObject, ISearchAbleObject, IReportAbleObject, IExportAbleObject, IImportAbleObject, INotifiableObject { internal ReviewBiz(AyContext dbcontext, long currentUserId, long userTranslationId, AuthorizationRoles UserRoles) { @@ -54,7 +55,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -88,7 +89,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } @@ -137,7 +138,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct); await SearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -170,7 +171,7 @@ namespace AyaNova.Biz await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); await transaction.CommitAsync(); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { @@ -241,7 +242,7 @@ namespace AyaNova.Biz { if ( (currentObj.Name != proposedObj.Name) || - (currentObj.Notes != proposedObj.Notes) || + (currentObj.Notes != proposedObj.Notes) || (currentObj.DueDate != proposedObj.DueDate) || (currentObj.UserId != proposedObj.UserId) || (currentObj.AssignedByUserId != proposedObj.AssignedByUserId)) @@ -266,7 +267,7 @@ namespace AyaNova.Biz return; } } - + //Does the object of this Review actually exist? if (!await BizObjectExistsInDatabase.ExistsAsync(proposedObj.ObjectType, proposedObj.ObjectId, ct)) { @@ -274,7 +275,7 @@ namespace AyaNova.Biz return; } - //Name required + //Name required if (string.IsNullOrWhiteSpace(proposedObj.Name)) AddError(ApiErrorCode.VALIDATION_REQUIRED, "Name"); @@ -461,6 +462,78 @@ namespace AyaNova.Biz + //////////////////////////////////////////////////////////////////////////////////////////////// + // NOTIFICATION PROCESSING + // + public async Task HandlePotentialNotificationEvent(AyaEvent ayaEvent, Review proposedObj, Review currentObj) + { + ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger(); + if (ServerBootConfig.SEEDING) return; + log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{this.BizType}, AyaEvent:{ayaEvent}]"); + + bool isNew = currentObj == null; + + if (ayaEvent == AyaEvent.Deleted) + { + + return; + } + + if (ayaEvent == AyaEvent.Created || ayaEvent == AyaEvent.Modified) + { + //Remove prior + await NotifyEventHelper.ClearPriorEventsForObject(ct, newObject.AyaType, newObject.Id, NotifyEventType.GeneralNotification);//assumes only general event for this object type is overdue here + + //set a deadman automatic internal notification if goes past due + var r = (Review)newObject; + + //it not completed yet and not overdue already (which could indicate an import or something) + if (r.CompletedDate == null && r.DueDate > DateTime.UtcNow) + { + var userNotifySub = await EnsureDefaultInAppUserNotificationSubscriptionExists(r.UserId, ct); + NotifySubscription supervisorNotifySub = null; + if (r.UserId != r.AssignedByUserId) + { + supervisorNotifySub = await EnsureDefaultInAppUserNotificationSubscriptionExists(r.AssignedByUserId, ct); + } + + { + NotifyEvent n = new NotifyEvent() + { + EventType = NotifyEventType.GeneralNotification, + UserId = r.UserId, + ObjectId = newObject.Id, + AyaType = AyaType.Review, + NotifySubscriptionId = userNotifySub.Id, + Name = "LT:ReviewOverDue - " + newObject.Name, + EventDate = r.DueDate + }; + await ct.NotifyEvent.AddAsync(n); + log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]"); + } + + if (supervisorNotifySub != null) + { + NotifyEvent n = new NotifyEvent() + { + EventType = NotifyEventType.GeneralNotification, + UserId = r.AssignedByUserId, + ObjectId = newObject.Id, + AyaType = AyaType.Review, + NotifySubscriptionId = supervisorNotifySub.Id, + Name = "LT:ReviewOverDue - " + newObject.Name, + EventDate = r.DueDate + }; + await ct.NotifyEvent.AddAsync(n); + log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]"); + } + } + } + + } + + + ///////////////////////////////////////////////////////////////////// diff --git a/server/AyaNova/biz/UnitBiz.cs b/server/AyaNova/biz/UnitBiz.cs index 5ec0c398..d0627ee6 100644 --- a/server/AyaNova/biz/UnitBiz.cs +++ b/server/AyaNova/biz/UnitBiz.cs @@ -49,7 +49,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -83,7 +83,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } @@ -132,7 +132,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct); await SearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -162,7 +162,7 @@ namespace AyaNova.Biz await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); await transaction.CommitAsync(); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { diff --git a/server/AyaNova/biz/UnitModelBiz.cs b/server/AyaNova/biz/UnitModelBiz.cs index f80db5d4..e023eb2f 100644 --- a/server/AyaNova/biz/UnitModelBiz.cs +++ b/server/AyaNova/biz/UnitModelBiz.cs @@ -49,7 +49,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -83,7 +83,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } @@ -132,7 +132,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct); await SearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -162,7 +162,7 @@ namespace AyaNova.Biz await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); await transaction.CommitAsync(); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { diff --git a/server/AyaNova/biz/UserBiz.cs b/server/AyaNova/biz/UserBiz.cs index e2ad5e16..08454d0e 100644 --- a/server/AyaNova/biz/UserBiz.cs +++ b/server/AyaNova/biz/UserBiz.cs @@ -67,7 +67,7 @@ namespace AyaNova.Biz { u.Active = false; var msg = $"User {u.Name} with no prior login automatically set to inactive to free up downgraded license"; - await NotifyEventProcessor.AddOpsProblemEvent(msg); + await NotifyEventHelper.AddOpsProblemEvent(msg); _log.LogInformation(msg); } await ct.SaveChangesAsync(); @@ -93,7 +93,7 @@ namespace AyaNova.Biz dbObject.Password = Hasher.hash(dbObject.Salt, ServerBootConfig.AYANOVA_SET_SUPERUSER_PW); ct.SaveChanges(); - NotifyEventProcessor.AddOpsProblemEvent("AYANOVA_SET_SUPERUSER_PW setting was used at most recent server boot to reset SuperUser account password").Wait(); + NotifyEventHelper.AddOpsProblemEvent("AYANOVA_SET_SUPERUSER_PW setting was used at most recent server boot to reset SuperUser account password").Wait(); } } @@ -166,7 +166,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); dtUser retUser = new dtUser(); CopyObject.Copy(newObject, retUser); return retUser; @@ -220,7 +220,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } @@ -322,7 +322,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct); await SearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; @@ -380,7 +380,7 @@ namespace AyaNova.Biz var ServerUrl = ServerGlobalOpsSettingsCache.Notify.AyaNovaServerURL; if (string.IsNullOrWhiteSpace(ServerUrl)) { - await NotifyEventProcessor.AddOpsProblemEvent("User::SendPasswordResetCode - The OPS Notification setting is empty for AyaNova Server URL. This prevents Notification system from linking events to openable objects."); + await NotifyEventHelper.AddOpsProblemEvent("User::SendPasswordResetCode - The OPS Notification setting is empty for AyaNova Server URL. This prevents Notification system from linking events to openable objects."); AddError(ApiErrorCode.VALIDATION_REQUIRED, "ServerUrl", "Error: no server url configured in notification settings. Can't direct user to server for login. Set server URL and try again."); return 0; } @@ -496,7 +496,7 @@ namespace AyaNova.Biz //all good do the commit if it's ours if (parentTransaction == null) await transaction.CommitAsync(); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { diff --git a/server/AyaNova/biz/VendorBiz.cs b/server/AyaNova/biz/VendorBiz.cs index 29ea1493..edab03b1 100644 --- a/server/AyaNova/biz/VendorBiz.cs +++ b/server/AyaNova/biz/VendorBiz.cs @@ -54,7 +54,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -88,7 +88,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } @@ -137,7 +137,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct); await SearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -166,7 +166,7 @@ namespace AyaNova.Biz await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); await transaction.CommitAsync(); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { diff --git a/server/AyaNova/biz/WidgetBiz.cs b/server/AyaNova/biz/WidgetBiz.cs index a86c21b1..c3eef189 100644 --- a/server/AyaNova/biz/WidgetBiz.cs +++ b/server/AyaNova/biz/WidgetBiz.cs @@ -57,7 +57,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -91,7 +91,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } @@ -140,7 +140,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct); await SearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -174,7 +174,7 @@ namespace AyaNova.Biz await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); //all good do the commit await transaction.CommitAsync(); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { diff --git a/server/AyaNova/biz/WorkOrderBiz.cs b/server/AyaNova/biz/WorkOrderBiz.cs index 37783389..31b09139 100644 --- a/server/AyaNova/biz/WorkOrderBiz.cs +++ b/server/AyaNova/biz/WorkOrderBiz.cs @@ -71,7 +71,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await WorkOrderSearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -96,7 +96,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await WorkOrderSearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } @@ -185,7 +185,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct); await WorkOrderSearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -233,7 +233,7 @@ namespace AyaNova.Biz } #endif await transaction.CommitAsync(); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { @@ -419,7 +419,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, AyaType.WorkOrderItem, AyaEvent.Created), ct); await ItemSearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -496,7 +496,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, AyaType.WorkOrderItem, AyaEvent.Modified), ct); await ItemSearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -567,7 +567,7 @@ namespace AyaNova.Biz //all good do the commit if it's ours if (parentTransaction == null) await transaction.CommitAsync(); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { @@ -688,7 +688,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, AyaType.WorkOrderItemExpense, AyaEvent.Created), ct); await ExpenseSearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -749,7 +749,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, AyaType.WorkOrderItemExpense, AyaEvent.Modified), ct); await ExpenseSearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -770,7 +770,7 @@ namespace AyaNova.Biz await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, AyaType.WorkOrderItemExpense, ct); await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); return true; } @@ -881,7 +881,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, AyaType.WorkOrderItemLabor, AyaEvent.Created), ct); await LaborSearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -942,7 +942,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, AyaType.WorkOrderItemLabor, AyaEvent.Modified), ct); await LaborSearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -963,7 +963,7 @@ namespace AyaNova.Biz await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, AyaType.WorkOrderItemLabor, ct); await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); return true; } @@ -1073,7 +1073,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, AyaType.WorkOrderItemLoan, AyaEvent.Created), ct); await LoanSearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -1134,7 +1134,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, AyaType.WorkOrderItemLoan, AyaEvent.Modified), ct); await LoanSearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -1155,7 +1155,7 @@ namespace AyaNova.Biz await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, AyaType.WorkOrderItemLoan, ct); await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); return true; } @@ -1326,7 +1326,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, AyaType.WorkOrderItemPart, AyaEvent.Modified), ct); await PartSearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -1347,7 +1347,7 @@ namespace AyaNova.Biz await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, AyaType.WorkOrderItemPart, ct); await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); return true; } @@ -1455,7 +1455,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, AyaType.WorkOrderItemPartRequest, AyaEvent.Created), ct); await PartRequestSearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -1516,7 +1516,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, AyaType.WorkOrderItemPartRequest, AyaEvent.Modified), ct); await PartRequestSearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -1537,7 +1537,7 @@ namespace AyaNova.Biz await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, AyaType.WorkOrderItemPartRequest, ct); await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); return true; } @@ -1648,7 +1648,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, AyaType.WorkOrderItemScheduledUser, AyaEvent.Created), ct); await ScheduledUserSearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -1709,7 +1709,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, AyaType.WorkOrderItemScheduledUser, AyaEvent.Modified), ct); await ScheduledUserSearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -1730,7 +1730,7 @@ namespace AyaNova.Biz await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, AyaType.WorkOrderItemScheduledUser, ct); await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); return true; } @@ -1841,7 +1841,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, AyaType.WorkOrderItemTask, AyaEvent.Created), ct); await TaskSearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -1902,7 +1902,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, AyaType.WorkOrderItemTask, AyaEvent.Modified), ct); await TaskSearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -1923,7 +1923,7 @@ namespace AyaNova.Biz await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, AyaType.WorkOrderItemTask, ct); await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); return true; } @@ -2034,7 +2034,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, AyaType.WorkOrderItemTravel, AyaEvent.Created), ct); await TravelSearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -2095,7 +2095,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, AyaType.WorkOrderItemTravel, AyaEvent.Modified), ct); await TravelSearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -2116,7 +2116,7 @@ namespace AyaNova.Biz await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, AyaType.WorkOrderItemTravel, ct); await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); return true; } @@ -2227,7 +2227,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, AyaType.WorkOrderItemUnit, AyaEvent.Created), ct); await UnitSearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -2288,7 +2288,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, AyaType.WorkOrderItemUnit, AyaEvent.Modified), ct); await UnitSearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return dbObject; } @@ -2309,7 +2309,7 @@ namespace AyaNova.Biz await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, AyaType.WorkOrderItemUnit, ct); await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); return true; } diff --git a/server/AyaNova/biz/WorkorderTemplateBiz.cs b/server/AyaNova/biz/WorkorderTemplateBiz.cs index 3fc68a70..98bd12f9 100644 --- a/server/AyaNova/biz/WorkorderTemplateBiz.cs +++ b/server/AyaNova/biz/WorkorderTemplateBiz.cs @@ -86,7 +86,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(outObj, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, outObj.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return outObj; } @@ -128,7 +128,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct); await SearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } @@ -169,7 +169,7 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct); await SearchIndexAsync(dbObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj); return true; } @@ -221,7 +221,7 @@ namespace AyaNova.Biz await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct); await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags); await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct); - await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); + await NotifyEventHelper.HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); return true; } diff --git a/server/AyaNova/generator/CoreJobBackup.cs b/server/AyaNova/generator/CoreJobBackup.cs index 68548953..acf896e5 100644 --- a/server/AyaNova/generator/CoreJobBackup.cs +++ b/server/AyaNova/generator/CoreJobBackup.cs @@ -88,7 +88,7 @@ namespace AyaNova.Biz var msg = $"Error during data backup \"{Result}\""; await JobsBiz.LogJobAsync(Guid.Empty, msg); log.LogError($"BACKUP ERROR: {Result}"); - await NotifyEventProcessor.AddGeneralNotifyEvent(NotifyEventType.BackupStatus, msg,"Backup"); + await NotifyEventHelper.AddGeneralNotifyEvent(NotifyEventType.BackupStatus, msg,"Backup"); } //DO FILE BACKUP IF ATTACHMENTS BACKED UP @@ -110,14 +110,14 @@ namespace AyaNova.Biz log.LogDebug("Backup completed"); var duration=DateTime.Now - dtStartBackup; - await NotifyEventProcessor.AddGeneralNotifyEvent(NotifyEventType.BackupStatus, $"Backup ({(OnDemand ? "manual / on demand" : "scheduled")}) completed successfully, duration (h:m:s.ms): {duration.ToString()}, server re-opened","Backup"); + await NotifyEventHelper.AddGeneralNotifyEvent(NotifyEventType.BackupStatus, $"Backup ({(OnDemand ? "manual / on demand" : "scheduled")}) completed successfully, duration (h:m:s.ms): {duration.ToString()}, server re-opened","Backup"); } catch (Exception ex) { await JobsBiz.LogJobAsync(Guid.Empty, "LT:JobFailed"); await JobsBiz.LogJobAsync(Guid.Empty, ExceptionUtil.ExtractAllExceptionMessages(ex)); log.LogError(ex, "Backup failed"); - await NotifyEventProcessor.AddGeneralNotifyEvent(NotifyEventType.BackupStatus, "Backup failed","Backup", ex); + await NotifyEventHelper.AddGeneralNotifyEvent(NotifyEventType.BackupStatus, "Backup failed","Backup", ex); throw; } finally diff --git a/server/AyaNova/generator/CoreJobNotify.cs b/server/AyaNova/generator/CoreJobNotify.cs index f27e424d..b1d0a7e9 100644 --- a/server/AyaNova/generator/CoreJobNotify.cs +++ b/server/AyaNova/generator/CoreJobNotify.cs @@ -74,7 +74,7 @@ namespace AyaNova.Biz if (dtNowLocal.Hour > 6 && dtNowLocal.Hour < 10) { log.LogTrace("Notify health check submitted to subscribers"); - await NotifyEventProcessor.AddGeneralNotifyEvent(NotifyEventType.NotifyHealthCheck, "OK", ""); + await NotifyEventHelper.AddGeneralNotifyEvent(NotifyEventType.NotifyHealthCheck, "OK", ""); lastNotifyHealthCheckSentLocal = dtNowLocal; } } @@ -220,7 +220,7 @@ namespace AyaNova.Biz { log.LogTrace($"DeliverSMTP delivering notify event: {ne}"); if (string.IsNullOrWhiteSpace(ne.NotifySubscription.DeliveryAddress)) - await NotifyEventProcessor.AddGeneralNotifyEvent(NotifyEventType.GeneralNotification, $"No email address is set in subscription to deliver email notification for this event:{ne}", "Error", null, ne.UserId); + await NotifyEventHelper.AddGeneralNotifyEvent(NotifyEventType.GeneralNotification, $"No email address is set in subscription to deliver email notification for this event:{ne}", "Error", null, ne.UserId); @@ -262,7 +262,7 @@ namespace AyaNova.Biz if (!ServerGlobalOpsSettingsCache.Notify.SmtpDeliveryActive) { - await NotifyEventProcessor.AddGeneralNotifyEvent(NotifyEventType.GeneralNotification, $"Email notifications are set to OFF at server, unable to send email notification for this event:{ne}", "Error", null, ne.UserId); + await NotifyEventHelper.AddGeneralNotifyEvent(NotifyEventType.GeneralNotification, $"Email notifications are set to OFF at server, unable to send email notification for this event:{ne}", "Error", null, ne.UserId); log.LogInformation($"** WARNING: SMTP notification is currently set to Active=False; unable to deliver email notification, re-routed to in-app notification instead [UserId={ne.UserId}, Notify subscription={ne.NotifySubscriptionId}]. Change this setting or have users remove email delivery notifications if this is permanent **"); } else @@ -272,8 +272,8 @@ namespace AyaNova.Biz } catch (Exception ex) { - await NotifyEventProcessor.AddOpsProblemEvent("SMTP Notification failed", ex); - await NotifyEventProcessor.AddGeneralNotifyEvent(NotifyEventType.GeneralNotification, $"An error prevented delivering the following notification via email. System operator users have been notified:{ne}", "Error", null, ne.UserId); + await NotifyEventHelper.AddOpsProblemEvent("SMTP Notification failed", ex); + await NotifyEventHelper.AddGeneralNotifyEvent(NotifyEventType.GeneralNotification, $"An error prevented delivering the following notification via email. System operator users have been notified:{ne}", "Error", null, ne.UserId); } finally { @@ -299,7 +299,7 @@ namespace AyaNova.Biz } catch (Exception ex) { - await NotifyEventProcessor.AddOpsProblemEvent("SMTP (TEST) Notification failed", ex); + await NotifyEventHelper.AddOpsProblemEvent("SMTP (TEST) Notification failed", ex); return ExceptionUtil.ExtractAllExceptionMessages(ex); } @@ -313,7 +313,7 @@ namespace AyaNova.Biz var ServerUrl = ServerGlobalOpsSettingsCache.Notify.AyaNovaServerURL; if (string.IsNullOrWhiteSpace(ServerUrl)) { - NotifyEventProcessor.AddOpsProblemEvent("Notification system: The OPS Notification setting is empty for AyaNova Server URL. This prevents Notification system from linking events to openable objects.").Wait(); + NotifyEventHelper.AddOpsProblemEvent("Notification system: The OPS Notification setting is empty for AyaNova Server URL. This prevents Notification system from linking events to openable objects.").Wait(); return "OPS ERROR NO SERVER URL CONFIGURED"; } ServerUrl = ServerUrl.Trim().TrimEnd('/'); @@ -350,7 +350,7 @@ namespace AyaNova.Biz var ServerUrl = ServerGlobalOpsSettingsCache.Notify.AyaNovaServerURL; if (string.IsNullOrWhiteSpace(ServerUrl)) { - NotifyEventProcessor.AddOpsProblemEvent("Notification system: The OPS Notification setting is empty for AyaNova Server URL. This prevents Notification system from linking events to openable objects.").Wait(); + NotifyEventHelper.AddOpsProblemEvent("Notification system: The OPS Notification setting is empty for AyaNova Server URL. This prevents Notification system from linking events to openable objects.").Wait(); return "OPS ERROR NO SERVER URL CONFIGURED"; } ServerUrl = ServerUrl.Trim().TrimEnd('/'); @@ -365,7 +365,7 @@ namespace AyaNova.Biz var ServerUrl = ServerGlobalOpsSettingsCache.Notify.AyaNovaServerURL; if (string.IsNullOrWhiteSpace(ServerUrl)) { - NotifyEventProcessor.AddOpsProblemEvent("Notification system: The OPS Notification setting is empty for AyaNova Server URL. This prevents Notification system from linking events to openable objects.").Wait(); + NotifyEventHelper.AddOpsProblemEvent("Notification system: The OPS Notification setting is empty for AyaNova Server URL. This prevents Notification system from linking events to openable objects.").Wait(); return "OPS ERROR NO SERVER URL CONFIGURED"; } ServerUrl = ServerUrl.Trim().TrimEnd('/');