Browse Source

feat: 集成elsa

pull/612/head
cKey 4 years ago
parent
commit
5cd09b2637
  1. 23
      aspnet-core/LINGYUN.MicroService.Workflow.sln
  2. 2
      aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Application/LINGYUN/Abp/TextTemplating/TextTemplateAppService.cs
  3. 3
      aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/FodyWeavers.xml
  4. 30
      aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/FodyWeavers.xsd
  5. 19
      aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/LINGYUN.Abp.Workflow.Elsa.Server.csproj
  6. 13
      aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/LINGYUN/Abp/Workflow/Elsa/AbpWorkflowElsaServerModule.cs
  7. 3
      aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/FodyWeavers.xml
  8. 30
      aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/FodyWeavers.xsd
  9. 19
      aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/LINGYUN.Abp.Workflow.Elsa.csproj
  10. 26
      aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/LINGYUN/Abp/Workflow/Elsa/AbpTenantAccessor.cs
  11. 37
      aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/LINGYUN/Abp/Workflow/Elsa/AbpWorkflowElsaModule.cs
  12. 8
      aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/EntityFrameworkCore/WorkflowManagementMigrationsDbContext.cs
  13. 15
      aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/EventBus/Handlers/TenantSynchronizer.cs
  14. 15
      aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj
  15. 102
      aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowEngineManager.cs
  16. 30
      aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs
  17. 31
      aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs
  18. 1
      aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/appsettings.Development.json

23
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}

2
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)]

3
aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/FodyWeavers.xml

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait />
</Weavers>

30
aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/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>

19
aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa.Server/LINGYUN.Abp.Workflow.Elsa.Server.csproj

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\configureawait.props" />
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Elsa.Server.Api" Version="2.8.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LINGYUN.Abp.Workflow.Elsa\LINGYUN.Abp.Workflow.Elsa.csproj" />
</ItemGroup>
</Project>

13
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();
}
}

3
aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/FodyWeavers.xml

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait />
</Weavers>

30
aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/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>

19
aspnet-core/modules/workflow/LINGYUN.Abp.Workflow.Elsa/LINGYUN.Abp.Workflow.Elsa.csproj

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\configureawait.props" />
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Features" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Timing" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Threading" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Json" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Elsa" Version="2.8.2" />
</ItemGroup>
</Project>

26
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<string> GetTenantIdAsync(CancellationToken cancellationToken = default)
{
if (_currentTenant.IsAvailable)
{
return Task.FromResult(_currentTenant.GetId().ToString());
}
return Task.FromResult("");
}
}

37
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<ElsaOptionsBuilder>();
context.Services.AddElsa(options =>
{
options.AddCustomTenantAccessor<AbpTenantAccessor>();
options.AddConsoleActivities();
options.UseJsonSerializer((provider) =>
{
var jsonOptions = provider.GetRequiredService<IOptions<AbpNewtonsoftJsonSerializerOptions>>();
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);
});
}
}

8
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<WorkflowManage
{
base.OnModelCreating(modelBuilder);
modelBuilder.ConfigureWorkflow();
modelBuilder.ConfigureWorkflowManagement();
// modelBuilder.ConfigureWorkflow();
//modelBuilder.ConfigureWorkflowManagement();
}
}

15
aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/EventBus/Handlers/TenantSynchronizer.cs

@ -1,5 +1,4 @@
using LINGYUN.Abp.WorkflowManagement.EntityFrameworkCore;
using LINGYUN.Abp.Data.DbMigrator;
using LINGYUN.Abp.Data.DbMigrator;
using LINGYUN.Abp.MultiTenancy;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
@ -51,13 +50,13 @@ public class TenantSynchronizer :
{
Logger.LogInformation("Migrating the new tenant database with WorkflowManagement...");
// 迁移租户数据
await DbSchemaMigrator.MigrateAsync<WorkflowManagementDbContext>(
(connectionString, builder) =>
{
builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString));
//await DbSchemaMigrator.MigrateAsync<WorkflowManagementDbContext>(
// (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));

15
aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj

@ -7,6 +7,9 @@
<ItemGroup>
<PackageReference Include="AgileConfig.Client" Version="$(AgileConfigClientPackageVersion)" />
<PackageReference Include="Elsa.Activities.Http" Version="2.8.2" />
<PackageReference Include="Elsa.Activities.Temporal.Quartz" Version="2.8.2" />
<PackageReference Include="Elsa.Persistence.EntityFramework.MySql" Version="2.8.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="$(MicrosoftPackageVersion)">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@ -26,7 +29,6 @@
<PackageReference Include="Volo.Abp.AspNetCore.MultiTenancy" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Autofac" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.EventBus.RabbitMQ" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Swashbuckle" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySql" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Http.Client.IdentityModel.Web" Version="$(VoloAbpPackageVersion)" />
@ -44,15 +46,8 @@
<ProjectReference Include="..\..\modules\logging\LINGYUN.Abp.Serilog.Enrichers.UniqueId\LINGYUN.Abp.Serilog.Enrichers.UniqueId.csproj" />
<ProjectReference Include="..\..\modules\lt\LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore\LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\modules\oss-management\LINGYUN.Abp.BlobStoring.OssManagement\LINGYUN.Abp.BlobStoring.OssManagement.csproj" />
<ProjectReference Include="..\..\modules\workflow\LINGYUN.Abp.WorkflowCore.Components\LINGYUN.Abp.WorkflowCore.Components.csproj" />
<ProjectReference Include="..\..\modules\workflow\LINGYUN.Abp.WorkflowCore.DistributedLock\LINGYUN.Abp.WorkflowCore.DistributedLock.csproj" />
<ProjectReference Include="..\..\modules\workflow\LINGYUN.Abp.WorkflowCore.Elasticsearch\LINGYUN.Abp.WorkflowCore.Elasticsearch.csproj" />
<ProjectReference Include="..\..\modules\workflow\LINGYUN.Abp.WorkflowCore.LifeCycleEvent\LINGYUN.Abp.WorkflowCore.LifeCycleEvent.csproj" />
<ProjectReference Include="..\..\modules\workflow\LINGYUN.Abp.WorkflowCore.Persistence.EntityFrameworkCore\LINGYUN.Abp.WorkflowCore.Persistence.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\modules\workflow\LINGYUN.Abp.WorkflowCore.RabbitMQ\LINGYUN.Abp.WorkflowCore.RabbitMQ.csproj" />
<ProjectReference Include="..\..\modules\workflow\LINGYUN.Abp.WorkflowManagement.Application\LINGYUN.Abp.WorkflowManagement.Application.csproj" />
<ProjectReference Include="..\..\modules\workflow\LINGYUN.Abp.WorkflowManagement.EntityFrameworkCore\LINGYUN.Abp.WorkflowManagement.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\modules\workflow\LINGYUN.Abp.WorkflowManagement.HttpApi\LINGYUN.Abp.WorkflowManagement.HttpApi.csproj" />
<ProjectReference Include="..\..\modules\workflow\LINGYUN.Abp.Workflow.Elsa.Server\LINGYUN.Abp.Workflow.Elsa.Server.csproj" />
<ProjectReference Include="..\..\modules\workflow\LINGYUN.Abp.Workflow.Elsa\LINGYUN.Abp.Workflow.Elsa.csproj" />
</ItemGroup>
</Project>

102
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<WorkflowEngineManager> _logger;
public WorkflowEngineManager(
IWorkflowHost workflowHost,
IDbSchemaMigrator dbSchemaMigrator,
ILogger<WorkflowEngineManager> logger)
{
_logger = logger;
_workflowHost = workflowHost;
_dbSchemaMigrator = dbSchemaMigrator;
}
public async Task InitializeAsync(CancellationToken cancellationToken = default)
{
_logger.LogInformation("Migrating workflow core context...");
await _dbSchemaMigrator.MigrateAsync<WorkflowDbContext>(
(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<WorkflowManagementDbContext>(
(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<WorkflowEngineManager> _logger;
// public WorkflowEngineManager(
// IWorkflowHost workflowHost,
// IDbSchemaMigrator dbSchemaMigrator,
// ILogger<WorkflowEngineManager> logger)
// {
// _logger = logger;
// _workflowHost = workflowHost;
// _dbSchemaMigrator = dbSchemaMigrator;
// }
// public async Task InitializeAsync(CancellationToken cancellationToken = default)
// {
// _logger.LogInformation("Migrating workflow core context...");
// await _dbSchemaMigrator.MigrateAsync<WorkflowDbContext>(
// (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<WorkflowManagementDbContext>(
// (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);
// }
//}

30
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<ElsaOptionsBuilder>(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<AbpBlobStoringOptions>(options =>
{
preActions.Configure(options);
options.Containers.Configure<WorkflowContainer>((containerConfiguration) =>
//options.Containers.Configure<WorkflowContainer>((containerConfiguration) =>
//{
// containerConfiguration.UseOssManagement(config =>
// {
// config.Bucket = configuration[OssManagementBlobProviderConfigurationNames.Bucket] ?? "workflow";
// });
//});
options.Containers.ConfigureAll((_, containerConfiguration) =>
{
containerConfiguration.UseOssManagement(config =>
{

31
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)

1
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",

Loading…
Cancel
Save