11 changed files with 243 additions and 20 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,17 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.1</TargetFramework> |
|||
<RootNamespace /> |
|||
<Nullable>enable</Nullable> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\webhooks\LINGYUN.Abp.Webhooks\LINGYUN.Abp.Webhooks.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.Elsa\LINGYUN.Abp.Elsa.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,11 @@ |
|||
using LINGYUN.Abp.Webhooks; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace LINGYUN.Abp.Elsa.Activities.Webhooks; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpElsaModule), |
|||
typeof(AbpWebhooksModule))] |
|||
public class AbpElsaActivitiesWebhooksModule : AbpModule |
|||
{ |
|||
} |
|||
@ -0,0 +1,79 @@ |
|||
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 LINGYUN.Abp.Webhooks; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace LINGYUN.Abp.Elsa.Activities.Webhooks; |
|||
|
|||
[Action( |
|||
Category = "PublishWebhook", |
|||
Description = "Sends webhooks to subscriptions.", |
|||
Outcomes = new[] { OutcomeNames.Done })] |
|||
public class PublishWebhook : Activity |
|||
{ |
|||
private readonly IWebhookPublisher _webhookPublisher; |
|||
|
|||
[ActivityInput( |
|||
Hint = "Unique name of the webhook.", |
|||
SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })] |
|||
public string WebhooName { get; set; } |
|||
|
|||
[ActivityInput( |
|||
Hint = "Data to send.", |
|||
UIHint = ActivityInputUIHints.MultiLine, |
|||
SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid }, |
|||
DefaultWorkflowStorageProvider = TransientWorkflowStorageProvider.ProviderName |
|||
)] |
|||
public object WebhookData { get; set; } |
|||
|
|||
[ActivityInput( |
|||
Hint = "If true, It sends the exact same data as the parameter to clients.", |
|||
SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })] |
|||
public bool SendExactSameData { get; set; } |
|||
|
|||
[ActivityInput( |
|||
Hint = "If true, webhook will only contain given headers. If false given headers will be added to predefined headers in subscription.", |
|||
SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })] |
|||
public bool UseOnlyGivenHeaders { get; set; } |
|||
|
|||
[ActivityInput( |
|||
Hint = "That headers will be sent with the webhook.", |
|||
UIHint = ActivityInputUIHints.MultiLine, DefaultSyntax = SyntaxNames.Json, |
|||
SupportedSyntaxes = new[] { SyntaxNames.Json, SyntaxNames.JavaScript, SyntaxNames.Liquid }, |
|||
Category = PropertyCategories.Advanced |
|||
)] |
|||
public IDictionary<string, string> Headers { get; set; } |
|||
|
|||
public PublishWebhook( |
|||
IWebhookPublisher webhookPublisher) |
|||
{ |
|||
_webhookPublisher = webhookPublisher; |
|||
} |
|||
|
|||
|
|||
protected async override ValueTask<IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context) |
|||
{ |
|||
var tenantId = context.GetTenantId(); |
|||
|
|||
await _webhookPublisher.PublishAsync( |
|||
WebhooName, |
|||
WebhookData, |
|||
tenantId, |
|||
SendExactSameData, |
|||
new WebhookHeader |
|||
{ |
|||
UseOnlyGivenHeaders = UseOnlyGivenHeaders, |
|||
Headers = Headers |
|||
}); |
|||
|
|||
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.Webhooks; |
|||
|
|||
[Feature("Webhooks")] |
|||
public class Startup : StartupBase |
|||
{ |
|||
public override void ConfigureElsa(ElsaOptionsBuilder elsa, IConfiguration configuration) |
|||
{ |
|||
elsa.AddWebhooksActivities(); |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using Elsa.Options; |
|||
using LINGYUN.Abp.Elsa.Activities.Webhooks; |
|||
|
|||
namespace Microsoft.Extensions.DependencyInjection; |
|||
|
|||
public static class WebhooksServiceCollectionExtensions |
|||
{ |
|||
public static ElsaOptionsBuilder AddWebhooksActivities(this ElsaOptionsBuilder options) |
|||
{ |
|||
options.AddActivity<PublishWebhook>(); |
|||
|
|||
return options; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue