16 changed files with 295 additions and 13 deletions
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait ContinueOnCapturedContext="false" /> |
|||
</Weavers> |
|||
@ -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> |
|||
@ -0,0 +1,20 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.1</TargetFramework> |
|||
<RootNamespace /> |
|||
<Nullable>enable</Nullable> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Emailing" Version="$(VoloAbpPackageVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.Elsa\LINGYUN.Abp.Elsa.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,11 @@ |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.Emailing; |
|||
|
|||
namespace LINGYUN.Abp.Elsa.Activities.Emailing; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpElsaModule), |
|||
typeof(AbpEmailingModule))] |
|||
public class AbpElsaActivitiesEmailingModule : AbpModule |
|||
{ |
|||
} |
|||
@ -0,0 +1,81 @@ |
|||
using Elsa; |
|||
using Elsa.ActivityResults; |
|||
using Elsa.Attributes; |
|||
using Elsa.Design; |
|||
using Elsa.Expressions; |
|||
using Elsa.Providers.WorkflowStorage; |
|||
using Elsa.Services; |
|||
using Elsa.Services.Models; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Emailing; |
|||
using Volo.Abp.TextTemplating; |
|||
|
|||
namespace LINGYUN.Abp.Elsa.Activities.Emailing; |
|||
|
|||
/// <summary>
|
|||
/// 发送邮件
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 与elsa基础SendEmail命名冲突,故改名
|
|||
/// 此活动使用abp框架内置邮件发送接口<see cref="IEmailSender"/>
|
|||
/// </remarks>
|
|||
[Action( |
|||
Category = "Emailing", |
|||
Description = "Send an email message.", |
|||
Outcomes = new[] { OutcomeNames.Done })] |
|||
public class SendEmailing : Activity |
|||
{ |
|||
private readonly IEmailSender _emailSender; |
|||
private readonly ITemplateRenderer _templateRenderer; |
|||
|
|||
public SendEmailing( |
|||
IEmailSender emailSender, |
|||
ITemplateRenderer templateRenderer) |
|||
{ |
|||
_emailSender = emailSender; |
|||
_templateRenderer = templateRenderer; |
|||
} |
|||
|
|||
[ActivityInput(Hint = "The recipients email addresses.", UIHint = ActivityInputUIHints.MultiText, DefaultSyntax = SyntaxNames.Json, SupportedSyntaxes = new[] { SyntaxNames.Json, SyntaxNames.JavaScript })] |
|||
public ICollection<string> To { get; set; } = new List<string>(); |
|||
|
|||
[ActivityInput(Hint = "The subject of the email message.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })] |
|||
public string? Subject { get; set; } |
|||
|
|||
[ActivityInput(Hint = "The body of the email message.", UIHint = ActivityInputUIHints.MultiLine, SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })] |
|||
public string? Body { get; set; } |
|||
|
|||
[ActivityInput(Hint = "The body of the email message.", UIHint = ActivityInputUIHints.MultiLine, SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })] |
|||
public string? Culture { get; set; } |
|||
|
|||
[ActivityInput(Hint = "The template name of render the email message.", UIHint = ActivityInputUIHints.MultiLine, SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })] |
|||
public string? Template { get; set; } |
|||
|
|||
[ActivityInput( |
|||
Hint = "Model parameters used to format the contents of the template.", |
|||
UIHint = ActivityInputUIHints.MultiLine, |
|||
SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid }, |
|||
DefaultWorkflowStorageProvider = TransientWorkflowStorageProvider.ProviderName |
|||
)] |
|||
public object? Model { get; set; } |
|||
|
|||
protected async override ValueTask<IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context) |
|||
{ |
|||
var to = To.JoinAsString(";"); |
|||
var content = Body; |
|||
|
|||
if (!Template.IsNullOrWhiteSpace()) |
|||
{ |
|||
content = await _templateRenderer.RenderAsync( |
|||
Template, |
|||
Model, |
|||
Culture); |
|||
} |
|||
|
|||
await _emailSender.SendAsync(to, Subject, content); |
|||
|
|||
return Done(); |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using Elsa.Attributes; |
|||
using Elsa.Options; |
|||
using Elsa.Services.Startup; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
|
|||
namespace LINGYUN.Abp.Elsa.Activities.Emailing; |
|||
|
|||
[Feature("Emailing")] |
|||
public class Startup : StartupBase |
|||
{ |
|||
public override void ConfigureElsa(ElsaOptionsBuilder elsa, IConfiguration configuration) |
|||
{ |
|||
elsa.AddEmailingActivities(); |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using Elsa.Options; |
|||
using LINGYUN.Abp.Elsa.Activities.Emailing; |
|||
|
|||
namespace Microsoft.Extensions.DependencyInjection; |
|||
|
|||
public static class EmailingServiceCollectionExtensions |
|||
{ |
|||
public static ElsaOptionsBuilder AddEmailingActivities(this ElsaOptionsBuilder options) |
|||
{ |
|||
options |
|||
.AddActivity<SendEmailing>(); |
|||
|
|||
return options; |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait ContinueOnCapturedContext="false" /> |
|||
</Weavers> |
|||
@ -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> |
|||
@ -0,0 +1,25 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.1</TargetFramework> |
|||
<RootNamespace /> |
|||
<Nullable>Enable</Nullable> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Core" Version="$(VoloAbpPackageVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.Elsa.Activities.BlobStoring\LINGYUN.Abp.Elsa.Activities.BlobStoring.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.Elsa.Activities.Emailing\LINGYUN.Abp.Elsa.Activities.Emailing.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.Elsa.Activities.IM\LINGYUN.Abp.Elsa.Activities.IM.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.Elsa.Activities.Notifications\LINGYUN.Abp.Elsa.Activities.Notifications.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.Elsa.Activities.Sms\LINGYUN.Abp.Elsa.Activities.Sms.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.Elsa\LINGYUN.Abp.Elsa.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,40 @@ |
|||
using Elsa; |
|||
using Elsa.Options; |
|||
using LINGYUN.Abp.Elsa.Activities.BlobStoring; |
|||
using LINGYUN.Abp.Elsa.Activities.Emailing; |
|||
using LINGYUN.Abp.Elsa.Activities.IM; |
|||
using LINGYUN.Abp.Elsa.Activities.Notifications; |
|||
using LINGYUN.Abp.Elsa.Activities.Sms; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace LINGYUN.Abp.Elsa.Activities; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpElsaModule), |
|||
typeof(AbpElsaActivitiesBlobStoringModule), |
|||
typeof(AbpElsaActivitiesEmailingModule), |
|||
typeof(AbpElsaActivitiesIMModule), |
|||
typeof(AbpElsaActivitiesNotificationsModule), |
|||
typeof(AbpElsaActivitiesSmsModule))] |
|||
public class AbpElsaActivitiesModule : AbpModule |
|||
{ |
|||
public override void PreConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
var configuration = context.Services.GetConfiguration(); |
|||
var elsaSection = configuration.GetSection("Elsa"); |
|||
var startups = new[] |
|||
{ |
|||
typeof(Emailing.Startup), |
|||
typeof(BlobStoring.Startup), |
|||
typeof(Notifications.Startup), |
|||
typeof(Sms.Startup), |
|||
typeof(IM.Startup), |
|||
}; |
|||
|
|||
PreConfigure<ElsaOptionsBuilder>(elsa => |
|||
{ |
|||
elsa.AddFeatures(startups, configuration); |
|||
}); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue