diff --git a/aspnet-core/LINGYUN.MicroService.Workflow.sln b/aspnet-core/LINGYUN.MicroService.Workflow.sln index 4bf4a9847..62d97309e 100644 --- a/aspnet-core/LINGYUN.MicroService.Workflow.sln +++ b/aspnet-core/LINGYUN.MicroService.Workflow.sln @@ -79,6 +79,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Elsa.Activities EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.Core", "modules\common\LINGYUN.Abp.Notifications.Core\LINGYUN.Abp.Notifications.Core.csproj", "{CE1B9AD0-7CDA-4459-86A3-A3162C1095D9}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Elsa.Activities.Webhooks", "modules\elsa\LINGYUN.Abp.Elsa.Activities.Webhooks\LINGYUN.Abp.Elsa.Activities.Webhooks.csproj", "{2CA34976-4A80-485C-8572-6004829BB727}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Webhooks.Core", "modules\webhooks\LINGYUN.Abp.Webhooks.Core\LINGYUN.Abp.Webhooks.Core.csproj", "{44E4EBFA-6F25-4FD7-A4B3-536C3A42677C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Webhooks", "modules\webhooks\LINGYUN.Abp.Webhooks\LINGYUN.Abp.Webhooks.csproj", "{6489B162-2B28-42B9-9AD4-EB5CCBB8AE85}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Webhooks.EventBus", "modules\webhooks\LINGYUN.Abp.Webhooks.EventBus\LINGYUN.Abp.Webhooks.EventBus.csproj", "{B6246B7A-4095-433A-B981-5D1E43CDF712}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -205,6 +213,22 @@ Global {CE1B9AD0-7CDA-4459-86A3-A3162C1095D9}.Debug|Any CPU.Build.0 = Debug|Any CPU {CE1B9AD0-7CDA-4459-86A3-A3162C1095D9}.Release|Any CPU.ActiveCfg = Release|Any CPU {CE1B9AD0-7CDA-4459-86A3-A3162C1095D9}.Release|Any CPU.Build.0 = Release|Any CPU + {2CA34976-4A80-485C-8572-6004829BB727}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2CA34976-4A80-485C-8572-6004829BB727}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2CA34976-4A80-485C-8572-6004829BB727}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2CA34976-4A80-485C-8572-6004829BB727}.Release|Any CPU.Build.0 = Release|Any CPU + {44E4EBFA-6F25-4FD7-A4B3-536C3A42677C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {44E4EBFA-6F25-4FD7-A4B3-536C3A42677C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {44E4EBFA-6F25-4FD7-A4B3-536C3A42677C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {44E4EBFA-6F25-4FD7-A4B3-536C3A42677C}.Release|Any CPU.Build.0 = Release|Any CPU + {6489B162-2B28-42B9-9AD4-EB5CCBB8AE85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6489B162-2B28-42B9-9AD4-EB5CCBB8AE85}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6489B162-2B28-42B9-9AD4-EB5CCBB8AE85}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6489B162-2B28-42B9-9AD4-EB5CCBB8AE85}.Release|Any CPU.Build.0 = Release|Any CPU + {B6246B7A-4095-433A-B981-5D1E43CDF712}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B6246B7A-4095-433A-B981-5D1E43CDF712}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B6246B7A-4095-433A-B981-5D1E43CDF712}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B6246B7A-4095-433A-B981-5D1E43CDF712}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -243,6 +267,10 @@ Global {9E213E6F-77CB-4068-93EB-465C47FDA8FA} = {F1CCBEC7-ACAB-4DC5-909E-D8CC2E1B7EEC} {EEE9DF30-1901-4070-8E03-A8D8A0E10E34} = {F1CCBEC7-ACAB-4DC5-909E-D8CC2E1B7EEC} {CE1B9AD0-7CDA-4459-86A3-A3162C1095D9} = {6DA78E72-BA55-4ECF-97DB-6258174D3E2A} + {2CA34976-4A80-485C-8572-6004829BB727} = {F1CCBEC7-ACAB-4DC5-909E-D8CC2E1B7EEC} + {44E4EBFA-6F25-4FD7-A4B3-536C3A42677C} = {6DA78E72-BA55-4ECF-97DB-6258174D3E2A} + {6489B162-2B28-42B9-9AD4-EB5CCBB8AE85} = {6DA78E72-BA55-4ECF-97DB-6258174D3E2A} + {B6246B7A-4095-433A-B981-5D1E43CDF712} = {6DA78E72-BA55-4ECF-97DB-6258174D3E2A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6BB7A5DE-DA12-44DC-BC9B-0F6CA524346F} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/FodyWeavers.xml b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/FodyWeavers.xml new file mode 100644 index 000000000..c485a4548 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/FodyWeavers.xsd b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/LINGYUN.Abp.Elsa.Activities.Webhooks.csproj b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/LINGYUN.Abp.Elsa.Activities.Webhooks.csproj new file mode 100644 index 000000000..a45d3bae0 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/LINGYUN.Abp.Elsa.Activities.Webhooks.csproj @@ -0,0 +1,17 @@ + + + + + + + netstandard2.1 + + enable + + + + + + + + diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/LINGYUN/Abp/Elsa/Activities/Webhooks/AbpElsaActivitiesWebhooksModule.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/LINGYUN/Abp/Elsa/Activities/Webhooks/AbpElsaActivitiesWebhooksModule.cs new file mode 100644 index 000000000..1b283d108 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/LINGYUN/Abp/Elsa/Activities/Webhooks/AbpElsaActivitiesWebhooksModule.cs @@ -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 +{ +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/LINGYUN/Abp/Elsa/Activities/Webhooks/Activities/PublishWebhook.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/LINGYUN/Abp/Elsa/Activities/Webhooks/Activities/PublishWebhook.cs new file mode 100644 index 000000000..f0d074103 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/LINGYUN/Abp/Elsa/Activities/Webhooks/Activities/PublishWebhook.cs @@ -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 Headers { get; set; } + + public PublishWebhook( + IWebhookPublisher webhookPublisher) + { + _webhookPublisher = webhookPublisher; + } + + + protected async override ValueTask OnExecuteAsync(ActivityExecutionContext context) + { + var tenantId = context.GetTenantId(); + + await _webhookPublisher.PublishAsync( + WebhooName, + WebhookData, + tenantId, + SendExactSameData, + new WebhookHeader + { + UseOnlyGivenHeaders = UseOnlyGivenHeaders, + Headers = Headers + }); + + return Done(); + } +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/LINGYUN/Abp/Elsa/Activities/Webhooks/Startup.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/LINGYUN/Abp/Elsa/Activities/Webhooks/Startup.cs new file mode 100644 index 000000000..427463ad2 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/LINGYUN/Abp/Elsa/Activities/Webhooks/Startup.cs @@ -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(); + } +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/Microsoft/Extensions/DependencyInjection/WebhooksServiceCollectionExtensions.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/Microsoft/Extensions/DependencyInjection/WebhooksServiceCollectionExtensions.cs new file mode 100644 index 000000000..584b29d49 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.Webhooks/Microsoft/Extensions/DependencyInjection/WebhooksServiceCollectionExtensions.cs @@ -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(); + + return options; + } +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities/LINGYUN.Abp.Elsa.Activities.csproj b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities/LINGYUN.Abp.Elsa.Activities.csproj index 73b071bda..e65f01489 100644 --- a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities/LINGYUN.Abp.Elsa.Activities.csproj +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities/LINGYUN.Abp.Elsa.Activities.csproj @@ -19,6 +19,7 @@ + diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities/LINGYUN/Abp/Elsa/Activities/AbpElsaActivitiesModule.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities/LINGYUN/Abp/Elsa/Activities/AbpElsaActivitiesModule.cs index 470c82f5d..77df108b3 100644 --- a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities/LINGYUN/Abp/Elsa/Activities/AbpElsaActivitiesModule.cs +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities/LINGYUN/Abp/Elsa/Activities/AbpElsaActivitiesModule.cs @@ -5,6 +5,7 @@ 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 LINGYUN.Abp.Elsa.Activities.Webhooks; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Modularity; @@ -30,6 +31,7 @@ public class AbpElsaActivitiesModule : AbpModule typeof(Notifications.Startup), typeof(Sms.Startup), typeof(IM.Startup), + typeof(Webhooks.Startup), }; PreConfigure(elsa => diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/appsettings.Development.json b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/appsettings.Development.json index f42c473b1..d385505c6 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/appsettings.Development.json +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/appsettings.Development.json @@ -1,11 +1,11 @@ { "AgileConfig": { "env": "DEV", - "appId": "LINGYUN.Abp.WorkflowManagement", + "appId": "LINGYUN.Abp.Workflow", "secret": "1q2w3E*", "nodes": "http://127.0.0.1:15000", - "name": "LINGYUN.Abp.WorkflowManagement", - "tag": "LINGYUN.Abp.WorkflowManagement" + "name": "LINGYUN.Abp.Workflow", + "tag": "LINGYUN.Abp.Workflow" }, "App": { "TrackingEntitiesChanged": true, @@ -22,6 +22,21 @@ "AbpSettingManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", "AbpSaas": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456" }, + "Quartz": { + "UsePersistentStore": false, + "Properties": { + "quartz.jobStore.dataSource": "tkm", + "quartz.jobStore.type": "Quartz.Impl.AdoJobStore.JobStoreTX,Quartz", + "quartz.jobStore.driverDelegateType": "Quartz.Impl.AdoJobStore.MySQLDelegate,Quartz", + "quartz.dataSource.tkm.connectionString": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", + "quartz.dataSource.tkm.connectionStringName": "TaskManagement", + "quartz.dataSource.tkm.provider": "MySqlConnector", + "quartz.jobStore.clustered": "true", + "quartz.serializer.type": "json", + "quartz.scheduler.instanceName": "workflow", + "quartz.scheduler.instanceId": "212c489d-cb5d-4e0a-bde9-80d4a29d379b" + } + }, "Elsa": { "Features": { "DefaultPersistence": { @@ -45,6 +60,7 @@ "Notification": true, "Sms": true, "IM": true, + "PublishWebhook": true, "Webhooks": { "Enabled": true, "ConnectionStringIdentifier": "Workflow", @@ -66,7 +82,7 @@ }, "Rebus": { "RabbitMQ": { - "Connection": "amqp://admin:662874@127.0.0.1:5672/" + "Connection": "amqp://guest:guest@127.0.0.1:5672/" } }, "Server": { @@ -93,27 +109,33 @@ "OssManagement": { "Bucket": "workflow" }, - "RabbitMQ": { - "Connections": { - "AbpWorkflowCore": { - "HostName": "127.0.0.1", - "Port": 5672, - "UserName": "admin", - "Password": "123456", - "VirtualHost": "/" - } - }, - "EventBus": { - "ConnectionName": "AbpWorkflowCore", - "ClientName": "workflow.server", - "ExchangeName": "AbpWorkflowCore" - } - }, "DistributedLock": { "Redis": { "Configuration": "127.0.0.1,defaultDatabase=15" } }, + "CAP": { + "EventBus": { + "DefaultGroupName": "Workflow", + "GroupNamePrefix": "Dev", + "Version": "v1", + "FailedRetryInterval": 300, + "FailedRetryCount": 10, + "CollectorCleaningInterval": 3600000 + }, + "MySql": { + "TableNamePrefix": "wf", + "ConnectionString": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456" + }, + "RabbitMQ": { + "HostName": "127.0.0.1", + "Port": 5672, + "UserName": "guest", + "Password": "guest", + "ExchangeName": "LINGYUN.Abp.Application", + "VirtualHost": "/" + } + }, "Redis": { "Configuration": "127.0.0.1,defaultDatabase=10", "InstanceName": "LINGYUN.Abp.Application"