Browse Source

增强通知模块

pull/587/head
cKey 4 years ago
parent
commit
7e1cc16e0a
  1. 7
      aspnet-core/LINGYUN.MicroService.All.sln
  2. 9
      aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpExceptionHandlingNotificationDefinitionProvider.cs
  3. 5
      aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN/Abp/ExceptionHandling/Notifications/AbpNotificationsExceptionSubscriber.cs
  4. 3
      aspnet-core/modules/common/LINGYUN.Abp.Notifications.Emailing/FodyWeavers.xml
  5. 30
      aspnet-core/modules/common/LINGYUN.Abp.Notifications.Emailing/FodyWeavers.xsd
  6. 20
      aspnet-core/modules/common/LINGYUN.Abp.Notifications.Emailing/LINGYUN.Abp.Notifications.Emailing.csproj
  7. 22
      aspnet-core/modules/common/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/AbpNotificationsEmailingModule.cs
  8. 77
      aspnet-core/modules/common/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/EmailingNotificationPublishProvider.cs
  9. 2
      aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN/Abp/Notifications/SignalR/SignalRNotificationPublishProvider.cs
  10. 2
      aspnet-core/modules/common/LINGYUN.Abp.Notifications.Sms/LINGYUN/Abp/Notifications/Sms/SmsNotificationPublishProvider.cs
  11. 13
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationDefinition.cs
  12. 24
      aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationProviderNames.cs
  13. 31
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/AbpMessageServiceNotificationDefinitionProvider.cs
  14. 13
      aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Abstractions/LINGYUN/Abp/BackgroundTasks/JobInfo.cs
  15. 4
      aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzJobExecutorProvider.cs
  16. 9
      aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/Internal/JobExecutedEvent.cs
  17. 2
      aspnet-core/modules/wechat/LINGYUN.Abp.Notifications.WeChat.MiniProgram/LINGYUN/Abp/Notifications/WeChat/MiniProgram/WeChatMiniProgramNotificationPublishProvider.cs
  18. 51
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/RealtimeMessageTemplateProvider.cs
  19. 37
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/ExceptionNotifier/en.tpl
  20. 37
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/ExceptionNotifier/zh-Hans.tpl
  21. 1
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/NewTenantRegisterd/en.tpl
  22. 1
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/NewTenantRegisterd/zh-Hans.tpl
  23. 1
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/WelcomeToApplication/en.tpl
  24. 1
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/WelcomeToApplication/zh-Hans.tpl
  25. 10
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/layout.tpl
  26. 5
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/TenantSynchronizer.cs
  27. 1
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Local/UserCreateSendWelcomeEventHandler.cs
  28. 8
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj
  29. 4
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs

7
aspnet-core/LINGYUN.MicroService.All.sln

@ -402,6 +402,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.PermissionManag
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Identity.OrganizaztionUnits", "modules\authorization\LINGYUN.Abp.Identity.OrganizaztionUnits\LINGYUN.Abp.Identity.OrganizaztionUnits.csproj", "{76A5564E-033B-4AA6-A22B-78B6EB134CC6}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Identity.OrganizaztionUnits", "modules\authorization\LINGYUN.Abp.Identity.OrganizaztionUnits\LINGYUN.Abp.Identity.OrganizaztionUnits.csproj", "{76A5564E-033B-4AA6-A22B-78B6EB134CC6}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.Emailing", "modules\common\LINGYUN.Abp.Notifications.Emailing\LINGYUN.Abp.Notifications.Emailing.csproj", "{88502844-D83C-4541-96AC-A8291E261F63}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -1036,6 +1038,10 @@ Global
{76A5564E-033B-4AA6-A22B-78B6EB134CC6}.Debug|Any CPU.Build.0 = Debug|Any CPU {76A5564E-033B-4AA6-A22B-78B6EB134CC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76A5564E-033B-4AA6-A22B-78B6EB134CC6}.Release|Any CPU.ActiveCfg = Release|Any CPU {76A5564E-033B-4AA6-A22B-78B6EB134CC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76A5564E-033B-4AA6-A22B-78B6EB134CC6}.Release|Any CPU.Build.0 = Release|Any CPU {76A5564E-033B-4AA6-A22B-78B6EB134CC6}.Release|Any CPU.Build.0 = Release|Any CPU
{88502844-D83C-4541-96AC-A8291E261F63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88502844-D83C-4541-96AC-A8291E261F63}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88502844-D83C-4541-96AC-A8291E261F63}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88502844-D83C-4541-96AC-A8291E261F63}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -1232,6 +1238,7 @@ Global
{902D822A-52B6-481C-96C5-ECD891FF83FC} = {9EC33D45-CCC7-41DF-829E-6B89A640FE35} {902D822A-52B6-481C-96C5-ECD891FF83FC} = {9EC33D45-CCC7-41DF-829E-6B89A640FE35}
{46244C99-3A0D-4D88-9F24-2B7B586ADBA4} = {CC362C67-6FC1-42B3-A130-8120AA8D790C} {46244C99-3A0D-4D88-9F24-2B7B586ADBA4} = {CC362C67-6FC1-42B3-A130-8120AA8D790C}
{76A5564E-033B-4AA6-A22B-78B6EB134CC6} = {9EC33D45-CCC7-41DF-829E-6B89A640FE35} {76A5564E-033B-4AA6-A22B-78B6EB134CC6} = {9EC33D45-CCC7-41DF-829E-6B89A640FE35}
{88502844-D83C-4541-96AC-A8291E261F63} = {8AC72641-30D3-4ACF-89FA-808FADC55C2E}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718} SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718}

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

@ -20,8 +20,13 @@ namespace LINGYUN.Abp.ExceptionHandling.Notifications
notificationType: NotificationType.System, notificationType: NotificationType.System,
lifetime: NotificationLifetime.Persistent, lifetime: NotificationLifetime.Persistent,
allowSubscriptionToClients: false) allowSubscriptionToClients: false)
// TODO: 全局常量 // 指定通知提供程序
.WithProviders("SignalR"); .WithProviders(
NotificationProviderNames.SignalR,
NotificationProviderNames.Emailing)
// 特定的通知提供程序属性
// 此处为邮件通知定义的模板名称
.WithProperty("Template", "ExceptionNotifier");
} }
protected LocalizableString L(string name) protected LocalizableString L(string name)

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

@ -25,7 +25,10 @@ namespace LINGYUN.Abp.ExceptionHandling.Notifications
NotificationData notificationData = new NotificationData(); NotificationData notificationData = new NotificationData();
// 写入通知数据 // 写入通知数据
//TODO:集成TextTemplate完成格式化的推送 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( notificationData.WriteStandardData(
context.Exception.GetType().FullName, context.Exception.GetType().FullName,
context.Exception.Message, context.Exception.Message,

3
aspnet-core/modules/common/LINGYUN.Abp.Notifications.Emailing/FodyWeavers.xml

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait ContinueOnCapturedContext="false" />
</Weavers>

30
aspnet-core/modules/common/LINGYUN.Abp.Notifications.Emailing/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>

20
aspnet-core/modules/common/LINGYUN.Abp.Notifications.Emailing/LINGYUN.Abp.Notifications.Emailing.csproj

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\configureawait.props" />
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Emailing" Version="$(VoloAbpPackageVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\identity\LINGYUN.Abp.Identity.Domain\LINGYUN.Abp.Identity.Domain.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.Notifications\LINGYUN.Abp.Notifications.csproj" />
</ItemGroup>
</Project>

22
aspnet-core/modules/common/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/AbpNotificationsEmailingModule.cs

@ -0,0 +1,22 @@
using LINGYUN.Abp.Identity;
using Volo.Abp.Emailing;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.Notifications.Emailing;
[DependsOn(
typeof(AbpNotificationModule),
typeof(AbpEmailingModule),
typeof(AbpIdentityDomainModule))]
public class AbpNotificationsEmailingModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpNotificationOptions>(options =>
{
options.PublishProviders.Add<EmailingNotificationPublishProvider>();
options.NotificationDataMappings
.MappingDefault(EmailingNotificationPublishProvider.ProviderName, data => data);
});
}
}

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

@ -0,0 +1,77 @@
using LINGYUN.Abp.Identity;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Emailing;
using Volo.Abp.TextTemplating;
namespace LINGYUN.Abp.Notifications.Emailing;
public class EmailingNotificationPublishProvider : NotificationPublishProvider
{
public const string ProviderName = NotificationProviderNames.Emailing;
public override string Name => ProviderName;
protected IEmailSender EmailSender { get; }
protected ITemplateRenderer TemplateRenderer { get; }
protected IStringLocalizerFactory LocalizerFactory { get; }
protected IIdentityUserRepository UserRepository { get; }
protected INotificationDefinitionManager NotificationDefinitionManager { get; }
public EmailingNotificationPublishProvider(
IServiceProvider serviceProvider,
IEmailSender emailSender,
ITemplateRenderer templateRenderer,
IStringLocalizerFactory localizerFactory,
IIdentityUserRepository userRepository,
INotificationDefinitionManager notificationDefinitionManager)
: base(serviceProvider)
{
EmailSender = emailSender;
TemplateRenderer = templateRenderer;
LocalizerFactory = localizerFactory;
UserRepository = userRepository;
NotificationDefinitionManager = notificationDefinitionManager;
}
protected async override Task PublishAsync(
NotificationInfo notification,
IEnumerable<UserIdentifier> identifiers,
CancellationToken cancellationToken = default)
{
var userIds = identifiers.Select(x => x.UserId).ToList();
var userList = await UserRepository.GetListByIdListAsync(userIds, cancellationToken: cancellationToken);
var emailAddress = userList.Where(x => x.EmailConfirmed).Select(x => x.Email).Distinct().JoinAsString(",");
if (emailAddress.IsNullOrWhiteSpace())
{
Logger.LogWarning("The subscriber did not confirm the email address and could not send email notifications!");
return;
}
var notificationDefinition = NotificationDefinitionManager.Get(notification.Name);
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!");
return;
}
var content = await TemplateRenderer.RenderAsync(
template.ToString(),
globalContext: notification.Data.ExtraProperties);
await EmailSender.SendAsync(emailAddress, notificationDisplayName, content);
}
}

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

@ -12,7 +12,7 @@ namespace LINGYUN.Abp.Notifications.SignalR
{ {
public class SignalRNotificationPublishProvider : NotificationPublishProvider public class SignalRNotificationPublishProvider : NotificationPublishProvider
{ {
public const string ProviderName = "SignalR"; public const string ProviderName = NotificationProviderNames.SignalR;
public override string Name => ProviderName; public override string Name => ProviderName;
private readonly IHubContext<NotificationsHub> _hubContext; private readonly IHubContext<NotificationsHub> _hubContext;

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

@ -9,7 +9,7 @@ namespace LINGYUN.Abp.Notifications.Sms
{ {
public class SmsNotificationPublishProvider : NotificationPublishProvider public class SmsNotificationPublishProvider : NotificationPublishProvider
{ {
public const string ProviderName = "Sms"; public const string ProviderName = NotificationProviderNames.Sms;
private IUserPhoneFinder _userPhoneFinder; private IUserPhoneFinder _userPhoneFinder;
protected IUserPhoneFinder UserPhoneFinder => LazyGetRequiredService(ref _userPhoneFinder); protected IUserPhoneFinder UserPhoneFinder => LazyGetRequiredService(ref _userPhoneFinder);

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

@ -50,6 +50,12 @@ namespace LINGYUN.Abp.Notifications
/// </summary> /// </summary>
public List<string> Providers { get; } public List<string> Providers { get; }
/// <summary>
/// 额外属性
/// </summary>
[NotNull]
public Dictionary<string, object> Properties { get; }
public NotificationDefinition( public NotificationDefinition(
string name, string name,
ILocalizableString displayName = null, ILocalizableString displayName = null,
@ -66,6 +72,7 @@ namespace LINGYUN.Abp.Notifications
AllowSubscriptionToClients = allowSubscriptionToClients; AllowSubscriptionToClients = allowSubscriptionToClients;
Providers = new List<string>(); Providers = new List<string>();
Properties = new Dictionary<string, object>();
} }
public virtual NotificationDefinition WithProviders(params string[] providers) public virtual NotificationDefinition WithProviders(params string[] providers)
@ -78,6 +85,12 @@ namespace LINGYUN.Abp.Notifications
return this; return this;
} }
public virtual NotificationDefinition WithProperty(string key, object value)
{
Properties[key] = value;
return this;
}
public override string ToString() public override string ToString()
{ {
return $"[{nameof(NotificationDefinition)} {Name}]"; return $"[{nameof(NotificationDefinition)} {Name}]";

24
aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/NotificationProviderNames.cs

@ -0,0 +1,24 @@
namespace LINGYUN.Abp.Notifications;
/// <summary>
/// 内置通知提供者
/// </summary>
public static class NotificationProviderNames
{
/// <summary>
/// SignalR 实时通知
/// </summary>
public const string SignalR = "SignalR";
/// <summary>
/// 短信通知
/// </summary>
public const string Sms = "Sms";
/// <summary>
/// 邮件通知
/// </summary>
public const string Emailing = "Emailing";
/// <summary>
/// 微信小程序模板通知
/// </summary>
public const string WechatMiniProgram = "WeChat.MiniProgram";
}

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

@ -23,7 +23,10 @@ namespace LINGYUN.Abp.MessageService.Notifications
lifetime: NotificationLifetime.OnlyOne, lifetime: NotificationLifetime.OnlyOne,
allowSubscriptionToClients: false allowSubscriptionToClients: false
) )
.WithProviders(); .WithProviders(
NotificationProviderNames.SignalR,
NotificationProviderNames.Emailing)
.WithProperty("Template", "NewTenantRegisterd");
var usersGroup = context.AddGroup( var usersGroup = context.AddGroup(
UserNotificationNames.GroupName, UserNotificationNames.GroupName,
@ -35,7 +38,11 @@ namespace LINGYUN.Abp.MessageService.Notifications
L("Notifications:WelcomeToApplication"), L("Notifications:WelcomeToApplication"),
notificationType: NotificationType.System, notificationType: NotificationType.System,
lifetime: NotificationLifetime.OnlyOne, lifetime: NotificationLifetime.OnlyOne,
allowSubscriptionToClients: true); allowSubscriptionToClients: true)
.WithProviders(
NotificationProviderNames.SignalR,
NotificationProviderNames.Emailing)
.WithProperty("Template", "WelcomeToApplication");
var imGroup = context.AddGroup( var imGroup = context.AddGroup(
MessageServiceNotificationNames.IM.GroupName, MessageServiceNotificationNames.IM.GroupName,
@ -46,35 +53,45 @@ namespace LINGYUN.Abp.MessageService.Notifications
L("Notifications:FriendValidation"), L("Notifications:FriendValidation"),
notificationType: NotificationType.System, notificationType: NotificationType.System,
lifetime: NotificationLifetime.Persistent, lifetime: NotificationLifetime.Persistent,
allowSubscriptionToClients: true); allowSubscriptionToClients: true)
.WithProviders(
NotificationProviderNames.SignalR);
imGroup.AddNotification( imGroup.AddNotification(
MessageServiceNotificationNames.IM.NewFriend, MessageServiceNotificationNames.IM.NewFriend,
L("Notifications:NewFriend"), L("Notifications:NewFriend"),
L("Notifications:NewFriend"), L("Notifications:NewFriend"),
notificationType: NotificationType.System, notificationType: NotificationType.System,
lifetime: NotificationLifetime.Persistent, lifetime: NotificationLifetime.Persistent,
allowSubscriptionToClients: true); allowSubscriptionToClients: true)
.WithProviders(
NotificationProviderNames.SignalR);
imGroup.AddNotification( imGroup.AddNotification(
MessageServiceNotificationNames.IM.JoinGroup, MessageServiceNotificationNames.IM.JoinGroup,
L("Notifications:JoinGroup"), L("Notifications:JoinGroup"),
L("Notifications:JoinGroup"), L("Notifications:JoinGroup"),
notificationType: NotificationType.System, notificationType: NotificationType.System,
lifetime: NotificationLifetime.Persistent, lifetime: NotificationLifetime.Persistent,
allowSubscriptionToClients: true); allowSubscriptionToClients: true)
.WithProviders(
NotificationProviderNames.SignalR);
imGroup.AddNotification( imGroup.AddNotification(
MessageServiceNotificationNames.IM.ExitGroup, MessageServiceNotificationNames.IM.ExitGroup,
L("Notifications:ExitGroup"), L("Notifications:ExitGroup"),
L("Notifications:ExitGroup"), L("Notifications:ExitGroup"),
notificationType: NotificationType.System, notificationType: NotificationType.System,
lifetime: NotificationLifetime.Persistent, lifetime: NotificationLifetime.Persistent,
allowSubscriptionToClients: true); allowSubscriptionToClients: true)
.WithProviders(
NotificationProviderNames.SignalR);
imGroup.AddNotification( imGroup.AddNotification(
MessageServiceNotificationNames.IM.DissolveGroup, MessageServiceNotificationNames.IM.DissolveGroup,
L("Notifications:DissolveGroup"), L("Notifications:DissolveGroup"),
L("Notifications:DissolveGroup"), L("Notifications:DissolveGroup"),
notificationType: NotificationType.System, notificationType: NotificationType.System,
lifetime: NotificationLifetime.Persistent, lifetime: NotificationLifetime.Persistent,
allowSubscriptionToClients: true); allowSubscriptionToClients: true)
.WithProviders(
NotificationProviderNames.SignalR);
} }
protected LocalizableString L(string name) protected LocalizableString L(string name)

13
aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Abstractions/LINGYUN/Abp/BackgroundTasks/JobInfo.cs

@ -113,8 +113,11 @@ public class JobInfo
/// 指定运行节点 /// 指定运行节点
/// </summary> /// </summary>
public string NodeName { get; set; } public string NodeName { get; set; }
/// <summary>
public int GetCanBeTriggered() /// 计算作业可触发次数
/// </summary>
/// <returns></returns>
public int CalcCanBeTriggered()
{ {
// 无限次 // 无限次
var maxCount = -1; var maxCount = -1;
@ -144,6 +147,12 @@ public class JobInfo
{ {
maxCount = 0; maxCount = 0;
} }
if (maxCount > 0)
{
// 触发重试时,失败间隔时间调整
Interval = 60;
}
} }
return maxCount; return maxCount;

4
aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzJobExecutorProvider.cs

@ -82,7 +82,7 @@ public class QuartzJobExecutorProvider : IQuartzJobExecutorProvider, ISingletonD
Logger.LogWarning($"The task: {job.Group} - {job.Name} periodic task Cron expression was invalid and the task trigger could not be created."); Logger.LogWarning($"The task: {job.Group} - {job.Name} periodic task Cron expression was invalid and the task trigger could not be created.");
return null; return null;
} }
if (job.GetCanBeTriggered() == 0) if (job.CalcCanBeTriggered() == 0)
{ {
Logger.LogWarning($"The task: {job.Group} - {job.Name} reached trigger peak and the task trigger could not be created."); Logger.LogWarning($"The task: {job.Group} - {job.Name} reached trigger peak and the task trigger could not be created.");
return null; return null;
@ -102,7 +102,7 @@ public class QuartzJobExecutorProvider : IQuartzJobExecutorProvider, ISingletonD
case JobType.Once: case JobType.Once:
case JobType.Persistent: case JobType.Persistent:
default: default:
var maxCount = job.GetCanBeTriggered(); var maxCount = job.CalcCanBeTriggered();
if (maxCount == 0) if (maxCount == 0)
{ {
Logger.LogWarning($"The task: {job.Group} - {job.Name} reached trigger peak and the task trigger could not be created."); Logger.LogWarning($"The task: {job.Group} - {job.Name} reached trigger peak and the task trigger could not be created.");

9
aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/Internal/JobExecutedEvent.cs

@ -53,6 +53,15 @@ public class JobExecutedEvent : JobEventBase<JobExecutedEvent>, ITransientDepend
{ {
job.Priority = JobPriority.Low; job.Priority = JobPriority.Low;
} }
// 等待时间调整
if (job.Interval <= 0)
{
job.Interval = 50;
}
var retryInterval = job.Interval * 1.5;
job.Interval = Convert.ToInt32(retryInterval);
} }
// 当未设置最大重试次数时不会标记停止 // 当未设置最大重试次数时不会标记停止

2
aspnet-core/modules/wechat/LINGYUN.Abp.Notifications.WeChat.MiniProgram/LINGYUN/Abp/Notifications/WeChat/MiniProgram/WeChatMiniProgramNotificationPublishProvider.cs

@ -14,7 +14,7 @@ namespace LINGYUN.Abp.Notifications.WeChat.MiniProgram
/// </summary> /// </summary>
public class WeChatMiniProgramNotificationPublishProvider : NotificationPublishProvider public class WeChatMiniProgramNotificationPublishProvider : NotificationPublishProvider
{ {
public const string ProviderName = "WeChat.MiniProgram"; public const string ProviderName = NotificationProviderNames.WechatMiniProgram;
public override string Name => ProviderName; public override string Name => ProviderName;
protected ISubscribeMessager SubscribeMessager { get; } protected ISubscribeMessager SubscribeMessager { get; }
protected AbpNotificationsWeChatMiniProgramOptions Options { get; } protected AbpNotificationsWeChatMiniProgramOptions Options { get; }

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

@ -0,0 +1,51 @@
using Volo.Abp.TextTemplating;
using Volo.Abp.TextTemplating.Scriban;
namespace LY.MicroService.RealtimeMessage.Emailing;
public class RealtimeMessageTemplateProvider : TemplateDefinitionProvider
{
public override void Define(ITemplateDefinitionContext context)
{
context.Add(CreateEmailTemplate());
}
protected virtual TemplateDefinition[] CreateEmailTemplate()
{
return new TemplateDefinition[]
{
new TemplateDefinition(
name: "EmailNotifierLayout",
defaultCultureName: "en",
isLayout: true)
.WithScribanEngine()
.WithVirtualFilePath(
"/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),
};
}
}

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

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

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

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

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

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

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

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

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

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

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

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

10
aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Emailing/Templates/layout.tpl

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{title}}</title>
</head>
<body leftmargin="8" marginwidth="0" topmargin="8" marginheight="4" offset="0">
{{content}}
</body>
</html>

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

@ -80,20 +80,21 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed
TenantNotificationNames.NewTenantRegistered); TenantNotificationNames.NewTenantRegistered);
var notificationData = new NotificationData(); var notificationData = new NotificationData();
notificationData.TrySetData("name", eventData.Name);
notificationData.WriteLocalizedData( notificationData.WriteLocalizedData(
new LocalizableStringInfo( new LocalizableStringInfo(
LocalizationResourceNameAttribute.GetName(typeof(MessageServiceResource)), LocalizationResourceNameAttribute.GetName(typeof(MessageServiceResource)),
"NewTenantRegisteredNotificationTitle", "NewTenantRegisteredNotificationTitle",
new Dictionary<object, object> new Dictionary<object, object>
{ {
{ "User", eventData.Name } { "Name", eventData.Name },
}), }),
new LocalizableStringInfo( new LocalizableStringInfo(
LocalizationResourceNameAttribute.GetName(typeof(MessageServiceResource)), LocalizationResourceNameAttribute.GetName(typeof(MessageServiceResource)),
"NewTenantRegisteredNotificationMessage", "NewTenantRegisteredNotificationMessage",
new Dictionary<object, object> new Dictionary<object, object>
{ {
{ "User", eventData.Name} { "Name", eventData.Name}
}), }),
DateTime.Now, eventData.AdminEmailAddress); DateTime.Now, eventData.AdminEmailAddress);

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

@ -42,6 +42,7 @@ namespace LY.MicroService.RealtimeMessage.EventBus
// L("WelcomeToApplicationFormUser", eventData.Entity.Name ?? eventData.Entity.UserName), // L("WelcomeToApplicationFormUser", eventData.Entity.Name ?? eventData.Entity.UserName),
// DateTime.Now, eventData.Entity.UserName); // DateTime.Now, eventData.Entity.UserName);
userWelcomeNotifictionData.TrySetData("user", eventData.Entity.UserName);
userWelcomeNotifictionData userWelcomeNotifictionData
.WriteLocalizedData( .WriteLocalizedData(
new LocalizableStringInfo( new LocalizableStringInfo(

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

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
@ -7,6 +7,10 @@
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Localization\Resources\*.json" /> <EmbeddedResource Include="Localization\Resources\*.json" />
<EmbeddedResource Include="Emailing\Templates\*.tpl" />
<EmbeddedResource Include="Emailing\Templates\ExceptionNotifier\*.tpl" />
<EmbeddedResource Include="Emailing\Templates\NewTenantRegisterd*.tpl" />
<EmbeddedResource Include="Emailing\Templates\WelcomeToApplication\*.tpl" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -48,8 +52,10 @@
<ProjectReference Include="..\..\modules\common\LINGYUN.Abp.ExceptionHandling.Notifications\LINGYUN.Abp.ExceptionHandling.Notifications.csproj" /> <ProjectReference Include="..\..\modules\common\LINGYUN.Abp.ExceptionHandling.Notifications\LINGYUN.Abp.ExceptionHandling.Notifications.csproj" />
<ProjectReference Include="..\..\modules\common\LINGYUN.Abp.EventBus.CAP\LINGYUN.Abp.EventBus.CAP.csproj" /> <ProjectReference Include="..\..\modules\common\LINGYUN.Abp.EventBus.CAP\LINGYUN.Abp.EventBus.CAP.csproj" />
<ProjectReference Include="..\..\modules\common\LINGYUN.Abp.IM.SignalR\LINGYUN.Abp.IM.SignalR.csproj" /> <ProjectReference Include="..\..\modules\common\LINGYUN.Abp.IM.SignalR\LINGYUN.Abp.IM.SignalR.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\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" />
<ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.TaskManagement.EntityFrameworkCore\LINGYUN.Abp.TaskManagement.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.TaskManagement.EntityFrameworkCore\LINGYUN.Abp.TaskManagement.EntityFrameworkCore.csproj" />

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

@ -7,12 +7,14 @@ using LINGYUN.Abp.BackgroundTasks.Quartz;
using LINGYUN.Abp.Data.DbMigrator; using LINGYUN.Abp.Data.DbMigrator;
using LINGYUN.Abp.EventBus.CAP; using LINGYUN.Abp.EventBus.CAP;
using LINGYUN.Abp.ExceptionHandling.Notifications; using LINGYUN.Abp.ExceptionHandling.Notifications;
using LINGYUN.Abp.Identity.EntityFrameworkCore;
using LINGYUN.Abp.Identity.WeChat; using LINGYUN.Abp.Identity.WeChat;
using LINGYUN.Abp.IM.SignalR; using LINGYUN.Abp.IM.SignalR;
using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.Localization.CultureMap;
using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore;
using LINGYUN.Abp.MessageService; using LINGYUN.Abp.MessageService;
using LINGYUN.Abp.MessageService.EntityFrameworkCore; using LINGYUN.Abp.MessageService.EntityFrameworkCore;
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.WeChat.MiniProgram; using LINGYUN.Abp.Notifications.WeChat.MiniProgram;
@ -31,7 +33,6 @@ using Volo.Abp.AspNetCore.Serilog;
using Volo.Abp.Autofac; using Volo.Abp.Autofac;
using Volo.Abp.BackgroundWorkers; using Volo.Abp.BackgroundWorkers;
using Volo.Abp.Caching.StackExchangeRedis; using Volo.Abp.Caching.StackExchangeRedis;
using Volo.Abp.Identity.EntityFrameworkCore;
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;
@ -62,6 +63,7 @@ namespace LY.MicroService.RealtimeMessage;
typeof(AbpBackgroundWorkersModule), typeof(AbpBackgroundWorkersModule),
typeof(AbpIMSignalRModule), typeof(AbpIMSignalRModule),
typeof(AbpNotificationsSmsModule), typeof(AbpNotificationsSmsModule),
typeof(AbpNotificationsEmailingModule),
typeof(AbpNotificationsSignalRModule), typeof(AbpNotificationsSignalRModule),
typeof(AbpNotificationsWeChatMiniProgramModule), typeof(AbpNotificationsWeChatMiniProgramModule),
typeof(AbpNotificationsExceptionHandlingModule), typeof(AbpNotificationsExceptionHandlingModule),

Loading…
Cancel
Save