From 5cd09b2637cd30ecce2cd24356fadaf24d5689b9 Mon Sep 17 00:00:00 2001
From: cKey <35512826+colinin@users.noreply.github.com>
Date: Wed, 29 Jun 2022 22:31:02 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E9=9B=86=E6=88=90elsa?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
aspnet-core/LINGYUN.MicroService.Workflow.sln | 23 +++-
.../TextTemplating/TextTemplateAppService.cs | 2 +
.../FodyWeavers.xml | 3 +
.../FodyWeavers.xsd | 30 ++++++
.../LINGYUN.Abp.Workflow.Elsa.Server.csproj | 19 ++++
.../Elsa/AbpWorkflowElsaServerModule.cs | 13 +++
.../LINGYUN.Abp.Workflow.Elsa/FodyWeavers.xml | 3 +
.../LINGYUN.Abp.Workflow.Elsa/FodyWeavers.xsd | 30 ++++++
.../LINGYUN.Abp.Workflow.Elsa.csproj | 19 ++++
.../Abp/Workflow/Elsa/AbpTenantAccessor.cs | 26 +++++
.../Workflow/Elsa/AbpWorkflowElsaModule.cs | 37 +++++++
.../WorkflowManagementMigrationsDbContext.cs | 8 +-
.../EventBus/Handlers/TenantSynchronizer.cs | 15 ++-
...ice.WorkflowManagement.HttpApi.Host.csproj | 15 +--
.../WorkflowEngineManager.cs | 102 +++++++++---------
...owManagementHttpApiHostModule.Configure.cs | 30 +++++-
.../WorkflowManagementHttpApiHostModule.cs | 31 +++---
.../appsettings.Development.json | 1 +
18 files changed, 310 insertions(+), 97 deletions(-)
create mode 100644 aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/FodyWeavers.xml
create mode 100644 aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/FodyWeavers.xsd
create mode 100644 aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/LINGYUN.Abp.Workflow.Elsa.Server.csproj
create mode 100644 aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/LINGYUN/Abp/Workflow/Elsa/AbpWorkflowElsaServerModule.cs
create mode 100644 aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/FodyWeavers.xml
create mode 100644 aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/FodyWeavers.xsd
create mode 100644 aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/LINGYUN.Abp.Workflow.Elsa.csproj
create mode 100644 aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/LINGYUN/Abp/Workflow/Elsa/AbpTenantAccessor.cs
create mode 100644 aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/LINGYUN/Abp/Workflow/Elsa/AbpWorkflowElsaModule.cs
diff --git a/aspnet-core/LINGYUN.MicroService.Workflow.sln b/aspnet-core/LINGYUN.MicroService.Workflow.sln
index 0e6d1504e..e5eda2254 100644
--- a/aspnet-core/LINGYUN.MicroService.Workflow.sln
+++ b/aspnet-core/LINGYUN.MicroService.Workflow.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflow-core", "workflow-core", "{A2963E0D-D290-40B2-9B36-75F4A5922ABF}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "framework", "framework", "{A2963E0D-D290-40B2-9B36-75F4A5922ABF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WorkflowCore", "modules\workflow\LINGYUN.Abp.WorkflowCore\LINGYUN.Abp.WorkflowCore.csproj", "{F7152D31-9292-43A8-A018-4137A6F1BD92}"
EndProject
@@ -47,6 +47,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflow-tests", "workflow-
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WorkflowCore.Tests", "tests\LINGYUN.Abp.WorkflowCore.Tests\LINGYUN.Abp.WorkflowCore.Tests.csproj", "{0A21C843-4175-42F2-A95D-A75ED1DC1E05}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflow-core", "workflow-core", "{DFE3435C-DD59-496F-BB77-6F7D62D2EA88}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "elsa", "elsa", "{F1CCBEC7-ACAB-4DC5-909E-D8CC2E1B7EEC}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Workflow.Elsa", "modules\workflow\LINGYUN.Abp.Workflow.Elsa\LINGYUN.Abp.Workflow.Elsa.csproj", "{A6718032-429C-4136-8969-7F39EAE14E8F}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Workflow.Elsa.Server", "modules\workflow\LINGYUN.Abp.Workflow.Elsa.Server\LINGYUN.Abp.Workflow.Elsa.Server.csproj", "{2F2BDD2D-86D7-4DA9-9F69-76517A00EB5C}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -121,17 +129,27 @@ Global
{0A21C843-4175-42F2-A95D-A75ED1DC1E05}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A21C843-4175-42F2-A95D-A75ED1DC1E05}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A21C843-4175-42F2-A95D-A75ED1DC1E05}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A6718032-429C-4136-8969-7F39EAE14E8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A6718032-429C-4136-8969-7F39EAE14E8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A6718032-429C-4136-8969-7F39EAE14E8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A6718032-429C-4136-8969-7F39EAE14E8F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2F2BDD2D-86D7-4DA9-9F69-76517A00EB5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2F2BDD2D-86D7-4DA9-9F69-76517A00EB5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2F2BDD2D-86D7-4DA9-9F69-76517A00EB5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2F2BDD2D-86D7-4DA9-9F69-76517A00EB5C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
+ {A2963E0D-D290-40B2-9B36-75F4A5922ABF} = {DFE3435C-DD59-496F-BB77-6F7D62D2EA88}
{F7152D31-9292-43A8-A018-4137A6F1BD92} = {A2963E0D-D290-40B2-9B36-75F4A5922ABF}
{3DB8079B-C5B8-48C0-9F4F-1ACEA0421E17} = {A2963E0D-D290-40B2-9B36-75F4A5922ABF}
{C82A0FD1-53F3-47A2-99A4-748998B93499} = {A2963E0D-D290-40B2-9B36-75F4A5922ABF}
{A1DBB050-CA03-40FE-A097-F3AFE32C4E6D} = {A2963E0D-D290-40B2-9B36-75F4A5922ABF}
{9F46A441-3CBE-49B8-BB69-3DCAE4EF34BD} = {A2963E0D-D290-40B2-9B36-75F4A5922ABF}
{8F904E49-E6DA-499D-8127-DB60DA6B2EE9} = {A2963E0D-D290-40B2-9B36-75F4A5922ABF}
+ {15F788FB-C7D0-4EE2-B1D9-EB9F3CCB7F33} = {DFE3435C-DD59-496F-BB77-6F7D62D2EA88}
{13D116F7-C158-48D3-A78A-6F2BFAED1CDF} = {15F788FB-C7D0-4EE2-B1D9-EB9F3CCB7F33}
{F8C68D4C-297D-42E0-84FB-D271CD13FAD0} = {A2963E0D-D290-40B2-9B36-75F4A5922ABF}
{30C99D6C-29CA-4E13-A009-484A34258643} = {C4496993-41F5-4821-829E-B80A8B3BC260}
@@ -142,7 +160,10 @@ Global
{C4B1160A-BF25-4868-B962-342ABA4A96EF} = {C4496993-41F5-4821-829E-B80A8B3BC260}
{9F9453F3-7124-4C22-91E3-0DC41A4FD8AB} = {A2963E0D-D290-40B2-9B36-75F4A5922ABF}
{D5ED348D-D6F0-4093-BD7D-20E05AA1EB7B} = {6CB521FC-AC40-49A6-B9A5-91399CAA59AB}
+ {57CB3446-B825-4C55-A24A-E15EB2CAA80D} = {DFE3435C-DD59-496F-BB77-6F7D62D2EA88}
{0A21C843-4175-42F2-A95D-A75ED1DC1E05} = {57CB3446-B825-4C55-A24A-E15EB2CAA80D}
+ {A6718032-429C-4136-8969-7F39EAE14E8F} = {F1CCBEC7-ACAB-4DC5-909E-D8CC2E1B7EEC}
+ {2F2BDD2D-86D7-4DA9-9F69-76517A00EB5C} = {F1CCBEC7-ACAB-4DC5-909E-D8CC2E1B7EEC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6BB7A5DE-DA12-44DC-BC9B-0F6CA524346F}
diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/LINGYUN/Abp/TextTemplating/TextTemplateAppService.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/LINGYUN/Abp/TextTemplating/TextTemplateAppService.cs
index 0dd0e0e1f..1f90ac77f 100644
--- a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/LINGYUN/Abp/TextTemplating/TextTemplateAppService.cs
+++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/LINGYUN/Abp/TextTemplating/TextTemplateAppService.cs
@@ -110,6 +110,8 @@ public class TextTemplateAppService : AbpTextTemplatingAppServiceBase, ITextTemp
.GetListAsync(x => x.Name.Equals(templateDefinition.Name) && x.Culture.Equals(input.Culture));
await TextTemplateRepository.DeleteManyAsync(templates);
+
+ await CurrentUnitOfWork.SaveChangesAsync();
}
[Authorize(AbpTextTemplatingPermissions.TextTemplate.Update)]
diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/FodyWeavers.xml b/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/FodyWeavers.xml
new file mode 100644
index 000000000..ac6b5b292
--- /dev/null
+++ b/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/FodyWeavers.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/FodyWeavers.xsd b/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/FodyWeavers.xsd
new file mode 100644
index 000000000..11da52550
--- /dev/null
+++ b/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/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/workflow/LINGYUN.Abp.Workflow.Elsa.Server/LINGYUN.Abp.Workflow.Elsa.Server.csproj b/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/LINGYUN.Abp.Workflow.Elsa.Server.csproj
new file mode 100644
index 000000000..af75e3e64
--- /dev/null
+++ b/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/LINGYUN.Abp.Workflow.Elsa.Server.csproj
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+ net6.0
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/LINGYUN/Abp/Workflow/Elsa/AbpWorkflowElsaServerModule.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/LINGYUN/Abp/Workflow/Elsa/AbpWorkflowElsaServerModule.cs
new file mode 100644
index 000000000..3ca1b38cc
--- /dev/null
+++ b/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/LINGYUN/Abp/Workflow/Elsa/AbpWorkflowElsaServerModule.cs
@@ -0,0 +1,13 @@
+using Microsoft.Extensions.DependencyInjection;
+using Volo.Abp.Modularity;
+
+namespace LINGYUN.Abp.Workflow.Elsa;
+
+[DependsOn(typeof(AbpWorkflowElsaModule))]
+public class AbpWorkflowElsaServerModule : AbpModule
+{
+ public override void ConfigureServices(ServiceConfigurationContext context)
+ {
+ context.Services.AddElsaApiEndpoints();
+ }
+}
diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/FodyWeavers.xml b/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/FodyWeavers.xml
new file mode 100644
index 000000000..ac6b5b292
--- /dev/null
+++ b/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/FodyWeavers.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/FodyWeavers.xsd b/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/FodyWeavers.xsd
new file mode 100644
index 000000000..11da52550
--- /dev/null
+++ b/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/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/workflow/LINGYUN.Abp.Workflow.Elsa/LINGYUN.Abp.Workflow.Elsa.csproj b/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/LINGYUN.Abp.Workflow.Elsa.csproj
new file mode 100644
index 000000000..64a503192
--- /dev/null
+++ b/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/LINGYUN.Abp.Workflow.Elsa.csproj
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+ netstandard2.1
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/LINGYUN/Abp/Workflow/Elsa/AbpTenantAccessor.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/LINGYUN/Abp/Workflow/Elsa/AbpTenantAccessor.cs
new file mode 100644
index 000000000..530e0c462
--- /dev/null
+++ b/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/LINGYUN/Abp/Workflow/Elsa/AbpTenantAccessor.cs
@@ -0,0 +1,26 @@
+using Elsa.Services;
+using System.Threading;
+using System.Threading.Tasks;
+using Volo.Abp.MultiTenancy;
+
+namespace LINGYUN.Abp.Workflow.Elsa;
+
+public class AbpTenantAccessor : ITenantAccessor
+{
+ private readonly ICurrentTenant _currentTenant;
+
+ public AbpTenantAccessor(
+ ICurrentTenant currentTenant)
+ {
+ _currentTenant = currentTenant;
+ }
+
+ public Task GetTenantIdAsync(CancellationToken cancellationToken = default)
+ {
+ if (_currentTenant.IsAvailable)
+ {
+ return Task.FromResult(_currentTenant.GetId().ToString());
+ }
+ return Task.FromResult("");
+ }
+}
diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/LINGYUN/Abp/Workflow/Elsa/AbpWorkflowElsaModule.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/LINGYUN/Abp/Workflow/Elsa/AbpWorkflowElsaModule.cs
new file mode 100644
index 000000000..c1065058d
--- /dev/null
+++ b/aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/LINGYUN/Abp/Workflow/Elsa/AbpWorkflowElsaModule.cs
@@ -0,0 +1,37 @@
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Options;
+using Newtonsoft.Json;
+using System.Collections.Generic;
+using System.Linq;
+using Volo.Abp.Json.Newtonsoft;
+using Volo.Abp.Modularity;
+using ElsaOptionsBuilder = Elsa.Options.ElsaOptionsBuilder;
+
+namespace LINGYUN.Abp.Workflow.Elsa;
+
+public class AbpWorkflowElsaModule : AbpModule
+{
+ public override void ConfigureServices(ServiceConfigurationContext context)
+ {
+ var builder = context.Services.GetPreConfigureActions();
+
+ context.Services.AddElsa(options =>
+ {
+ options.AddCustomTenantAccessor();
+ options.AddConsoleActivities();
+ options.UseJsonSerializer((provider) =>
+ {
+ var jsonOptions = provider.GetRequiredService>();
+ var jsonConverters = jsonOptions.Value.Converters
+ .Select(c => (JsonConverter)provider.GetRequiredService(c))
+ .ToList();
+ var jsonSettings = new JsonSerializerSettings();
+ jsonSettings.Converters.InsertRange(0, jsonConverters);
+
+ return JsonSerializer.Create(jsonSettings);
+ });
+
+ builder.Configure(options);
+ });
+ }
+}
diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/EntityFrameworkCore/WorkflowManagementMigrationsDbContext.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/EntityFrameworkCore/WorkflowManagementMigrationsDbContext.cs
index 44bbb3b19..999446046 100644
--- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/EntityFrameworkCore/WorkflowManagementMigrationsDbContext.cs
+++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/EntityFrameworkCore/WorkflowManagementMigrationsDbContext.cs
@@ -1,6 +1,4 @@
-using LINGYUN.Abp.WorkflowCore.Persistence.EntityFrameworkCore;
-using LINGYUN.Abp.WorkflowManagement.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
namespace LY.MicroService.WorkflowManagement.EntityFrameworkCore;
@@ -17,7 +15,7 @@ public class WorkflowManagementMigrationsDbContext : AbpDbContext(
- (connectionString, builder) =>
- {
- builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString));
+ //await DbSchemaMigrator.MigrateAsync(
+ // (connectionString, builder) =>
+ // {
+ // builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString));
- return new WorkflowManagementDbContext(builder.Options);
- });
+ // return new WorkflowManagementDbContext(builder.Options);
+ // });
Logger.LogInformation("Migrated the new tenant database with WorkflowManagement...");
await DataSeeder.SeedAsync(new DataSeedContext(eventData.Id));
diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj
index da09fc5a5..5248cd744 100644
--- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj
+++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj
@@ -7,6 +7,9 @@
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
@@ -26,7 +29,6 @@
-
@@ -44,15 +46,8 @@
-
-
-
-
-
-
-
-
-
+
+
diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowEngineManager.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowEngineManager.cs
index d705f9c6f..41e794a02 100644
--- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowEngineManager.cs
+++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowEngineManager.cs
@@ -1,62 +1,58 @@
using LINGYUN.Abp.Data.DbMigrator;
-using LINGYUN.Abp.WorkflowCore.Persistence.EntityFrameworkCore;
-using LINGYUN.Abp.WorkflowManagement;
-using LINGYUN.Abp.WorkflowManagement.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
-using WorkflowCore.Interface;
namespace LY.MicroService.WorkflowManagement;
-public class WorkflowEngineManager : IWorkflowEngineManager, ISingletonDependency
-{
- private readonly IWorkflowHost _workflowHost;
- private readonly IDbSchemaMigrator _dbSchemaMigrator;
-
- private readonly ILogger _logger;
- public WorkflowEngineManager(
- IWorkflowHost workflowHost,
- IDbSchemaMigrator dbSchemaMigrator,
- ILogger logger)
- {
- _logger = logger;
- _workflowHost = workflowHost;
- _dbSchemaMigrator = dbSchemaMigrator;
- }
-
- public async Task InitializeAsync(CancellationToken cancellationToken = default)
- {
- _logger.LogInformation("Migrating workflow core context...");
- await _dbSchemaMigrator.MigrateAsync(
- (connectionString, builder) =>
- {
- builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString));
-
- return new WorkflowDbContext(builder.Options);
- });
- _logger.LogInformation("Migrated workflow core context.");
-
- _logger.LogInformation("Migrating workflow management context...");
- await _dbSchemaMigrator.MigrateAsync(
- (connectionString, builder) =>
- {
- builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString));
-
- return new WorkflowManagementDbContext(builder.Options);
- });
- _logger.LogInformation("Migrated workflow management context.");
- }
-
- public async Task StartAsync(CancellationToken cancellationToken = default)
- {
- await _workflowHost.StartAsync(cancellationToken);
- }
-
- public async Task StopAsync(CancellationToken cancellationToken = default)
- {
- await _workflowHost.StopAsync(cancellationToken);
- }
-}
+//public class WorkflowEngineManager : IWorkflowEngineManager, ISingletonDependency
+//{
+// private readonly IWorkflowHost _workflowHost;
+// private readonly IDbSchemaMigrator _dbSchemaMigrator;
+
+// private readonly ILogger _logger;
+// public WorkflowEngineManager(
+// IWorkflowHost workflowHost,
+// IDbSchemaMigrator dbSchemaMigrator,
+// ILogger logger)
+// {
+// _logger = logger;
+// _workflowHost = workflowHost;
+// _dbSchemaMigrator = dbSchemaMigrator;
+// }
+
+// public async Task InitializeAsync(CancellationToken cancellationToken = default)
+// {
+// _logger.LogInformation("Migrating workflow core context...");
+// await _dbSchemaMigrator.MigrateAsync(
+// (connectionString, builder) =>
+// {
+// builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString));
+
+// return new WorkflowDbContext(builder.Options);
+// });
+// _logger.LogInformation("Migrated workflow core context.");
+
+// _logger.LogInformation("Migrating workflow management context...");
+// await _dbSchemaMigrator.MigrateAsync(
+// (connectionString, builder) =>
+// {
+// builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString));
+
+// return new WorkflowManagementDbContext(builder.Options);
+// });
+// _logger.LogInformation("Migrated workflow management context.");
+// }
+
+// public async Task StartAsync(CancellationToken cancellationToken = default)
+// {
+// await _workflowHost.StartAsync(cancellationToken);
+// }
+
+// public async Task StopAsync(CancellationToken cancellationToken = default)
+// {
+// await _workflowHost.StopAsync(cancellationToken);
+// }
+//}
diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs
index 60e5e1e40..4b1d99b6b 100644
--- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs
+++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs
@@ -1,12 +1,16 @@
-using LINGYUN.Abp.BlobStoring.OssManagement;
+using Elsa;
+using Elsa.Options;
+using Elsa.Persistence.EntityFramework.Core.Extensions;
+using Elsa.Persistence.EntityFramework.MySql;
+using LINGYUN.Abp.BlobStoring.OssManagement;
using LINGYUN.Abp.ExceptionHandling;
using LINGYUN.Abp.ExceptionHandling.Emailing;
using LINGYUN.Abp.Serilog.Enrichers.Application;
-using LINGYUN.Abp.WorkflowCore.Components;
using Medallion.Threading;
using Medallion.Threading.Redis;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.DataProtection;
+using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.StackExchangeRedis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -47,6 +51,19 @@ public partial class WorkflowManagementHttpApiHostModule
AbpSerilogEnrichersConsts.ApplicationName = "WorkflowManagement";
}
+ private void PreConfigureElsa(IConfiguration configuration)
+ {
+ PreConfigure(builder =>
+ {
+ // TODO: 取消注释持久化
+ //var connectionString = configuration.GetConnectionString("Workflow");
+ //builder.UseEntityFrameworkPersistence(ef =>
+ // ef.UseMySql(connectionString));
+ builder.AddQuartzTemporalActivities()
+ .AddJavaScriptActivities();
+ });
+ }
+
private void ConfigureDistributedLock(IServiceCollection services, IConfiguration configuration)
{
var redis = ConnectionMultiplexer.Connect(configuration["DistributedLock:Redis:Configuration"]);
@@ -59,7 +76,14 @@ public partial class WorkflowManagementHttpApiHostModule
Configure(options =>
{
preActions.Configure(options);
- options.Containers.Configure((containerConfiguration) =>
+ //options.Containers.Configure((containerConfiguration) =>
+ //{
+ // containerConfiguration.UseOssManagement(config =>
+ // {
+ // config.Bucket = configuration[OssManagementBlobProviderConfigurationNames.Bucket] ?? "workflow";
+ // });
+ //});
+ options.Containers.ConfigureAll((_, containerConfiguration) =>
{
containerConfiguration.UseOssManagement(config =>
{
diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs
index 6576fa8ff..44f41790f 100644
--- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs
+++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs
@@ -6,13 +6,7 @@ using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore;
using LINGYUN.Abp.Saas.EntityFrameworkCore;
using LINGYUN.Abp.Serilog.Enrichers.Application;
using LINGYUN.Abp.Serilog.Enrichers.UniqueId;
-using LINGYUN.Abp.WorkflowCore.Components;
-using LINGYUN.Abp.WorkflowCore.DistributedLock;
-using LINGYUN.Abp.WorkflowCore.LifeCycleEvent;
-using LINGYUN.Abp.WorkflowCore.Persistence.EntityFrameworkCore;
-using LINGYUN.Abp.WorkflowCore.RabbitMQ;
-using LINGYUN.Abp.WorkflowManagement;
-using LINGYUN.Abp.WorkflowManagement.EntityFrameworkCore;
+using LINGYUN.Abp.Workflow.Elsa;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
@@ -25,7 +19,6 @@ using Volo.Abp.AspNetCore.Serilog;
using Volo.Abp.Autofac;
using Volo.Abp.Caching.StackExchangeRedis;
using Volo.Abp.EntityFrameworkCore.MySQL;
-using Volo.Abp.EventBus.RabbitMq;
using Volo.Abp.FeatureManagement.EntityFrameworkCore;
using Volo.Abp.Http.Client.IdentityModel.Web;
using Volo.Abp.Modularity;
@@ -40,16 +33,17 @@ namespace LY.MicroService.WorkflowManagement;
typeof(AbpSerilogEnrichersUniqueIdModule),
typeof(AbpAuditLoggingElasticsearchModule),
typeof(AbpAspNetCoreSerilogModule),
- typeof(AbpEventBusRabbitMqModule),
typeof(AbpBlobStoringOssManagementModule),
- typeof(WorkflowManagementApplicationModule),
- typeof(WorkflowManagementHttpApiModule),
- typeof(WorkflowManagementEntityFrameworkCoreModule),
- typeof(AbpWorkflowCoreComponentsModule),
- typeof(AbpWorkflowCoreDistributedLockModule),
- typeof(AbpWorkflowCoreLifeCycleEventModule),
- typeof(AbpWorkflowCoreRabbitMQModule),
- typeof(AbpWorkflowCorePersistenceEntityFrameworkCoreModule),
+ typeof(AbpWorkflowElsaModule),
+ typeof(AbpWorkflowElsaServerModule),
+ //typeof(WorkflowManagementApplicationModule),
+ //typeof(WorkflowManagementHttpApiModule),
+ //typeof(WorkflowManagementEntityFrameworkCoreModule),
+ //typeof(AbpWorkflowCoreComponentsModule),
+ //typeof(AbpWorkflowCoreDistributedLockModule),
+ //typeof(AbpWorkflowCoreLifeCycleEventModule),
+ //typeof(AbpWorkflowCoreRabbitMQModule),
+ //typeof(AbpWorkflowCorePersistenceEntityFrameworkCoreModule),
typeof(AbpEntityFrameworkCoreMySQLModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpEmailingExceptionHandlingModule),
@@ -70,8 +64,11 @@ public partial class WorkflowManagementHttpApiHostModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
+ var configuration = context.Services.GetConfiguration();
+
PreConfigureApp();
PreConfigureFeature();
+ PreConfigureElsa(configuration);
}
public override void ConfigureServices(ServiceConfigurationContext context)
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 2a5e3458f..246bc11f2 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
@@ -12,6 +12,7 @@
},
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=Workflow;User Id=root;Password=123456",
+ "Workflow": "Server=127.0.0.1;Database=Elsa;User Id=root;Password=123456",
"WorkflowManagement": "Server=127.0.0.1;Database=Workflow;User Id=root;Password=123456",
"AbpWorkflowCore": "Server=127.0.0.1;Database=Workflow;User Id=root;Password=123456",
"AbpFeatureManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456",