Browse Source

feat: 增加通知模板解析模块.

pull/1075/head
colin 1 year ago
parent
commit
c702f5d080
  1. 2
      .github/workflows/publish.yml
  2. 2
      .github/workflows/release.yml
  3. 14
      aspnet-core/LINGYUN.MicroService.All.sln
  4. 7
      aspnet-core/LINGYUN.MicroService.SingleProject.sln
  5. 3
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/FodyWeavers.xml
  6. 30
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/FodyWeavers.xsd
  7. 20
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/LINGYUN.Abp.Notifications.Templating.csproj
  8. 17
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/LINGYUN/Abp/Notifications/Templating/AbpNotificationsResolveOptions.cs
  9. 9
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/LINGYUN/Abp/Notifications/Templating/AbpNotificationsTemplatingModule.cs
  10. 11
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/LINGYUN/Abp/Notifications/Templating/INotificationTemplateResolveContext.cs
  11. 9
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/LINGYUN/Abp/Notifications/Templating/INotificationTemplateResolveContributor.cs
  12. 17
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/LINGYUN/Abp/Notifications/Templating/INotificationTemplateResolver.cs
  13. 26
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/LINGYUN/Abp/Notifications/Templating/NotificationTemplateResolveContext.cs
  14. 13
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/LINGYUN/Abp/Notifications/Templating/NotificationTemplateResolveContributorBase.cs
  15. 16
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/LINGYUN/Abp/Notifications/Templating/NotificationTemplateResolveResult.cs
  16. 58
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/LINGYUN/Abp/Notifications/Templating/NotificationTemplateResolver.cs
  17. 47
      aspnet-core/services/Directory.Packages.props
  18. 13
      aspnet-core/services/LY.AIO.Applications.Single/LY.AIO.Applications.Single.csproj
  19. 21
      aspnet-core/services/LY.MicroService.Applications.Single/EventBus/Distributed/NotificationEventHandler.cs
  20. 1
      aspnet-core/services/LY.MicroService.Applications.Single/LY.MicroService.Applications.Single.csproj
  21. 3
      aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs
  22. 21
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/NotificationEventHandler.cs
  23. 1
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj
  24. 2
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs
  25. 4
      aspnet-core/templates/micro/PackageName.CompanyName.ProjectName.csproj
  26. 4
      aspnet-core/templates/micro/content/Directory.Packages.props
  27. 4
      aspnet-core/templates/micro/content/common.props
  28. 6
      aspnet-core/templates/micro/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/PackageName.CompanyName.ProjectName.HttpApi.Host.csproj
  29. 23
      aspnet-core/templates/micro/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/Program.cs
  30. 8
      aspnet-core/templates/micro/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/ProjectNameHttpApiHostModule.cs
  31. 20
      aspnet-core/templates/micro/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/appsettings.json
  32. 26
      aspnet-core/tests/LINGYUN.Abp.Notifications.Templating.Tests/LINGYUN.Abp.Notifications.Templating.Tests.csproj
  33. 8
      aspnet-core/tests/LINGYUN.Abp.Notifications.Templating.Tests/LINGYUN/Abp/Notifications/Templating/AbpNotificationsTemplatingTestBase.cs
  34. 14
      aspnet-core/tests/LINGYUN.Abp.Notifications.Templating.Tests/LINGYUN/Abp/Notifications/Templating/AbpNotificationsTemplatingTestModule.cs
  35. 20
      aspnet-core/tests/LINGYUN.Abp.Notifications.Templating.Tests/LINGYUN/Abp/Notifications/Templating/NewtownsoftJsonTemplateResolveContributor.cs
  36. 29
      aspnet-core/tests/LINGYUN.Abp.Notifications.Templating.Tests/LINGYUN/Abp/Notifications/Templating/NotificationModel.cs
  37. 75
      aspnet-core/tests/LINGYUN.Abp.Notifications.Templating.Tests/LINGYUN/Abp/Notifications/Templating/NotificationTemplateResolverTests.cs
  38. 29
      aspnet-core/tests/LINGYUN.Abp.Notifications.Templating.Tests/LINGYUN/Abp/Notifications/Templating/ToObjectNotificationTemplateResolveContributor.cs

2
.github/workflows/publish.yml

@ -2,7 +2,7 @@ name: "Publish"
on:
push:
branches: [ rel-8.3.4 ]
branches: [ main ]
env:
DOTNET_VERSION: "8.0.200"

2
.github/workflows/release.yml

@ -2,7 +2,7 @@ name: "Tagged Release"
on:
push:
branches: [ rel-8.3.4 ]
branches: [ main ]
jobs:
tagged-release:

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

@ -767,6 +767,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.I
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.HttpApi.Client", "modules\realtime-notifications\LINGYUN.Abp.Notifications.HttpApi.Client\LINGYUN.Abp.Notifications.HttpApi.Client.csproj", "{3CBD1342-C021-49FB-933F-FAC1DAFC7B48}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.Templating", "modules\realtime-notifications\LINGYUN.Abp.Notifications.Templating\LINGYUN.Abp.Notifications.Templating.csproj", "{E2AC3DB8-D579-49A3-845B-528C77A1EC75}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.Templating.Tests", "tests\LINGYUN.Abp.Notifications.Templating.Tests\LINGYUN.Abp.Notifications.Templating.Tests.csproj", "{F47EDB4F-1F92-4887-8F33-BFCEB61BB51A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -1969,6 +1973,14 @@ Global
{3CBD1342-C021-49FB-933F-FAC1DAFC7B48}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3CBD1342-C021-49FB-933F-FAC1DAFC7B48}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3CBD1342-C021-49FB-933F-FAC1DAFC7B48}.Release|Any CPU.Build.0 = Release|Any CPU
{E2AC3DB8-D579-49A3-845B-528C77A1EC75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2AC3DB8-D579-49A3-845B-528C77A1EC75}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2AC3DB8-D579-49A3-845B-528C77A1EC75}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2AC3DB8-D579-49A3-845B-528C77A1EC75}.Release|Any CPU.Build.0 = Release|Any CPU
{F47EDB4F-1F92-4887-8F33-BFCEB61BB51A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F47EDB4F-1F92-4887-8F33-BFCEB61BB51A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F47EDB4F-1F92-4887-8F33-BFCEB61BB51A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F47EDB4F-1F92-4887-8F33-BFCEB61BB51A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -2340,6 +2352,8 @@ Global
{76DDE71D-00BD-4BC8-AEA2-31209E2B7E05} = {B05CB08F-C088-4D6D-97EE-A94A5D1AE4A6}
{267933BD-BFB8-4906-BA39-DF193B2FD558} = {B05CB08F-C088-4D6D-97EE-A94A5D1AE4A6}
{3CBD1342-C021-49FB-933F-FAC1DAFC7B48} = {1A23BB7F-1839-4204-88C5-7E9A6C9FBF1E}
{E2AC3DB8-D579-49A3-845B-528C77A1EC75} = {1A23BB7F-1839-4204-88C5-7E9A6C9FBF1E}
{F47EDB4F-1F92-4887-8F33-BFCEB61BB51A} = {370D7CD5-1E17-4F3D-BBFA-03429F6D4F2F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718}

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

@ -616,6 +616,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.AuditLogging.IP
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LY.MicroService.Applications.Single.EntityFrameworkCore.MySql", "migrations\LY.MicroService.Applications.Single.EntityFrameworkCore.MySql\LY.MicroService.Applications.Single.EntityFrameworkCore.MySql.csproj", "{746813A9-4221-42D8-AAB5-66CB69EC844F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.Templating", "modules\realtime-notifications\LINGYUN.Abp.Notifications.Templating\LINGYUN.Abp.Notifications.Templating.csproj", "{8CFA17AA-568C-4B40-A48E-1212123ABDD6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -1622,6 +1624,10 @@ Global
{746813A9-4221-42D8-AAB5-66CB69EC844F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{746813A9-4221-42D8-AAB5-66CB69EC844F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{746813A9-4221-42D8-AAB5-66CB69EC844F}.Release|Any CPU.Build.0 = Release|Any CPU
{8CFA17AA-568C-4B40-A48E-1212123ABDD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8CFA17AA-568C-4B40-A48E-1212123ABDD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8CFA17AA-568C-4B40-A48E-1212123ABDD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8CFA17AA-568C-4B40-A48E-1212123ABDD6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -1921,6 +1927,7 @@ Global
{5BE31786-EAAB-4C86-8FFF-C07F27FBFD1C} = {99B7CBDE-A251-4738-97F0-DB1DB484BEE1}
{77B3C7A4-15C7-4EFF-8451-4F13B4CCA4AE} = {C22741F9-FC56-4AE3-B543-9F15C779D345}
{746813A9-4221-42D8-AAB5-66CB69EC844F} = {0D69B63D-F082-4D57-9FF0-355642C56993}
{8CFA17AA-568C-4B40-A48E-1212123ABDD6} = {42F31C68-B8B2-4BE0-9AD0-A7DFA6092629}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {711A43C0-A2F8-4E5C-9B9F-F2551E4B3FF1}

3
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/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/realtime-notifications/LINGYUN.Abp.Notifications.Templating/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/realtime-notifications/LINGYUN.Abp.Notifications.Templating/LINGYUN.Abp.Notifications.Templating.csproj

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\configureawait.props" />
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
<AssemblyName>LINGYUN.Abp.Notifications.Templating</AssemblyName>
<PackageId>LINGYUN.Abp.Notifications.Templating</PackageId>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\LINGYUN.Abp.Notifications.Core\LINGYUN.Abp.Notifications.Core.csproj" />
</ItemGroup>
</Project>

17
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/LINGYUN/Abp/Notifications/Templating/AbpNotificationsResolveOptions.cs

@ -0,0 +1,17 @@
using JetBrains.Annotations;
using System.Collections.Generic;
namespace LINGYUN.Abp.Notifications.Templating;
public class AbpNotificationsResolveOptions
{
/// <summary>
/// 模板解析提供者列表
/// </summary>
[NotNull]
public List<INotificationTemplateResolveContributor> TemplateResolvers { get; }
public AbpNotificationsResolveOptions()
{
TemplateResolvers = new List<INotificationTemplateResolveContributor>();
}
}

9
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/LINGYUN/Abp/Notifications/Templating/AbpNotificationsTemplatingModule.cs

@ -0,0 +1,9 @@
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.Notifications.Templating;
[DependsOn(typeof(AbpNotificationsCoreModule))]
public class AbpNotificationsTemplatingModule : AbpModule
{
}

11
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/LINGYUN/Abp/Notifications/Templating/INotificationTemplateResolveContext.cs

@ -0,0 +1,11 @@
using Volo.Abp.DependencyInjection;
namespace LINGYUN.Abp.Notifications.Templating;
public interface INotificationTemplateResolveContext : IServiceProviderAccessor
{
NotificationTemplate Template { get; }
object Model { get; set; }
bool Handled { get; set; }
}

9
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/LINGYUN/Abp/Notifications/Templating/INotificationTemplateResolveContributor.cs

@ -0,0 +1,9 @@
using System.Threading.Tasks;
namespace LINGYUN.Abp.Notifications.Templating;
public interface INotificationTemplateResolveContributor
{
string Name { get; }
Task ResolveAsync(INotificationTemplateResolveContext context);
}

17
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/LINGYUN/Abp/Notifications/Templating/INotificationTemplateResolver.cs

@ -0,0 +1,17 @@
using JetBrains.Annotations;
using System.Threading.Tasks;
namespace LINGYUN.Abp.Notifications.Templating;
/// <summary>
/// 通知模板模型解析接口
/// </summary>
public interface INotificationTemplateResolver
{
/// <summary>
/// 解析模板数据
/// </summary>
/// <param name="template"></param>
/// <returns></returns>
[NotNull]
Task<NotificationTemplateResolveResult> ResolveAsync(NotificationTemplate template);
}

26
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/LINGYUN/Abp/Notifications/Templating/NotificationTemplateResolveContext.cs

@ -0,0 +1,26 @@
using System;
namespace LINGYUN.Abp.Notifications.Templating;
public class NotificationTemplateResolveContext : INotificationTemplateResolveContext
{
public IServiceProvider ServiceProvider { get; }
public NotificationTemplate Template { get; }
public object Model { get; set; }
public bool Handled { get; set; }
public bool HasResolvedModel()
{
return Handled || Model != null;
}
public NotificationTemplateResolveContext(
NotificationTemplate template,
IServiceProvider serviceProvider)
{
Template = template;
ServiceProvider = serviceProvider;
}
}

13
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/LINGYUN/Abp/Notifications/Templating/NotificationTemplateResolveContributorBase.cs

@ -0,0 +1,13 @@
using System.Threading.Tasks;
namespace LINGYUN.Abp.Notifications.Templating;
public abstract class NotificationTemplateResolveContributorBase : INotificationTemplateResolveContributor
{
public abstract string Name { get; }
/// <summary>
/// 实现此接口处理模板数据
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public abstract Task ResolveAsync(INotificationTemplateResolveContext context);
}

16
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/LINGYUN/Abp/Notifications/Templating/NotificationTemplateResolveResult.cs

@ -0,0 +1,16 @@
using System.Collections.Generic;
namespace LINGYUN.Abp.Notifications.Templating;
public class NotificationTemplateResolveResult
{
/// <summary>
/// 模板数据
/// </summary>
public object Model { get; set; }
public List<string> AppliedResolvers { get; }
public NotificationTemplateResolveResult()
{
AppliedResolvers = new List<string>();
}
}

58
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/LINGYUN/Abp/Notifications/Templating/NotificationTemplateResolver.cs

@ -0,0 +1,58 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using System;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
namespace LINGYUN.Abp.Notifications.Templating;
public class NotificationTemplateResolver : INotificationTemplateResolver, ITransientDependency
{
private readonly IServiceProvider _serviceProvider;
private readonly AbpNotificationsResolveOptions _options;
public NotificationTemplateResolver(
IOptions<AbpNotificationsResolveOptions> options,
IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
_options = options.Value;
}
public async virtual Task<NotificationTemplateResolveResult> ResolveAsync(NotificationTemplate template)
{
var result = new NotificationTemplateResolveResult();
using (var serviceScope = _serviceProvider.CreateScope())
{
var context = new NotificationTemplateResolveContext(template, serviceScope.ServiceProvider);
foreach (var resolveContributor in _options.TemplateResolvers)
{
// TODO: 设定为每一个通知都配置自己的解析提供者?
/**
if (resolveContributor.Name.Equals(template.Name))
{
await resolveContributor.ResolveAsync(context);
}
if (context.HasResolvedModel())
{
result.Model = context.Model;
break;
}
**/
await resolveContributor.ResolveAsync(context);
result.AppliedResolvers.Add(resolveContributor.Name);
if (context.HasResolvedModel())
{
result.Model = context.Model;
break;
}
}
}
return result;
}
}

47
aspnet-core/services/Directory.Packages.props

@ -3,53 +3,6 @@
<PropertyGroup>
<LYAbpPackageVersion>8.3.4</LYAbpPackageVersion>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="DistributedLock.Redis" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Elsa.Activities.Email" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Elsa.Activities.Http" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Elsa.Activities.UserTask" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Elsa.Activities.Temporal.Quartz" Version="$(LYAbpPackageVersion)" />
<!--<PackageVersion Include="Elsa.Designer.Components.Web" Version="$(LYAbpPackageVersion)" />-->
<PackageVersion Include="Elsa.Webhooks.Api" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="OpenIddict.Validation.DataProtection" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="OpenIddict.Server.DataProtection" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Serilog.AspNetCore" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Serilog.Enrichers.Environment" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Serilog.Enrichers.Assembly" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Serilog.Enrichers.Process" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Serilog.Enrichers.Thread" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Serilog.Settings.Configuration" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Serilog.Sinks.Elasticsearch" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Serilog.Sinks.File" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Quartz.Serialization.Json" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Volo.Abp.Account.Web.OpenIddict" Version="$(LYAbpPackageVersion)" />
<!--<PackageVersion Include="Volo.Abp.Account.Web.IdentityServer" Version="$(LYAbpPackageVersion)" />-->
<PackageVersion Include="Volo.Abp.AspNetCore.Serilog" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Volo.Abp.Autofac" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Volo.Abp.Caching.StackExchangeRedis" Version="$(LYAbpPackageVersion)" />
<!-- <PackageVersion Include="Volo.Abp.EntityFrameworkCore.MySQL" Version="$(LYAbpPackageVersion)" />-->
<PackageVersion Include="Volo.Abp.EntityFrameworkCore.PostgreSql" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Volo.Abp.FeatureManagement.Application" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Volo.Abp.FeatureManagement.HttpApi" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Volo.Abp.PermissionManagement.Application" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Volo.Abp.PermissionManagement.Domain.Identity" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Volo.Abp.PermissionManagement.Domain.IdentityServer" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Volo.Abp.PermissionManagement.Domain.OpenIddict" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Volo.Abp.PermissionManagement.HttpApi" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Volo.Abp.Identity.AspNetCore" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Volo.Abp.Imaging.ImageSharp" Version="$(LYAbpPackageVersion)" />
<!--<PackageVersion Include="Volo.Abp.IdentityServer.EntityFrameworkCore" Version="$(LYAbpPackageVersion)" />-->
<PackageVersion Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="$(LYAbpPackageVersion)" />
<PackageVersion Include="Volo.Abp.OpenIddict.EntityFrameworkCore" Version="$(LYAbpPackageVersion)" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="LINGYUN.Abp.AuditLogging.EntityFrameworkCore" Version="$(LYAbpPackageVersion)" />

13
aspnet-core/services/LY.AIO.Applications.Single/LY.AIO.Applications.Single.csproj

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\common.secrets.props" />
@ -54,6 +54,7 @@
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" />
<PackageReference Include="Volo.Abp.OpenIddict.EntityFrameworkCore" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="LINGYUN.Abp.AuditLogging.EntityFrameworkCore" />
<PackageReference Include="LINGYUN.Abp.AuditLogging" />
@ -212,8 +213,6 @@
<PackageReference Include="LINGYUN.Abp.UI.Navigation.VueVbenAdmin" />
<PackageReference Include="LINGYUN.Platform.Application.Contracts" />
<PackageReference Include="LINGYUN.Platform.Application" />
<PackageReference Include="LINGYUN.Platform.Application.Contracts" />
<PackageReference Include="LINGYUN.Platform.Application" />
<PackageReference Include="LINGYUN.Platform.Domain.Shared" />
<PackageReference Include="LINGYUN.Platform.Domain" />
<PackageReference Include="LINGYUN.Platform.EntityFrameworkCore" />
@ -261,12 +260,4 @@
<PackageReference Include="LINGYUN.Abp.WebhooksManagement.HttpApi" />
<PackageReference Include="LINGYUN.Abp.Webhooks" />
</ItemGroup>
<ItemGroup>
<Folder Include="blobs\host\public\" />
</ItemGroup>
<ItemGroup>
<None Remove="blobs\host\public\iShot_2024-12-04_11.51.43.png" />
</ItemGroup>
</Project>

21
aspnet-core/services/LY.MicroService.Applications.Single/EventBus/Distributed/NotificationEventHandler.cs

@ -1,4 +1,5 @@
using LINGYUN.Abp.Notifications;
using LINGYUN.Abp.Notifications.Templating;
using LY.MicroService.Applications.Single.BackgroundJobs;
using LY.MicroService.Applications.Single.MultiTenancy;
using Microsoft.Extensions.Localization;
@ -65,6 +66,10 @@ namespace LY.MicroService.Applications.Single.EventBus.Distributed
/// </summary>
protected IStringLocalizerFactory StringLocalizerFactory { get; }
/// <summary>
/// Reference to <see cref="INotificationTemplateResolver"/>.
/// </summary>
protected INotificationTemplateResolver NotificationTemplateResolver { get; }
/// <summary>
/// Reference to <see cref="INotificationDataSerializer"/>.
/// </summary>
protected INotificationDataSerializer NotificationDataSerializer { get; }
@ -94,6 +99,7 @@ namespace LY.MicroService.Applications.Single.EventBus.Distributed
IOptions<AbpNotificationsPublishOptions> options,
INotificationStore notificationStore,
INotificationDataSerializer notificationDataSerializer,
INotificationTemplateResolver notificationTemplateResolver,
INotificationDefinitionManager notificationDefinitionManager,
INotificationSubscriptionManager notificationSubscriptionManager,
INotificationPublishProviderManager notificationPublishProviderManager)
@ -107,6 +113,7 @@ namespace LY.MicroService.Applications.Single.EventBus.Distributed
StringLocalizerFactory = stringLocalizerFactory;
NotificationStore = notificationStore;
NotificationDataSerializer = notificationDataSerializer;
NotificationTemplateResolver = notificationTemplateResolver;
NotificationDefinitionManager = notificationDefinitionManager;
NotificationSubscriptionManager = notificationSubscriptionManager;
NotificationPublishProviderManager = notificationPublishProviderManager;
@ -130,23 +137,25 @@ namespace LY.MicroService.Applications.Single.EventBus.Distributed
}
using (CultureHelper.Use(culture, culture))
{
var result = await NotificationTemplateResolver.ResolveAsync(eventData.Data);
if (notification.NotificationType == NotificationType.System)
{
using (CurrentTenant.Change(null))
{
await SendToTenantAsync(null, notification, eventData);
await SendToTenantAsync(null, notification, eventData, result);
var allActiveTenants = await TenantConfigurationCache.GetTenantsAsync();
foreach (var activeTenant in allActiveTenants)
{
await SendToTenantAsync(activeTenant.Id, notification, eventData);
await SendToTenantAsync(activeTenant.Id, notification, eventData, result);
}
}
}
else
{
await SendToTenantAsync(eventData.TenantId, notification, eventData);
await SendToTenantAsync(eventData.TenantId, notification, eventData, result);
}
}
}
@ -183,7 +192,8 @@ namespace LY.MicroService.Applications.Single.EventBus.Distributed
protected async virtual Task SendToTenantAsync(
Guid? tenantId,
NotificationDefinition notification,
NotificationEto<NotificationTemplate> eventData)
NotificationEto<NotificationTemplate> eventData,
NotificationTemplateResolveResult templateResolveResult)
{
using (CurrentTenant.Change(tenantId))
{
@ -219,7 +229,8 @@ namespace LY.MicroService.Applications.Single.EventBus.Distributed
// 由于模板通知受租户影响, 格式化失败的消息将被丢弃.
message = await TemplateRenderer.RenderAsync(
templateName: eventData.Data.Name,
model: eventData.Data.ExtraProperties,
// 序列化之后数据可能需要自行处理, 如未处理数据, 将使用默认数据渲染模板
model: templateResolveResult.Model ?? eventData.Data.ExtraProperties,
cultureName: eventData.Data.Culture,
globalContext: new Dictionary<string, object>
{

1
aspnet-core/services/LY.MicroService.Applications.Single/LY.MicroService.Applications.Single.csproj

@ -202,6 +202,7 @@
<ProjectReference Include="..\..\modules\realtime-notifications\LINGYUN.Abp.Notifications.Domain\LINGYUN.Abp.Notifications.Domain.csproj" />
<ProjectReference Include="..\..\modules\realtime-notifications\LINGYUN.Abp.Notifications.EntityFrameworkCore\LINGYUN.Abp.Notifications.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\modules\realtime-notifications\LINGYUN.Abp.Notifications.HttpApi\LINGYUN.Abp.Notifications.HttpApi.csproj" />
<ProjectReference Include="..\..\modules\realtime-notifications\LINGYUN.Abp.Notifications.Templating\LINGYUN.Abp.Notifications.Templating.csproj" />
<ProjectReference Include="..\..\modules\realtime-notifications\LINGYUN.Abp.Notifications.WeChat.MiniProgram\LINGYUN.Abp.Notifications.WeChat.MiniProgram.csproj" />
<ProjectReference Include="..\..\modules\realtime-notifications\LINGYUN.Abp.Notifications.WeChat.Work\LINGYUN.Abp.Notifications.WeChat.Work.csproj" />
<ProjectReference Include="..\..\modules\openIddict\LINGYUN.Abp.OpenIddict.Application.Contracts\LINGYUN.Abp.OpenIddict.Application.Contracts.csproj" />

3
aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs

@ -1,6 +1,7 @@
using LINGYUN.Abp.AuditLogging.IP.Location;
using LINGYUN.Abp.EventBus.CAP;
using LINGYUN.Abp.IP2Region;
using LINGYUN.Abp.Notifications.Templating;
using LY.MicroService.Applications.Single.EntityFrameworkCore;
using LY.MicroService.Applications.Single.EntityFrameworkCore.MySql;
using Volo.Abp.MailKit;
@ -295,6 +296,8 @@ namespace LY.MicroService.Applications.Single;
typeof(AbpNotificationsSignalRModule),
// 通知模块 邮件通知
typeof(AbpNotificationsEmailingModule),
// 通知模块 模板解析
typeof(AbpNotificationsTemplatingModule),
// 通知模块 微信小程序
typeof(AbpNotificationsWeChatMiniProgramModule),
// 多租户模块 版本

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

@ -1,4 +1,5 @@
using LINGYUN.Abp.Notifications;
using LINGYUN.Abp.Notifications.Templating;
using LY.MicroService.RealtimeMessage.BackgroundJobs;
using LY.MicroService.RealtimeMessage.MultiTenancy;
using Microsoft.Extensions.Localization;
@ -74,6 +75,10 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed
/// </summary>
protected INotificationDataSerializer NotificationDataSerializer { get; }
/// <summary>
/// Reference to <see cref="INotificationTemplateResolver"/>.
/// </summary>
protected INotificationTemplateResolver NotificationTemplateResolver { get; }
/// <summary>
/// Reference to <see cref="INotificationDefinitionManager"/>.
/// </summary>
protected INotificationDefinitionManager NotificationDefinitionManager { get; }
@ -99,6 +104,7 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed
IOptions<AbpNotificationsPublishOptions> options,
INotificationStore notificationStore,
INotificationDataSerializer notificationDataSerializer,
INotificationTemplateResolver notificationTemplateResolver,
INotificationDefinitionManager notificationDefinitionManager,
INotificationSubscriptionManager notificationSubscriptionManager,
INotificationPublishProviderManager notificationPublishProviderManager)
@ -112,6 +118,7 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed
StringLocalizerFactory = stringLocalizerFactory;
NotificationStore = notificationStore;
NotificationDataSerializer = notificationDataSerializer;
NotificationTemplateResolver = notificationTemplateResolver;
NotificationDefinitionManager = notificationDefinitionManager;
NotificationSubscriptionManager = notificationSubscriptionManager;
NotificationPublishProviderManager = notificationPublishProviderManager;
@ -135,23 +142,25 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed
}
using (CultureHelper.Use(culture, culture))
{
var result = await NotificationTemplateResolver.ResolveAsync(eventData.Data);
if (notification.NotificationType == NotificationType.System)
{
using (CurrentTenant.Change(null))
{
await SendToTenantAsync(null, notification, eventData);
await SendToTenantAsync(null, notification, eventData, result);
var allActiveTenants = await TenantConfigurationCache.GetTenantsAsync();
foreach (var activeTenant in allActiveTenants)
{
await SendToTenantAsync(activeTenant.Id, notification, eventData);
await SendToTenantAsync(activeTenant.Id, notification, eventData, result);
}
}
}
else
{
await SendToTenantAsync(eventData.TenantId, notification, eventData);
await SendToTenantAsync(eventData.TenantId, notification, eventData, result);
}
}
}
@ -188,7 +197,8 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed
protected async virtual Task SendToTenantAsync(
Guid? tenantId,
NotificationDefinition notification,
NotificationEto<NotificationTemplate> eventData)
NotificationEto<NotificationTemplate> eventData,
NotificationTemplateResolveResult templateResolveResult)
{
using (CurrentTenant.Change(tenantId))
{
@ -224,7 +234,8 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed
// 由于模板通知受租户影响, 格式化失败的消息将被丢弃.
message = await TemplateRenderer.RenderAsync(
templateName: eventData.Data.Name,
model: eventData.Data.ExtraProperties,
// 解决序列化后的数据无法渲染模板
model: templateResolveResult.Model ?? eventData.Data.ExtraProperties,
cultureName: eventData.Data.Culture,
globalContext: new Dictionary<string, object>
{

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

@ -89,6 +89,7 @@
<ProjectReference Include="..\..\modules\realtime-notifications\LINGYUN.Abp.Notifications.HttpApi\LINGYUN.Abp.Notifications.HttpApi.csproj" />
<ProjectReference Include="..\..\modules\realtime-notifications\LINGYUN.Abp.Notifications.SignalR\LINGYUN.Abp.Notifications.SignalR.csproj" />
<ProjectReference Include="..\..\modules\realtime-notifications\LINGYUN.Abp.Notifications.Sms\LINGYUN.Abp.Notifications.Sms.csproj" />
<ProjectReference Include="..\..\modules\realtime-notifications\LINGYUN.Abp.Notifications.Templating\LINGYUN.Abp.Notifications.Templating.csproj" />
<ProjectReference Include="..\..\modules\realtime-notifications\LINGYUN.Abp.Notifications.WeChat.MiniProgram\LINGYUN.Abp.Notifications.WeChat.MiniProgram.csproj" />
<ProjectReference Include="..\..\modules\realtime-notifications\LINGYUN.Abp.Notifications.WeChat.Work\LINGYUN.Abp.Notifications.WeChat.Work.csproj" />
<ProjectReference Include="..\..\modules\realtime-notifications\LINGYUN.Abp.Notifications.WxPusher\LINGYUN.Abp.Notifications.WxPusher.csproj" />

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

@ -28,6 +28,7 @@ using LINGYUN.Abp.Notifications.EntityFrameworkCore;
using LINGYUN.Abp.Notifications.Jobs;
using LINGYUN.Abp.Notifications.SignalR;
using LINGYUN.Abp.Notifications.Sms;
using LINGYUN.Abp.Notifications.Templating;
using LINGYUN.Abp.Notifications.WeChat.MiniProgram;
using LINGYUN.Abp.Notifications.WeChat.Work;
using LINGYUN.Abp.Notifications.WxPusher;
@ -101,6 +102,7 @@ namespace LY.MicroService.RealtimeMessage;
typeof(AbpNotificationsWeChatMiniProgramModule),
typeof(AbpNotificationsWeChatWorkModule),
typeof(AbpNotificationsExceptionHandlingModule),
typeof(AbpNotificationsTemplatingModule),
typeof(AbpWeChatWorkHandlersModule),
typeof(AbpWeChatOfficialHandlersModule),
typeof(AbpIdentityNotificationsModule),

4
aspnet-core/templates/micro/PackageName.CompanyName.ProjectName.csproj

@ -3,13 +3,13 @@
<TargetFramework>net8.0</TargetFramework> <!-- 或其他适合的框架 -->
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>LINGYUN.Abp.MicroService.Templates</PackageId>
<Version>8.3.0</Version>
<Version>8.3.4</Version>
<Authors>colin.in@foxmail.com</Authors>
<Description>Abp framework micro-service template</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageProjectUrl>https://github.com/colinin/abp-next-admin</PackageProjectUrl>
<PackageTags>micro webapi cloud</PackageTags>
<PackageTags>abp micro webapi cloud</PackageTags>
<PackageType>Template</PackageType>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/colinin/abp-next-admin</RepositoryUrl>

4
aspnet-core/templates/micro/content/Directory.Packages.props

@ -2,8 +2,8 @@
<PropertyGroup>
<DotNetCoreCAPPackageVersion>8.2.0</DotNetCoreCAPPackageVersion>
<ElsaPackageVersion>2.14.1</ElsaPackageVersion>
<VoloAbpPackageVersion>8.3.0</VoloAbpPackageVersion>
<LINGYUNAbpPackageVersion>8.3.0</LINGYUNAbpPackageVersion>
<VoloAbpPackageVersion>8.3.4</VoloAbpPackageVersion>
<LINGYUNAbpPackageVersion>8.3.4</LINGYUNAbpPackageVersion>
<MicrosoftExtensionsPackageVersion>8.0.0</MicrosoftExtensionsPackageVersion>
<MicrosoftAspNetCorePackageVersion>8.0.0</MicrosoftAspNetCorePackageVersion>
<MicrosoftEntityFrameworkCorePackageVersion>8.0.0</MicrosoftEntityFrameworkCorePackageVersion>

4
aspnet-core/templates/micro/content/common.props

@ -1,12 +1,12 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Version>8.2.1</Version>
<Version>8.3.4</Version>
<Authors>colin</Authors>
<NoWarn>$(NoWarn);CS1591;CS0436;CS8618;NU1803</NoWarn>
<PackageProjectUrl>https://github.com/colinin/abp-next-admin</PackageProjectUrl>
<PackageOutputPath>$(SolutionDir)LocalNuget</PackageOutputPath>
<PackageVersion>8.2.1</PackageVersion>
<PackageVersion>8.3.4</PackageVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/colinin/abp-next-admin</RepositoryUrl>

6
aspnet-core/templates/micro/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/PackageName.CompanyName.ProjectName.HttpApi.Host.csproj

@ -31,10 +31,6 @@
<PackageReference Include="LINGYUN.Abp.Serilog.Enrichers.Application" />
<PackageReference Include="LINGYUN.Abp.Serilog.Enrichers.UniqueId" />
<PackageReference Include="LINGYUN.Abp.TextTemplating.EntityFrameworkCore" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" />
<PackageReference Include="DistributedLock.Redis" />
@ -59,7 +55,7 @@
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" />
<PackageReference Include="Volo.Abp.Autofac" />
<PackageReference Include="Volo.Abp.DistributedLocking" />
<PackageReference Include="Volo.Abp.MailKit" />
<PackageReference Include="Volo.Abp.MailKit" />
<PackageReference Include="Volo.Abp.Swashbuckle" />
<PackageReference Include="Volo.Abp.Http.Client.IdentityModel.Web" />
<PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" />

23
aspnet-core/templates/micro/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/Program.cs

@ -23,15 +23,19 @@ public class Program
Log.Information("Starting web host.");
var builder = WebApplication.CreateBuilder(args);
builder.Host.AddAppSettingsSecretsJson()
builder.Host
.AddAppSettingsSecretsJson()
.UseAutofac()
.ConfigureAppConfiguration((context, config) =>
{
var configuration = config.Build();
var agileConfigEnabled = configuration["AgileConfig:IsEnabled"];
if (agileConfigEnabled.IsNullOrEmpty() || bool.Parse(agileConfigEnabled))
var agileConfig = context.Configuration.GetSection("AgileConfig");//IsEnabled
if (agileConfig.Exists())
{
config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration));
var isAgileConfigEnabled = agileConfig["IsEnabled"];
if (isAgileConfigEnabled.IsNullOrWhiteSpace() || bool.Parse(isAgileConfigEnabled))
{
config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration));
}
}
})
.UseSerilog((context, provider, config) =>
@ -45,12 +49,11 @@ public class Program
options.ApplicationName = ProjectNameHttpApiHostModule.ApplicationName;
// 搜索 Modules 目录下所有文件作为插件
// 取消显示引用所有其他项目的模块,改为通过插件的形式引用
var pluginFolder = Path.Combine(
Directory.GetCurrentDirectory(), "Modules");
var pluginFolder = Path.Combine(Directory.GetCurrentDirectory(), "Modules");
DirectoryHelper.CreateIfNotExists(pluginFolder);
options.PlugInSources.AddFolder(
pluginFolder,
SearchOption.AllDirectories);
options.PlugInSources.AddFolder(pluginFolder, SearchOption.AllDirectories);
});
var app = builder.Build();
await app.InitializeApplicationAsync();

8
aspnet-core/templates/micro/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/ProjectNameHttpApiHostModule.cs

@ -1,12 +1,14 @@
using LINGYUN.Abp.AspNetCore.HttpOverrides;
using LINGYUN.Abp.AspNetCore.Mvc.Wrapper;
using LINGYUN.Abp.AuditLogging.Elasticsearch;
using LINGYUN.Abp.EventBus.CAP;
using LINGYUN.Abp.ExceptionHandling.Emailing;
using LINGYUN.Abp.Identity.Session.AspNetCore;
using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore;
using LINGYUN.Abp.TextTemplating.EntityFrameworkCore;
using LINGYUN.Abp.Saas.EntityFrameworkCore;
using LINGYUN.Abp.Serilog.Enrichers.Application;
using LINGYUN.Abp.Serilog.Enrichers.UniqueId;
using LINGYUN.Abp.TextTemplating.EntityFrameworkCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
@ -22,13 +24,11 @@ using Volo.Abp.Caching.StackExchangeRedis;
using Volo.Abp.DistributedLocking;
using Volo.Abp.FeatureManagement.EntityFrameworkCore;
using Volo.Abp.Http.Client.IdentityModel.Web;
using Volo.Abp.MailKit;
using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.Swashbuckle;
using LINGYUN.Abp.AspNetCore.HttpOverrides;
using LINGYUN.Abp.Identity.Session.AspNetCore;
using Volo.Abp.MailKit;
namespace PackageName.CompanyName.ProjectName;

20
aspnet-core/templates/micro/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/appsettings.json

@ -1,4 +1,9 @@
{
"App": {
"CorsOrigins": "http://127.0.0.1:30000",
"RefreshClaimsUrl": "http://127.0.0.1:30015/",
"HealthChecks": "/healthz"
},
"Clock": {
"Kind": "Local"
},
@ -44,6 +49,9 @@
"path": "Logs/Debug-.log",
"restrictedToMinimumLevel": "Debug",
"rollingInterval": "Day",
"rollOnFileSizeLimit": true,
"retainedFileCountLimit": 50,
"fileSizeLimitBytes": 5242880,
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}"
}
},
@ -53,6 +61,9 @@
"path": "Logs/Info-.log",
"restrictedToMinimumLevel": "Information",
"rollingInterval": "Day",
"rollOnFileSizeLimit": true,
"retainedFileCountLimit": 50,
"fileSizeLimitBytes": 5242880,
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}"
}
},
@ -62,6 +73,9 @@
"path": "Logs/Warn-.log",
"restrictedToMinimumLevel": "Warning",
"rollingInterval": "Day",
"rollOnFileSizeLimit": true,
"retainedFileCountLimit": 50,
"fileSizeLimitBytes": 5242880,
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}"
}
},
@ -71,6 +85,9 @@
"path": "Logs/Error-.log",
"restrictedToMinimumLevel": "Error",
"rollingInterval": "Day",
"rollOnFileSizeLimit": true,
"retainedFileCountLimit": 50,
"fileSizeLimitBytes": 5242880,
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}"
}
},
@ -80,6 +97,9 @@
"path": "Logs/Fatal-.log",
"restrictedToMinimumLevel": "Fatal",
"rollingInterval": "Day",
"rollOnFileSizeLimit": true,
"retainedFileCountLimit": 50,
"fileSizeLimitBytes": 5242880,
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}"
}
}

26
aspnet-core/tests/LINGYUN.Abp.Notifications.Templating.Tests/LINGYUN.Abp.Notifications.Templating.Tests.csproj

@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace />
<IsPackable>false</IsPackable>
<Configurations>Debug;Release;</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Volo.Abp.Json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\modules\realtime-notifications\LINGYUN.Abp.Notifications.Templating\LINGYUN.Abp.Notifications.Templating.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.TestBase\LINGYUN.Abp.TestsBase.csproj" />
</ItemGroup>
</Project>

8
aspnet-core/tests/LINGYUN.Abp.Notifications.Templating.Tests/LINGYUN/Abp/Notifications/Templating/AbpNotificationsTemplatingTestBase.cs

@ -0,0 +1,8 @@
using LINGYUN.Abp.Tests;
namespace LINGYUN.Abp.Notifications.Templating;
public class AbpNotificationsTemplatingTestBase : AbpTestsBase<AbpNotificationsTemplatingTestModule>
{
}

14
aspnet-core/tests/LINGYUN.Abp.Notifications.Templating.Tests/LINGYUN/Abp/Notifications/Templating/AbpNotificationsTemplatingTestModule.cs

@ -0,0 +1,14 @@
using LINGYUN.Abp.Tests;
using Volo.Abp.Json;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.Notifications.Templating;
[DependsOn(
typeof(AbpNotificationsTemplatingModule),
typeof(AbpJsonModule),
typeof(AbpTestsBaseModule))]
public class AbpNotificationsTemplatingTestModule : AbpModule
{
}

20
aspnet-core/tests/LINGYUN.Abp.Notifications.Templating.Tests/LINGYUN/Abp/Notifications/Templating/NewtownsoftJsonTemplateResolveContributor.cs

@ -0,0 +1,20 @@
using Newtonsoft.Json.Linq;
using System.Threading.Tasks;
namespace LINGYUN.Abp.Notifications.Templating;
internal class NewtownsoftJsonTemplateResolveContributor : INotificationTemplateResolveContributor
{
public string Name => "ToDynamic";
public Task ResolveAsync(INotificationTemplateResolveContext context)
{
var jsonObject = new JObject();
foreach (var prop in context.Template.ExtraProperties)
{
jsonObject.Add(prop.Key, prop.Value.ToString());
}
context.Model = jsonObject.ToObject<NotificationSimpleModel>();
return Task.CompletedTask;
}
}

29
aspnet-core/tests/LINGYUN.Abp.Notifications.Templating.Tests/LINGYUN/Abp/Notifications/Templating/NotificationModel.cs

@ -0,0 +1,29 @@
using System.Collections.Generic;
namespace LINGYUN.Abp.Notifications.Templating;
public class NotificationSimpleModel
{
public string Name { get; set; }
public string Firend { get; set; }
}
public class NotificationModel
{
public string Name { get; set; }
public List<NotificationJob> Jobs { get; set; }
}
public class NotificationJob
{
public string Name { get; set; }
public NotificationJob()
{
}
public NotificationJob(string name)
{
Name = name;
}
}

75
aspnet-core/tests/LINGYUN.Abp.Notifications.Templating.Tests/LINGYUN/Abp/Notifications/Templating/NotificationTemplateResolverTests.cs

@ -0,0 +1,75 @@
using LINGYUN.Abp.RealTime;
using Newtonsoft.Json;
using Shouldly;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Json;
using Xunit;
namespace LINGYUN.Abp.Notifications.Templating;
public class NotificationTemplateResolverTests : AbpNotificationsTemplatingTestBase
{
private IJsonSerializer _jsonSerializer;
public NotificationTemplateResolverTests()
{
_jsonSerializer = GetRequiredService<IJsonSerializer>();
}
[Fact]
public async Task Resolve_Deserialize_To_Object()
{
var notificationTemplate = new NotificationTemplate(
"Test",
data: new Dictionary<string, object>
{
{ "Name", "Tom" },
{ "Jobs", new List<NotificationJob>
{
new NotificationJob("Catch Jerry"),
new NotificationJob("Hit Pike")
}
}
});
var receivedEto = _jsonSerializer.Deserialize<RealTimeEto<NotificationTemplate>>(
_jsonSerializer.Serialize(
new RealTimeEto<NotificationTemplate>(notificationTemplate)));
var contributor = new ToObjectNotificationTemplateResolveContributor();
var context = new NotificationTemplateResolveContext(receivedEto.Data, ServiceProvider);
await contributor.ResolveAsync(context);
var model = context.Model.ShouldBeOfType<NotificationModel>();
model.Name.ShouldBe("Tom");
model.Jobs.Count.ShouldBe(2);
model.Jobs[0].Name.ShouldBe("Catch Jerry");
model.Jobs[1].Name.ShouldBe("Hit Pike");
}
[Fact]
public async Task Resolve_Deserialize_To_Dynamic()
{
var notificationTemplate = new NotificationTemplate(
"Test",
data: new Dictionary<string, object>
{
{ "Name", "Tom" },
{ "Firend", "Jerry" }
});
var receivedEto = _jsonSerializer.Deserialize<RealTimeEto<NotificationTemplate>>(
_jsonSerializer.Serialize(
new RealTimeEto<NotificationTemplate>(notificationTemplate)));
var contributor = new NewtownsoftJsonTemplateResolveContributor();
var context = new NotificationTemplateResolveContext(receivedEto.Data, ServiceProvider);
await contributor.ResolveAsync(context);
dynamic model = context.Model;
Assert.Equal(model.Name, "Tom");
Assert.Equal(model.Firend, "Jerry");
}
}

29
aspnet-core/tests/LINGYUN.Abp.Notifications.Templating.Tests/LINGYUN/Abp/Notifications/Templating/ToObjectNotificationTemplateResolveContributor.cs

@ -0,0 +1,29 @@
using Microsoft.Extensions.DependencyInjection;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.Json;
namespace LINGYUN.Abp.Notifications.Templating;
internal class ToObjectNotificationTemplateResolveContributor : INotificationTemplateResolveContributor
{
public string Name => "ToObject";
public Task ResolveAsync(INotificationTemplateResolveContext context)
{
var model = new NotificationModel();
var nameObj = context.Template.GetProperty(nameof(NotificationModel.Name));
model.Name = nameObj.ToString();
var jobsObj = context.Template.GetProperty(nameof(NotificationModel.Jobs));
var jsonSerializer = context.ServiceProvider.GetRequiredService<IJsonSerializer>();
model.Jobs = jsonSerializer.Deserialize<List<NotificationJob>>(jobsObj.ToString());
context.Model = model;
return Task.CompletedTask;
}
}
Loading…
Cancel
Save