This commit is contained in:
@@ -101,9 +101,9 @@ namespace AyaNova.Biz
|
|||||||
//append exception message if not null
|
//append exception message if not null
|
||||||
if (except != null)
|
if (except != null)
|
||||||
message += $"\nException error: {ExceptionUtil.ExtractAllExceptionMessages(except)}";
|
message += $"\nException error: {ExceptionUtil.ExtractAllExceptionMessages(except)}";
|
||||||
|
|
||||||
foreach (var sub in subs)
|
foreach (var sub in subs)
|
||||||
{
|
{
|
||||||
//note flag ~SERVER~ means to client to substitute "Server" translation key text instead
|
//note flag ~SERVER~ means to client to substitute "Server" translation key text instead
|
||||||
NotifyEvent n = new NotifyEvent() { EventType = eventType, UserId = sub.UserId, Message = message, NotifySubscriptionId = sub.Id, Name = "~SERVER~" };
|
NotifyEvent n = new NotifyEvent() { EventType = eventType, UserId = sub.UserId, Message = message, NotifySubscriptionId = sub.Id, Name = "~SERVER~" };
|
||||||
await ct.NotifyEvent.AddAsync(n);
|
await ct.NotifyEvent.AddAsync(n);
|
||||||
|
|||||||
@@ -274,6 +274,20 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//used by internal notification and other processes i.e. "Server" in all languages for server based notifications
|
||||||
|
internal static async Task<Dictionary<long, string>> GetAllTranslationsForKey(string translationKey)
|
||||||
|
{
|
||||||
|
|
||||||
|
#if (DEBUG)
|
||||||
|
TrackRequestedKey(translationKey);
|
||||||
|
#endif
|
||||||
|
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||||
|
{
|
||||||
|
return await ct.TranslationItem.Where(z => z.Key == translationKey).AsNoTracking().ToDictionaryAsync(z => z.TranslationId, z => z.Display);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Get the CJKIndex value for the translation specified
|
//Get the CJKIndex value for the translation specified
|
||||||
internal static async Task<bool> GetCJKIndexAsync(long translationId, AyContext ct)
|
internal static async Task<bool> GetCJKIndexAsync(long translationId, AyContext ct)
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ namespace AyaNova.Biz
|
|||||||
//temporary list to hold translations as required during delivery
|
//temporary list to hold translations as required during delivery
|
||||||
private static Dictionary<long, List<NameIdItem>> _transCache = new Dictionary<long, List<NameIdItem>>();
|
private static Dictionary<long, List<NameIdItem>> _transCache = new Dictionary<long, List<NameIdItem>>();
|
||||||
private static Dictionary<long, long> _UserTranslationIdCache = new Dictionary<long, long>();
|
private static Dictionary<long, long> _UserTranslationIdCache = new Dictionary<long, long>();
|
||||||
|
private static Dictionary<long, string> _ServerTheWordTranslations = new Dictionary<long, string>();
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// DoSweep
|
// DoSweep
|
||||||
@@ -117,6 +118,8 @@ namespace AyaNova.Biz
|
|||||||
_UserTranslationIdCache.Add(userid, transId);
|
_UserTranslationIdCache.Add(userid, transId);
|
||||||
await CacheNotifyEventTypeTranslations(transId);
|
await CacheNotifyEventTypeTranslations(transId);
|
||||||
}
|
}
|
||||||
|
//cache all translations of the word "Server" for server notifications
|
||||||
|
_ServerTheWordTranslations = await TranslationBiz.GetAllTranslationsForKey("Server");
|
||||||
|
|
||||||
//iterate and deliver
|
//iterate and deliver
|
||||||
foreach (var notifyevent in events)
|
foreach (var notifyevent in events)
|
||||||
@@ -209,7 +212,12 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
|
|
||||||
var transid = _UserTranslationIdCache[ne.NotifySubscription.UserId];
|
var transid = _UserTranslationIdCache[ne.NotifySubscription.UserId];
|
||||||
var subject = $"AY:{GetTranslatedNotifyEventName(ne.EventType, transid)}:{ne.Name}";
|
var name = ne.Name;
|
||||||
|
if (name == "~SERVER~")
|
||||||
|
{
|
||||||
|
name = _ServerTheWordTranslations.First(z => z.Key == transid).Value;
|
||||||
|
}
|
||||||
|
var subject = $"AY:{GetTranslatedNotifyEventName(ne.EventType, transid)}:{name}";
|
||||||
|
|
||||||
IMailer m = AyaNova.Util.ServiceProviderProvider.Mailer;
|
IMailer m = AyaNova.Util.ServiceProviderProvider.Mailer;
|
||||||
try
|
try
|
||||||
|
|||||||
Reference in New Issue
Block a user