Browse Source

feat: add support notification template

pull/605/head
cKey 4 years ago
parent
commit
77ae8de9de
  1. 5
      aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpExceptionHandlingNotificationDefinitionProvider.cs
  2. 30
      aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpNotificationsExceptionSubscriber.cs
  3. 47
      aspnet-core/modules/common/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/EmailingNotificationPublishProvider.cs
  4. 30
      aspnet-core/modules/common/LINGYUN.Abp.Notifications.TextTemplating/FodyWeavers.xsd
  5. 9
      aspnet-core/modules/common/LINGYUN.Abp.Notifications.TextTemplating/LINGYUN/Abp/Notifications/TextTemplating/NotificationTemplateContentContributor.cs
  6. 41
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN.Abp.Notifications.csproj
  7. 12
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationModule.cs
  8. 23
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationTemplateDefinitionProvider.cs
  9. 2
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/INotificationTemplateStore.cs
  10. 28
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationDefinition.cs
  11. 6
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationTemplate.cs
  12. 2
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NullNotificationTemplateStore.cs
  13. 5
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationSendDto.cs
  14. 10
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationTemplateDto.cs
  15. 11
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationTemplateGetInput.cs
  16. 19
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationTemplateSetInput.cs
  17. 9
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/INotificationAppService.cs
  18. 2
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/AbpMessageServiceApplicationAutoMapperProfile.cs
  19. 16
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/MyNotificationAppService.cs
  20. 114
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/NotificationAppService.cs
  21. 1
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Localization/Resources/en.json
  22. 1
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Localization/Resources/zh-Hans.json
  23. 4
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/MessageServiceErrorCodes.cs
  24. 14
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Notifications/NotificationTemplateConsts.cs
  25. 19
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs
  26. 4
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/AbpMessageServiceNotificationDefinitionProvider.cs
  27. 11
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/INotificationTemplateRepository.cs
  28. 32
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationTemplate.cs
  29. 31
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationTemplateStore.cs
  30. 2
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/AbpMessageServiceEntityFrameworkCoreModule.cs
  31. 17
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs
  32. 32
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationTemplateRepository.cs
  33. 29
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Notifications/NotificationController.cs
  34. 67
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/RealtimeMessageTemplateProvider.cs
  35. 14
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/ExceptionNotifier/en.tpl
  36. 15
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/ExceptionNotifier/zh-Hans.tpl
  37. 2
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/NewTenantRegisterd/en.tpl
  38. 2
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/NewTenantRegisterd/zh-Hans.tpl
  39. 2
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/WelcomeToApplication/en.tpl
  40. 2
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/WelcomeToApplication/zh-Hans.tpl
  41. 24
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/NotificationEventHandler.cs
  42. 38
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/TenantSynchronizer.cs
  43. 40
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Local/UserCreateSendWelcomeEventHandler.cs
  44. 3
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj
  45. 690
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/20220624035652_Add-Entity-Notification-Template.Designer.cs
  46. 51
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/20220624035652_Add-Entity-Notification-Template.cs
  47. 932
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/RealtimeMessageMigrationsDbContextModelSnapshot.cs
  48. 6
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs
  49. 2
      aspnet-core/services/LY.MicroService.identityServer/Emailing/Templates/MailSecurityVerify.tpl

5
aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpExceptionHandlingNotificationDefinitionProvider.cs

@ -24,9 +24,8 @@ namespace LINGYUN.Abp.ExceptionHandling.Notifications
.WithProviders( .WithProviders(
NotificationProviderNames.SignalR, NotificationProviderNames.SignalR,
NotificationProviderNames.Emailing) NotificationProviderNames.Emailing)
// 特定的通知提供程序属性 // 设定为模板通知
// 此处为邮件通知定义的模板名称 .WithTemplate(typeof(ExceptionHandlingResource));
.WithProperty("Template", "ExceptionNotifier");
} }
protected LocalizableString L(string name) protected LocalizableString L(string name)

30
aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpNotificationsExceptionSubscriber.cs

@ -2,6 +2,7 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using System; using System;
using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
@ -22,24 +23,21 @@ namespace LINGYUN.Abp.ExceptionHandling.Notifications
protected override async Task SendErrorNotifierAsync(ExceptionSendNotifierContext context) protected override async Task SendErrorNotifierAsync(ExceptionSendNotifierContext context)
{ {
var notificationSender = context.ServiceProvider.GetRequiredService<INotificationSender>(); var notificationSender = context.ServiceProvider.GetRequiredService<INotificationSender>();
// 发送错误模板消息
NotificationData notificationData = new NotificationData();
// 写入通知数据
notificationData.TrySetData("header", "An application exception has occurred");
notificationData.TrySetData("footer", $"Copyright to LY Colin © {DateTime.Now.Year}");
notificationData.TrySetData("loglevel", context.LogLevel.ToString());
notificationData.TrySetData("stacktrace", context.Exception.ToString());
notificationData.WriteStandardData(
context.Exception.GetType().FullName,
context.Exception.Message,
DateTime.Now,
"System");
await notificationSender.SendNofiterAsync( await notificationSender.SendNofiterAsync(
AbpExceptionHandlingNotificationNames.NotificationName, AbpExceptionHandlingNotificationNames.NotificationName,
notificationData, new NotificationTemplate(
AbpExceptionHandlingNotificationNames.NotificationName,
formUser: "System",
data: new Dictionary<string, object>
{
{ "header", "An application exception has occurred" },
{ "footer", $"Copyright to LY Colin © {DateTime.Now.Year}" },
{ "loglevel", context.LogLevel.ToString() },
{ "stackTrace", context.Exception.ToString() },
}),
user: null, user: null,
CurrentTenant.Id, CurrentTenant.Id,
NotificationSeverity.Error); NotificationSeverity.Error);
} }
} }

47
aspnet-core/modules/common/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/EmailingNotificationPublishProvider.cs

@ -1,12 +1,15 @@
using LINGYUN.Abp.Identity; using LINGYUN.Abp.Identity;
using LINGYUN.Abp.RealTime.Localization;
using Microsoft.Extensions.Localization; using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Emailing; using Volo.Abp.Emailing;
using Volo.Abp.Localization;
using Volo.Abp.TextTemplating; using Volo.Abp.TextTemplating;
namespace LINGYUN.Abp.Notifications.Emailing; namespace LINGYUN.Abp.Notifications.Emailing;
@ -17,28 +20,26 @@ public class EmailingNotificationPublishProvider : NotificationPublishProvider
public override string Name => ProviderName; public override string Name => ProviderName;
protected IEmailSender EmailSender { get; } protected AbpLocalizationOptions LocalizationOptions { get; }
protected ITemplateRenderer TemplateRenderer { get; } protected IEmailSender EmailSender { get; }
protected IStringLocalizerFactory LocalizerFactory { get; } protected IStringLocalizerFactory LocalizerFactory { get; }
protected IIdentityUserRepository UserRepository { get; } protected IIdentityUserRepository UserRepository { get; }
protected INotificationDefinitionManager NotificationDefinitionManager { get; }
public EmailingNotificationPublishProvider( public EmailingNotificationPublishProvider(
IEmailSender emailSender, IEmailSender emailSender,
ITemplateRenderer templateRenderer, ITemplateRenderer templateRenderer,
IStringLocalizerFactory localizerFactory, IStringLocalizerFactory localizerFactory,
IIdentityUserRepository userRepository, IIdentityUserRepository userRepository,
INotificationDefinitionManager notificationDefinitionManager) IOptions<AbpLocalizationOptions> localizationOptions)
{ {
EmailSender = emailSender; EmailSender = emailSender;
TemplateRenderer = templateRenderer;
LocalizerFactory = localizerFactory; LocalizerFactory = localizerFactory;
UserRepository = userRepository; UserRepository = userRepository;
NotificationDefinitionManager = notificationDefinitionManager;
LocalizationOptions = localizationOptions.Value;
} }
protected async override Task PublishAsync( protected async override Task PublishAsync(
@ -56,20 +57,30 @@ public class EmailingNotificationPublishProvider : NotificationPublishProvider
return; return;
} }
var notificationDefinition = NotificationDefinitionManager.Get(notification.Name); if (!notification.Data.NeedLocalizer())
var notificationDisplayName = notificationDefinition.DisplayName.Localize(LocalizerFactory).Value;
notificationDefinition.Properties.TryGetValue("Template", out var template);
if (template == null)
{ {
Logger.LogWarning("The email template is not specified, so the email notification cannot be sent!"); var title = notification.Data.TryGetData("title").ToString();
return; var message = notification.Data.TryGetData("message").ToString();
await EmailSender.SendAsync(emailAddress, title, message);
} }
else
{
var titleInfo = notification.Data.TryGetData("title").As<LocalizableStringInfo>();
var titleResource = GetResource(titleInfo.ResourceName);
var title = LocalizerFactory.Create(titleResource.ResourceType)[titleInfo.Name, titleInfo.Values].Value;
var messageInfo = notification.Data.TryGetData("message").As<LocalizableStringInfo>();
var messageResource = GetResource(messageInfo.ResourceName);
var message = LocalizerFactory.Create(messageResource.ResourceType)[messageInfo.Name, messageInfo.Values].Value;
var content = await TemplateRenderer.RenderAsync( await EmailSender.SendAsync(emailAddress, title, message);
template.ToString(), }
globalContext: notification.Data.ExtraProperties); }
await EmailSender.SendAsync(emailAddress, notificationDisplayName, content); private LocalizationResource GetResource(string resourceName)
{
return LocalizationOptions.Resources.Values
.First(x => x.ResourceName.Equals(resourceName));
} }
} }

30
aspnet-core/modules/common/LINGYUN.Abp.Notifications.TextTemplating/FodyWeavers.xsd

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" />
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

9
aspnet-core/modules/common/LINGYUN.Abp.Notifications.TextTemplating/LINGYUN/Abp/Notifications/TextTemplating/NotificationTemplateContentContributor.cs

@ -9,8 +9,15 @@ public class NotificationTemplateContentContributor : ITemplateContentContributo
{ {
public async virtual Task<string> GetOrNullAsync(TemplateContentContributorContext context) public async virtual Task<string> GetOrNullAsync(TemplateContentContributorContext context)
{ {
var notificationDefinitionManager = context.ServiceProvider.GetRequiredService<INotificationDefinitionManager>();
var notification = notificationDefinitionManager.GetOrNull(context.TemplateDefinition.Name);
if (notification == null)
{
return null;
}
var store = context.ServiceProvider.GetRequiredService<INotificationTemplateStore>(); var store = context.ServiceProvider.GetRequiredService<INotificationTemplateStore>();
return await store.GetOrNullAsync(context.TemplateDefinition.Name, context.Culture); return await store.GetContentOrNullAsync(context.TemplateDefinition.Name, context.Culture);
} }
} }

41
aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN.Abp.Notifications.csproj

@ -1,30 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\configureawait.props" /> <Import Project="..\..\..\configureawait.props" />
<Import Project="..\..\..\common.props" /> <Import Project="..\..\..\common.props" />
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace /> <RootNamespace />
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Remove="LINGYUN\Abp\Notifications\Localization\Resources\*.json" /> <None Remove="LINGYUN\Abp\Notifications\Localization\Resources\*.json" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="LINGYUN\Abp\Notifications\Localization\Resources\*.json" /> <EmbeddedResource Include="LINGYUN\Abp\Notifications\Localization\Resources\*.json" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Volo.Abp.EventBus" Version="$(VoloAbpPackageVersion)" /> <PackageReference Include="Volo.Abp.EventBus" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Json" Version="$(VoloAbpPackageVersion)" /> <PackageReference Include="Volo.Abp.Json" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.BackgroundJobs.Abstractions" Version="$(VoloAbpPackageVersion)" /> <PackageReference Include="Volo.Abp.BackgroundJobs.Abstractions" Version="$(VoloAbpPackageVersion)" />
</ItemGroup> <PackageReference Include="Volo.Abp.TextTemplating.Core" Version="$(VoloAbpPackageVersion)" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\LINGYUN.Abp.IdGenerator\LINGYUN.Abp.IdGenerator.csproj" /> <ProjectReference Include="..\LINGYUN.Abp.IdGenerator\LINGYUN.Abp.IdGenerator.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.RealTime\LINGYUN.Abp.RealTime.csproj" /> <ProjectReference Include="..\LINGYUN.Abp.RealTime\LINGYUN.Abp.RealTime.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

12
aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationModule.cs

@ -10,6 +10,7 @@ using Volo.Abp.Json;
using Volo.Abp.Json.SystemTextJson; using Volo.Abp.Json.SystemTextJson;
using Volo.Abp.Localization; using Volo.Abp.Localization;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.TextTemplating;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
namespace LINGYUN.Abp.Notifications namespace LINGYUN.Abp.Notifications
@ -21,7 +22,8 @@ namespace LINGYUN.Abp.Notifications
typeof(AbpIdGeneratorModule), typeof(AbpIdGeneratorModule),
typeof(AbpJsonModule), typeof(AbpJsonModule),
typeof(AbpLocalizationModule), typeof(AbpLocalizationModule),
typeof(AbpRealTimeModule))] typeof(AbpRealTimeModule),
typeof(AbpTextTemplatingCoreModule))]
public class AbpNotificationModule : AbpModule public class AbpNotificationModule : AbpModule
{ {
public override void PreConfigureServices(ServiceConfigurationContext context) public override void PreConfigureServices(ServiceConfigurationContext context)
@ -47,6 +49,12 @@ namespace LINGYUN.Abp.Notifications
{ {
options.UnsupportedTypes.Add<NotificationInfo>(); options.UnsupportedTypes.Add<NotificationInfo>();
}); });
var preActions = context.Services.GetPreConfigureActions<AbpNotificationOptions>();
Configure<AbpNotificationOptions>(options =>
{
preActions.Configure(options);
});
} }
private void AutoAddDefinitionProviders(IServiceCollection services) private void AutoAddDefinitionProviders(IServiceCollection services)
@ -61,10 +69,8 @@ namespace LINGYUN.Abp.Notifications
} }
}); });
var preActions = services.GetPreConfigureActions<AbpNotificationOptions>();
Configure<AbpNotificationOptions>(options => Configure<AbpNotificationOptions>(options =>
{ {
preActions.Configure(options);
options.DefinitionProviders.AddIfNotContains(definitionProviders); options.DefinitionProviders.AddIfNotContains(definitionProviders);
}); });
} }

23
aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationTemplateDefinitionProvider.cs

@ -0,0 +1,23 @@
using System.Linq;
using Volo.Abp.TextTemplating;
namespace LINGYUN.Abp.Notifications;
public class AbpNotificationTemplateDefinitionProvider : TemplateDefinitionProvider
{
private readonly INotificationDefinitionManager _notificationDefinitionManager;
public AbpNotificationTemplateDefinitionProvider(
INotificationDefinitionManager notificationDefinitionManager)
{
_notificationDefinitionManager = notificationDefinitionManager;
}
public override void Define(ITemplateDefinitionContext context)
{
var notifications = _notificationDefinitionManager.GetAll().Where(n => n.Template != null);
foreach (var notification in notifications)
{
context.Add(notification.Template);
}
}
}

2
aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/INotificationTemplateStore.cs

@ -5,5 +5,5 @@ namespace LINGYUN.Abp.Notifications;
public interface INotificationTemplateStore public interface INotificationTemplateStore
{ {
Task<string> GetOrNullAsync(string templateName, string culture = null, CancellationToken cancellationToken = default); Task<string> GetContentOrNullAsync(string templateName, string culture = null, CancellationToken cancellationToken = default);
} }

28
aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationDefinition.cs

@ -3,12 +3,13 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Localization; using Volo.Abp.Localization;
using Volo.Abp.TextTemplating;
/* /*
* 2020-10-29 * 2020-10-29
* INotificationSender指定接收者,,,() * INotificationSender指定接收者,,,()
*/ */
namespace LINGYUN.Abp.Notifications namespace LINGYUN.Abp.Notifications
{ {
public class NotificationDefinition public class NotificationDefinition
@ -49,6 +50,10 @@ namespace LINGYUN.Abp.Notifications
/// 通知提供者 /// 通知提供者
/// </summary> /// </summary>
public List<string> Providers { get; } public List<string> Providers { get; }
/// <summary>
/// 通知模板
/// </summary>
public TemplateDefinition Template { get; private set; }
/// <summary> /// <summary>
/// 额外属性 /// 额外属性
/// </summary> /// </summary>
@ -84,6 +89,23 @@ namespace LINGYUN.Abp.Notifications
return this; return this;
} }
public virtual NotificationDefinition WithTemplate(
Type localizationResource = null,
bool isLayout = false,
string layout = null,
string defaultCultureName = null)
{
Template = new TemplateDefinition(
Name,
localizationResource,
DisplayName,
isLayout,
layout,
defaultCultureName);
return this;
}
public virtual NotificationDefinition WithProperty(string key, object value) public virtual NotificationDefinition WithProperty(string key, object value)
{ {
Properties[key] = value; Properties[key] = value;

6
aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationTemplate.cs

@ -14,7 +14,6 @@ namespace LINGYUN.Abp.Notifications;
public class NotificationTemplate : IHasExtraProperties public class NotificationTemplate : IHasExtraProperties
{ {
public string Name { get; set; } public string Name { get; set; }
public string Title { get; set; }
public string Culture { get; set; } public string Culture { get; set; }
public string FormUser { get; set; } public string FormUser { get; set; }
public object this[string key] public object this[string key]
@ -27,16 +26,17 @@ public class NotificationTemplate : IHasExtraProperties
} }
} }
public ExtraPropertyDictionary ExtraProperties { get; set; } public ExtraPropertyDictionary ExtraProperties { get; set; }
public NotificationTemplate() { }
public NotificationTemplate( public NotificationTemplate(
string name, string name,
string title,
string culture = null, string culture = null,
string formUser = null, string formUser = null,
IDictionary<string, object> data = null) IDictionary<string, object> data = null)
{ {
Name = Check.NotNullOrWhiteSpace(name, nameof(name)); Name = Check.NotNullOrWhiteSpace(name, nameof(name));
Title = title;
Culture = culture; Culture = culture;
FormUser = formUser; FormUser = formUser;

2
aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NullNotificationTemplateStore.cs

@ -9,7 +9,7 @@ public class NullNotificationTemplateStore : INotificationTemplateStore, ISingle
{ {
public readonly static INotificationTemplateStore Instance = new NullNotificationTemplateStore(); public readonly static INotificationTemplateStore Instance = new NullNotificationTemplateStore();
public Task<string> GetOrNullAsync(string templateName, string culture = null, CancellationToken cancellationToken = default) public Task<string> GetContentOrNullAsync(string templateName, string culture = null, CancellationToken cancellationToken = default)
{ {
return Task.FromResult<string>(null); return Task.FromResult<string>(null);
} }

5
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationSendDto.cs

@ -1,5 +1,6 @@
using LINGYUN.Abp.Notifications; using LINGYUN.Abp.Notifications;
using System; using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace LINGYUN.Abp.MessageService.Notifications namespace LINGYUN.Abp.MessageService.Notifications
@ -10,7 +11,9 @@ namespace LINGYUN.Abp.MessageService.Notifications
[StringLength(NotificationConsts.MaxNameLength)] [StringLength(NotificationConsts.MaxNameLength)]
public string Name { get; set; } public string Name { get; set; }
public NotificationData Data { get; set; } = new NotificationData(); public Dictionary<string, object> Data { get; set; } = new Dictionary<string, object>();
public string Culture { get; set; }
public Guid? ToUserId { get; set; } public Guid? ToUserId { get; set; }

10
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationTemplateDto.cs

@ -0,0 +1,10 @@
namespace LINGYUN.Abp.MessageService.Notifications;
public class NotificationTemplateDto
{
public string Name { get; set; }
public string Description { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public string Culture { get; set; }
}

11
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationTemplateGetInput.cs

@ -0,0 +1,11 @@
using System.ComponentModel.DataAnnotations;
namespace LINGYUN.Abp.MessageService.Notifications;
public class NotificationTemplateGetInput
{
[Required]
public string Name { get; set; }
public string Culture { get; set; }
}

19
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationTemplateSetInput.cs

@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Validation;
namespace LINGYUN.Abp.MessageService.Notifications;
public class NotificationTemplateSetInput
{
[Required]
[DynamicStringLength(typeof(NotificationTemplateConsts), nameof(NotificationTemplateConsts.MaxNameLength))]
public string Name { get; set; }
[Required]
[DynamicStringLength(typeof(NotificationTemplateConsts), nameof(NotificationTemplateConsts.MaxCultureLength))]
public string Culture { get; set; }
[Required]
[DynamicStringLength(typeof(NotificationTemplateConsts), nameof(NotificationTemplateConsts.MaxContentLength))]
public string Content { get; set; }
}

9
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/INotificationAppService.cs

@ -1,9 +1,16 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
namespace LINGYUN.Abp.MessageService.Notifications namespace LINGYUN.Abp.MessageService.Notifications
{ {
public interface INotificationAppService public interface INotificationAppService
{ {
Task<NotificationTemplateDto> SetTemplateAsync(NotificationTemplateSetInput input);
Task<NotificationTemplateDto> GetTemplateAsync(NotificationTemplateGetInput input);
Task<ListResultDto<NotificationTemplateDto>> GetAssignableTemplatesAsync();
Task SendAsync(NotificationSendDto input); Task SendAsync(NotificationSendDto input);
} }
} }

2
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/AbpMessageServiceApplicationAutoMapperProfile.cs

@ -23,6 +23,8 @@ namespace LINGYUN.Abp.MessageService
} }
return new NotificationData(); return new NotificationData();
})); }));
CreateMap<Notifications.NotificationTemplate, NotificationTemplateDto>();
} }
} }
} }

16
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/MyNotificationAppService.cs

@ -31,22 +31,6 @@ namespace LINGYUN.Abp.MessageService.Notifications
NotificationDefinitionManager = notificationDefinitionManager; NotificationDefinitionManager = notificationDefinitionManager;
} }
public async virtual Task SendNofiterAsync(NotificationSendDto input)
{
UserIdentifier user = null;
if (input.ToUserId.HasValue)
{
user = new UserIdentifier(input.ToUserId.Value, input.ToUserName);
}
await NotificationSender
.SendNofiterAsync(
input.Name,
input.Data,
user,
CurrentTenant.Id,
input.Severity);
}
public async virtual Task MarkReadStateAsync(NotificationMarkReadStateInput input) public async virtual Task MarkReadStateAsync(NotificationMarkReadStateInput input)
{ {
await NotificationStore.ChangeUserNotificationsReadStateAsync( await NotificationStore.ChangeUserNotificationsReadStateAsync(

114
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/NotificationAppService.cs

@ -1,35 +1,137 @@
using LINGYUN.Abp.Notifications; using LINGYUN.Abp.Notifications;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.TextTemplating;
namespace LINGYUN.Abp.MessageService.Notifications namespace LINGYUN.Abp.MessageService.Notifications
{ {
[Authorize] [Authorize]
public class NotificationAppService : ApplicationService, INotificationAppService public class NotificationAppService : ApplicationService, INotificationAppService
{ {
protected ITemplateContentProvider TemplateContentProvider { get; }
protected INotificationSender NotificationSender { get; } protected INotificationSender NotificationSender { get; }
protected INotificationDefinitionManager NotificationDefinitionManager { get; }
protected INotificationTemplateRepository NotificationTemplateRepository { get; }
public NotificationAppService( public NotificationAppService(
INotificationSender notificationSender) INotificationSender notificationSender,
ITemplateContentProvider templateContentProvider,
INotificationDefinitionManager notificationDefinitionManager,
INotificationTemplateRepository notificationTemplateRepository)
{ {
NotificationSender = notificationSender; NotificationSender = notificationSender;
TemplateContentProvider = templateContentProvider;
NotificationDefinitionManager = notificationDefinitionManager;
NotificationTemplateRepository = notificationTemplateRepository;
}
public async virtual Task<NotificationTemplateDto> SetTemplateAsync(NotificationTemplateSetInput input)
{
var notification = GetNotificationDefinition(input.Name);
var template = await NotificationTemplateRepository.GetByNameAsync(input.Name, input.Culture);
if (template == null)
{
template = new NotificationTemplate(
GuidGenerator.Create(),
notification.Name,
notification.DisplayName.Localize(StringLocalizerFactory),
input.Content,
input.Culture,
notification.Description?.Localize(StringLocalizerFactory));
template = await NotificationTemplateRepository.InsertAsync(template);
}
else
{
template.SetContent(input.Content);
await NotificationTemplateRepository.UpdateAsync(template);
}
await CurrentUnitOfWork.SaveChangesAsync();
return ObjectMapper.Map<NotificationTemplate, NotificationTemplateDto>(template);
} }
public virtual async Task SendAsync(NotificationSendDto input) public async virtual Task<NotificationTemplateDto> GetTemplateAsync(NotificationTemplateGetInput input)
{
var notification = GetNotificationDefinition(input.Name);
var culture = input.Culture ?? CultureInfo.CurrentCulture.Name;
var content = await TemplateContentProvider.GetContentOrNullAsync(notification.Name, culture);
return new NotificationTemplateDto
{
Culture = culture,
Content = content,
Name = notification.Name,
Title = notification.DisplayName.Localize(StringLocalizerFactory),
Description = notification.Description?.Localize(StringLocalizerFactory),
};
}
public virtual Task<ListResultDto<NotificationTemplateDto>> GetAssignableTemplatesAsync()
{
var templates = new List<NotificationTemplateDto>();
var notifications = NotificationDefinitionManager.GetAll().Where(n => n.Template != null);
foreach (var notification in notifications)
{
templates.Add(
new NotificationTemplateDto
{
Name = notification.Name,
Culture = CultureInfo.CurrentCulture.Name,
Title = notification.DisplayName.Localize(StringLocalizerFactory),
Description = notification.Description?.Localize(StringLocalizerFactory),
});
}
return Task.FromResult(new ListResultDto<NotificationTemplateDto>(templates));
}
public async virtual Task SendAsync(NotificationSendDto input)
{ {
var notification = GetNotificationDefinition(input.Name);
UserIdentifier user = null; UserIdentifier user = null;
if (input.ToUserId.HasValue) if (input.ToUserId.HasValue)
{ {
user = new UserIdentifier(input.ToUserId.Value, input.ToUserName); user = new UserIdentifier(input.ToUserId.Value, input.ToUserName);
} }
await NotificationSender await NotificationSender
.SendNofiterAsync( .SendNofiterAsync(
input.Name, name: input.Name,
input.Data, template: new Abp.Notifications.NotificationTemplate(
user, notification.Name,
culture: input.Culture ?? CultureInfo.CurrentCulture.Name,
formUser: CurrentUser.Name ?? CurrentUser.UserName,
data: input.Data),
user: user,
CurrentTenant.Id, CurrentTenant.Id,
input.Severity); input.Severity);
} }
protected virtual NotificationDefinition GetNotificationDefinition(string name)
{
var notification = NotificationDefinitionManager.GetOrNull(name);
if (notification == null || notification.Template == null)
{
throw new BusinessException(
MessageServiceErrorCodes.NotificationTemplateNotFound,
$"The notification template {name} does not exist!")
.WithData("Name", name);
}
return notification;
}
} }
} }

1
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Localization/Resources/en.json

@ -18,6 +18,7 @@
"LINGYUN.Abp.Message:03404": "Sending the message failed: the user does not exist or is deactivated!", "LINGYUN.Abp.Message:03404": "Sending the message failed: the user does not exist or is deactivated!",
"LINGYUN.Abp.Message:03410": "Users refuse to add friends", "LINGYUN.Abp.Message:03410": "Users refuse to add friends",
"LINGYUN.Abp.Message:03411": "The other party is already your friend or has sent an authentication request. The operation cannot be repeated!", "LINGYUN.Abp.Message:03411": "The other party is already your friend or has sent an authentication request. The operation cannot be repeated!",
"LINGYUN.Abp.Message:05404": "The notification template does not exist!",
"MarkSelectedAsRead": "Mark selected as read", "MarkSelectedAsRead": "Mark selected as read",
"MarkAs": "Mark as", "MarkAs": "Mark as",
"Read": "Read", "Read": "Read",

1
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Localization/Resources/zh-Hans.json

@ -18,6 +18,7 @@
"LINGYUN.Abp.Message:03404": "发送消息失败: 用户不存在或已注销账号!", "LINGYUN.Abp.Message:03404": "发送消息失败: 用户不存在或已注销账号!",
"LINGYUN.Abp.Message:03410": "用户拒绝添加好友", "LINGYUN.Abp.Message:03410": "用户拒绝添加好友",
"LINGYUN.Abp.Message:03411": "对方已是您的好友或已发送验证请求,不能重复操作!", "LINGYUN.Abp.Message:03411": "对方已是您的好友或已发送验证请求,不能重复操作!",
"LINGYUN.Abp.Message:05404": "通知模板不存在!",
"MarkSelectedAsRead": "标记选中已读", "MarkSelectedAsRead": "标记选中已读",
"MarkAs": "标记为", "MarkAs": "标记为",
"Read": "已读", "Read": "已读",

4
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/MessageServiceErrorCodes.cs

@ -99,5 +99,9 @@
/// 你需要验证问题才能添加好友 /// 你需要验证问题才能添加好友
/// </summary> /// </summary>
public const string YouNeedValidationQuestingByAddFriend = Namespace + ":03302"; public const string YouNeedValidationQuestingByAddFriend = Namespace + ":03302";
/// <summary>
/// 通知模板不存在!
/// </summary>
public const string NotificationTemplateNotFound = Namespace + ":05404";
} }
} }

14
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN/Abp/MessageService/Notifications/NotificationTemplateConsts.cs

@ -0,0 +1,14 @@
namespace LINGYUN.Abp.MessageService.Notifications;
public static class NotificationTemplateConsts
{
public static int MaxNameLength { get; set; } = 100;
public static int MaxTitleLength { get; set; } = 100;
public static int MaxContentLength { get; set; } = 1024 * 1024;
public static int MaxDescriptionLength { get; set; } = 255;
public static int MaxCultureLength { get; set; } = 30;
}

19
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs

@ -17,6 +17,25 @@ namespace LINGYUN.Abp.MessageService.Mapper
{ {
public MessageServiceDomainAutoMapperProfile() public MessageServiceDomainAutoMapperProfile()
{ {
CreateMap<Notification, NotificationInfo>()
.ForMember(dto => dto.Id, map => map.MapFrom(src => src.NotificationId.ToString()))
.ForMember(dto => dto.Name, map => map.MapFrom(src => src.NotificationName))
.ForMember(dto => dto.Lifetime, map => map.Ignore())
.ForMember(dto => dto.Type, map => map.MapFrom(src => src.Type))
.ForMember(dto => dto.Severity, map => map.MapFrom(src => src.Severity))
.ForMember(dto => dto.CreationTime, map => map.MapFrom(src => src.CreationTime))
.ForMember(dto => dto.Data, map => map.MapFrom((src, nfi) =>
{
var dataType = Type.GetType(src.NotificationTypeName);
var data = Activator.CreateInstance(dataType);
if (data is NotificationData notificationData)
{
notificationData.ExtraProperties = src.ExtraProperties;
return notificationData;
}
return new NotificationData();
}));
CreateMap<UserNotificationInfo, NotificationInfo>() CreateMap<UserNotificationInfo, NotificationInfo>()
.ForMember(dto => dto.Id, map => map.MapFrom(src => src.Id.ToString())) .ForMember(dto => dto.Id, map => map.MapFrom(src => src.Id.ToString()))
.ForMember(dto => dto.Name, map => map.MapFrom(src => src.Name)) .ForMember(dto => dto.Name, map => map.MapFrom(src => src.Name))

4
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/AbpMessageServiceNotificationDefinitionProvider.cs

@ -26,7 +26,7 @@ namespace LINGYUN.Abp.MessageService.Notifications
.WithProviders( .WithProviders(
NotificationProviderNames.SignalR, NotificationProviderNames.SignalR,
NotificationProviderNames.Emailing) NotificationProviderNames.Emailing)
.WithProperty("Template", "NewTenantRegisterd"); .WithTemplate(typeof(MessageServiceResource));
var usersGroup = context.AddGroup( var usersGroup = context.AddGroup(
UserNotificationNames.GroupName, UserNotificationNames.GroupName,
@ -42,7 +42,7 @@ namespace LINGYUN.Abp.MessageService.Notifications
.WithProviders( .WithProviders(
NotificationProviderNames.SignalR, NotificationProviderNames.SignalR,
NotificationProviderNames.Emailing) NotificationProviderNames.Emailing)
.WithProperty("Template", "WelcomeToApplication"); .WithTemplate(typeof(MessageServiceResource));
var imGroup = context.AddGroup( var imGroup = context.AddGroup(
MessageServiceNotificationNames.IM.GroupName, MessageServiceNotificationNames.IM.GroupName,

11
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/INotificationTemplateRepository.cs

@ -0,0 +1,11 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
namespace LINGYUN.Abp.MessageService.Notifications;
public interface INotificationTemplateRepository : IBasicRepository<NotificationTemplate, Guid>
{
Task<NotificationTemplate> GetByNameAsync(string name, string culture = null, CancellationToken cancellationToken = default);
}

32
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationTemplate.cs

@ -1,11 +1,37 @@
using System; using System;
using System.Collections.Generic; using Volo.Abp;
using System.Text;
using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;
namespace LINGYUN.Abp.MessageService.Notifications; namespace LINGYUN.Abp.MessageService.Notifications;
public class NotificationTemplate : AuditedAggregateRoot<Guid> public class NotificationTemplate : AuditedEntity<Guid>, IMultiTenant
{ {
public virtual Guid? TenantId { get; protected set; }
public virtual string Name { get; private set; }
public virtual string Description { get; private set; }
public virtual string Title { get; private set; }
public virtual string Content { get; private set; }
public virtual string Culture { get; private set; }
protected NotificationTemplate() { }
public NotificationTemplate(
Guid id,
string name,
string title,
string content,
string culture,
string description = null)
: base(id)
{
Name = Check.NotNullOrWhiteSpace(name, nameof(name), NotificationTemplateConsts.MaxNameLength);
Title = Check.NotNullOrWhiteSpace(title, nameof(title), NotificationTemplateConsts.MaxTitleLength);
Content = Check.NotNullOrWhiteSpace(content, nameof(content), NotificationTemplateConsts.MaxContentLength);
Culture = Check.NotNullOrWhiteSpace(culture, nameof(culture), NotificationTemplateConsts.MaxCultureLength);
Description = Check.Length(description, nameof(description), NotificationTemplateConsts.MaxDescriptionLength);
}
public void SetContent(string content)
{
Content = Check.NotNullOrWhiteSpace(content, nameof(content), NotificationTemplateConsts.MaxContentLength);
}
} }

31
aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationTemplateStore.cs

@ -0,0 +1,31 @@
using LINGYUN.Abp.Notifications;
using Microsoft.Extensions.DependencyInjection;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
namespace LINGYUN.Abp.MessageService.Notifications;
[Dependency(ServiceLifetime.Transient, ReplaceServices = true)]
[ExposeServices(typeof(INotificationTemplateStore))]
public class NotificationTemplateStore : INotificationTemplateStore
{
protected INotificationTemplateRepository NotificationTemplateRepository { get; }
public NotificationTemplateStore(
INotificationTemplateRepository notificationTemplateRepository)
{
NotificationTemplateRepository = notificationTemplateRepository;
}
public async virtual Task<string> GetContentOrNullAsync(string templateName, string culture = null, CancellationToken cancellationToken = default)
{
var template = await NotificationTemplateRepository.GetByNameAsync(
templateName,
culture ?? CultureInfo.CurrentCulture.Name,
cancellationToken);
return template?.Content;
}
}

2
aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/AbpMessageServiceEntityFrameworkCoreModule.cs

@ -18,6 +18,8 @@ namespace LINGYUN.Abp.MessageService.EntityFrameworkCore
context.Services.AddAbpDbContext<MessageServiceDbContext>(options => context.Services.AddAbpDbContext<MessageServiceDbContext>(options =>
{ {
options.AddRepository<Notification, EfCoreNotificationRepository>(); options.AddRepository<Notification, EfCoreNotificationRepository>();
options.AddRepository<NotificationTemplate, EfCoreNotificationTemplateRepository>();
options.AddRepository<UserNotification, EfCoreUserNotificationRepository>(); options.AddRepository<UserNotification, EfCoreUserNotificationRepository>();
options.AddRepository<UserSubscribe, EfCoreUserSubscribeRepository>(); options.AddRepository<UserSubscribe, EfCoreUserSubscribeRepository>();

17
aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs

@ -34,6 +34,23 @@ namespace LINGYUN.Abp.MessageService.EntityFrameworkCore
b.HasIndex(p => new { p.TenantId, p.NotificationName }); b.HasIndex(p => new { p.TenantId, p.NotificationName });
}); });
builder.Entity<NotificationTemplate>(b =>
{
b.ToTable(options.TablePrefix + "NotificationTemplates", options.Schema);
b.Property(p => p.Name).HasMaxLength(NotificationTemplateConsts.MaxNameLength).IsRequired();
b.Property(p => p.Title).HasMaxLength(NotificationTemplateConsts.MaxTitleLength).IsRequired();
b.Property(p => p.Content).HasMaxLength(NotificationTemplateConsts.MaxContentLength).IsRequired();
b.Property(p => p.Culture).HasMaxLength(NotificationTemplateConsts.MaxCultureLength).IsRequired();
b.Property(p => p.Description).HasMaxLength(NotificationTemplateConsts.MaxDescriptionLength);
b.ConfigureByConvention();
b.HasIndex(p => new { p.TenantId, p.Name })
.HasDatabaseName("IX_Tenant_Notification_Template_Name");
});
builder.Entity<UserNotification>(b => builder.Entity<UserNotification>(b =>
{ {
b.ToTable(options.TablePrefix + "UserNotifications", options.Schema); b.ToTable(options.TablePrefix + "UserNotifications", options.Schema);

32
aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationTemplateRepository.cs

@ -0,0 +1,32 @@
using LINGYUN.Abp.MessageService.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
namespace LINGYUN.Abp.MessageService.Notifications;
public class EfCoreNotificationTemplateRepository :
EfCoreRepository<IMessageServiceDbContext, NotificationTemplate, Guid>,
INotificationTemplateRepository,
ITransientDependency
{
public EfCoreNotificationTemplateRepository(
IDbContextProvider<IMessageServiceDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
public async virtual Task<NotificationTemplate> GetByNameAsync(string name, string culture = null, CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.Where(x => x.Name.Equals(name))
.WhereIf(!culture.IsNullOrWhiteSpace(), x => x.Culture.Equals(culture))
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
}
}

29
aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN/Abp/MessageService/Notifications/NotificationController.cs

@ -1,10 +1,13 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
namespace LINGYUN.Abp.MessageService.Notifications namespace LINGYUN.Abp.MessageService.Notifications
{ {
[Authorize]
[RemoteService(Name = AbpMessageServiceConsts.RemoteServiceName)] [RemoteService(Name = AbpMessageServiceConsts.RemoteServiceName)]
[Route("api/notifilers")] [Route("api/notifilers")]
public class NotificationController : AbpController, INotificationAppService public class NotificationController : AbpController, INotificationAppService
@ -18,9 +21,31 @@ namespace LINGYUN.Abp.MessageService.Notifications
} }
[HttpPost] [HttpPost]
public virtual async Task SendAsync(NotificationSendDto input) public async virtual Task SendAsync(NotificationSendDto input)
{ {
await NotificationAppService.SendAsync(input); await NotificationAppService.SendAsync(input);
} }
[HttpPost]
[Route("templates")]
public async virtual Task<NotificationTemplateDto> SetTemplateAsync(NotificationTemplateSetInput input)
{
return await NotificationAppService.SetTemplateAsync(input);
}
[HttpGet]
[Route("templates/{Name}")]
[Route("templates/{Culture}/{Name}")]
public async virtual Task<NotificationTemplateDto> GetTemplateAsync(NotificationTemplateGetInput input)
{
return await NotificationAppService.GetTemplateAsync(input);
}
[HttpGet]
[Route("templates")]
public async virtual Task<ListResultDto<NotificationTemplateDto>> GetAssignableTemplatesAsync()
{
return await NotificationAppService.GetAssignableTemplatesAsync();
}
} }
} }

67
aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/RealtimeMessageTemplateProvider.cs

@ -1,5 +1,8 @@
using Volo.Abp.TextTemplating; using LINGYUN.Abp.ExceptionHandling.Notifications;
using Volo.Abp.MultiTenancy;
using Volo.Abp.TextTemplating;
using Volo.Abp.TextTemplating.Scriban; using Volo.Abp.TextTemplating.Scriban;
using Volo.Abp.Users;
namespace LY.MicroService.RealtimeMessage.Emailing; namespace LY.MicroService.RealtimeMessage.Emailing;
@ -8,6 +11,38 @@ public class RealtimeMessageTemplateProvider : TemplateDefinitionProvider
public override void Define(ITemplateDefinitionContext context) public override void Define(ITemplateDefinitionContext context)
{ {
context.Add(CreateEmailTemplate()); context.Add(CreateEmailTemplate());
ReplaceDefaultTemplatePath(context);
}
protected virtual void ReplaceDefaultTemplatePath(ITemplateDefinitionContext context)
{
var exceptionTemplate = context.GetOrNull(AbpExceptionHandlingNotificationNames.NotificationName);
if (exceptionTemplate != null)
{
exceptionTemplate
.WithScribanEngine()
.WithVirtualFilePath("/Emailing/Templates/ExceptionNotifier", isInlineLocalized: false)
.Layout = "EmailNotifierLayout";
}
var tenantRegisterdTemplate = context.GetOrNull(TenantNotificationNames.NewTenantRegistered);
if (tenantRegisterdTemplate != null)
{
tenantRegisterdTemplate
.WithScribanEngine()
.WithVirtualFilePath("/Emailing/Templates/NewTenantRegisterd", isInlineLocalized: false)
.Layout = "EmailNotifierLayout";
}
var welcomeToApplicationTemplate = context.GetOrNull(UserNotificationNames.WelcomeToApplication);
if (welcomeToApplicationTemplate != null)
{
welcomeToApplicationTemplate
.WithScribanEngine()
.WithVirtualFilePath("/Emailing/Templates/WelcomeToApplication", isInlineLocalized: false)
.Layout = "EmailNotifierLayout";
}
} }
protected virtual TemplateDefinition[] CreateEmailTemplate() protected virtual TemplateDefinition[] CreateEmailTemplate()
@ -18,34 +53,8 @@ public class RealtimeMessageTemplateProvider : TemplateDefinitionProvider
name: "EmailNotifierLayout", name: "EmailNotifierLayout",
defaultCultureName: "en", defaultCultureName: "en",
isLayout: true) isLayout: true)
.WithScribanEngine() .WithScribanEngine()
.WithVirtualFilePath( .WithVirtualFilePath( "/Emailing/Templates/layout.tpl", isInlineLocalized: true),
"/Emailing/Templates/layout.tpl",
isInlineLocalized: false),
new TemplateDefinition(
name: "ExceptionNotifier",
defaultCultureName: "en",
layout: "EmailNotifierLayout")
.WithScribanEngine()
.WithVirtualFilePath(
"/Emailing/Templates/ExceptionNotifier",
isInlineLocalized: false),
new TemplateDefinition(
"NewTenantRegisterd",
defaultCultureName: "en",
layout: "EmailNotifierLayout")
.WithScribanEngine()
.WithVirtualFilePath(
"/Emailing/Templates/NewTenantRegisterd",
isInlineLocalized: false),
new TemplateDefinition(
"WelcomeToApplication",
defaultCultureName: "en",
layout: "EmailNotifierLayout")
.WithScribanEngine()
.WithVirtualFilePath(
"/Emailing/Templates/WelcomeToApplication",
isInlineLocalized: false),
}; };
} }
} }

14
aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/ExceptionNotifier/en.tpl

@ -1,17 +1,17 @@
<table width="95%" cellpadding="0" cellspacing="0" style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif"> <table width="95%" cellpadding="0" cellspacing="0" style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif">
<tr> <tr>
<td> <td>
<br /> <b><font color="#0B610B">{{ header }}</font></b> <br /> <b><font color="#0B610B">{{ model.header }}</font></b>
<hr size="2" width="100%" align="center" /> <hr size="2" width="100%" align="center" />
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<ul> <ul>
<li>Type &nbsp;:&nbsp;{{ type }}</li> <li>Type &nbsp;:&nbsp;{{ model.type }}</li>
<li>Message &nbsp;:&nbsp;{{ message }}</li> <li>Message &nbsp;:&nbsp;{{ model.message }}</li>
<li>Alarm level&nbsp;:&nbsp;{{ loglevel }}</li> <li>Alarm level&nbsp;:&nbsp;{{ model.loglevel }}</li>
<li>TriggerTime&nbsp;:&nbsp;{{ createTime }}</li> <li>TriggerTime&nbsp;:&nbsp;{{ creationTime }}</li>
</ul> </ul>
</td> </td>
</tr> </tr>
@ -23,14 +23,14 @@
</tr> </tr>
<tr> <tr>
<td> <td>
<pre style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif">{{ stacktrace }}</pre> <pre style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif">{{ model.stackTrace }}</pre>
<br /> <br />
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<br /> <br />
<b style="float: right"><font color="#0B610B">{{ footer }}</font></b> <b style="float: right"><font color="#0B610B">{{ model.footer }}</font></b>
<hr size="2" width="100%" align="center" /> <hr size="2" width="100%" align="center" />
</td> </td>
</tr> </tr>

15
aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/ExceptionNotifier/zh-Hans.tpl

@ -1,17 +1,18 @@
<table width="95%" cellpadding="0" cellspacing="0" style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif"> <table width="95%" cellpadding="0" cellspacing="0" style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif">
<tr> <tr>
<td> <td>
<br /> <b><font color="#0B610B">{{ header }}</font></b> <br /> <b><font color="#0B610B">{{ model.header }}</font></b>
<hr size="2" width="100%" align="center" /> <hr size="2" width="100%" align="center" />
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<ul> <ul>
<li>异常类型&nbsp;:&nbsp;{{ title }}</li> <li>异常类型&nbsp;:&nbsp;{{ model.title }}</li>
<li>异常信息&nbsp;:&nbsp;{{ message }}</li> <li>异常信息&nbsp;:&nbsp;{{ model.message }}</li>
<li>告警级别&nbsp;:&nbsp;{{ loglevel }}</li> <li>告警级别&nbsp;:&nbsp;{{ model.loglevel }}</li>
<li>触发时间&nbsp;:&nbsp;{{ createTime }}</li> <!-- 全局变量 creationTime -->
<li>触发时间&nbsp;:&nbsp;{{ creationTime }}</li>
</ul> </ul>
</td> </td>
</tr> </tr>
@ -23,14 +24,14 @@
</tr> </tr>
<tr> <tr>
<td> <td>
<pre style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif">{{ stacktrace }}</pre> <pre style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif">{{ model.stackTrace }}</pre>
<br /> <br />
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<br /> <br />
<b style="float: right"><font color="#0B610B">{{ footer }}</font></b> <b style="float: right"><font color="#0B610B">{{ model.footer }}</font></b>
<hr size="2" width="100%" align="center" /> <hr size="2" width="100%" align="center" />
</td> </td>
</tr> </tr>

2
aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/NewTenantRegisterd/en.tpl

@ -1 +1 @@
<h3>A new tenant {{name}} has been created.</h3> <h3>A new tenant {{model.name}} has been created.</h3>

2
aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/NewTenantRegisterd/zh-Hans.tpl

@ -1 +1 @@
<h3>一个新的租户 {{name}} 已建立,切换租户开始! </h3> <h3>一个新的租户 {{model.name}} 已建立,切换租户开始! </h3>

2
aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/WelcomeToApplication/en.tpl

@ -1 +1 @@
<h3>{{user}}, Welcome to my application!</h3> <h3>{{model.name}}, Welcome to my application!</h3>

2
aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/WelcomeToApplication/zh-Hans.tpl

@ -1 +1 @@
<h3>{{user}}, Welcome to my application!</h3> <h3>{{model.name}}, 欢迎您的加入!</h3>

24
aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/NotificationEventHandler.cs

@ -118,23 +118,28 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed
var notificationInfo = new NotificationInfo var notificationInfo = new NotificationInfo
{ {
Name = notification.Name, Name = notification.Name,
CreationTime = eventData.CreationTime, TenantId = eventData.TenantId,
Severity = eventData.Severity, Severity = eventData.Severity,
Type = notification.NotificationType,
CreationTime = eventData.CreationTime,
Lifetime = notification.NotificationLifetime, Lifetime = notification.NotificationLifetime,
TenantId = eventData.TenantId,
Type = notification.NotificationType
}; };
notificationInfo.SetId(eventData.Id); notificationInfo.SetId(eventData.Id);
var title = eventData.Data.Title; var title = notification.DisplayName.Localize(StringLocalizerFactory);
if (title.IsNullOrWhiteSpace())
{
title = notification.DisplayName.Localize(StringLocalizerFactory);
}
var message = await TemplateRenderer.RenderAsync( var message = await TemplateRenderer.RenderAsync(
templateName: eventData.Data.Name, templateName: eventData.Data.Name,
model: eventData.Data.ExtraProperties,
cultureName: eventData.Data.Culture, cultureName: eventData.Data.Culture,
globalContext: eventData.Data.ExtraProperties); globalContext: new Dictionary<string, object>
{
{ "notification", notification.Name },
{ "formUser", eventData.Data.FormUser },
{ "notificationId", eventData.Id },
{ "title", title.ToString() },
{ "creationTime", eventData.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") },
});
var notificationData = new NotificationData(); var notificationData = new NotificationData();
notificationData.WriteStandardData( notificationData.WriteStandardData(
@ -142,6 +147,7 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed
message: message, message: message,
createTime: eventData.CreationTime, createTime: eventData.CreationTime,
formUser: eventData.Data.FormUser); formUser: eventData.Data.FormUser);
notificationData.ExtraProperties.AddIfNotContains(eventData.Data.ExtraProperties);
notificationInfo.Data = notificationData; notificationInfo.Data = notificationData;

38
aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/TenantSynchronizer.cs

@ -81,34 +81,22 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed
tenantAdminUserIdentifier, tenantAdminUserIdentifier,
TenantNotificationNames.NewTenantRegistered); TenantNotificationNames.NewTenantRegistered);
var notificationData = new NotificationData(); Logger.LogInformation("publish new tenant notification..");
notificationData.TrySetData("name", eventData.Name); await NotificationSender.SendNofiterAsync(
notificationData.WriteLocalizedData( TenantNotificationNames.NewTenantRegistered,
new LocalizableStringInfo( new NotificationTemplate(
LocalizationResourceNameAttribute.GetName(typeof(MessageServiceResource)), TenantNotificationNames.NewTenantRegistered,
"NewTenantRegisteredNotificationTitle", formUser: eventData.AdminEmailAddress,
new Dictionary<object, object> data: new Dictionary<string, object>
{
{ "Name", eventData.Name },
}),
new LocalizableStringInfo(
LocalizationResourceNameAttribute.GetName(typeof(MessageServiceResource)),
"NewTenantRegisteredNotificationMessage",
new Dictionary<object, object>
{ {
{ "Name", eventData.Name} { "name", eventData.Name },
{ "email", eventData.AdminEmailAddress },
{ "id", eventData.Id },
}), }),
DateTime.Now, eventData.AdminEmailAddress); tenantAdminUserIdentifier,
eventData.Id,
NotificationSeverity.Success);
Logger.LogInformation("publish new tenant notification..");
// 发布租户创建通知
await NotificationSender
.SendNofiterAsync(
TenantNotificationNames.NewTenantRegistered,
notificationData,
tenantAdminUserIdentifier,
eventData.Id,
NotificationSeverity.Success);
Logger.LogInformation("tenant administrator subscribes to new tenant events.."); Logger.LogInformation("tenant administrator subscribes to new tenant events..");
} }
catch(Exception ex) catch(Exception ex)

40
aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Local/UserCreateSendWelcomeEventHandler.cs

@ -1,13 +1,10 @@
using LINGYUN.Abp.MessageService.Localization; using LINGYUN.Abp.Notifications;
using LINGYUN.Abp.Notifications;
using LINGYUN.Abp.RealTime.Localization;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities.Events; using Volo.Abp.Domain.Entities.Events;
using Volo.Abp.EventBus; using Volo.Abp.EventBus;
using Volo.Abp.Localization;
using Volo.Abp.Users; using Volo.Abp.Users;
namespace LY.MicroService.RealtimeMessage.EventBus namespace LY.MicroService.RealtimeMessage.EventBus
@ -31,35 +28,18 @@ namespace LY.MicroService.RealtimeMessage.EventBus
// 订阅用户欢迎消息 // 订阅用户欢迎消息
await SubscribeInternalNotifers(userIdentifer, eventData.Entity.TenantId); await SubscribeInternalNotifers(userIdentifer, eventData.Entity.TenantId);
var userWelcomeNotifictionData = new NotificationData(); await _notificationSender.SendNofiterAsync(
UserNotificationNames.WelcomeToApplication,
userWelcomeNotifictionData.TrySetData("user", eventData.Entity.UserName); new NotificationTemplate(
userWelcomeNotifictionData UserNotificationNames.WelcomeToApplication,
.WriteLocalizedData( formUser: eventData.Entity.UserName,
new LocalizableStringInfo( data: new Dictionary<string, object>
LocalizationResourceNameAttribute.GetName(typeof(MessageServiceResource)),
"WelcomeToApplicationFormUser",
new Dictionary<object, object>
{
{ "User", eventData.Entity.UserName }
}),
new LocalizableStringInfo(
LocalizationResourceNameAttribute.GetName(typeof(MessageServiceResource)),
"WelcomeToApplicationFormUser",
new Dictionary<object, object>
{ {
{ "User", eventData.Entity.UserName } { "name", eventData.Entity.UserName },
}), }),
DateTime.Now, eventData.Entity.UserName);
await _notificationSender
.SendNofiterAsync(
UserNotificationNames.WelcomeToApplication,
userWelcomeNotifictionData,
userIdentifer, userIdentifer,
eventData.Entity.TenantId, eventData.Entity.Id,
NotificationSeverity.Info NotificationSeverity.Info);
);
} }
private async Task SubscribeInternalNotifers(UserIdentifier userIdentifer, Guid? tenantId = null) private async Task SubscribeInternalNotifers(UserIdentifier userIdentifer, Guid? tenantId = null)

3
aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj

@ -9,7 +9,7 @@
<EmbeddedResource Include="Localization\Resources\*.json" /> <EmbeddedResource Include="Localization\Resources\*.json" />
<EmbeddedResource Include="Emailing\Templates\*.tpl" /> <EmbeddedResource Include="Emailing\Templates\*.tpl" />
<EmbeddedResource Include="Emailing\Templates\ExceptionNotifier\*.tpl" /> <EmbeddedResource Include="Emailing\Templates\ExceptionNotifier\*.tpl" />
<EmbeddedResource Include="Emailing\Templates\NewTenantRegisterd*.tpl" /> <EmbeddedResource Include="Emailing\Templates\NewTenantRegisterd\*.tpl" />
<EmbeddedResource Include="Emailing\Templates\WelcomeToApplication\*.tpl" /> <EmbeddedResource Include="Emailing\Templates\WelcomeToApplication\*.tpl" />
</ItemGroup> </ItemGroup>
@ -55,6 +55,7 @@
<ProjectReference Include="..\..\modules\common\LINGYUN.Abp.Notifications.Emailing\LINGYUN.Abp.Notifications.Emailing.csproj" /> <ProjectReference Include="..\..\modules\common\LINGYUN.Abp.Notifications.Emailing\LINGYUN.Abp.Notifications.Emailing.csproj" />
<ProjectReference Include="..\..\modules\common\LINGYUN.Abp.Notifications.SignalR\LINGYUN.Abp.Notifications.SignalR.csproj" /> <ProjectReference Include="..\..\modules\common\LINGYUN.Abp.Notifications.SignalR\LINGYUN.Abp.Notifications.SignalR.csproj" />
<ProjectReference Include="..\..\modules\common\LINGYUN.Abp.Notifications.Sms\LINGYUN.Abp.Notifications.Sms.csproj" /> <ProjectReference Include="..\..\modules\common\LINGYUN.Abp.Notifications.Sms\LINGYUN.Abp.Notifications.Sms.csproj" />
<ProjectReference Include="..\..\modules\common\LINGYUN.Abp.Notifications.TextTemplating\LINGYUN.Abp.Notifications.TextTemplating.csproj" />
<ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.EntityFrameworkCore\LINGYUN.Abp.Identity.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.EntityFrameworkCore\LINGYUN.Abp.Identity.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.BackgroundTasks.Quartz\LINGYUN.Abp.BackgroundTasks.Quartz.csproj" /> <ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.BackgroundTasks.Quartz\LINGYUN.Abp.BackgroundTasks.Quartz.csproj" />
<ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.BackgroundTasks.ExceptionHandling\LINGYUN.Abp.BackgroundTasks.ExceptionHandling.csproj" /> <ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.BackgroundTasks.ExceptionHandling\LINGYUN.Abp.BackgroundTasks.ExceptionHandling.csproj" />

690
aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/20220624035652_Add-Entity-Notification-Template.Designer.cs

@ -0,0 +1,690 @@
// <auto-generated />
using System;
using LY.MicroService.RealtimeMessage.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Volo.Abp.EntityFrameworkCore;
#nullable disable
namespace LY.MicroService.RealtimeMessage.Migrations
{
[DbContext(typeof(RealtimeMessageMigrationsDbContext))]
[Migration("20220624035652_Add-Entity-Notification-Template")]
partial class AddEntityNotificationTemplate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql)
.HasAnnotation("ProductVersion", "6.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatCard", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<int>("Age")
.HasColumnType("int");
b.Property<string>("AvatarUrl")
.HasMaxLength(512)
.HasColumnType("varchar(512)");
b.Property<DateTime?>("Birthday")
.HasColumnType("datetime(6)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("Description")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<DateTime?>("LastOnlineTime")
.HasColumnType("datetime(6)");
b.Property<string>("NickName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<int>("Sex")
.HasColumnType("int");
b.Property<string>("Sign")
.HasMaxLength(30)
.HasColumnType("varchar(30)");
b.Property<int>("State")
.HasColumnType("int");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.Property<string>("UserName")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId");
b.ToTable("AppUserChatCards", (string)null);
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatFriend", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<bool>("Black")
.HasColumnType("tinyint(1)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("Description")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<bool>("DontDisturb")
.HasColumnType("tinyint(1)");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<Guid>("FrientId")
.HasColumnType("char(36)");
b.Property<bool>("IsStatic")
.HasColumnType("tinyint(1)");
b.Property<string>("RemarkName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<bool>("SpecialFocus")
.HasColumnType("tinyint(1)");
b.Property<byte>("Status")
.HasColumnType("tinyint unsigned");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId", "FrientId");
b.ToTable("AppUserChatFriends", (string)null);
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatSetting", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<bool>("AllowAddFriend")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowAnonymous")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowReceiveMessage")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowSendMessage")
.HasColumnType("tinyint(1)");
b.Property<bool>("RequireAddFriendValition")
.HasColumnType("tinyint(1)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId");
b.ToTable("AppUserChatSettings", (string)null);
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserMessage", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Content")
.IsRequired()
.HasMaxLength(1048576)
.HasColumnType("longtext");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<long>("MessageId")
.HasColumnType("bigint");
b.Property<Guid>("ReceiveUserId")
.HasColumnType("char(36)");
b.Property<string>("SendUserName")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<int>("Source")
.HasColumnType("int");
b.Property<sbyte>("State")
.HasColumnType("tinyint");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TenantId", "ReceiveUserId");
b.ToTable("AppUserMessages", (string)null);
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.ChatGroup", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("Address")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<Guid>("AdminUserId")
.HasColumnType("char(36)");
b.Property<bool>("AllowAnonymous")
.HasColumnType("tinyint(1)");
b.Property<bool>("AllowSendMessage")
.HasColumnType("tinyint(1)");
b.Property<string>("AvatarUrl")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("Description")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<int>("MaxUserCount")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("varchar(20)");
b.Property<string>("Notice")
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<string>("Tag")
.HasMaxLength(512)
.HasColumnType("varchar(512)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.HasKey("Id");
b.HasIndex("TenantId", "Name");
b.ToTable("AppChatGroups", (string)null);
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupChatBlack", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<Guid>("ShieldUserId")
.HasColumnType("char(36)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.HasKey("Id");
b.HasIndex("TenantId", "GroupId");
b.ToTable("AppGroupChatBlacks", (string)null);
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupMessage", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Content")
.IsRequired()
.HasMaxLength(1048576)
.HasColumnType("longtext");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<long>("MessageId")
.HasColumnType("bigint");
b.Property<string>("SendUserName")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<int>("Source")
.HasColumnType("int");
b.Property<sbyte>("State")
.HasColumnType("tinyint");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TenantId", "GroupId");
b.ToTable("AppGroupMessages", (string)null);
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserChatGroup", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<long>("GroupId")
.HasColumnType("bigint");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "GroupId", "UserId");
b.ToTable("AppUserChatGroups", (string)null);
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserGroupCard", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<bool>("IsAdmin")
.HasColumnType("tinyint(1)");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<string>("NickName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<DateTime?>("SilenceEnd")
.HasColumnType("datetime(6)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId");
b.ToTable("AppUserGroupCards", (string)null);
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.Notification", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<DateTime?>("ExpirationTime")
.HasColumnType("datetime(6)");
b.Property<string>("ExtraProperties")
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<long>("NotificationId")
.HasColumnType("bigint");
b.Property<string>("NotificationName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("NotificationTypeName")
.IsRequired()
.HasMaxLength(512)
.HasColumnType("varchar(512)");
b.Property<sbyte>("Severity")
.HasColumnType("tinyint");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TenantId", "NotificationName");
b.ToTable("AppNotifications", (string)null);
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.NotificationTemplate", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)");
b.Property<string>("Content")
.IsRequired()
.HasMaxLength(1048576)
.HasColumnType("longtext");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("Culture")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("varchar(30)");
b.Property<string>("Description")
.HasMaxLength(255)
.HasColumnType("varchar(255)");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.HasKey("Id");
b.HasIndex("TenantId", "Name")
.HasDatabaseName("IX_Tenant_Notification_Template_Name");
b.ToTable("AppNotificationTemplates", (string)null);
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.UserNotification", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<long>("NotificationId")
.HasColumnType("bigint");
b.Property<int>("ReadStatus")
.HasColumnType("int");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId", "NotificationId")
.HasDatabaseName("IX_Tenant_User_Notification_Id");
b.ToTable("AppUserNotifications", (string)null);
});
modelBuilder.Entity("LINGYUN.Abp.MessageService.Subscriptions.UserSubscribe", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<string>("NotificationName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<Guid>("UserId")
.HasColumnType("char(36)");
b.Property<string>("UserName")
.IsRequired()
.ValueGeneratedOnAdd()
.HasMaxLength(128)
.HasColumnType("varchar(128)")
.HasDefaultValue("/");
b.HasKey("Id");
b.HasIndex("TenantId", "UserId", "NotificationName")
.IsUnique()
.HasDatabaseName("IX_Tenant_User_Notification_Name");
b.ToTable("AppUserSubscribes", (string)null);
});
#pragma warning restore 612, 618
}
}
}

51
aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/20220624035652_Add-Entity-Notification-Template.cs

@ -0,0 +1,51 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace LY.MicroService.RealtimeMessage.Migrations
{
public partial class AddEntityNotificationTemplate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AppNotificationTemplates",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
Name = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Description = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Title = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Content = table.Column<string>(type: "longtext", maxLength: 1048576, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Culture = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_AppNotificationTemplates", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_Tenant_Notification_Template_Name",
table: "AppNotificationTemplates",
columns: new[] { "TenantId", "Name" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AppNotificationTemplates");
}
}
}

932
aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/RealtimeMessageMigrationsDbContextModelSnapshot.cs

File diff suppressed because it is too large

6
aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs

@ -17,6 +17,7 @@ using LINGYUN.Abp.MessageService.EntityFrameworkCore;
using LINGYUN.Abp.Notifications.Emailing; using LINGYUN.Abp.Notifications.Emailing;
using LINGYUN.Abp.Notifications.SignalR; using LINGYUN.Abp.Notifications.SignalR;
using LINGYUN.Abp.Notifications.Sms; using LINGYUN.Abp.Notifications.Sms;
using LINGYUN.Abp.Notifications.TextTemplating;
using LINGYUN.Abp.Notifications.WeChat.MiniProgram; using LINGYUN.Abp.Notifications.WeChat.MiniProgram;
using LINGYUN.Abp.Saas.EntityFrameworkCore; using LINGYUN.Abp.Saas.EntityFrameworkCore;
using LINGYUN.Abp.Serilog.Enrichers.Application; using LINGYUN.Abp.Serilog.Enrichers.Application;
@ -36,6 +37,7 @@ using Volo.Abp.Caching.StackExchangeRedis;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.TextTemplating.Scriban;
namespace LY.MicroService.RealtimeMessage; namespace LY.MicroService.RealtimeMessage;
@ -67,6 +69,8 @@ namespace LY.MicroService.RealtimeMessage;
typeof(AbpNotificationsSignalRModule), typeof(AbpNotificationsSignalRModule),
typeof(AbpNotificationsWeChatMiniProgramModule), typeof(AbpNotificationsWeChatMiniProgramModule),
typeof(AbpNotificationsExceptionHandlingModule), typeof(AbpNotificationsExceptionHandlingModule),
typeof(AbpNotificationsTextTemplatingModule),
typeof(AbpTextTemplatingScribanModule),
typeof(AbpCAPEventBusModule), typeof(AbpCAPEventBusModule),
typeof(AbpCachingStackExchangeRedisModule), typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpAspNetCoreHttpOverridesModule),
@ -105,6 +109,8 @@ public partial class RealtimeMessageHttpApiHostModule : AbpModule
ConfigureCors(context.Services, configuration); ConfigureCors(context.Services, configuration);
ConfigureSeedWorker(context.Services, hostingEnvironment.IsDevelopment()); ConfigureSeedWorker(context.Services, hostingEnvironment.IsDevelopment());
ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment()); ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment());
context.Services.AddAlwaysAllowAuthorization();
} }
public override void OnApplicationInitialization(ApplicationInitializationContext context) public override void OnApplicationInitialization(ApplicationInitializationContext context)

2
aspnet-core/services/LY.MicroService.identityServer/Emailing/Templates/MailSecurityVerify.tpl

@ -1,5 +1,5 @@
<div style="position: absolute;"> <div style="position: absolute;">
<span>{{L "VerifyMyEmailAddress" model.user}}</span> <span>{{L "VerifyMyEmailAddress"}}{{model.user}}</span>
<p style="display:block; padding:0 50px; width: 150px; height:48px; line-height:48px; color:#cc0000; font-size:26px; background:#9c9797; font-weight:bold;">{{model.code}}</p> <p style="display:block; padding:0 50px; width: 150px; height:48px; line-height:48px; color:#cc0000; font-size:26px; background:#9c9797; font-weight:bold;">{{model.code}}</p>
<span>{{L "MailSecurityVerifyRemarks"}}</span> <span>{{L "MailSecurityVerifyRemarks"}}</span>
</div> </div>
Loading…
Cancel
Save