This commit is contained in:
2021-06-08 22:52:58 +00:00
parent d1bc8b7dfc
commit a04649fc58

View File

@@ -66,9 +66,6 @@ namespace AyaNova.Biz
} }
} }
using (AyContext ct = AyaNova.Util.ServiceProviderProvider.DBContext) using (AyContext ct = AyaNova.Util.ServiceProviderProvider.DBContext)
{ {
var events = await ct.NotifyEvent.AsNoTracking().ToListAsync(); var events = await ct.NotifyEvent.AsNoTracking().ToListAsync();
@@ -101,7 +98,7 @@ namespace AyaNova.Biz
if (Subscription.DeliveryMethod == NotifyDeliveryMethod.App) if (Subscription.DeliveryMethod == NotifyDeliveryMethod.App)
await DeliverInApp(notifyevent, ct); await DeliverInApp(notifyevent, ct);
else if (Subscription.DeliveryMethod == NotifyDeliveryMethod.SMTP) 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 try
{ {
log.LogTrace($"DeliverSMTP delivering notify event: {ne}"); 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); 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"); TranslationKeysToFetch.Add("Server");
var EventTypeTranslationKey = "NotifyEvent" + ne.EventType.ToString(); var EventTypeTranslationKey = "NotifyEvent" + ne.EventType.ToString();
TranslationKeysToFetch.Add(EventTypeTranslationKey); 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 LT = await TranslationBiz.GetSubsetStaticAsync(TranslationKeysToFetch, transid);
var NotifySubscriptionTheWord = LT["NotifySubscription"]; var NotifySubscriptionTheWord = LT["NotifySubscription"];
@@ -175,17 +172,6 @@ namespace AyaNova.Biz
var body = ""; var body = "";
//NOTE: if need any other exemptions besides backup status make a separate static function "CanOpen(NotifyEventType)" //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) 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 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 // //Used to directly open a report at client
private static string OpenReportUrlBuilder(long objectId, long reportId) // private static string OpenReportUrlBuilder(long objectId, long reportId)
{ // {
//CLIENT EXPECTS: open report links to have a query string [CLIENTAPPURL]/viewreport?oid=[objectid]&rid=[reportid] // //CLIENT EXPECTS: open report links to have a query string [CLIENTAPPURL]/viewreport?oid=[objectid]&rid=[reportid]
var ServerUrl = ServerGlobalOpsSettingsCache.Notify.AyaNovaServerURL; // var ServerUrl = ServerGlobalOpsSettingsCache.Notify.AyaNovaServerURL;
if (string.IsNullOrWhiteSpace(ServerUrl)) // 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(); // 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"; // return "OPS ERROR NO SERVER URL CONFIGURED";
} // }
ServerUrl = ServerUrl.Trim().TrimEnd('/'); // ServerUrl = ServerUrl.Trim().TrimEnd('/');
return $"{ServerUrl}/viewreport?oid={objectId}&rid={reportId}"; // return $"{ServerUrl}/viewreport?oid={objectId}&rid={reportId}";
} // }