|
|
|
@ -17,6 +17,7 @@ using Volo.Abp.EventBus.Distributed; |
|
|
|
using Volo.Abp.Json; |
|
|
|
using Volo.Abp.Localization; |
|
|
|
using Volo.Abp.MultiTenancy; |
|
|
|
using Volo.Abp.Settings; |
|
|
|
using Volo.Abp.TextTemplating; |
|
|
|
using Volo.Abp.Uow; |
|
|
|
|
|
|
|
@ -43,6 +44,10 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed |
|
|
|
/// </summary>
|
|
|
|
protected AbpNotificationsPublishOptions Options { get; } |
|
|
|
/// <summary>
|
|
|
|
/// Reference to <see cref="ISettingProvider"/>.
|
|
|
|
/// </summary>
|
|
|
|
protected ISettingProvider SettingProvider { get; } |
|
|
|
/// <summary>
|
|
|
|
/// Reference to <see cref="ICurrentTenant"/>.
|
|
|
|
/// </summary>
|
|
|
|
protected ICurrentTenant CurrentTenant { get; } |
|
|
|
@ -96,6 +101,7 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed |
|
|
|
/// </summary>
|
|
|
|
public NotificationEventHandler( |
|
|
|
ICurrentTenant currentTenant, |
|
|
|
ISettingProvider settingProvider, |
|
|
|
ITenantConfigurationCache tenantConfigurationCache, |
|
|
|
IJsonSerializer jsonSerializer, |
|
|
|
ITemplateRenderer templateRenderer, |
|
|
|
@ -112,6 +118,7 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed |
|
|
|
Options = options.Value; |
|
|
|
TenantConfigurationCache = tenantConfigurationCache; |
|
|
|
CurrentTenant = currentTenant; |
|
|
|
SettingProvider = settingProvider; |
|
|
|
JsonSerializer = jsonSerializer; |
|
|
|
TemplateRenderer = templateRenderer; |
|
|
|
BackgroundJobManager = backgroundJobManager; |
|
|
|
@ -138,7 +145,8 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed |
|
|
|
var culture = eventData.Data.Culture; |
|
|
|
if (culture.IsNullOrWhiteSpace()) |
|
|
|
{ |
|
|
|
culture = CultureInfo.CurrentCulture.Name; |
|
|
|
var cultureSet = await SettingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage); |
|
|
|
culture = cultureSet ?? CultureInfo.CurrentCulture.Name; |
|
|
|
} |
|
|
|
using (CultureHelper.Use(culture, culture)) |
|
|
|
{ |
|
|
|
@ -173,7 +181,14 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var culture = eventData.Data.TryGetData(NotificationData.CultureKey)?.ToString(); |
|
|
|
if (culture.IsNullOrWhiteSpace()) |
|
|
|
{ |
|
|
|
var cultureSet = await SettingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage); |
|
|
|
culture = cultureSet ?? CultureInfo.CurrentCulture.Name; |
|
|
|
} |
|
|
|
using (CultureHelper.Use(culture, culture)) |
|
|
|
{ |
|
|
|
if (notification.NotificationType == NotificationType.System) |
|
|
|
{ |
|
|
|
using (CurrentTenant.Change(null)) |
|
|
|
@ -193,6 +208,7 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed |
|
|
|
await SendToTenantAsync(eventData.TenantId, notification, eventData); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected async virtual Task SendToTenantAsync( |
|
|
|
Guid? tenantId, |
|
|
|
|