This commit is contained in:
2021-06-08 22:45:01 +00:00
parent e907bbcb13
commit d1bc8b7dfc

View File

@@ -112,7 +112,7 @@ namespace AyaNova.Biz
} }
finally finally
{ {
log.LogTrace("Notify is done setting to not running state and tagging lastRun timestamp"); log.LogTrace("Notify is done setting to not running state and tagging lastRun timestamp");
lastRun = DateTime.UtcNow; lastRun = DateTime.UtcNow;
NotifyIsRunning = false; NotifyIsRunning = false;
@@ -130,17 +130,7 @@ namespace AyaNova.Biz
} }
/*
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
*/
private static async Task DeliverSMTP(NotifyEvent ne, NotifySubscription sub, AyContext ct) private static async Task DeliverSMTP(NotifyEvent ne, NotifySubscription sub, AyContext ct)
{ {
try try
@@ -155,6 +145,7 @@ the first link is to the workorder, teh second one that says workorder is to the
//Email notification requires pre-translated values //Email notification requires pre-translated values
List<string> TranslationKeysToFetch = new List<string>(); List<string> TranslationKeysToFetch = new List<string>();
TranslationKeysToFetch.Add(ne.AyaType.ToString()); TranslationKeysToFetch.Add(ne.AyaType.ToString());
TranslationKeysToFetch.Add("NotifySubscription");
if (ne.Name == "~SERVER~") if (ne.Name == "~SERVER~")
TranslationKeysToFetch.Add("Server"); TranslationKeysToFetch.Add("Server");
var EventTypeTranslationKey = "NotifyEvent" + ne.EventType.ToString(); var EventTypeTranslationKey = "NotifyEvent" + ne.EventType.ToString();
@@ -162,28 +153,43 @@ the first link is to the workorder, teh second one that says workorder is to the
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 == sub.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 name = ne.Name; var name = ne.Name;
if (name == "~SERVER~") if (name == "~SERVER~")
name = LT["Server"]; name = LT["Server"];
//AyaType translation //AyaType translation
var AyaTypeTranslated = string.Empty; var AyaTypeTranslated = "-";
if (ne.AyaType != AyaType.NoType) if (ne.AyaType != AyaType.NoType)
AyaTypeTranslated = $":{LT[ne.AyaType.ToString()]}"; AyaTypeTranslated = $"{LT[ne.AyaType.ToString()]}";
//subscription name translation
var SubscriptionTypeName = LT[EventTypeTranslationKey];
var subject = $"AY:{AyaTypeTranslated}:{name}:{SubscriptionTypeName}";
var subject = $"AY{AyaTypeTranslated}:{LT[EventTypeTranslationKey]}:{name}";
//subscription link translation
var SubscriptionTypeName = AyaTypeTranslated;
IMailer m = AyaNova.Util.ServiceProviderProvider.Mailer; IMailer m = AyaNova.Util.ServiceProviderProvider.Mailer;
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)
{ {
body = OpenObjectUrlBuilder(ne.AyaType, ne.ObjectId, ne.EventType) + "\n"; body = $"{AyaTypeTranslated}\n{OpenObjectUrlBuilder(ne.AyaType, ne.ObjectId, ne.EventType)}\n";
} }
body += ne.Message; body += ne.Message;
@@ -192,7 +198,7 @@ the first link is to the workorder, teh second one that says workorder is to the
if (!body.EndsWith('\n')) if (!body.EndsWith('\n'))
body += "\n"; body += "\n";
body += $"-----\n({SubscriptionTypeName}: {OpenSubscriptionUrlBuilder(ne.NotifySubscriptionId)} )\n"; body += $"-----\n{NotifySubscriptionTheWord}\n{OpenSubscriptionUrlBuilder(ne.NotifySubscriptionId)}\n";
if (!ServerGlobalOpsSettingsCache.Notify.SmtpDeliveryActive) if (!ServerGlobalOpsSettingsCache.Notify.SmtpDeliveryActive)
{ {