Merge pull request #1207 from elsa-workflows/docker_postgre_yes
Docker postgre yes
This commit is contained in:
commit
0bd5b8f743
28
Elsa.sln
28
Elsa.sln
|
|
@ -321,7 +321,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElsaDashboard.Samples.Blazo
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Samples.FaultyWorkflows", "src\samples\aspnet\Elsa.Samples.FaultyWorkflows\Elsa.Samples.FaultyWorkflows.csproj", "{84751112-C2B7-41D4-98F5-D87D7C2E1DAE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Activities.Conductor", "src\activities\Elsa.Activities.Conductor\Elsa.Activities.Conductor.csproj", "{4D4022DD-244B-47EE-95FA-7071EC687B24}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Activities.Conductor", "src\activities\Elsa.Activities.Conductor\Elsa.Activities.Conductor.csproj", "{4D4022DD-244B-47EE-95FA-7071EC687B24}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "aspnetcore", "aspnetcore", "{39DE1EE2-DF4F-44EB-9F5A-551BEADD6673}"
|
||||
EndProject
|
||||
|
|
@ -653,6 +653,16 @@ Global
|
|||
{3DF05CFC-AC77-489F-9A42-C4FDB599AA69}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D55BC08B-CA82-478A-99F7-EDE90AC33160}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D55BC08B-CA82-478A-99F7-EDE90AC33160}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D55BC08B-CA82-478A-99F7-EDE90AC33160}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D55BC08B-CA82-478A-99F7-EDE90AC33160}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{775EFD59-F99C-4D38-B54E-9734C9D9649A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{775EFD59-F99C-4D38-B54E-9734C9D9649A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{775EFD59-F99C-4D38-B54E-9734C9D9649A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{775EFD59-F99C-4D38-B54E-9734C9D9649A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{30A9B140-14F5-4D00-84ED-1447F96D13C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{30A9B140-14F5-4D00-84ED-1447F96D13C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{30A9B140-14F5-4D00-84ED-1447F96D13C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{30A9B140-14F5-4D00-84ED-1447F96D13C8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BE284508-9582-4FCB-B0DD-0761AB940AD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BE284508-9582-4FCB-B0DD-0761AB940AD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BE284508-9582-4FCB-B0DD-0761AB940AD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
@ -661,10 +671,6 @@ Global
|
|||
{3EB488DF-3C28-4DAD-B43E-6062E39629AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3EB488DF-3C28-4DAD-B43E-6062E39629AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3EB488DF-3C28-4DAD-B43E-6062E39629AB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{775EFD59-F99C-4D38-B54E-9734C9D9649A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{775EFD59-F99C-4D38-B54E-9734C9D9649A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{30A9B140-14F5-4D00-84ED-1447F96D13C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{30A9B140-14F5-4D00-84ED-1447F96D13C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3E2423CF-50E6-4D2B-8749-17B1EF540FE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3E2423CF-50E6-4D2B-8749-17B1EF540FE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3E2423CF-50E6-4D2B-8749-17B1EF540FE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
@ -679,8 +685,12 @@ Global
|
|||
{9ACA06DA-9AFE-41A2-8109-EFED8B9B14A1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D1644D32-AA51-4D10-942E-F2722DB963B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D1644D32-AA51-4D10-942E-F2722DB963B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D1644D32-AA51-4D10-942E-F2722DB963B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D1644D32-AA51-4D10-942E-F2722DB963B4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7756E22A-AD59-46C1-A019-1D28D7217347}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7756E22A-AD59-46C1-A019-1D28D7217347}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7756E22A-AD59-46C1-A019-1D28D7217347}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7756E22A-AD59-46C1-A019-1D28D7217347}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7B84277D-96EF-4C7F-9D5E-8CBB2D26E5EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7B84277D-96EF-4C7F-9D5E-8CBB2D26E5EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7B84277D-96EF-4C7F-9D5E-8CBB2D26E5EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
@ -723,6 +733,8 @@ Global
|
|||
{EE147504-555D-4EFC-A79A-34748666AA6C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1129868E-BA72-44C4-941C-A28D9001504B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1129868E-BA72-44C4-941C-A28D9001504B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1129868E-BA72-44C4-941C-A28D9001504B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1129868E-BA72-44C4-941C-A28D9001504B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{24A99602-F743-4B1A-AC96-599F34AE916C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{24A99602-F743-4B1A-AC96-599F34AE916C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{24A99602-F743-4B1A-AC96-599F34AE916C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
@ -848,13 +860,14 @@ Global
|
|||
{B09A6E42-EF42-4693-BA0E-5EE1D7F81FFD} = {DBBD242E-4437-4BDB-919F-A70839BE75FA}
|
||||
{495BE954-E6EA-41A9-8054-A5CA5DD0924E} = {DBBD242E-4437-4BDB-919F-A70839BE75FA}
|
||||
{D86B94DC-A53C-4A67-A820-828DD359C49B} = {4673732F-2853-47BD-91B8-C95C229D2C89}
|
||||
{F1EF5639-021A-4D22-9D4A-73D57C88EBFA} = {39DE1EE2-DF4F-44EB-9F5A-551BEADD6673}
|
||||
{3A30EFFE-32D8-40B8-9C62-427037BB5424} = {EEBEA8AF-C8A8-4C71-A96C-D5836DE24359}
|
||||
{3DF05CFC-AC77-489F-9A42-C4FDB599AA69} = {8B6B40A8-DF21-4CD2-BABD-474B79D0C3AF}
|
||||
{D55BC08B-CA82-478A-99F7-EDE90AC33160} = {C865B0FD-E505-48F0-BFAF-0D4D7C1B5CA1}
|
||||
{BE284508-9582-4FCB-B0DD-0761AB940AD7} = {B43B546E-23F3-46E8-ACB7-D04F05CDA180}
|
||||
{3EB488DF-3C28-4DAD-B43E-6062E39629AB} = {FC9F520F-BA51-4AD2-BFEE-EF787798E734}
|
||||
{775EFD59-F99C-4D38-B54E-9734C9D9649A} = {22E75696-6FE9-436A-9097-EE21C603F818}
|
||||
{30A9B140-14F5-4D00-84ED-1447F96D13C8} = {FC9F520F-BA51-4AD2-BFEE-EF787798E734}
|
||||
{BE284508-9582-4FCB-B0DD-0761AB940AD7} = {B43B546E-23F3-46E8-ACB7-D04F05CDA180}
|
||||
{3EB488DF-3C28-4DAD-B43E-6062E39629AB} = {FC9F520F-BA51-4AD2-BFEE-EF787798E734}
|
||||
{3E2423CF-50E6-4D2B-8749-17B1EF540FE4} = {22E75696-6FE9-436A-9097-EE21C603F818}
|
||||
{9937FB02-72D9-4FCD-B31E-8E60CFF1B37F} = {DA71CDAA-8DD3-4D5F-9FBD-8E4B37A2D925}
|
||||
{61C16CA0-B190-4642-A81A-5C03705CA2C1} = {9937FB02-72D9-4FCD-B31E-8E60CFF1B37F}
|
||||
|
|
@ -880,7 +893,6 @@ Global
|
|||
{84751112-C2B7-41D4-98F5-D87D7C2E1DAE} = {22E75696-6FE9-436A-9097-EE21C603F818}
|
||||
{4D4022DD-244B-47EE-95FA-7071EC687B24} = {B43B546E-23F3-46E8-ACB7-D04F05CDA180}
|
||||
{39DE1EE2-DF4F-44EB-9F5A-551BEADD6673} = {4673732F-2853-47BD-91B8-C95C229D2C89}
|
||||
{F1EF5639-021A-4D22-9D4A-73D57C88EBFA} = {39DE1EE2-DF4F-44EB-9F5A-551BEADD6673}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {8B0975FD-7050-48B0-88C5-48C33378E158}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\..\..\common.props" />
|
||||
<Import Project="..\..\..\..\configureawait.props" />
|
||||
|
|
@ -12,6 +12,10 @@
|
|||
<PackageTags>elsa, workflows, webhooks</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Extensions\WebhookServiceCollectionExtensions.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="System.Text.Encodings.Web" Version="5.0.1" />
|
||||
|
|
@ -22,11 +26,6 @@
|
|||
<ProjectReference Include="..\..\..\server\Elsa.Server.Api\Elsa.Server.Api.csproj" />
|
||||
<ProjectReference Include="..\..\Elsa.Activities.Http\Elsa.Activities.Http.csproj" />
|
||||
<ProjectReference Include="..\Elsa.Webhooks.Abstractions\Elsa.Webhooks.Abstractions.csproj" />
|
||||
<ProjectReference Include="..\Elsa.Webhooks.Persistence.EntityFramework.Core\Elsa.Webhooks.Persistence.EntityFramework.Core.csproj" />
|
||||
<ProjectReference Include="..\Elsa.Webhooks.Persistence.EntityFramework.MySql\Elsa.Webhooks.Persistence.EntityFramework.MySql.csproj" />
|
||||
<ProjectReference Include="..\Elsa.Webhooks.Persistence.EntityFramework.PostgreSql\Elsa.Webhooks.Persistence.EntityFramework.PostgreSql.csproj" />
|
||||
<ProjectReference Include="..\Elsa.Webhooks.Persistence.EntityFramework.Sqlite\Elsa.Webhooks.Persistence.EntityFramework.Sqlite.csproj" />
|
||||
<ProjectReference Include="..\Elsa.Webhooks.Persistence.EntityFramework.SqlServer\Elsa.Webhooks.Persistence.EntityFramework.SqlServer.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ using System.Net.Mime;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Activities.Webhooks.Swagger.Examples;
|
||||
using Elsa.Models;
|
||||
using Elsa.Persistence.Specifications;
|
||||
using Elsa.Server.Api.Models;
|
||||
using Elsa.Server.Api.Services;
|
||||
|
|
@ -40,7 +39,7 @@ namespace Elsa.Activities.Webhooks.Endpoints.WebhookDefinitions
|
|||
OperationId = "WebhookDefinitions.List",
|
||||
Tags = new[] { "WebhookDefinitions" })
|
||||
]
|
||||
public async Task<ActionResult<PagedList<WorkflowDefinition>>> Handle(CancellationToken cancellationToken = default)
|
||||
public async Task<ActionResult<PagedList<WebhookDefinition>>> Handle(CancellationToken cancellationToken = default)
|
||||
{
|
||||
var specification = Specification<WebhookDefinition>.Identity;
|
||||
var items = await _store.FindManyAsync(specification, cancellationToken: cancellationToken);
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ namespace Elsa.Activities.Webhooks.Endpoints.WebhookDefinitions
|
|||
{
|
||||
[ApiController]
|
||||
[ApiVersion("1")]
|
||||
[Route("v{apiVersion:apiVersion}/webhook-definitions/{id}")]
|
||||
[Route("v{apiVersion:apiVersion}/webhook-definitions")]
|
||||
[Produces("application/json")]
|
||||
public class Put : ControllerBase
|
||||
public class Update : ControllerBase
|
||||
{
|
||||
private readonly IWebhookDefinitionStore _store;
|
||||
public Put(IWebhookDefinitionStore store) => _store = store;
|
||||
public Update(IWebhookDefinitionStore store) => _store = store;
|
||||
|
||||
[HttpPut]
|
||||
[ProducesResponseType(typeof(WebhookDefinition), StatusCodes.Status200OK)]
|
||||
|
|
@ -44,7 +44,7 @@ namespace Elsa.Activities.Webhooks.Endpoints.WebhookDefinitions
|
|||
webhookDefinition.PayloadTypeName = request.PayloadTypeName?.Trim();
|
||||
webhookDefinition.IsEnabled = request.IsEnabled;
|
||||
|
||||
await _store.SaveAsync(webhookDefinition, cancellationToken);
|
||||
await _store.UpdateAsync(webhookDefinition, cancellationToken);
|
||||
|
||||
return Ok(webhookDefinition);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,18 @@
|
|||
using System;
|
||||
using Elsa.Activities.Webhooks.ActivityTypes;
|
||||
using Elsa.Activities.Webhooks.Bookmarks;
|
||||
using Elsa.Activities.Webhooks.Persistence.Decorators;
|
||||
using Elsa.Services;
|
||||
using Elsa.Webhooks.Persistence;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Elsa.Activities.Webhooks.Extensions
|
||||
{
|
||||
public static class WebhookOptionsBuilderExtensions
|
||||
{
|
||||
public static ElsaOptionsBuilder AddWebhooks(
|
||||
this ElsaOptionsBuilder elsaOptions,
|
||||
Action<WebhookOptionsBuilder>? configure = default)
|
||||
public static ElsaOptionsBuilder AddWebhooks(this ElsaOptionsBuilder elsaOptions)
|
||||
{
|
||||
var services = elsaOptions.Services;
|
||||
|
||||
// Configure Webhooks.
|
||||
var webhookOptionsBuilder = new WebhookOptionsBuilder(elsaOptions.Services);
|
||||
configure?.Invoke(webhookOptionsBuilder);
|
||||
|
||||
// Services.
|
||||
services
|
||||
elsaOptions.Services
|
||||
.AddScoped<IActivityTypeProvider, WebhookActivityTypeProvider>()
|
||||
.AddScoped(sp => webhookOptionsBuilder.WebhookOptions.WebhookDefinitionStoreFactory(sp))
|
||||
.AddBookmarkProvider<WebhookBookmarkProvider>();
|
||||
|
||||
services.Decorate<IWebhookDefinitionStore, InitializingWebhookDefinitionStore>();
|
||||
services.Decorate<IWebhookDefinitionStore, EventPublishingWebhookDefinitionStore>();
|
||||
|
||||
return elsaOptions;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,6 @@ namespace Elsa.Activities.Webhooks.Options
|
|||
WebhookDefinitionStoreFactory = provider => ActivatorUtilities.CreateInstance<InMemoryWebhookDefinitionStore>(provider);
|
||||
}
|
||||
|
||||
internal Func<IServiceProvider, IWebhookDefinitionStore> WebhookDefinitionStoreFactory { get; set; }
|
||||
public Func<IServiceProvider, IWebhookDefinitionStore> WebhookDefinitionStoreFactory { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using Elsa.Activities.Webhooks.Extensions;
|
||||
using Elsa.Attributes;
|
||||
using Elsa.Services.Startup;
|
||||
using Elsa.Webhooks.Persistence.EntityFramework.Sqlite;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace Elsa.Activities.Webhooks
|
||||
|
|
@ -11,8 +10,7 @@ namespace Elsa.Activities.Webhooks
|
|||
{
|
||||
public override void ConfigureElsa(ElsaOptionsBuilder elsa, IConfiguration configuration)
|
||||
{
|
||||
// TODO: Read selected persistence provider from config.
|
||||
elsa.AddWebhooks(webhooks => webhooks.UseEntityFrameworkPersistence(ef => ef.UseWebhookSqlite()));
|
||||
elsa.AddWebhooks();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\persistence\Elsa.Persistence.EntityFramework\Elsa.Persistence.EntityFramework.Core\Elsa.Persistence.EntityFramework.Core.csproj" />
|
||||
<ProjectReference Include="..\Elsa.Activities.Webhooks\Elsa.Activities.Webhooks.csproj" />
|
||||
<ProjectReference Include="..\Elsa.Webhooks.Abstractions\Elsa.Webhooks.Abstractions.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
using System;
|
||||
using Elsa.Activities.Webhooks;
|
||||
using Elsa.Activities.Webhooks.Persistence.Decorators;
|
||||
using Elsa.Services.Startup;
|
||||
using Elsa.Webhooks.Persistence.EntityFramework.Core.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Elsa.Webhooks.Persistence.EntityFramework.Core
|
||||
{
|
||||
public abstract class EntityFrameworkWebhookStartupBase : StartupBase
|
||||
{
|
||||
protected abstract string ProviderName { get; }
|
||||
|
||||
public override void ConfigureElsa(ElsaOptionsBuilder elsa, IConfiguration configuration)
|
||||
{
|
||||
var services = elsa.Services;
|
||||
var section = configuration.GetSection($"Elsa:Persistence:{ProviderName}");
|
||||
var connectionStringName = section.GetValue<string>("ConnectionStringName");
|
||||
var connectionString = section.GetValue<string>("ConnectionString");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(connectionString))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(connectionStringName))
|
||||
connectionStringName = ProviderName;
|
||||
|
||||
connectionString = configuration.GetConnectionString(connectionStringName);
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(connectionString))
|
||||
connectionString = GetDefaultConnectionString();
|
||||
|
||||
var webhookOptionsBuilder = new WebhookOptionsBuilder(services);
|
||||
webhookOptionsBuilder.UseEntityFrameworkPersistence(options => Configure(options, connectionString));
|
||||
|
||||
services.AddScoped(sp => webhookOptionsBuilder.WebhookOptions.WebhookDefinitionStoreFactory(sp));
|
||||
|
||||
services.Decorate<IWebhookDefinitionStore, InitializingWebhookDefinitionStore>();
|
||||
services.Decorate<IWebhookDefinitionStore, EventPublishingWebhookDefinitionStore>();
|
||||
}
|
||||
|
||||
protected virtual string GetDefaultConnectionString() => throw new Exception($"No connection string specified for the {ProviderName} provider");
|
||||
protected abstract void Configure(DbContextOptionsBuilder options, string connectionString);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
using System;
|
||||
using Elsa.Activities.Webhooks;
|
||||
using Elsa.Persistence.EntityFramework.Core;
|
||||
using Elsa.Runtime;
|
||||
using Elsa.Webhooks.Persistence.EntityFramework.Core;
|
||||
using Elsa.Webhooks.Persistence.EntityFramework.Core.Services;
|
||||
using Elsa.Webhooks.Persistence.EntityFramework.Core.StartupTasks;
|
||||
using Elsa.Webhooks.Persistence.EntityFramework.Core.Stores;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Elsa.Activities.Webhooks.Extensions
|
||||
namespace Elsa.Webhooks.Persistence.EntityFramework.Core.Extensions
|
||||
{
|
||||
public static class WebhookServiceCollectionExtensions
|
||||
{
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
using Elsa.Attributes;
|
||||
using Elsa.Webhooks.Persistence.EntityFramework.Core;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Elsa.Webhooks.Persistence.EntityFramework.MySql
|
||||
{
|
||||
[Feature("Webhooks:Persistence:EntityFrameworkCore:MySql")]
|
||||
public class Startup : EntityFrameworkWebhookStartupBase
|
||||
{
|
||||
protected override string ProviderName => "MySql";
|
||||
protected override void Configure(DbContextOptionsBuilder options, string connectionString) => options.UseWebhookMySql(connectionString);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
using Elsa.Webhooks.Persistence.EntityFramework.Core;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
|
||||
|
||||
namespace Elsa.Webhooks.Persistence.EntityFramework.MySql
|
||||
{
|
||||
|
|
@ -11,6 +12,7 @@ namespace Elsa.Webhooks.Persistence.EntityFramework.MySql
|
|||
public static DbContextOptionsBuilder UseWebhookMySql(this DbContextOptionsBuilder builder, string connectionString) =>
|
||||
builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString), db => db
|
||||
.MigrationsAssembly(typeof(WebhookMySqlElsaContextFactory).Assembly.GetName().Name)
|
||||
.MigrationsHistoryTable(WebhookContext.MigrationsHistoryTable, WebhookContext.ElsaSchema));
|
||||
.MigrationsHistoryTable(WebhookContext.MigrationsHistoryTable, WebhookContext.ElsaSchema)
|
||||
.SchemaBehavior(MySqlSchemaBehavior.Ignore));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
using Elsa.Attributes;
|
||||
using Elsa.Webhooks.Persistence.EntityFramework.Core;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Elsa.Webhooks.Persistence.EntityFramework.PostgreSql
|
||||
{
|
||||
[Feature("Webhooks:Persistence:EntityFrameworkCore:PostgreSql")]
|
||||
public class Startup : EntityFrameworkWebhookStartupBase
|
||||
{
|
||||
protected override string ProviderName => "PostgreSql";
|
||||
protected override void Configure(DbContextOptionsBuilder options, string connectionString) => options.UseWebhookPostgreSql(connectionString);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
using Elsa.Attributes;
|
||||
using Elsa.Webhooks.Persistence.EntityFramework.Core;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Elsa.Webhooks.Persistence.EntityFramework.SqlServer
|
||||
{
|
||||
[Feature("Webhooks:Persistence:EntityFrameworkCore:SqlServer")]
|
||||
public class Startup : EntityFrameworkWebhookStartupBase
|
||||
{
|
||||
protected override string ProviderName => "SqlServer";
|
||||
protected override void Configure(DbContextOptionsBuilder options, string connectionString) => options.UseWebhookSqlServer(connectionString);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
using Elsa.Attributes;
|
||||
using Elsa.Webhooks.Persistence.EntityFramework.Core;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Elsa.Webhooks.Persistence.EntityFramework.Sqlite
|
||||
{
|
||||
[Feature("Webhooks:Persistence:EntityFrameworkCore:Sqlite")]
|
||||
public class Startup : EntityFrameworkWebhookStartupBase
|
||||
{
|
||||
protected override string ProviderName => "Sqlite";
|
||||
protected override string GetDefaultConnectionString() => "Data Source=elsa.sqlite.db;Cache=Shared;";
|
||||
protected override void Configure(DbContextOptionsBuilder options, string connectionString) => options.UseWebhookSqlite(connectionString);
|
||||
}
|
||||
}
|
||||
|
|
@ -11,37 +11,35 @@ namespace Elsa.Webhooks.Persistence.MongoDb.Extensions
|
|||
{
|
||||
public static class WebhookServiceCollectionExtensions
|
||||
{
|
||||
public static ElsaOptionsBuilder UseMongoDbPersistence(this ElsaOptionsBuilder elsa, Action<ElsaMongoDbOptions> configureOptions) => UseMongoDbPersistence<ElsaMongoDbContext>(elsa, configureOptions);
|
||||
public static WebhookOptionsBuilder UseWebhookMongoDbPersistence(this WebhookOptionsBuilder webhookOptions, Action<ElsaMongoDbOptions> configureOptions) => UseWebhookMongoDbPersistence<ElsaMongoDbContext>(webhookOptions, configureOptions);
|
||||
|
||||
public static ElsaOptionsBuilder UseMongoDbPersistence<TDbContext>(this ElsaOptionsBuilder elsa, Action<ElsaMongoDbOptions> configureOptions) where TDbContext : ElsaMongoDbContext
|
||||
public static WebhookOptionsBuilder UseWebhookMongoDbPersistence<TDbContext>(this WebhookOptionsBuilder webhookOptions, Action<ElsaMongoDbOptions> configureOptions) where TDbContext : ElsaMongoDbContext
|
||||
{
|
||||
AddCore<TDbContext>(elsa);
|
||||
elsa.Services.Configure(configureOptions);
|
||||
AddCore<TDbContext>(webhookOptions);
|
||||
webhookOptions.Services.Configure(configureOptions);
|
||||
|
||||
return elsa;
|
||||
return webhookOptions;
|
||||
}
|
||||
|
||||
public static ElsaOptionsBuilder UseMongoDbPersistence(this ElsaOptionsBuilder elsa, IConfiguration configuration) => UseMongoDbPersistence<ElsaMongoDbContext>(elsa, configuration);
|
||||
public static WebhookOptionsBuilder UseWebhookMongoDbPersistence(this WebhookOptionsBuilder webhookOptions, IConfiguration configuration) => UseWebhookMongoDbPersistence<ElsaMongoDbContext>(webhookOptions, configuration);
|
||||
|
||||
public static ElsaOptionsBuilder UseMongoDbPersistence<TDbContext>(this ElsaOptionsBuilder elsa, IConfiguration configuration) where TDbContext : ElsaMongoDbContext
|
||||
public static WebhookOptionsBuilder UseWebhookMongoDbPersistence<TDbContext>(this WebhookOptionsBuilder webhookOptions, IConfiguration configuration) where TDbContext : ElsaMongoDbContext
|
||||
{
|
||||
AddCore<TDbContext>(elsa);
|
||||
elsa.Services.Configure<ElsaMongoDbOptions>(configuration);
|
||||
return elsa;
|
||||
AddCore<TDbContext>(webhookOptions);
|
||||
webhookOptions.Services.Configure<ElsaMongoDbOptions>(configuration);
|
||||
return webhookOptions;
|
||||
}
|
||||
|
||||
private static void AddCore<TDbContext>(ElsaOptionsBuilder elsa) where TDbContext : ElsaMongoDbContext
|
||||
private static void AddCore<TDbContext>(WebhookOptionsBuilder webhookOptions) where TDbContext : ElsaMongoDbContext
|
||||
{
|
||||
elsa.Services
|
||||
webhookOptions.Services
|
||||
.AddSingleton<MongoDbWebhookDefinitionStore>()
|
||||
.AddSingleton<TDbContext>()
|
||||
.AddSingleton<ElsaMongoDbContext, TDbContext>()
|
||||
.AddSingleton(sp => sp.GetRequiredService<TDbContext>().WebhookDefinitions)
|
||||
.AddStartupTask<DatabaseInitializer>();
|
||||
|
||||
var webhookOptionsBuilder = new WebhookOptionsBuilder(elsa.Services);
|
||||
|
||||
webhookOptionsBuilder.UseWebhookDefinitionStore(sp => sp.GetRequiredService<MongoDbWebhookDefinitionStore>());
|
||||
webhookOptions.UseWebhookDefinitionStore(sp => sp.GetRequiredService<MongoDbWebhookDefinitionStore>());
|
||||
|
||||
DatabaseRegister.RegisterMapsAndSerializers();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,10 +28,9 @@ namespace Elsa.Webhooks.Persistence.MongoDb.Services
|
|||
var builder = Builders<WebhookDefinition>.IndexKeys;
|
||||
var tenantKeysDefinition = builder.Ascending(x => x.TenantId);
|
||||
var nameKeysDefinition = builder.Ascending(x => x.Name);
|
||||
var webhookIdDefinition = builder.Ascending(x => x.Id);
|
||||
var collection = _mongoContext.WebhookDefinitions;
|
||||
await CreateIndexesAsync(_mongoContext.WebhookDefinitions, cancellationToken, tenantKeysDefinition, webhookIdDefinition, nameKeysDefinition);
|
||||
await collection.Indexes.CreateOneAsync(new CreateIndexModel<WebhookDefinition>(webhookIdDefinition, new CreateIndexOptions { Unique = true }), cancellationToken: cancellationToken);
|
||||
var pathKeysDefinition = builder.Ascending(x => x.Path);
|
||||
var payloadKeysDefinition = builder.Ascending(x => x.PayloadTypeName);
|
||||
await CreateIndexesAsync(_mongoContext.WebhookDefinitions, cancellationToken, tenantKeysDefinition, nameKeysDefinition, pathKeysDefinition, payloadKeysDefinition);
|
||||
}
|
||||
|
||||
private async Task CreateIndexesAsync<T>(IMongoCollection<T> collection, CancellationToken cancellationToken, params IndexKeysDefinition<T>[] definitions)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
using Elsa.Activities.Webhooks;
|
||||
using Elsa.Activities.Webhooks.Persistence.Decorators;
|
||||
using Elsa.Attributes;
|
||||
using Elsa.Persistence.MongoDb.Options;
|
||||
using Elsa.Services.Startup;
|
||||
using Elsa.Webhooks.Persistence.MongoDb.Extensions;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Elsa.Webhooks.Persistence.MongoDb
|
||||
{
|
||||
[Feature("Webhooks:Persistence:MongoDb")]
|
||||
public class Startup : StartupBase
|
||||
{
|
||||
public override void ConfigureElsa(ElsaOptionsBuilder elsa, IConfiguration configuration)
|
||||
{
|
||||
var services = elsa.Services;
|
||||
var section = configuration.GetSection($"Elsa:Persistence:MongoDb");
|
||||
var connectionStringName = section.GetValue<string>("ConnectionStringName");
|
||||
var connectionString = section.GetValue<string>("ConnectionString");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(connectionString))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(connectionStringName))
|
||||
connectionStringName = "MongoDb";
|
||||
|
||||
connectionString = configuration.GetConnectionString(connectionStringName);
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(connectionString))
|
||||
connectionString = "mongodb://localhost:27017/Elsa";
|
||||
|
||||
var webhookOptionsBuilder = new WebhookOptionsBuilder(services);
|
||||
webhookOptionsBuilder.UseWebhookMongoDbPersistence(options => options.ConnectionString = connectionString);
|
||||
|
||||
services.AddScoped(sp => webhookOptionsBuilder.WebhookOptions.WebhookDefinitionStoreFactory(sp));
|
||||
services.Decorate<IWebhookDefinitionStore, InitializingWebhookDefinitionStore>();
|
||||
services.Decorate<IWebhookDefinitionStore, EventPublishingWebhookDefinitionStore>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ namespace Elsa.Webhooks.Persistence.YesSql.Documents
|
|||
{
|
||||
public class WebhookDefinitionDocument : YesSqlDocument
|
||||
{
|
||||
public string WebhookDefinitionId { get; set; } = default!;
|
||||
public string DefinitionId { get; set; } = default!;
|
||||
public string? TenantId { get; set; }
|
||||
public string Name { get; set; } = default!;
|
||||
public string Path { get; set; } = default!;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\..\..\common.props" />
|
||||
<Import Project="..\..\..\..\configureawait.props" />
|
||||
|
|
|
|||
|
|
@ -1,41 +1,45 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using Elsa.Activities.Webhooks;
|
||||
using Elsa.Webhooks.Persistence.YesSql.Services;
|
||||
using Elsa.Persistence.YesSql;
|
||||
using Elsa.Runtime;
|
||||
using Elsa.Webhooks.Persistence.YesSql.Indexes;
|
||||
using Elsa.Webhooks.Persistence.YesSql.Stores;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using YesSql;
|
||||
using YesSql.Indexes;
|
||||
using Elsa.Runtime;
|
||||
using Elsa.Webhooks.Persistence.YesSql.Mapping;
|
||||
using Elsa.Persistence.YesSql.Services;
|
||||
using YesSql.Provider.Sqlite;
|
||||
using Elsa.Persistence.YesSql.Data;
|
||||
using Elsa.Webhooks.Persistence.YesSql.Indexes;
|
||||
using Elsa.Webhooks.Persistence.YesSql.Mapping;
|
||||
|
||||
namespace Elsa.Webhooks.Persistence.YesSql.Extensions
|
||||
{
|
||||
public static class WebhookServiceCollectionExtensions
|
||||
{
|
||||
public static ElsaOptionsBuilder UseYesSqlPersistence(this ElsaOptionsBuilder elsa, Action<IServiceProvider, IConfiguration> configure)
|
||||
public static WebhookOptionsBuilder UseWebhookYesSqlPersistence(this WebhookOptionsBuilder webhookOptions) => webhookOptions.UseWebhookYesSqlPersistence(config => config.UseSqLite("Data Source=elsa.yessql.db;Cache=Shared", IsolationLevel.ReadUncommitted));
|
||||
public static WebhookOptionsBuilder UseWebhookYesSqlPersistence(this WebhookOptionsBuilder webhookOptions, Action<IConfiguration> configure) => webhookOptions.UseWebhookYesSqlPersistence((_, config) => configure(config));
|
||||
|
||||
public static WebhookOptionsBuilder UseWebhookYesSqlPersistence(this WebhookOptionsBuilder webhookOptions, Action<IServiceProvider, IConfiguration> configure)
|
||||
{
|
||||
elsa.Services
|
||||
webhookOptions.Services
|
||||
.AddScoped<YesSqlWebhookDefinitionStore>()
|
||||
.AddSingleton(sp => CreateStore(sp, configure))
|
||||
.AddSingleton<ISessionProvider, SessionProvider>()
|
||||
.AddScoped(CreateSession)
|
||||
.AddScoped<IDataMigrationManager, DataMigrationManager>()
|
||||
.AddStartupTask<DatabaseInitializer>()
|
||||
.AddStartupTask<RunMigrations>()
|
||||
.AddDataMigration<Migrations>()
|
||||
.AddAutoMapperProfile<AutoMapperProfile>()
|
||||
.AddIndexProvider<WebhookDefinitionIndexProvider>();
|
||||
|
||||
var webhookOptionsBuilder = new WebhookOptionsBuilder(elsa.Services);
|
||||
webhookOptions.UseWebhookDefinitionStore(sp => sp.GetRequiredService<YesSqlWebhookDefinitionStore>());
|
||||
|
||||
webhookOptionsBuilder.UseWebhookDefinitionStore(sp => sp.GetRequiredService<YesSqlWebhookDefinitionStore>());
|
||||
|
||||
return elsa;
|
||||
return webhookOptions;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddIndexProvider<T>(this IServiceCollection services) where T : class, IIndexProvider => services.AddSingleton<IIndexProvider, T>();
|
||||
public static IServiceCollection AddScopedIndexProvider<T>(this IServiceCollection services) where T : class, IIndexProvider => services.AddScoped<IScopedIndexProvider>();
|
||||
|
||||
public static IServiceCollection AddDataMigration<T>(this IServiceCollection services) where T : class, IDataMigration => services.AddScoped<IDataMigration, T>();
|
||||
|
||||
private static IStore CreateStore(
|
||||
IServiceProvider serviceProvider,
|
||||
Action<IServiceProvider, Configuration> configure)
|
||||
|
|
@ -59,7 +63,7 @@ namespace Elsa.Webhooks.Persistence.YesSql.Extensions
|
|||
|
||||
private static ISession CreateSession(IServiceProvider serviceProvider)
|
||||
{
|
||||
var provider = serviceProvider.GetRequiredService<ISessionProvider>();
|
||||
var provider = serviceProvider.GetRequiredService<Elsa.Persistence.YesSql.Services.ISessionProvider>();
|
||||
return provider.CreateSession();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace Elsa.Webhooks.Persistence.YesSql.Indexes
|
|||
{
|
||||
public class WebhookDefinitionIndex : MapIndex
|
||||
{
|
||||
public string WebhookDefinitionId { get; set; } = default!;
|
||||
public string DefinitionId { get; set; } = default!;
|
||||
public string? TenantId { get; set; }
|
||||
public bool IsEnabled { get; set; }
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ namespace Elsa.Webhooks.Persistence.YesSql.Indexes
|
|||
.Map(
|
||||
webhookDefinition => new WebhookDefinitionIndex
|
||||
{
|
||||
WebhookDefinitionId = webhookDefinition.WebhookDefinitionId,
|
||||
DefinitionId = webhookDefinition.DefinitionId,
|
||||
TenantId = webhookDefinition.TenantId,
|
||||
IsEnabled = webhookDefinition.IsEnabled
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,10 @@ namespace Elsa.Webhooks.Persistence.YesSql.Mapping
|
|||
public AutoMapperProfile()
|
||||
{
|
||||
CreateMap<WebhookDefinition, WebhookDefinitionDocument>()
|
||||
.ForMember(d => d.DefinitionId, d => d.MapFrom(s => s.Id))
|
||||
.ForMember(d => d.Id, d => d.Ignore())
|
||||
.ReverseMap()
|
||||
.ForMember(d => d.Id, d => d.MapFrom(s => s.Id));
|
||||
.ForMember(d => d.Id, d => d.MapFrom(s => s.DefinitionId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Elsa.Webhooks.Persistence.YesSql
|
|||
{
|
||||
SchemaBuilder.CreateMapIndexTable<WebhookDefinitionIndex>(
|
||||
table => table
|
||||
.Column<string>(nameof(WebhookDefinitionIndex.WebhookDefinitionId))
|
||||
.Column<string>(nameof(WebhookDefinitionIndex.DefinitionId))
|
||||
.Column<string?>(nameof(WebhookDefinitionIndex.TenantId))
|
||||
.Column<bool>(nameof(WebhookDefinitionIndex.IsEnabled)),
|
||||
CollectionNames.WebhookDefinitions);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Services;
|
||||
using Elsa.Webhooks.Persistence.YesSql.Data;
|
||||
using YesSql;
|
||||
|
||||
namespace Elsa.Webhooks.Persistence.YesSql.Services
|
||||
{
|
||||
public class DatabaseInitializer : IStartupTask
|
||||
{
|
||||
private readonly IStore _store;
|
||||
|
||||
public DatabaseInitializer(IStore store)
|
||||
{
|
||||
_store = store;
|
||||
}
|
||||
|
||||
public int Order => 0;
|
||||
|
||||
public async Task ExecuteAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
await _store.InitializeCollectionAsync(CollectionNames.WebhookDefinitions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
using System;
|
||||
using Elsa.Activities.Webhooks;
|
||||
using Elsa.Activities.Webhooks.Persistence.Decorators;
|
||||
using Elsa.Attributes;
|
||||
using Elsa.Services.Startup;
|
||||
using Elsa.Webhooks.Persistence.YesSql.Extensions;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using YesSql.Provider.MySql;
|
||||
using YesSql.Provider.PostgreSql;
|
||||
using YesSql.Provider.Sqlite;
|
||||
using YesSql.Provider.SqlServer;
|
||||
|
||||
namespace Elsa.Webhooks.Persistence.YesSql
|
||||
{
|
||||
[Feature("Webhooks:Persistence:YesSql:Sqlite")]
|
||||
public class SqliteStartup : YesSqlStartupBase
|
||||
{
|
||||
protected override string ProviderName => "Sqlite";
|
||||
protected override string GetDefaultConnectionString() => "Data Source=elsa.yessql.db;Cache=Shared";
|
||||
protected override void Configure(global::YesSql.IConfiguration options, string connectionString) => options.UseSqLite(connectionString);
|
||||
}
|
||||
|
||||
[Feature("Webhooks:Persistence:YesSql:SqlServer")]
|
||||
public class SqlServerStartup : YesSqlStartupBase
|
||||
{
|
||||
protected override string ProviderName => "SqlServer";
|
||||
protected override void Configure(global::YesSql.IConfiguration options, string connectionString) => options.UseSqlServer(connectionString);
|
||||
}
|
||||
|
||||
[Feature("Webhooks:Persistence:YesSql:MySql")]
|
||||
public class MySqlStartup : YesSqlStartupBase
|
||||
{
|
||||
protected override string ProviderName => "MySql";
|
||||
protected override void Configure(global::YesSql.IConfiguration options, string connectionString) => options.UseMySql(connectionString);
|
||||
}
|
||||
|
||||
[Feature("Webhooks:Persistence:YesSql:PostgreSql")]
|
||||
public class PostgreSqlStartup : YesSqlStartupBase
|
||||
{
|
||||
protected override string ProviderName => "PostgreSql";
|
||||
protected override void Configure(global::YesSql.IConfiguration options, string connectionString) => options.UsePostgreSql(connectionString);
|
||||
}
|
||||
|
||||
public abstract class YesSqlStartupBase : StartupBase
|
||||
{
|
||||
protected abstract string ProviderName { get; }
|
||||
|
||||
public override void ConfigureElsa(ElsaOptionsBuilder elsa, IConfiguration configuration)
|
||||
{
|
||||
var services = elsa.Services;
|
||||
var section = configuration.GetSection($"Elsa:Persistence:{ProviderName}");
|
||||
var connectionStringName = section.GetValue<string>("ConnectionStringName");
|
||||
var connectionString = section.GetValue<string>("ConnectionString");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(connectionString))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(connectionStringName))
|
||||
connectionStringName = ProviderName;
|
||||
|
||||
connectionString = configuration.GetConnectionString(connectionStringName);
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(connectionString))
|
||||
connectionString = GetDefaultConnectionString();
|
||||
|
||||
var webhookOptionsBuilder = new WebhookOptionsBuilder(services);
|
||||
webhookOptionsBuilder.UseWebhookYesSqlPersistence(options => Configure(options, connectionString));
|
||||
|
||||
services.AddScoped(sp => webhookOptionsBuilder.WebhookOptions.WebhookDefinitionStoreFactory(sp));
|
||||
services.Decorate<IWebhookDefinitionStore, InitializingWebhookDefinitionStore>();
|
||||
services.Decorate<IWebhookDefinitionStore, EventPublishingWebhookDefinitionStore>();
|
||||
}
|
||||
|
||||
protected virtual string GetDefaultConnectionString() => throw new Exception($"No connection string specified for the {ProviderName} provider");
|
||||
protected abstract void Configure(global::YesSql.IConfiguration options, string connectionString);
|
||||
}
|
||||
}
|
||||
|
|
@ -21,13 +21,13 @@ namespace Elsa.Webhooks.Persistence.YesSql.Stores
|
|||
{
|
||||
}
|
||||
|
||||
protected override async Task<WebhookDefinitionDocument?> FindDocumentAsync(ISession session, WebhookDefinition entity, CancellationToken cancellationToken) => await Query<WebhookDefinitionIndex>(session, x => x.WebhookDefinitionId == entity.Id).FirstOrDefaultAsync();
|
||||
protected override async Task<WebhookDefinitionDocument?> FindDocumentAsync(ISession session, WebhookDefinition entity, CancellationToken cancellationToken) => await Query<WebhookDefinitionIndex>(session, x => x.DefinitionId == entity.Id).FirstOrDefaultAsync();
|
||||
|
||||
protected override IQuery<WebhookDefinitionDocument> MapSpecification(ISession session, ISpecification<WebhookDefinition> specification)
|
||||
{
|
||||
return specification switch
|
||||
{
|
||||
EntityIdSpecification<WebhookDefinition> s => Query<WebhookDefinitionIndex>(session, x => x.WebhookDefinitionId == s.Id),
|
||||
EntityIdSpecification<WebhookDefinition> s => Query<WebhookDefinitionIndex>(session, x => x.DefinitionId == s.Id),
|
||||
_ => AutoMapSpecification<WebhookDefinitionIndex>(session, specification)
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,6 @@ export class ElsaWebhookDefinitionEditorScreen {
|
|||
this.saving = true;
|
||||
|
||||
try {
|
||||
|
||||
if (request.id == null)
|
||||
webhookDefinition = await client.webhookDefinitionsApi.save(request);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@
|
|||
<ProjectReference Include="..\..\..\activities\Elsa.Activities.Temporal.Quartz\Elsa.Activities.Temporal.Quartz.csproj" />
|
||||
<ProjectReference Include="..\..\..\activities\Elsa.Activities.UserTask\Elsa.Activities.UserTask.csproj" />
|
||||
<ProjectReference Include="..\..\..\activities\webhooks\Elsa.Activities.Webhooks\Elsa.Activities.Webhooks.csproj" />
|
||||
<ProjectReference Include="..\..\..\activities\webhooks\Elsa.Webhooks.Persistence.EntityFramework.MySql\Elsa.Webhooks.Persistence.EntityFramework.MySql.csproj" />
|
||||
<ProjectReference Include="..\..\..\activities\webhooks\Elsa.Webhooks.Persistence.EntityFramework.PostgreSql\Elsa.Webhooks.Persistence.EntityFramework.PostgreSql.csproj" />
|
||||
<ProjectReference Include="..\..\..\activities\webhooks\Elsa.Webhooks.Persistence.EntityFramework.Sqlite\Elsa.Webhooks.Persistence.EntityFramework.Sqlite.csproj" />
|
||||
<ProjectReference Include="..\..\..\activities\webhooks\Elsa.Webhooks.Persistence.EntityFramework.SqlServer\Elsa.Webhooks.Persistence.EntityFramework.SqlServer.csproj" />
|
||||
<ProjectReference Include="..\..\..\activities\webhooks\Elsa.Webhooks.Persistence.MongoDb\Elsa.Webhooks.Persistence.MongoDb.csproj" />
|
||||
<ProjectReference Include="..\..\..\activities\webhooks\Elsa.Webhooks.Persistence.YesSql\Elsa.Webhooks.Persistence.YesSql.csproj" />
|
||||
<ProjectReference Include="..\..\..\caching\Elsa.Caching.Rebus\Elsa.Caching.Rebus.csproj" />
|
||||
|
|
|
|||
143
src/samples/server/Elsa.Samples.Server.Host/README.md
Normal file
143
src/samples/server/Elsa.Samples.Server.Host/README.md
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
### Configure persistence in appsettings.json
|
||||
|
||||
EF Sqlite
|
||||
```
|
||||
"Elsa": {
|
||||
"Features": [
|
||||
"Persistence:EntityFrameworkCore:Sqlite",
|
||||
...
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
EF MySQL
|
||||
```
|
||||
"Elsa": {
|
||||
"Features": [
|
||||
"Persistence:EntityFrameworkCore:MySql",
|
||||
...
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
EF SQL Server
|
||||
```
|
||||
"Elsa": {
|
||||
"Features": [
|
||||
"Persistence:EntityFrameworkCore:SqlServer",
|
||||
...
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
EF Postgre
|
||||
```
|
||||
"Elsa": {
|
||||
"Features": [
|
||||
"Persistence:EntityFrameworkCore:PostgreSql",
|
||||
...
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
EF MongoDB
|
||||
```
|
||||
"Elsa": {
|
||||
"Features": [
|
||||
"Persistence:MongoDb",
|
||||
...
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
YesSql Sqlite
|
||||
```
|
||||
"Elsa": {
|
||||
"Features": [
|
||||
"Persistence:YesSql:Sqlite",
|
||||
...
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
YesSql MySQL
|
||||
```
|
||||
"Elsa": {
|
||||
"Features": [
|
||||
"Persistence:YesSql:MySql",
|
||||
...
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
YesSql SQL Server
|
||||
```
|
||||
"Elsa": {
|
||||
"Features": [
|
||||
"Persistence:YesSql:SqlServer",
|
||||
...
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
YesSql Postgre
|
||||
```
|
||||
"Elsa": {
|
||||
"Features": [
|
||||
"Persistence:YesSql:PostgreSql",
|
||||
...
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
### Configure modular activity providers such as Webhooks
|
||||
It is required to add modular activity provider and additional persistence feature for your modular activity provider.
|
||||
The persistence providers should match for Elsa Core and modular activity providers.
|
||||
Two examples below are given to set up Elsa Core and Webhooks persistence as follow.
|
||||
|
||||
EF Sqlite
|
||||
```
|
||||
"Elsa": {
|
||||
"Features": [
|
||||
"Persistence:EntityFrameworkCore:Sqlite",
|
||||
"Webhooks"
|
||||
"Webhooks:Persistence:EntityFrameworkCore:Sqlite",
|
||||
...
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
EF MongoDB
|
||||
```
|
||||
"Elsa": {
|
||||
"Features": [
|
||||
"Persistence:MongoDb",
|
||||
"Webhooks"
|
||||
"Webhooks:Persistence:MongoDb",
|
||||
...
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
### Configure connection strings for each persistence
|
||||
|
||||
```
|
||||
"ConnectionStrings": {
|
||||
...
|
||||
"MySql": "Server=LAPTOP-B76STK67;Database=Elsa;Uid=myUsername;Pwd=myPassword;",
|
||||
"SqlServer": "Server=LAPTOP-B76STK67;Database=Elsa;Integrated Security=true;MultipleActiveResultSets=True;Max Pool Size=500;Connection Timeout=3600",
|
||||
"Sqlite": "Data Source=elsa.sqlite.db;Cache=Shared;",
|
||||
"MongoDb": "mongodb://localhost:27017/Elsa",
|
||||
"PostgreSql": "Server=127.0.0.1;Port=5433;Database=elsa;User Id=postgres;Password=Password12!;"
|
||||
},
|
||||
```
|
||||
|
||||
### Connection strings
|
||||
MySql
|
||||
https://www.connectionstrings.com/mysql/
|
||||
SQL Server
|
||||
https://www.connectionstrings.com/sql-server/
|
||||
Postgres
|
||||
https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
|
||||
MongoDb
|
||||
https://docs.mongodb.com/manual/reference/connection-string/
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using Elsa.Samples.Server.Host.Activities;
|
||||
using Elsa.Server.Hangfire.Extensions;
|
||||
using Hangfire;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
|
|
@ -32,7 +33,6 @@ namespace Elsa.Samples.Server.Host
|
|||
{
|
||||
typeof(Elsa.Activities.Console.Startup),
|
||||
typeof(Elsa.Activities.Http.Startup),
|
||||
typeof(Elsa.Activities.Webhooks.Startup),
|
||||
typeof(Elsa.Activities.AzureServiceBus.Startup),
|
||||
typeof(Elsa.Activities.Conductor.Startup),
|
||||
typeof(Elsa.Activities.UserTask.Startup),
|
||||
|
|
@ -51,6 +51,16 @@ namespace Elsa.Samples.Server.Host
|
|||
typeof(Persistence.YesSql.PostgreSqlStartup),
|
||||
typeof(Elsa.Server.Hangfire.Startup),
|
||||
typeof(Elsa.Scripting.JavaScript.Startup),
|
||||
typeof(Elsa.Activities.Webhooks.Startup),
|
||||
typeof(Webhooks.Persistence.EntityFramework.Sqlite.Startup),
|
||||
typeof(Webhooks.Persistence.EntityFramework.SqlServer.Startup),
|
||||
typeof(Webhooks.Persistence.EntityFramework.MySql.Startup),
|
||||
typeof(Webhooks.Persistence.EntityFramework.PostgreSql.Startup),
|
||||
typeof(Webhooks.Persistence.MongoDb.Startup),
|
||||
typeof(Webhooks.Persistence.YesSql.SqliteStartup),
|
||||
typeof(Webhooks.Persistence.YesSql.SqlServerStartup),
|
||||
typeof(Webhooks.Persistence.YesSql.MySqlStartup),
|
||||
typeof(Webhooks.Persistence.YesSql.PostgreSqlStartup),
|
||||
};
|
||||
|
||||
services
|
||||
|
|
|
|||
|
|
@ -11,9 +11,11 @@
|
|||
"ConnectionStrings": {
|
||||
"RabbitMq": "amqp://localhost:5672",
|
||||
"Redis": "localhost:6379,abortConnect=false",
|
||||
"MySql": "Server=LAPTOP-B76STK67;Database=Elsa;Uid=myUsername;Pwd=myPassword;",
|
||||
"SqlServer": "Server=LAPTOP-B76STK67;Database=Elsa;Integrated Security=true;MultipleActiveResultSets=True;Max Pool Size=500;Connection Timeout=3600",
|
||||
"Sqlite": "Data Source=elsa.sqlite.db;Cache=Shared;",
|
||||
"MongoDb": "mongodb://localhost:27017/Elsa"
|
||||
"Sqlite": "Data Source=elsa.sqlite.yes.db;Cache=Shared;",
|
||||
"MongoDb": "mongodb://localhost:27017/Elsa",
|
||||
"PostgreSql": "Server=127.0.0.1;Port=5432;Database=elsa;User Id=postgres;Password=password;"
|
||||
},
|
||||
"Elsa": {
|
||||
"Features": [
|
||||
|
|
@ -26,8 +28,25 @@
|
|||
"JavaScript:Activities",
|
||||
"UserTask",
|
||||
"Conductor",
|
||||
"Telnyx"
|
||||
"Telnyx",
|
||||
"Webhooks",
|
||||
"Webhooks:Persistence:EntityFrameworkCore:Sqlite"
|
||||
],
|
||||
"Persistence:MySql": {
|
||||
"ConnectionStringName": "MySql"
|
||||
},
|
||||
"Persistence:SqlServer": {
|
||||
"ConnectionStringName": "SqlServer"
|
||||
},
|
||||
"Persistence:Sqlite": {
|
||||
"ConnectionStringName": "Sqlite"
|
||||
},
|
||||
"Persistence:MongoDb": {
|
||||
"ConnectionStringName": "MongoDb"
|
||||
},
|
||||
"Persistence:PostgreSql": {
|
||||
"ConnectionStringName": "PostgreSql"
|
||||
},
|
||||
"WorkflowChannels": {
|
||||
"Channels": [
|
||||
"High",
|
||||
|
|
@ -35,10 +54,7 @@
|
|||
"Low"
|
||||
],
|
||||
"Default": "Normal"
|
||||
},
|
||||
"Persistence:Sqlite": {
|
||||
"ConnectionStringName": "Sqlite"
|
||||
},
|
||||
},
|
||||
"Http": {
|
||||
"BaseUrl": "https://localhost:11000",
|
||||
"BasePath": "/workflows"
|
||||
|
|
|
|||
Loading…
Reference in a new issue