Additional samples + fixes and improvements (#3574)
* Incremental work on samples * Rename HTTP middleware and update samples * Rename HTTP Activities to Workflows * Automatically register core activities when adding Elsa * Fix feature registration bug * Add default auth feature * Make activity serializer more flexible * Bump designer version * Add workflow server + designer samples * Simplify EntityFrameworkCore projects * Update solution * Add Sqlite package references to ensure the correct version is used * Update sample project with EF Core * Update EF extensions * Add server + designer sample project * Cleanup AllInOne project and add some XML comments * Rename ci.yml and add CI for Docker file
This commit is contained in:
parent
b3a6c6d80e
commit
e6536636d7
61
.github/workflows/all-in-one-web.yml
vendored
Normal file
61
.github/workflows/all-in-one-web.yml
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
name: Build and deploy All In One reference application as Docker image
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- v3
|
||||
|
||||
jobs:
|
||||
push_to_registry:
|
||||
name: Push Docker image to Docker Hub
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
with:
|
||||
platforms: all
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v3
|
||||
with:
|
||||
# list of Docker images to use as base name for tags
|
||||
images: |
|
||||
elsaworkflows/elsa-v3
|
||||
flavor: |
|
||||
latest=true
|
||||
# generate Docker tags based on the following events/attributes
|
||||
tags: |
|
||||
type=sha
|
||||
|
||||
- name: Login to DockerHub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USER }}
|
||||
password: ${{ secrets.DOCKER_PASS }}
|
||||
|
||||
- name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
context: .
|
||||
file: ./src/bundles/Elsa.AllInOne.Web/Dockerfile
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
|
||||
- name: Image digest
|
||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||
37
Elsa.sln
37
Elsa.sln
|
|
@ -12,9 +12,10 @@ ProjectSection(SolutionItems) = preProject
|
|||
docker-compose.yml = docker-compose.yml
|
||||
common.props = common.props
|
||||
configureawait.props = configureawait.props
|
||||
.github\workflows\ci.yml = .github\workflows\ci.yml
|
||||
.gitignore = .gitignore
|
||||
icon.png = icon.png
|
||||
.github\workflows\packages.yml = .github\workflows\packages.yml
|
||||
.github\workflows\all-in-one-web.yml = .github\workflows\all-in-one-web.yml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{0354F050-3992-4DD4-B0EE-5FBA04AC72B6}"
|
||||
|
|
@ -93,9 +94,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Common", "src\modules\
|
|||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "worker", "worker", "{389D40B8-005F-46A1-9493-1FE6065F04FD}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Persistence.EntityFrameworkCore", "src\modules\Elsa.Persistence.EntityFrameworkCore\Elsa.Persistence.EntityFrameworkCore.csproj", "{7CC95512-7F44-45C3-A669-95B7048D4730}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.EntityFrameworkCore", "src\modules\Elsa.EntityFrameworkCore\Elsa.EntityFrameworkCore.csproj", "{7CC95512-7F44-45C3-A669-95B7048D4730}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Persistence.EntityFrameworkCore.Sqlite", "src\modules\Elsa.Persistence.EntityFrameworkCore.Sqlite\Elsa.Persistence.EntityFrameworkCore.Sqlite.csproj", "{CAC22763-4A1C-4FC5-AC0D-6148927596D6}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.EntityFrameworkCore.Sqlite", "src\modules\Elsa.EntityFrameworkCore.Sqlite\Elsa.EntityFrameworkCore.Sqlite.csproj", "{CAC22763-4A1C-4FC5-AC0D-6148927596D6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.HelloWorld", "src\samples\console\Elsa.Samples.HelloWorld\Elsa.Samples.HelloWorld.csproj", "{D253AFC2-9496-4538-B424-47CC579B7A96}"
|
||||
EndProject
|
||||
|
|
@ -111,7 +112,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.TelnyxIntegrat
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.Composition", "src\samples\console\Elsa.Samples.Composition\Elsa.Samples.Composition.csproj", "{1AA0AEFC-BD58-4284-A6C5-AD15C5C79782}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Persistence.EntityFrameworkCore.SqlServer", "src\modules\Elsa.Persistence.EntityFrameworkCore.SqlServer\Elsa.Persistence.EntityFrameworkCore.SqlServer.csproj", "{555A4306-3BAB-409E-8BB8-3171A5867B2C}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.EntityFrameworkCore.SqlServer", "src\modules\Elsa.EntityFrameworkCore.SqlServer\Elsa.EntityFrameworkCore.SqlServer.csproj", "{555A4306-3BAB-409E-8BB8-3171A5867B2C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Email", "src\modules\Elsa.Email\Elsa.Email.csproj", "{1E5BD8D9-55BE-41E2-B389-6AB9F26C22AF}"
|
||||
EndProject
|
||||
|
|
@ -123,6 +124,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Testing.Shared", "src\
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.WorkflowFunctions", "src\samples\console\Elsa.Samples.WorkflowFunctions\Elsa.Samples.WorkflowFunctions.csproj", "{4782CA82-83B0-437E-8C97-636BB8B402EA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.MyBackendApi", "src\samples\aspnet\Elsa.Samples.MyBackendApi\Elsa.Samples.MyBackendApi.csproj", "{1A37795B-EBAB-4A9F-8CF0-373DA3D4C64A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.WorkflowServer", "src\samples\aspnet\Elsa.Samples.WorkflowServer\Elsa.Samples.WorkflowServer.csproj", "{89157FB8-A25B-42EC-A91F-37DFEE274C8C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.WorkflowDesigner", "src\samples\aspnet\Elsa.Samples.WorkflowDesigner\Elsa.Samples.WorkflowDesigner.csproj", "{812B3B34-D2DD-4A3B-BA2D-3D3C52E0C062}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.WorkflowServerAndDesigner", "src\samples\aspnet\Elsa.Samples.WorkflowServerAndDesigner\Elsa.Samples.WorkflowServerAndDesigner.csproj", "{34FBB2D3-4E2B-4411-95F2-C6B56899826A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -313,6 +322,22 @@ Global
|
|||
{4782CA82-83B0-437E-8C97-636BB8B402EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4782CA82-83B0-437E-8C97-636BB8B402EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4782CA82-83B0-437E-8C97-636BB8B402EA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1A37795B-EBAB-4A9F-8CF0-373DA3D4C64A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1A37795B-EBAB-4A9F-8CF0-373DA3D4C64A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1A37795B-EBAB-4A9F-8CF0-373DA3D4C64A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1A37795B-EBAB-4A9F-8CF0-373DA3D4C64A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{89157FB8-A25B-42EC-A91F-37DFEE274C8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{89157FB8-A25B-42EC-A91F-37DFEE274C8C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{89157FB8-A25B-42EC-A91F-37DFEE274C8C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{89157FB8-A25B-42EC-A91F-37DFEE274C8C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{812B3B34-D2DD-4A3B-BA2D-3D3C52E0C062}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{812B3B34-D2DD-4A3B-BA2D-3D3C52E0C062}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{812B3B34-D2DD-4A3B-BA2D-3D3C52E0C062}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{812B3B34-D2DD-4A3B-BA2D-3D3C52E0C062}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{34FBB2D3-4E2B-4411-95F2-C6B56899826A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{34FBB2D3-4E2B-4411-95F2-C6B56899826A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{34FBB2D3-4E2B-4411-95F2-C6B56899826A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{34FBB2D3-4E2B-4411-95F2-C6B56899826A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{155227F0-A33B-40AA-A4B4-06F813EB921B} = {61017E64-6D00-49CB-9E81-5002DC8F7D5F}
|
||||
|
|
@ -368,5 +393,9 @@ Global
|
|||
{DF8CCA17-6B00-42C6-B4EC-61B42AA91EE0} = {56C2FFB8-EA54-45B5-A095-4A78142EB4B5}
|
||||
{AD8C4BB0-C78F-496C-B326-1D82C02C7568} = {C6658DE0-2B2F-47F0-BB61-2CA66D435C09}
|
||||
{4782CA82-83B0-437E-8C97-636BB8B402EA} = {873BFC3E-63C2-4495-A503-5EC05DCD84E4}
|
||||
{1A37795B-EBAB-4A9F-8CF0-373DA3D4C64A} = {56C2FFB8-EA54-45B5-A095-4A78142EB4B5}
|
||||
{89157FB8-A25B-42EC-A91F-37DFEE274C8C} = {56C2FFB8-EA54-45B5-A095-4A78142EB4B5}
|
||||
{812B3B34-D2DD-4A3B-BA2D-3D3C52E0C062} = {56C2FFB8-EA54-45B5-A095-4A78142EB4B5}
|
||||
{34FBB2D3-4E2B-4411-95F2-C6B56899826A} = {56C2FFB8-EA54-45B5-A095-4A78142EB4B5}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=abcdefghijklmnopqrstuvwxyz/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Deconstructor/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Telnyx/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
|
|
@ -16,8 +16,8 @@
|
|||
<ProjectReference Include="..\..\modules\Elsa.Identity\Elsa.Identity.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.Jobs\Elsa.Jobs.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.Liquid\Elsa.Liquid.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.Persistence.EntityFrameworkCore.Sqlite\Elsa.Persistence.EntityFrameworkCore.Sqlite.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.Persistence.EntityFrameworkCore\Elsa.Persistence.EntityFrameworkCore.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.EntityFrameworkCore.Sqlite\Elsa.EntityFrameworkCore.Sqlite.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.EntityFrameworkCore\Elsa.EntityFrameworkCore.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.Quartz\Elsa.Quartz.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.Workflows.Api\Elsa.Workflows.Api.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.Workflows.Designer\Elsa.Workflows.Designer.csproj" />
|
||||
|
|
|
|||
|
|
@ -1,38 +1,29 @@
|
|||
using Elsa.Extensions;
|
||||
using Elsa.Jobs.Extensions;
|
||||
using Elsa.Http;
|
||||
using Elsa.Http.Extensions;
|
||||
using Elsa.Identity;
|
||||
using Elsa.Identity.Extensions;
|
||||
using Elsa.Identity.Features;
|
||||
using Elsa.Identity.Options;
|
||||
using Elsa.JavaScript.Activities;
|
||||
using Elsa.JavaScript.Extensions;
|
||||
using Elsa.Labels.Extensions;
|
||||
using Elsa.Scheduling.Activities;
|
||||
using Elsa.Liquid.Extensions;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.ActivityDefinitions;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.Labels;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.Runtime;
|
||||
using Elsa.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
using Elsa.EntityFrameworkCore.Modules.Labels;
|
||||
using Elsa.EntityFrameworkCore.Modules.Runtime;
|
||||
using Elsa.EntityFrameworkCore.Sqlite.Modules.ActivityDefinitions;
|
||||
using Elsa.EntityFrameworkCore.Sqlite.Modules.Labels;
|
||||
using Elsa.EntityFrameworkCore.Sqlite.Modules.Runtime;
|
||||
using Elsa.Requirements;
|
||||
using Elsa.Scheduling.Extensions;
|
||||
using Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Post;
|
||||
using Elsa.Workflows.Api.Features;
|
||||
using Elsa.Workflows.Core;
|
||||
using Elsa.Workflows.Core.Activities;
|
||||
using Elsa.Workflows.Management.Extensions;
|
||||
using Elsa.Workflows.Runtime.Extensions;
|
||||
using FastEndpoints;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
var services = builder.Services;
|
||||
var configuration = builder.Configuration;
|
||||
var sqliteConnectionString = configuration.GetConnectionString("Sqlite");
|
||||
var sqliteConnectionString = configuration.GetConnectionString("Sqlite")!;
|
||||
var identityOptions = new IdentityOptions();
|
||||
var identitySection = configuration.GetSection("Identity");
|
||||
identitySection.Bind(identityOptions);
|
||||
|
|
@ -41,19 +32,13 @@ identitySection.Bind(identityOptions);
|
|||
services
|
||||
.AddElsa(elsa => elsa
|
||||
.UseWorkflows()
|
||||
.UseWorkflowRuntime()
|
||||
.UseWorkflowManagement(management => management
|
||||
.AddActivitiesFrom<WriteLine>()
|
||||
.AddActivitiesFrom<HttpEndpoint>()
|
||||
.AddActivitiesFrom<Delay>()
|
||||
.AddActivitiesFrom<RunJavaScript>()
|
||||
)
|
||||
.UseWorkflowApiEndpoints()
|
||||
.UseWorkflowsApi()
|
||||
.UseIdentity(identity =>
|
||||
{
|
||||
identity.CreateDefaultUser = true;
|
||||
identity.IdentityOptions = options => identitySection.Bind(options);
|
||||
identity.IdentityOptions = identityOptions;
|
||||
})
|
||||
.UseDefaultAuthentication()
|
||||
.UseWorkflowRuntime(runtime => { runtime.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString)); })
|
||||
.UseLabels(labels => labels.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString)))
|
||||
.UseActivityDefinitions(feature => feature.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString)))
|
||||
|
|
@ -62,16 +47,9 @@ services
|
|||
.UseJavaScript()
|
||||
.UseLiquid()
|
||||
.UseHttp()
|
||||
.UseActivityDefinitions()
|
||||
);
|
||||
|
||||
services.AddHealthChecks();
|
||||
|
||||
// Authentication & Authorization.
|
||||
services
|
||||
.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||
.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, identityOptions.ConfigureJwtBearerOptions);
|
||||
|
||||
services.AddHttpContextAccessor();
|
||||
services.AddSingleton<IAuthorizationHandler, LocalHostRequirementHandler>();
|
||||
services.AddAuthorization(options => options.AddPolicy(IdentityPolicyNames.SecurityRoot, policy => policy.AddRequirements(new LocalHostRequirement())));
|
||||
|
|
@ -95,8 +73,8 @@ app.UseStaticFiles();
|
|||
app.UseRouting();
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
app.UseElsaFastEndpoints();
|
||||
app.UseHttpActivities();
|
||||
app.UseWorkflowsApi();
|
||||
app.UseWorkflows();
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\modules\Elsa.Jobs.Activities\Elsa.Jobs.Activities.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.ActivityDefinitions\Elsa.ActivityDefinitions.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.Persistence.EntityFrameworkCore.Sqlite\Elsa.Persistence.EntityFrameworkCore.Sqlite.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.Persistence.EntityFrameworkCore\Elsa.Persistence.EntityFrameworkCore.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.EntityFrameworkCore.Sqlite\Elsa.EntityFrameworkCore.Sqlite.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.EntityFrameworkCore\Elsa.EntityFrameworkCore.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.ProtoActor\Elsa.ProtoActor.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.Identity\Elsa.Identity.csproj" />
|
||||
<ProjectReference Include="..\Elsa\Elsa.csproj" />
|
||||
|
|
|
|||
|
|
@ -13,16 +13,16 @@ using Elsa.Jobs.Activities.Services;
|
|||
using Elsa.Jobs.Extensions;
|
||||
using Elsa.Labels.Extensions;
|
||||
using Elsa.Liquid.Extensions;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.Management;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.ActivityDefinitions;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.Labels;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.Management;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.Runtime;
|
||||
using Elsa.ProtoActor.Extensions;
|
||||
using Elsa.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
using Elsa.EntityFrameworkCore.Modules.Labels;
|
||||
using Elsa.EntityFrameworkCore.Modules.Management;
|
||||
using Elsa.EntityFrameworkCore.Modules.Runtime;
|
||||
using Elsa.EntityFrameworkCore.Sqlite.Modules.ActivityDefinitions;
|
||||
using Elsa.EntityFrameworkCore.Sqlite.Modules.Labels;
|
||||
using Elsa.EntityFrameworkCore.Sqlite.Modules.Management;
|
||||
using Elsa.EntityFrameworkCore.Sqlite.Modules.Runtime;
|
||||
using Elsa.Requirements;
|
||||
using Elsa.Scheduling.Activities;
|
||||
using Elsa.Scheduling.Extensions;
|
||||
using Elsa.WorkflowContexts.Extensions;
|
||||
using Elsa.Workflows.Api.Extensions;
|
||||
|
|
@ -32,17 +32,13 @@ using Elsa.Workflows.Core.Middleware.Workflows;
|
|||
using Elsa.Workflows.Management.Extensions;
|
||||
using Elsa.Workflows.Management.Services;
|
||||
using Elsa.Workflows.Runtime.Extensions;
|
||||
using Elsa.Workflows.Runtime.Implementations;
|
||||
using Elsa.WorkflowServer.Web.Jobs;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Proto.Persistence.Sqlite;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
var services = builder.Services;
|
||||
var configuration = builder.Configuration;
|
||||
var sqliteConnectionString = configuration.GetConnectionString("Sqlite");
|
||||
var sqliteConnectionString = configuration.GetConnectionString("Sqlite")!;
|
||||
var identityOptions = new IdentityOptions();
|
||||
var identitySection = configuration.GetSection("Identity");
|
||||
identitySection.Bind(identityOptions);
|
||||
|
|
@ -54,27 +50,27 @@ services
|
|||
.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString))
|
||||
.AddActivitiesFrom<WriteLine>()
|
||||
.AddActivitiesFrom<HttpEndpoint>()
|
||||
.AddActivitiesFrom<Elsa.Scheduling.Activities.Delay>()
|
||||
.AddActivitiesFrom<Delay>()
|
||||
.AddActivitiesFrom<RunJavaScript>()
|
||||
.AddActivitiesFrom<Program>()
|
||||
)
|
||||
.UseIdentity(identity =>
|
||||
{
|
||||
identity.CreateDefaultUser = true;
|
||||
identity.IdentityOptions = options => identitySection.Bind(options);
|
||||
identity.IdentityOptions = identityOptions;
|
||||
})
|
||||
.UseDefaultAuthentication()
|
||||
.UseWorkflowRuntime(runtime =>
|
||||
{
|
||||
//runtime.UseProtoActor(proto => proto.PersistenceProvider = _ => new SqliteProvider(new SqliteConnectionStringBuilder(sqliteConnectionString)));
|
||||
runtime.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString));
|
||||
//runtime.WorkflowStateExporter = sp => sp.GetRequiredService<AsyncWorkflowStateExporter>();
|
||||
})
|
||||
.UseLabels(labels => labels.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString)))
|
||||
.UseActivityDefinitions(feature => feature.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString)))
|
||||
.UseJobs(jobs => jobs.ConfigureOptions = options => options.WorkerCount = 10)
|
||||
.UseJobActivities()
|
||||
.UseScheduling()
|
||||
.UseWorkflowApiEndpoints()
|
||||
.UseWorkflowsApi()
|
||||
.UseJavaScript()
|
||||
.UseLiquid()
|
||||
.UseHttp()
|
||||
|
|
@ -82,12 +78,6 @@ services
|
|||
|
||||
services.AddHealthChecks();
|
||||
services.AddCors(cors => cors.AddDefaultPolicy(policy => policy.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin()));
|
||||
|
||||
// Authentication & Authorization.
|
||||
services
|
||||
.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||
.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, identityOptions.ConfigureJwtBearerOptions);
|
||||
|
||||
services.AddHttpContextAccessor();
|
||||
services.AddSingleton<IAuthorizationHandler, LocalHostRequirementHandler>();
|
||||
services.AddAuthorization(options => options.AddPolicy(IdentityPolicyNames.SecurityRoot, policy => policy.AddRequirements(new LocalHostRequirement())));
|
||||
|
|
@ -131,9 +121,9 @@ app.UseAuthentication();
|
|||
app.UseAuthorization();
|
||||
|
||||
// Register Elsa middleware.
|
||||
app.UseElsaFastEndpoints();
|
||||
app.UseWorkflowsApi();
|
||||
app.UseJsonSerializationErrorHandler();
|
||||
app.UseHttpActivities();
|
||||
app.UseWorkflows();
|
||||
|
||||
// Run.
|
||||
app.Run();
|
||||
|
|
@ -2,7 +2,9 @@ using Elsa.Features.Abstractions;
|
|||
using Elsa.Features.Attributes;
|
||||
using Elsa.Features.Services;
|
||||
using Elsa.Mediator.Features;
|
||||
using Elsa.Workflows.Core.Activities;
|
||||
using Elsa.Workflows.Core.Features;
|
||||
using Elsa.Workflows.Management.Extensions;
|
||||
using Elsa.Workflows.Management.Features;
|
||||
using Elsa.Workflows.Runtime.Features;
|
||||
|
||||
|
|
@ -18,8 +20,19 @@ namespace Elsa.Features;
|
|||
[DependsOn(typeof(WorkflowManagementFeature))]
|
||||
public class ElsaFeature : FeatureBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Set this to true to opt out of automatically registering activities from Elsa.Workflows.Core.
|
||||
/// </summary>
|
||||
public bool DisableAutomaticActivityRegistration { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public ElsaFeature(IModule module) : base(module)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Configure()
|
||||
{
|
||||
Module.UseWorkflowManagement(management => management.AddActivitiesFrom<WriteLine>());
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ public static class WebApplicationExtensions
|
|||
/// <param name="app"></param>
|
||||
/// <param name="routePrefix">The route prefix to apply to Elsa API endpoints.</param>
|
||||
/// <example>E.g. "elsa/api" will expose endpoints like this: "/elsa/api/workflow-definitions"</example>
|
||||
public static IApplicationBuilder UseElsaFastEndpoints(this IApplicationBuilder app, string routePrefix = "elsa/api") =>
|
||||
public static IApplicationBuilder UseWorkflowsApi(this IApplicationBuilder app, string routePrefix = "elsa/api") =>
|
||||
app.UseFastEndpoints(config =>
|
||||
{
|
||||
config.Endpoints.RoutePrefix = routePrefix;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public class Module : IModule
|
|||
{
|
||||
private record HostedServiceDescriptor(int Order, Type HostedServiceType);
|
||||
|
||||
private readonly ISet<IFeature> _features = new HashSet<IFeature>();
|
||||
private ISet<IFeature> _features = new HashSet<IFeature>();
|
||||
private readonly ICollection<HostedServiceDescriptor> _hostedServiceDescriptors = new List<HostedServiceDescriptor>();
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -59,6 +59,9 @@ public class Module : IModule
|
|||
var featureTypes = _features.Select(x => x.GetType()).TSort(x => x.GetCustomAttributes<DependsOn>().Select(dependsOn => dependsOn.Type)).ToList();
|
||||
var features = featureTypes.Select(featureType => _features.FirstOrDefault(x => x.GetType() == featureType) ?? (IFeature)Activator.CreateInstance(featureType, this)!).ToList();
|
||||
|
||||
// Update list with complete list of features. This is important because during the Configure phase, dependent features might configure other features, which should not be created as new instances.
|
||||
_features = features.ToHashSet();
|
||||
|
||||
foreach (var feature in features)
|
||||
{
|
||||
feature.Configure();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@elsa-workflows/elsa-workflows-designer",
|
||||
"version": "3.0.2-preview.11",
|
||||
"version": "3.0.2-preview.12",
|
||||
"description": "A workflow designer for Elsa 3",
|
||||
"main": "./dist/index.cjs.js",
|
||||
"module": "./dist/index.js",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
using Elsa.Persistence.EntityFrameworkCore.SqlServer.Extensions;
|
||||
using Elsa.EntityFrameworkCore.SqlServer.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Design;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Abstractions;
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Abstractions;
|
||||
|
||||
public abstract class SqlServerDesignTimeDbContextFactoryBase<TDbContext> : IDesignTimeDbContextFactory<TDbContext> where TDbContext : DbContext
|
||||
{
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Elsa.Persistence.EntityFrameworkCore\Elsa.Persistence.EntityFrameworkCore.csproj" />
|
||||
<ProjectReference Include="..\Elsa.EntityFrameworkCore\Elsa.EntityFrameworkCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
using Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
using Elsa.EntityFrameworkCore.Common;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Extensions;
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Extensions;
|
||||
|
||||
public static class DbContextOptionsBuilderExtensions
|
||||
{
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
using Elsa.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
|
|
@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.ActivityDefinitions
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.ActivityDefinitions
|
||||
{
|
||||
[DbContext(typeof(ActivityDefinitionsElsaDbContext))]
|
||||
[Migration("20221120175908_Initial")]
|
||||
|
|
@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.ActivityDefinitions
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.ActivityDefinitions
|
||||
{
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
using Elsa.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
|
|
@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.ActivityDefinitions
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.ActivityDefinitions
|
||||
{
|
||||
[DbContext(typeof(ActivityDefinitionsElsaDbContext))]
|
||||
partial class ActivityDefinitionsElsaDbContextModelSnapshot : ModelSnapshot
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// <auto-generated />
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
|
||||
using Elsa.EntityFrameworkCore.Modules.Labels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
|
|
@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.Labels
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.Labels
|
||||
{
|
||||
[DbContext(typeof(LabelsElsaDbContext))]
|
||||
[Migration("20221120175911_Initial")]
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.Labels
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.Labels
|
||||
{
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// <auto-generated />
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
|
||||
using Elsa.EntityFrameworkCore.Modules.Labels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
|
|
@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.Labels
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.Labels
|
||||
{
|
||||
[DbContext(typeof(LabelsElsaDbContext))]
|
||||
partial class LabelsElsaDbContextModelSnapshot : ModelSnapshot
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.Management;
|
||||
using Elsa.EntityFrameworkCore.Modules.Management;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
|
|
@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.Management
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.Management
|
||||
{
|
||||
[DbContext(typeof(ManagementElsaDbContext))]
|
||||
[Migration("20221120175914_Initial")]
|
||||
|
|
@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.Management
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.Management
|
||||
{
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.Management;
|
||||
using Elsa.EntityFrameworkCore.Modules.Management;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
|
|
@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.Management
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.Management
|
||||
{
|
||||
[DbContext(typeof(ManagementElsaDbContext))]
|
||||
partial class ManagementElsaDbContextModelSnapshot : ModelSnapshot
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
|
||||
using Elsa.EntityFrameworkCore.Modules.Runtime;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
|
|
@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.Runtime
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.Runtime
|
||||
{
|
||||
[DbContext(typeof(RuntimeElsaDbContext))]
|
||||
[Migration("20221120175917_Initial")]
|
||||
|
|
@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.Runtime
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.Runtime
|
||||
{
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
|
||||
using Elsa.EntityFrameworkCore.Modules.Runtime;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
|
|
@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.Runtime
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.Runtime
|
||||
{
|
||||
[DbContext(typeof(RuntimeElsaDbContext))]
|
||||
partial class RuntimeElsaDbContextModelSnapshot : ModelSnapshot
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using Elsa.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
using Elsa.EntityFrameworkCore.SqlServer.Abstractions;
|
||||
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Modules.ActivityDefinitions;
|
||||
|
||||
// ReSharper disable once UnusedType.Global
|
||||
public class DesignTimeDbContextFactory : SqlServerDesignTimeDbContextFactoryBase<ActivityDefinitionsElsaDbContext>
|
||||
{
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
using Elsa.Persistence.EntityFrameworkCore.SqlServer.Extensions;
|
||||
using Elsa.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
using Elsa.EntityFrameworkCore.SqlServer.Extensions;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Modules.ActivityDefinitions;
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Modules.ActivityDefinitions;
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using Elsa.EntityFrameworkCore.Modules.Labels;
|
||||
using Elsa.EntityFrameworkCore.SqlServer.Abstractions;
|
||||
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Modules.Labels;
|
||||
|
||||
// ReSharper disable once UnusedType.Global
|
||||
public class DesignTimeDbContextFactory : SqlServerDesignTimeDbContextFactoryBase<LabelsElsaDbContext>
|
||||
{
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
|
||||
using Elsa.Persistence.EntityFrameworkCore.SqlServer.Extensions;
|
||||
using Elsa.EntityFrameworkCore.Modules.Labels;
|
||||
using Elsa.EntityFrameworkCore.SqlServer.Extensions;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Modules.Labels;
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Modules.Labels;
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using Elsa.EntityFrameworkCore.Modules.Management;
|
||||
using Elsa.EntityFrameworkCore.SqlServer.Abstractions;
|
||||
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Modules.Management;
|
||||
|
||||
// ReSharper disable once UnusedType.Global
|
||||
public class DesignTimeDbContextFactory : SqlServerDesignTimeDbContextFactoryBase<ManagementElsaDbContext>
|
||||
{
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using Elsa.Persistence.EntityFrameworkCore.Modules.Management;
|
||||
using Elsa.Persistence.EntityFrameworkCore.SqlServer.Extensions;
|
||||
using Elsa.EntityFrameworkCore.Modules.Management;
|
||||
using Elsa.EntityFrameworkCore.SqlServer.Extensions;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Modules.Management;
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Modules.Management;
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using Elsa.EntityFrameworkCore.Modules.Runtime;
|
||||
using Elsa.EntityFrameworkCore.SqlServer.Abstractions;
|
||||
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Modules.Runtime;
|
||||
|
||||
// ReSharper disable once UnusedType.Global
|
||||
public class DesignTimeRuntimeDbContextFactory : SqlServerDesignTimeDbContextFactoryBase<RuntimeElsaDbContext>
|
||||
{
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
|
||||
using Elsa.Persistence.EntityFrameworkCore.SqlServer.Extensions;
|
||||
using Elsa.EntityFrameworkCore.Modules.Runtime;
|
||||
using Elsa.EntityFrameworkCore.SqlServer.Extensions;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Modules.Runtime;
|
||||
namespace Elsa.EntityFrameworkCore.SqlServer.Modules.Runtime;
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
using Elsa.Persistence.EntityFrameworkCore.Sqlite.Extensions;
|
||||
using Elsa.EntityFrameworkCore.Sqlite.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Design;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Abstractions;
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Abstractions;
|
||||
|
||||
public abstract class SqliteDesignTimeDbContextFactoryBase<TDbContext> : IDesignTimeDbContextFactory<TDbContext> where TDbContext : DbContext
|
||||
{
|
||||
12
src/modules/Elsa.EntityFrameworkCore.Sqlite/Constants.cs
Normal file
12
src/modules/Elsa.EntityFrameworkCore.Sqlite/Constants.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
namespace Elsa.EntityFrameworkCore.Sqlite;
|
||||
|
||||
/// <summary>
|
||||
/// Constants.
|
||||
/// </summary>
|
||||
public class Constants
|
||||
{
|
||||
/// <summary>
|
||||
/// Default connection string for SQLite.
|
||||
/// </summary>
|
||||
public const string DefaultConnectionString = "Data Source=elsa.sqlite.db;Cache=Shared;";
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0'">
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.12" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.12" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.12">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
|
@ -21,6 +22,7 @@
|
|||
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0'">
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="7.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
|
@ -28,7 +30,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Elsa.Persistence.EntityFrameworkCore\Elsa.Persistence.EntityFrameworkCore.csproj" />
|
||||
<ProjectReference Include="..\Elsa.EntityFrameworkCore\Elsa.EntityFrameworkCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
using Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
using Elsa.EntityFrameworkCore.Common;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Extensions;
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Extensions;
|
||||
|
||||
public static class DbContextOptionsBuilderExtensions
|
||||
{
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// <auto-generated />
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
using Elsa.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
|
@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Migrations.ActivityDefinitions
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.ActivityDefinitions
|
||||
{
|
||||
[DbContext(typeof(ActivityDefinitionsElsaDbContext))]
|
||||
[Migration("20221120175500_Initial")]
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Migrations.ActivityDefinitions
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.ActivityDefinitions
|
||||
{
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
// <auto-generated />
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
using Elsa.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Migrations.ActivityDefinitions
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.ActivityDefinitions
|
||||
{
|
||||
[DbContext(typeof(ActivityDefinitionsElsaDbContext))]
|
||||
partial class ActivityDefinitionsElsaDbContextModelSnapshot : ModelSnapshot
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// <auto-generated />
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
|
||||
using Elsa.EntityFrameworkCore.Modules.Labels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
|
@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Migrations.Labels
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.Labels
|
||||
{
|
||||
[DbContext(typeof(LabelsElsaDbContext))]
|
||||
[Migration("20221120175503_Initial")]
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Migrations.Labels
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.Labels
|
||||
{
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
// <auto-generated />
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
|
||||
using Elsa.EntityFrameworkCore.Modules.Labels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Migrations.Labels
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.Labels
|
||||
{
|
||||
[DbContext(typeof(LabelsElsaDbContext))]
|
||||
partial class LabelsElsaDbContextModelSnapshot : ModelSnapshot
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.Management;
|
||||
using Elsa.EntityFrameworkCore.Modules.Management;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
|
@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Migrations.Management
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.Management
|
||||
{
|
||||
[DbContext(typeof(ManagementElsaDbContext))]
|
||||
[Migration("20221120175506_Initial")]
|
||||
|
|
@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Migrations.Management
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.Management
|
||||
{
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.Management;
|
||||
using Elsa.EntityFrameworkCore.Modules.Management;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Migrations.Management
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.Management
|
||||
{
|
||||
[DbContext(typeof(ManagementElsaDbContext))]
|
||||
partial class ManagementElsaDbContextModelSnapshot : ModelSnapshot
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
|
||||
using Elsa.EntityFrameworkCore.Modules.Runtime;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
|
@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Migrations.Runtime
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.Runtime
|
||||
{
|
||||
[DbContext(typeof(RuntimeElsaDbContext))]
|
||||
[Migration("20221120175509_Initial")]
|
||||
|
|
@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Migrations.Runtime
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.Runtime
|
||||
{
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
|
||||
using Elsa.EntityFrameworkCore.Modules.Runtime;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Migrations.Runtime
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.Runtime
|
||||
{
|
||||
[DbContext(typeof(RuntimeElsaDbContext))]
|
||||
partial class RuntimeElsaDbContextModelSnapshot : ModelSnapshot
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using Elsa.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
using Elsa.EntityFrameworkCore.Sqlite.Abstractions;
|
||||
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Modules.ActivityDefinitions;
|
||||
|
||||
// ReSharper disable once UnusedType.Global
|
||||
public class DesignTimeDbContextFactory : SqliteDesignTimeDbContextFactoryBase<ActivityDefinitionsElsaDbContext>
|
||||
{
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Sqlite.Extensions;
|
||||
using Elsa.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
using Elsa.EntityFrameworkCore.Sqlite.Extensions;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.ActivityDefinitions;
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Modules.ActivityDefinitions;
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using Elsa.EntityFrameworkCore.Modules.Labels;
|
||||
using Elsa.EntityFrameworkCore.Sqlite.Abstractions;
|
||||
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Modules.Labels;
|
||||
|
||||
// ReSharper disable once UnusedType.Global
|
||||
public class DesignTimeDbContextFactory : SqliteDesignTimeDbContextFactoryBase<LabelsElsaDbContext>
|
||||
{
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Sqlite.Extensions;
|
||||
using Elsa.EntityFrameworkCore.Modules.Labels;
|
||||
using Elsa.EntityFrameworkCore.Sqlite.Extensions;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.Labels;
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Modules.Labels;
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using Elsa.EntityFrameworkCore.Modules.Management;
|
||||
using Elsa.EntityFrameworkCore.Sqlite.Abstractions;
|
||||
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Modules.Management;
|
||||
|
||||
// ReSharper disable once UnusedType.Global
|
||||
public class DesignTimeDbContextFactory : SqliteDesignTimeDbContextFactoryBase<ManagementElsaDbContext>
|
||||
{
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using Elsa.Persistence.EntityFrameworkCore.Modules.Management;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Sqlite.Extensions;
|
||||
using Elsa.EntityFrameworkCore.Modules.Management;
|
||||
using Elsa.EntityFrameworkCore.Sqlite.Extensions;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.Management;
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Modules.Management;
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using Elsa.EntityFrameworkCore.Modules.Runtime;
|
||||
using Elsa.EntityFrameworkCore.Sqlite.Abstractions;
|
||||
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Modules.Runtime;
|
||||
|
||||
// ReSharper disable once UnusedType.Global
|
||||
public class SqliteDesignTimeRuntimeDbContextFactory : SqliteDesignTimeDbContextFactoryBase<RuntimeElsaDbContext>
|
||||
{
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Sqlite.Extensions;
|
||||
using Elsa.EntityFrameworkCore.Modules.Runtime;
|
||||
using Elsa.EntityFrameworkCore.Sqlite.Extensions;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.Runtime;
|
||||
namespace Elsa.EntityFrameworkCore.Sqlite.Modules.Runtime;
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
using Elsa.Persistence.EntityFrameworkCore.Extensions;
|
||||
using Elsa.EntityFrameworkCore.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
namespace Elsa.EntityFrameworkCore.Common;
|
||||
|
||||
/// <summary>
|
||||
/// An optional base class to implement with some opinions on certain converters to install for certain DB providers.
|
||||
|
|
@ -3,7 +3,7 @@ using Elsa.Features.Services;
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
namespace Elsa.EntityFrameworkCore.Common;
|
||||
|
||||
public abstract class PersistenceFeatureBase<TDbContext> : FeatureBase where TDbContext : DbContext
|
||||
{
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Common
|
||||
namespace Elsa.EntityFrameworkCore.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Executes EF Core migrations using the specified <see cref="DbContext"/> type.
|
||||
|
|
@ -2,10 +2,10 @@ using System.Linq.Expressions;
|
|||
using EFCore.BulkExtensions;
|
||||
using Elsa.Common.Entities;
|
||||
using Elsa.Common.Models;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Extensions;
|
||||
using Elsa.EntityFrameworkCore.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
namespace Elsa.EntityFrameworkCore.Common;
|
||||
|
||||
public class Store<TDbContext, TEntity> where TDbContext : DbContext where TEntity : class
|
||||
{
|
||||
|
|
@ -23,7 +23,7 @@ public class Store<TDbContext, TEntity> where TDbContext : DbContext where TEnti
|
|||
{
|
||||
await using var dbContext = await CreateDbContextAsync(cancellationToken);
|
||||
entity = onSaving?.Invoke(dbContext, entity) ?? entity;
|
||||
await dbContext.BulkInsertOrUpdateAsync(new[] { entity }, config => { config.EnableShadowProperties = true; }, cancellationToken: cancellationToken);
|
||||
await dbContext.BulkUpsertAsync(new[] { entity }, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task SaveManyAsync(IEnumerable<TEntity> entities, CancellationToken cancellationToken = default) => await SaveManyAsync(entities, default, cancellationToken);
|
||||
|
|
@ -36,7 +36,7 @@ public class Store<TDbContext, TEntity> where TDbContext : DbContext where TEnti
|
|||
if (onSaving != null)
|
||||
entityList = entityList.Select(x => onSaving(dbContext, x)).ToList();
|
||||
|
||||
await dbContext.BulkInsertOrUpdateAsync(entityList, config => { config.EnableShadowProperties = true; }, cancellationToken: cancellationToken);
|
||||
await dbContext.BulkUpsertAsync(entityList, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<TEntity?> FindAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default) => await FindAsync(predicate, default, cancellationToken);
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Extensions;
|
||||
namespace Elsa.EntityFrameworkCore.Extensions;
|
||||
|
||||
internal static class DatabaseFacadeExtensions
|
||||
{
|
||||
|
|
@ -1,10 +1,16 @@
|
|||
using System.Linq.Expressions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Extensions;
|
||||
namespace Elsa.EntityFrameworkCore.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Provides extensions to <see cref="DbSet{TEntity}"/>.
|
||||
/// </summary>
|
||||
public static class DbSetExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Deletes matching results in bulk.
|
||||
/// </summary>
|
||||
public static async Task<int> DeleteWhereAsync<T>(this DbSet<T> set, DbContext dbContext, Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default) where T : class =>
|
||||
await set.Where(predicate).BatchDeleteWithWorkAroundAsync(dbContext, cancellationToken);
|
||||
await set.Where(predicate).BulkDeleteAsync(dbContext, cancellationToken);
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
using System.Linq.Expressions;
|
||||
using System.Net;
|
||||
using System.Runtime.CompilerServices;
|
||||
using EFCore.BulkExtensions;
|
||||
using Elsa.Common.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Elsa.EntityFrameworkCore.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Provides extensions to <see cref="IQueryable{T}"/>.
|
||||
/// </summary>
|
||||
public static class QueryableExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Deletes the matching results in bulk.
|
||||
/// </summary>
|
||||
public static async Task<int> BulkDeleteAsync<T>(this IQueryable<T> queryable, DbContext elsaContext, CancellationToken cancellationToken = default) where T : class
|
||||
{
|
||||
#if NET7_0_OR_GREATER
|
||||
return await queryable.ExecuteDeleteAsync(cancellationToken).ConfigureAwait(false);
|
||||
#else
|
||||
if (!elsaContext.Database.IsPostgres() && !elsaContext.Database.IsMySql() && !elsaContext.Database.IsOracle())
|
||||
return await queryable.BatchDeleteAsync(cancellationToken);
|
||||
|
||||
// Need this workaround https://github.com/borisdj/EFCore.BulkExtensions/issues/553 is solved.
|
||||
// Oracle also https://github.com/borisdj/EFCore.BulkExtensions/issues/375
|
||||
var records = await queryable.ToListAsync(cancellationToken);
|
||||
|
||||
foreach (var record in records)
|
||||
elsaContext.Remove(record);
|
||||
|
||||
return records.Count;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts or updates a list of entities in bulk.
|
||||
/// </summary>
|
||||
public static async Task BulkUpsertAsync<TDbContext, TEntity>(this TDbContext dbContext, IList<TEntity> entities, CancellationToken cancellationToken = default) where TDbContext : DbContext where TEntity : class =>
|
||||
await dbContext.BulkInsertOrUpdateAsync(entities, config => { config.EnableShadowProperties = true; }, cancellationToken: cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a paged result from the specified query.
|
||||
/// </summary>
|
||||
public static async Task<Page<TTarget>> PaginateAsync<T, TTarget>(this IQueryable<T> queryable, Expression<Func<T, TTarget>> projection, PageArgs? pageArgs = default)
|
||||
{
|
||||
var count = await queryable.CountAsync();
|
||||
if (pageArgs?.Offset != null) queryable = queryable.Skip(pageArgs.Offset.Value);
|
||||
if (pageArgs?.Limit != null) queryable = queryable.Take(pageArgs.Limit.Value);
|
||||
var results = await queryable.Select(projection).ToListAsync();
|
||||
return Page.Of(results, count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a paged result from the specified query.
|
||||
/// </summary>
|
||||
public static async Task<Page<T>> PaginateAsync<T>(this IQueryable<T> queryable, PageArgs? pageArgs = default)
|
||||
{
|
||||
var count = await queryable.CountAsync();
|
||||
if (pageArgs?.Offset != null) queryable = queryable.Skip(pageArgs.Offset.Value);
|
||||
if (pageArgs?.Limit != null) queryable = queryable.Take(pageArgs.Limit.Value);
|
||||
var results = await queryable.ToListAsync();
|
||||
return Page.Of(results, count);
|
||||
}
|
||||
}
|
||||
|
|
@ -5,12 +5,12 @@ using Elsa.ActivityDefinitions.Models;
|
|||
using Elsa.ActivityDefinitions.Services;
|
||||
using Elsa.Common.Extensions;
|
||||
using Elsa.Common.Models;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Extensions;
|
||||
using Elsa.EntityFrameworkCore.Common;
|
||||
using Elsa.EntityFrameworkCore.Extensions;
|
||||
using Elsa.Workflows.Core.Models;
|
||||
using Elsa.Workflows.Core.Serialization;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
|
||||
public class EFCoreActivityDefinitionStore : IActivityDefinitionStore
|
||||
{
|
||||
|
|
@ -2,7 +2,7 @@ using Elsa.ActivityDefinitions.Entities;
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
|
||||
public class Configurations : IEntityTypeConfiguration<ActivityDefinition>
|
||||
{
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
using Elsa.ActivityDefinitions.Entities;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
using Elsa.EntityFrameworkCore.Common;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
|
||||
public class ActivityDefinitionsElsaDbContext : ElsaDbContextBase
|
||||
{
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using Elsa.ActivityDefinitions.Features;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
using Elsa.ActivityDefinitions.Entities;
|
||||
using Elsa.ActivityDefinitions.Features;
|
||||
using Elsa.EntityFrameworkCore.Common;
|
||||
using Elsa.Features.Attributes;
|
||||
using Elsa.Features.Services;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.ActivityDefinitions;
|
||||
|
||||
[DependsOn(typeof(ActivityDefinitionsFeature))]
|
||||
public class EFCoreActivityDefinitionsPersistenceFeature : PersistenceFeatureBase<ActivityDefinitionsElsaDbContext>
|
||||
|
|
@ -2,7 +2,7 @@ using Elsa.Labels.Entities;
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.Labels;
|
||||
|
||||
public class Configurations : IEntityTypeConfiguration<Label>, IEntityTypeConfiguration<WorkflowDefinitionLabel>
|
||||
{
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
using Elsa.Labels.Entities;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
using Elsa.EntityFrameworkCore.Common;
|
||||
using Elsa.Labels.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.Labels;
|
||||
|
||||
public class LabelsElsaDbContext : ElsaDbContextBase
|
||||
{
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using Elsa.Labels.Features;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.Labels;
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
using Elsa.EntityFrameworkCore.Common;
|
||||
using Elsa.Features.Attributes;
|
||||
using Elsa.Features.Services;
|
||||
using Elsa.Labels.Entities;
|
||||
using Elsa.Labels.Extensions;
|
||||
using Elsa.Labels.Features;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.Labels;
|
||||
|
||||
[DependsOn(typeof(LabelsFeature))]
|
||||
public class EFCoreLabelPersistenceFeature : PersistenceFeatureBase<LabelsElsaDbContext>
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
using Elsa.Common.Models;
|
||||
using Elsa.EntityFrameworkCore.Common;
|
||||
using Elsa.Labels.Entities;
|
||||
using Elsa.Labels.Services;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Extensions;
|
||||
using Elsa.EntityFrameworkCore.Extensions;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.Labels;
|
||||
|
||||
public class EFCoreLabelStore : ILabelStore
|
||||
{
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
using Elsa.EntityFrameworkCore.Common;
|
||||
using Elsa.Labels.Entities;
|
||||
using Elsa.Labels.Services;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.Labels;
|
||||
|
||||
public class EFCoreWorkflowDefinitionLabelStore : IWorkflowDefinitionLabelStore
|
||||
{
|
||||
|
|
@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore;
|
|||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Management
|
||||
namespace Elsa.EntityFrameworkCore.Modules.Management
|
||||
{
|
||||
public class Configurations : IEntityTypeConfiguration<WorkflowDefinition>, IEntityTypeConfiguration<WorkflowInstance>
|
||||
{
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
using Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
using Elsa.EntityFrameworkCore.Common;
|
||||
using Elsa.Workflows.Management.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Management;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.Management;
|
||||
|
||||
public class ManagementElsaDbContext : ElsaDbContextBase
|
||||
{
|
||||
|
|
@ -1,9 +1,15 @@
|
|||
using Elsa.Workflows.Management.Features;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Management
|
||||
namespace Elsa.EntityFrameworkCore.Modules.Management
|
||||
{
|
||||
public static class Extensions
|
||||
/// <summary>
|
||||
/// Provides extensions to <see cref="WorkflowManagementFeature"/>.
|
||||
/// </summary>
|
||||
public static class WorkflowManagementFeatureExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets up the EF Core persistence provider.
|
||||
/// </summary>
|
||||
public static WorkflowManagementFeature UseEntityFrameworkCore(this WorkflowManagementFeature feature, Action<EFCoreManagementPersistenceFeature>? configure = default)
|
||||
{
|
||||
feature.Module.Configure(configure);
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
using Elsa.EntityFrameworkCore.Common;
|
||||
using Elsa.Features.Attributes;
|
||||
using Elsa.Features.Services;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
using Elsa.Workflows.Management.Entities;
|
||||
using Elsa.Workflows.Management.Features;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Management;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.Management;
|
||||
|
||||
[DependsOn(typeof(WorkflowManagementFeature))]
|
||||
public class EFCoreManagementPersistenceFeature : PersistenceFeatureBase<ManagementElsaDbContext>
|
||||
|
|
@ -2,8 +2,8 @@ using System.Linq.Expressions;
|
|||
using System.Text.Json;
|
||||
using Elsa.Common.Extensions;
|
||||
using Elsa.Common.Models;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Extensions;
|
||||
using Elsa.EntityFrameworkCore.Common;
|
||||
using Elsa.EntityFrameworkCore.Extensions;
|
||||
using Elsa.Workflows.Core.Models;
|
||||
using Elsa.Workflows.Core.Serialization;
|
||||
using Elsa.Workflows.Management.Entities;
|
||||
|
|
@ -11,7 +11,7 @@ using Elsa.Workflows.Management.Models;
|
|||
using Elsa.Workflows.Management.Services;
|
||||
using Namotion.Reflection;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Management;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.Management;
|
||||
|
||||
/// <inheritdoc />
|
||||
public class EFCoreWorkflowDefinitionStore : IWorkflowDefinitionStore
|
||||
|
|
@ -2,8 +2,8 @@ using System.Text.Json;
|
|||
using System.Text.Json.Serialization;
|
||||
using Elsa.Common.Entities;
|
||||
using Elsa.Common.Models;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Extensions;
|
||||
using Elsa.EntityFrameworkCore.Common;
|
||||
using Elsa.EntityFrameworkCore.Extensions;
|
||||
using Elsa.Workflows.Core.Models;
|
||||
using Elsa.Workflows.Core.Serialization;
|
||||
using Elsa.Workflows.Core.State;
|
||||
|
|
@ -11,7 +11,7 @@ using Elsa.Workflows.Management.Entities;
|
|||
using Elsa.Workflows.Management.Models;
|
||||
using Elsa.Workflows.Management.Services;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Management;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.Management;
|
||||
|
||||
/// <summary>
|
||||
/// An EF Core implementation of <see cref="IWorkflowInstanceStore"/>.
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
using Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
using Elsa.EntityFrameworkCore.Common;
|
||||
using Elsa.Workflows.Runtime.Models;
|
||||
using Elsa.Workflows.Runtime.Services;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.Runtime;
|
||||
|
||||
public class EFCoreBookmarkStore : IBookmarkStore
|
||||
{
|
||||
|
|
@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore;
|
|||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Runtime
|
||||
namespace Elsa.EntityFrameworkCore.Modules.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// EF Core configuration for various sets of <see cref="DbContext"/>.
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
using Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
using Elsa.EntityFrameworkCore.Common;
|
||||
using Elsa.Workflows.Core.State;
|
||||
using Elsa.Workflows.Management.Entities;
|
||||
using Elsa.Workflows.Runtime.Entities;
|
||||
using Elsa.Workflows.Runtime.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.Runtime;
|
||||
|
||||
public class RuntimeElsaDbContext : ElsaDbContextBase
|
||||
{
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using Elsa.Workflows.Runtime.Features;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Runtime
|
||||
namespace Elsa.EntityFrameworkCore.Modules.Runtime
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
using Elsa.EntityFrameworkCore.Common;
|
||||
using Elsa.Features.Attributes;
|
||||
using Elsa.Features.Services;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
using Elsa.Workflows.Core.State;
|
||||
using Elsa.Workflows.Runtime.Entities;
|
||||
using Elsa.Workflows.Runtime.Features;
|
||||
using Elsa.Workflows.Runtime.Models;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.Runtime;
|
||||
|
||||
[DependsOn(typeof(WorkflowRuntimeFeature))]
|
||||
public class EFCoreRuntimePersistenceFeature : PersistenceFeatureBase<RuntimeElsaDbContext>
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
using Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
using Elsa.EntityFrameworkCore.Common;
|
||||
using Elsa.Workflows.Runtime.Entities;
|
||||
using Elsa.Workflows.Runtime.Services;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.Runtime;
|
||||
|
||||
public class EFCoreTriggerStore : ITriggerStore
|
||||
{
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
using Elsa.Common.Entities;
|
||||
using Elsa.Common.Models;
|
||||
using Elsa.Persistence.EntityFrameworkCore.Common;
|
||||
using Elsa.EntityFrameworkCore.Common;
|
||||
using Elsa.Workflows.Runtime.Entities;
|
||||
using Elsa.Workflows.Runtime.Services;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.Runtime;
|
||||
|
||||
public class EFCoreWorkflowExecutionLogStore : IWorkflowExecutionLogStore
|
||||
{
|
||||
|
|
@ -9,7 +9,7 @@ using Elsa.Workflows.Core.State;
|
|||
using Elsa.Workflows.Runtime.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
|
||||
namespace Elsa.EntityFrameworkCore.Modules.Runtime;
|
||||
|
||||
/// <inheritdoc />
|
||||
public class EFCoreWorkflowStateStore : IWorkflowStateStore
|
||||
|
|
@ -3,7 +3,13 @@ using Microsoft.AspNetCore.Builder;
|
|||
|
||||
namespace Elsa.Http.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Adds extension methods to <see cref="IApplicationBuilder"/> related to workflow middleware components.
|
||||
/// </summary>
|
||||
public static class ApplicationBuilderExtensions
|
||||
{
|
||||
public static IApplicationBuilder UseHttpActivities(this IApplicationBuilder app) => app.UseMiddleware<HttpTriggerMiddleware>();
|
||||
/// <summary>
|
||||
/// Installs the <see cref="WorkflowsMiddleware"/> component.
|
||||
/// </summary>
|
||||
public static IApplicationBuilder UseWorkflows(this IApplicationBuilder app) => app.UseMiddleware<WorkflowsMiddleware>();
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue