From a04649fc58b11a30a0a5b6b3b793debf96ff7c07 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 8 Jun 2021 22:52:58 +0000 Subject: [PATCH] --- server/AyaNova/generator/CoreJobNotify.cs | 50 ++++++++--------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/server/AyaNova/generator/CoreJobNotify.cs b/server/AyaNova/generator/CoreJobNotify.cs index d204474b..2d0ae4d2 100644 --- a/server/AyaNova/generator/CoreJobNotify.cs +++ b/server/AyaNova/generator/CoreJobNotify.cs @@ -66,9 +66,6 @@ namespace AyaNova.Biz } } - - - using (AyContext ct = AyaNova.Util.ServiceProviderProvider.DBContext) { var events = await ct.NotifyEvent.AsNoTracking().ToListAsync(); @@ -101,7 +98,7 @@ namespace AyaNova.Biz if (Subscription.DeliveryMethod == NotifyDeliveryMethod.App) await DeliverInApp(notifyevent, ct); else if (Subscription.DeliveryMethod == NotifyDeliveryMethod.SMTP) - await DeliverSMTP(notifyevent, Subscription, ct); + await DeliverSMTP(notifyevent, Subscription.DeliveryAddress, ct); } } } @@ -131,12 +128,12 @@ namespace AyaNova.Biz - private static async Task DeliverSMTP(NotifyEvent ne, NotifySubscription sub, AyContext ct) + private static async Task DeliverSMTP(NotifyEvent ne, string deliveryAddress, AyContext ct) { try { log.LogTrace($"DeliverSMTP delivering notify event: {ne}"); - if (string.IsNullOrWhiteSpace(sub.DeliveryAddress)) + if (string.IsNullOrWhiteSpace(deliveryAddress)) { await NotifyEventHelper.AddGeneralNotifyEvent(NotifyEventType.GeneralNotification, $"No email address is set in subscription to deliver email notification. This event will be removed from the delivery queue as undeliverable: {ne}", "Error", null, ne.UserId); } @@ -150,7 +147,7 @@ namespace AyaNova.Biz TranslationKeysToFetch.Add("Server"); var EventTypeTranslationKey = "NotifyEvent" + ne.EventType.ToString(); TranslationKeysToFetch.Add(EventTypeTranslationKey); - var transid = await ct.UserOptions.AsNoTracking().Where(x => x.UserId == sub.UserId).Select(x => x.TranslationId).FirstOrDefaultAsync(); + var transid = await ct.UserOptions.AsNoTracking().Where(x => x.UserId == ne.UserId).Select(x => x.TranslationId).FirstOrDefaultAsync(); var LT = await TranslationBiz.GetSubsetStaticAsync(TranslationKeysToFetch, transid); var NotifySubscriptionTheWord = LT["NotifySubscription"]; @@ -175,17 +172,6 @@ namespace AyaNova.Biz var body = ""; //NOTE: if need any other exemptions besides backup status make a separate static function "CanOpen(NotifyEventType)" - /* -todo: this message sucks: - -http://localhost:8080/open/34/18 ------ -(:WorkOrder: http://localhost:8080/open/51/8 ) - - -the first link is to the workorder, teh second one that says workorder is to the subscription - -*/ if (ne.ObjectId != 0 || ne.EventType == NotifyEventType.BackupStatus) { @@ -207,7 +193,7 @@ the first link is to the workorder, teh second one that says workorder is to the } else { - await m.SendEmailAsync(sub.DeliveryAddress, subject, body, ServerGlobalOpsSettingsCache.Notify); + await m.SendEmailAsync(deliveryAddress, subject, body, ServerGlobalOpsSettingsCache.Notify); } } } @@ -284,19 +270,19 @@ the first link is to the workorder, teh second one that says workorder is to the } - //Used to directly open a report at client - private static string OpenReportUrlBuilder(long objectId, long reportId) - { - //CLIENT EXPECTS: open report links to have a query string [CLIENTAPPURL]/viewreport?oid=[objectid]&rid=[reportid] - var ServerUrl = ServerGlobalOpsSettingsCache.Notify.AyaNovaServerURL; - if (string.IsNullOrWhiteSpace(ServerUrl)) - { - 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('/'); - return $"{ServerUrl}/viewreport?oid={objectId}&rid={reportId}"; - } + // //Used to directly open a report at client + // private static string OpenReportUrlBuilder(long objectId, long reportId) + // { + // //CLIENT EXPECTS: open report links to have a query string [CLIENTAPPURL]/viewreport?oid=[objectid]&rid=[reportid] + // var ServerUrl = ServerGlobalOpsSettingsCache.Notify.AyaNovaServerURL; + // if (string.IsNullOrWhiteSpace(ServerUrl)) + // { + // 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('/'); + // return $"{ServerUrl}/viewreport?oid={objectId}&rid={reportId}"; + // }