Notify: fix footer
This commit is contained in:
parent
aa8d1cba60
commit
2f08aae86a
@ -330,6 +330,12 @@ public class NotifyEngine
|
|||||||
//Do styling here
|
//Do styling here
|
||||||
if (!string.IsNullOrEmpty(pattern.Styler))
|
if (!string.IsNullOrEmpty(pattern.Styler))
|
||||||
{
|
{
|
||||||
|
var tenantManager = serviceScope.ServiceProvider.GetService<TenantManager>();
|
||||||
|
var userManager = serviceScope.ServiceProvider.GetService<UserManager>();
|
||||||
|
|
||||||
|
var culture = await request.GetCulture(tenantManager, userManager);
|
||||||
|
CultureInfo.CurrentCulture = culture;
|
||||||
|
CultureInfo.CurrentUICulture = culture;
|
||||||
//We need to run through styler before templating
|
//We need to run through styler before templating
|
||||||
StyleMessage(serviceScope, noticeMessage);
|
StyleMessage(serviceScope, noticeMessage);
|
||||||
}
|
}
|
||||||
|
@ -139,4 +139,31 @@ public class NotifyRequest
|
|||||||
{
|
{
|
||||||
return ((INotifySource)scope.ServiceProvider.GetService(_notifySource.GetType())).GetSubscriptionProvider();
|
return ((INotifySource)scope.ServiceProvider.GetService(_notifySource.GetType())).GetSubscriptionProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<CultureInfo> GetCulture(TenantManager tenantManager, UserManager userManager)
|
||||||
|
{
|
||||||
|
var tagCulture = Arguments.FirstOrDefault(a => a.Tag == "Culture");
|
||||||
|
if (tagCulture != null)
|
||||||
|
{
|
||||||
|
return CultureInfo.GetCultureInfo((string)tagCulture.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
CultureInfo culture = null;
|
||||||
|
|
||||||
|
var tenant = await tenantManager.GetCurrentTenantAsync(false);
|
||||||
|
|
||||||
|
if (tenant != null)
|
||||||
|
{
|
||||||
|
culture = tenant.GetCulture();
|
||||||
|
}
|
||||||
|
|
||||||
|
var user = await userManager.SearchUserAsync(Recipient.ID);
|
||||||
|
|
||||||
|
if (!Core.Users.Constants.LostUser.Equals(user) && !string.IsNullOrEmpty(user.CultureName))
|
||||||
|
{
|
||||||
|
culture = user.GetCulture();
|
||||||
|
}
|
||||||
|
|
||||||
|
return culture;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public abstract class NotifySource : INotifySource
|
|||||||
|
|
||||||
public async Task<IActionProvider> GetActionProvider(NotifyRequest r)
|
public async Task<IActionProvider> GetActionProvider(NotifyRequest r)
|
||||||
{
|
{
|
||||||
var culture = await GetCulture(r);
|
var culture = await r.GetCulture(_tenantManager, _userManager);
|
||||||
CultureInfo.CurrentCulture = culture;
|
CultureInfo.CurrentCulture = culture;
|
||||||
CultureInfo.CurrentUICulture = culture;
|
CultureInfo.CurrentUICulture = culture;
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ public abstract class NotifySource : INotifySource
|
|||||||
|
|
||||||
public async Task<IPatternProvider> GetPatternProvider(NotifyRequest r)
|
public async Task<IPatternProvider> GetPatternProvider(NotifyRequest r)
|
||||||
{
|
{
|
||||||
var culture = await GetCulture(r);
|
var culture = await r.GetCulture(_tenantManager, _userManager);
|
||||||
CultureInfo.CurrentCulture = culture;
|
CultureInfo.CurrentCulture = culture;
|
||||||
CultureInfo.CurrentUICulture = culture;
|
CultureInfo.CurrentUICulture = culture;
|
||||||
|
|
||||||
@ -117,31 +117,4 @@ public abstract class NotifySource : INotifySource
|
|||||||
return new RecipientProviderImpl(_userManager)
|
return new RecipientProviderImpl(_userManager)
|
||||||
?? throw new NotifyException("Provider IRecipientsProvider not instanced.");
|
?? throw new NotifyException("Provider IRecipientsProvider not instanced.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<CultureInfo> GetCulture(NotifyRequest r)
|
|
||||||
{
|
|
||||||
var tagCulture = r.Arguments.FirstOrDefault(a => a.Tag == "Culture");
|
|
||||||
if (tagCulture != null)
|
|
||||||
{
|
|
||||||
return CultureInfo.GetCultureInfo((string)tagCulture.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
CultureInfo culture = null;
|
|
||||||
|
|
||||||
var tenant = await _tenantManager.GetCurrentTenantAsync(false);
|
|
||||||
|
|
||||||
if (tenant != null)
|
|
||||||
{
|
|
||||||
culture = tenant.GetCulture();
|
|
||||||
}
|
|
||||||
|
|
||||||
var user = await _userManager.SearchUserAsync(r.Recipient.ID);
|
|
||||||
|
|
||||||
if (!Users.Constants.LostUser.Equals(user) && !string.IsNullOrEmpty(user.CultureName))
|
|
||||||
{
|
|
||||||
culture = user.GetCulture();
|
|
||||||
}
|
|
||||||
|
|
||||||
return culture;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user