18 changed files with 310 additions and 97 deletions
@ -0,0 +1,3 @@ |
|||||
|
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
||||
|
<ConfigureAwait /> |
||||
|
</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,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> |
||||
@ -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(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
||||
|
<ConfigureAwait /> |
||||
|
</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,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> |
||||
@ -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(""); |
||||
|
} |
||||
|
} |
||||
@ -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); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -1,62 +1,58 @@ |
|||||
using LINGYUN.Abp.Data.DbMigrator; |
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.EntityFrameworkCore; |
||||
using Microsoft.Extensions.Logging; |
using Microsoft.Extensions.Logging; |
||||
using System.Threading; |
using System.Threading; |
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
using Volo.Abp.DependencyInjection; |
using Volo.Abp.DependencyInjection; |
||||
using WorkflowCore.Interface; |
|
||||
|
|
||||
namespace LY.MicroService.WorkflowManagement; |
namespace LY.MicroService.WorkflowManagement; |
||||
|
|
||||
public class WorkflowEngineManager : IWorkflowEngineManager, ISingletonDependency |
//public class WorkflowEngineManager : IWorkflowEngineManager, ISingletonDependency
|
||||
{ |
//{
|
||||
private readonly IWorkflowHost _workflowHost; |
// private readonly IWorkflowHost _workflowHost;
|
||||
private readonly IDbSchemaMigrator _dbSchemaMigrator; |
// private readonly IDbSchemaMigrator _dbSchemaMigrator;
|
||||
|
|
||||
private readonly ILogger<WorkflowEngineManager> _logger; |
// private readonly ILogger<WorkflowEngineManager> _logger;
|
||||
public WorkflowEngineManager( |
// public WorkflowEngineManager(
|
||||
IWorkflowHost workflowHost, |
// IWorkflowHost workflowHost,
|
||||
IDbSchemaMigrator dbSchemaMigrator, |
// IDbSchemaMigrator dbSchemaMigrator,
|
||||
ILogger<WorkflowEngineManager> logger) |
// ILogger<WorkflowEngineManager> logger)
|
||||
{ |
// {
|
||||
_logger = logger; |
// _logger = logger;
|
||||
_workflowHost = workflowHost; |
// _workflowHost = workflowHost;
|
||||
_dbSchemaMigrator = dbSchemaMigrator; |
// _dbSchemaMigrator = dbSchemaMigrator;
|
||||
} |
// }
|
||||
|
|
||||
public async Task InitializeAsync(CancellationToken cancellationToken = default) |
// public async Task InitializeAsync(CancellationToken cancellationToken = default)
|
||||
{ |
// {
|
||||
_logger.LogInformation("Migrating workflow core context..."); |
// _logger.LogInformation("Migrating workflow core context...");
|
||||
await _dbSchemaMigrator.MigrateAsync<WorkflowDbContext>( |
// await _dbSchemaMigrator.MigrateAsync<WorkflowDbContext>(
|
||||
(connectionString, builder) => |
// (connectionString, builder) =>
|
||||
{ |
// {
|
||||
builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
// builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString));
|
||||
|
|
||||
return new WorkflowDbContext(builder.Options); |
// return new WorkflowDbContext(builder.Options);
|
||||
}); |
// });
|
||||
_logger.LogInformation("Migrated workflow core context."); |
// _logger.LogInformation("Migrated workflow core context.");
|
||||
|
|
||||
_logger.LogInformation("Migrating workflow management context..."); |
// _logger.LogInformation("Migrating workflow management context...");
|
||||
await _dbSchemaMigrator.MigrateAsync<WorkflowManagementDbContext>( |
// await _dbSchemaMigrator.MigrateAsync<WorkflowManagementDbContext>(
|
||||
(connectionString, builder) => |
// (connectionString, builder) =>
|
||||
{ |
// {
|
||||
builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
// builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString));
|
||||
|
|
||||
return new WorkflowManagementDbContext(builder.Options); |
// return new WorkflowManagementDbContext(builder.Options);
|
||||
}); |
// });
|
||||
_logger.LogInformation("Migrated workflow management context."); |
// _logger.LogInformation("Migrated workflow management context.");
|
||||
} |
// }
|
||||
|
|
||||
public async Task StartAsync(CancellationToken cancellationToken = default) |
// public async Task StartAsync(CancellationToken cancellationToken = default)
|
||||
{ |
// {
|
||||
await _workflowHost.StartAsync(cancellationToken); |
// await _workflowHost.StartAsync(cancellationToken);
|
||||
} |
// }
|
||||
|
|
||||
public async Task StopAsync(CancellationToken cancellationToken = default) |
// public async Task StopAsync(CancellationToken cancellationToken = default)
|
||||
{ |
// {
|
||||
await _workflowHost.StopAsync(cancellationToken); |
// await _workflowHost.StopAsync(cancellationToken);
|
||||
} |
// }
|
||||
} |
//}
|
||||
|
|||||
Loading…
Reference in new issue