From bb669c2cfe468e0b8773cc85b2928a28d0009cc2 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Tue, 28 Feb 2023 15:14:45 +0100 Subject: [PATCH] Sycnrhonize access to publish / save workflow definition endpoint (#3743) * Refactor SaveAsync and Store APIs * Synchronize Publish endpoint --- .../Common/EntityStore.cs | 17 ++++++++++ .../Common/PersistenceFeatureBase.cs | 9 ++++++ .../Elsa.EntityFrameworkCore/Common/Store.cs | 24 +++++++------- .../Extensions/ExpressionExtensions.cs | 29 +++++++++++++++-- .../Extensions/QueryableExtensions.cs | 32 +++---------------- .../Modules/Labels/Feature.cs | 4 +-- .../Modules/Labels/LabelStore.cs | 6 ++-- .../Labels/WorkflowDefinitionLabelStore.cs | 20 ++++++++++-- ...oreWorkflowManagementPersistenceFeature.cs | 4 +-- .../WorkflowDefinitionPersistenceFeature.cs | 2 +- .../Management/WorkflowDefinitionStore.cs | 8 ++--- .../WorkflowInstancePersistenceFeature.cs | 2 +- .../Management/WorkflowInstanceStore.cs | 4 +-- .../DefaultRuntimePersistenceFeature.cs | 4 +-- .../ExecutionLogRecordPersistenceFeature.cs | 2 +- .../Modules/Runtime/TriggerStore.cs | 4 +-- .../Runtime/WorkflowExecutionLogStore.cs | 15 +++++++-- .../Modules/Runtime/WorkflowStateStore.cs | 4 +-- .../WorkflowDefinitions/Post/Endpoint.cs | 9 +++++- 19 files changed, 129 insertions(+), 70 deletions(-) create mode 100644 src/modules/Elsa.EntityFrameworkCore/Common/EntityStore.cs diff --git a/src/modules/Elsa.EntityFrameworkCore/Common/EntityStore.cs b/src/modules/Elsa.EntityFrameworkCore/Common/EntityStore.cs new file mode 100644 index 000000000..1b29927e2 --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore/Common/EntityStore.cs @@ -0,0 +1,17 @@ +using Elsa.Common.Entities; +using Microsoft.EntityFrameworkCore; + +namespace Elsa.EntityFrameworkCore.Common; + +public class EntityStore : Store where TDbContext : DbContext where TEntity : Entity +{ + public EntityStore(IDbContextFactory dbContextFactory) : base(dbContextFactory) + { + } + + public async Task SaveAsync(TEntity entity, CancellationToken cancellationToken = default) => await SaveAsync(entity, null, cancellationToken); + public async Task SaveAsync(TEntity entity, Func? onSaving, CancellationToken cancellationToken = default) => await SaveAsync(entity, x => x.Id, onSaving, cancellationToken); + + public async Task SaveManyAsync(IEnumerable entities, CancellationToken cancellationToken = default) => await SaveManyAsync(entities, default, cancellationToken); + public async Task SaveManyAsync(IEnumerable entities, Func? onSaving = default, CancellationToken cancellationToken = default) => await SaveManyAsync(entities, x => x.Id, onSaving, cancellationToken); +} \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore/Common/PersistenceFeatureBase.cs b/src/modules/Elsa.EntityFrameworkCore/Common/PersistenceFeatureBase.cs index e23c05882..c21505e8c 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Common/PersistenceFeatureBase.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Common/PersistenceFeatureBase.cs @@ -1,3 +1,4 @@ +using Elsa.Common.Entities; using Elsa.Features.Abstractions; using Elsa.Features.Services; using Microsoft.EntityFrameworkCore; @@ -37,4 +38,12 @@ public abstract class PersistenceFeatureBase : FeatureBase where TDb .AddSingleton() ; } + + protected void AddEntityStore() where TEntity : Entity where TStore : class + { + Services + .AddSingleton>() + .AddSingleton() + ; + } } \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore/Common/Store.cs b/src/modules/Elsa.EntityFrameworkCore/Common/Store.cs index 89d395dea..b62962b74 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Common/Store.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Common/Store.cs @@ -17,26 +17,24 @@ public class Store where TDbContext : DbContext where TEnti public async Task CreateDbContextAsync(CancellationToken cancellationToken = default) => await _dbContextFactory.CreateDbContextAsync(cancellationToken); - public async Task SaveAsync(TEntity entity, CancellationToken cancellationToken = default) => await SaveAsync(entity, default, default, cancellationToken); + public async Task SaveAsync(TEntity entity, Expression> keySelector, CancellationToken cancellationToken = default) => await SaveAsync(entity, keySelector, null, cancellationToken); - public async Task SaveAsync(TEntity entity, Expression>? uniqueField = default, CancellationToken cancellationToken = default) => await SaveAsync(entity, uniqueField, default, cancellationToken); - - public async Task SaveAsync(TEntity entity, Func? onSaving = default, CancellationToken cancellationToken = default) => await SaveAsync(entity, default, onSaving, cancellationToken); - - public async Task SaveAsync(TEntity entity, Expression>? uniqueField = default, Func? onSaving = default, CancellationToken cancellationToken = default) + public async Task SaveAsync(TEntity entity, Expression> keySelector, Func? onSaving, CancellationToken cancellationToken = default) { await using var dbContext = await CreateDbContextAsync(cancellationToken); entity = onSaving?.Invoke(dbContext, entity) ?? entity; - await dbContext.BulkUpsertAsync(new[] { entity }, uniqueField, cancellationToken); + var set = dbContext.Set(); + var lambda = keySelector.BuildEqualsExpresion(entity); + var exists = await set.AnyAsync(lambda, cancellationToken); + set.Entry(entity).State = exists ? EntityState.Modified : EntityState.Added; + + await dbContext.SaveChangesAsync(cancellationToken); } - public async Task SaveManyAsync(IEnumerable entities, CancellationToken cancellationToken = default) => await SaveManyAsync(entities, default, default, cancellationToken); - public async Task SaveManyAsync(IEnumerable entities, Expression>? uniqueField = default, CancellationToken cancellationToken = default) => await SaveManyAsync(entities, uniqueField, default, cancellationToken); + public async Task SaveManyAsync(IEnumerable entities, Expression> keySelector, CancellationToken cancellationToken = default) => await SaveManyAsync(entities, keySelector, default, cancellationToken); - public async Task SaveManyAsync(IEnumerable entities, Func? onSaving = default, CancellationToken cancellationToken = default) => await SaveManyAsync(entities, default, onSaving, cancellationToken); - - public async Task SaveManyAsync(IEnumerable entities, Expression>? uniqueField = default, Func? onSaving = default, CancellationToken cancellationToken = default) + public async Task SaveManyAsync(IEnumerable entities, Expression> keySelector, Func? onSaving = default, CancellationToken cancellationToken = default) { await using var dbContext = await CreateDbContextAsync(cancellationToken); var entityList = entities.ToList(); @@ -44,7 +42,7 @@ public class Store where TDbContext : DbContext where TEnti if (onSaving != null) entityList = entityList.Select(x => onSaving(dbContext, x)).ToList(); - await dbContext.BulkUpsertAsync(entityList, uniqueField, cancellationToken); + await dbContext.BulkUpsertAsync(entityList, keySelector, cancellationToken); } public async Task FindAsync(Expression> predicate, CancellationToken cancellationToken = default) => await FindAsync(predicate, default, cancellationToken); diff --git a/src/modules/Elsa.EntityFrameworkCore/Extensions/ExpressionExtensions.cs b/src/modules/Elsa.EntityFrameworkCore/Extensions/ExpressionExtensions.cs index e6e16f442..c8d8abc13 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Extensions/ExpressionExtensions.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Extensions/ExpressionExtensions.cs @@ -1,20 +1,43 @@ using System.Linq.Expressions; using System.Reflection; +using Elsa.Extensions; +using Elsa.Workflows.Runtime.Entities; namespace Elsa.EntityFrameworkCore.Extensions; public static class ExpressionExtensions { - public static Expression> BuildContainsExpression(this Func uniqueFieldDelegate, IEnumerable entities, PropertyInfo property) where TEntity : class + public static Expression> BuildContainsExpression(this Expression> keySelector, IEnumerable entities) where TEntity : class { - var list = entities.Select(uniqueFieldDelegate.Invoke); + var compiledKeySelector = keySelector.Compile(); + var list = entities.Select(compiledKeySelector); + var property = keySelector.GetProperty()!; var param = Expression.Parameter(typeof(TEntity)); + var body = Expression.Call( typeof(Enumerable), "Contains", - new[] {uniqueFieldDelegate.Method.ReturnType}, + new[] {compiledKeySelector.Method.ReturnType}, Expression.Constant(list), Expression.Property(param, property)); return Expression.Lambda>(body, param); } + + public static Expression> BuildEqualsExpresion(this Expression> keySelector, TEntity entity) + { + var keyName = keySelector.GetProperty()!.Name; + + // Define parameters for the lambda expression + var parameter = Expression.Parameter(typeof(TEntity), "x"); + var keySelectorLambda = Expression.Lambda>(Expression.Property(parameter, keyName), parameter); + + // Build the expression that compares the keys + var entityKey = keySelectorLambda.Compile()(entity); + var comparison = Expression.Equal(keySelectorLambda.Body, Expression.Constant(entityKey)); + + // Create the final lambda expression that can be used in AnyAsync + var lambda = Expression.Lambda>(comparison, parameter); + + return lambda; + } } \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore/Extensions/QueryableExtensions.cs b/src/modules/Elsa.EntityFrameworkCore/Extensions/QueryableExtensions.cs index 654d64154..bd53c4696 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Extensions/QueryableExtensions.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Extensions/QueryableExtensions.cs @@ -1,7 +1,5 @@ using System.Linq.Expressions; -using Elsa.Common.Entities; using Elsa.Common.Models; -using Elsa.Extensions; using Microsoft.EntityFrameworkCore; namespace Elsa.EntityFrameworkCore.Extensions; @@ -14,17 +12,13 @@ public static class QueryableExtensions /// /// Inserts or updates a list of entities in bulk. /// - public static async Task BulkUpsertAsync(this TDbContext dbContext, IList entities, Expression>? uniqueFieldExpression = default, CancellationToken cancellationToken = default) where TDbContext : DbContext where TEntity : class + public static async Task BulkUpsertAsync(this TDbContext dbContext, IList entities, Expression> keySelector, CancellationToken cancellationToken = default) where TDbContext : DbContext where TEntity : class { - uniqueFieldExpression = ResolveUniqueFieldExpression(uniqueFieldExpression); - var uniqueFieldDelegate = uniqueFieldExpression.Compile(); - var propertyInfo = uniqueFieldExpression.GetProperty()!; - var set = dbContext.Set(); - var lambda = uniqueFieldDelegate.BuildContainsExpression(entities, propertyInfo); - - var existingEntities = await set.AsNoTracking().Where(lambda).ToListAsync(cancellationToken); - var entitiesToUpdate = entities.Where(e => existingEntities.Any(ex => uniqueFieldDelegate.Invoke(ex).ToString() == uniqueFieldDelegate.Invoke(e).ToString())).ToList(); + var compiledKeySelector = keySelector.Compile(); + var containsLambda = keySelector.BuildContainsExpression(entities); + var existingEntities = await set.AsNoTracking().Where(containsLambda).ToListAsync(cancellationToken); + var entitiesToUpdate = entities.IntersectBy(existingEntities.Select(compiledKeySelector), compiledKeySelector).ToList(); var entitiesToInsert = entities.Except(entitiesToUpdate).ToList(); if (entitiesToUpdate.Any()) @@ -58,20 +52,4 @@ public static class QueryableExtensions var results = await queryable.ToListAsync(); return Page.Of(results, count); } - - private static Expression> ResolveUniqueFieldExpression(Expression>? uniqueFieldExpression) where TEntity : class - { - if (uniqueFieldExpression != null) return uniqueFieldExpression; - try - { - uniqueFieldExpression = e => ((Entity)(object)e).Id; - } - catch (Exception) - { - throw new Exception( - "Unique field expression must be passed via BulkUpsertAsync if default object to upsert is not of type Entity."); - } - - return uniqueFieldExpression; - } } \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Labels/Feature.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Labels/Feature.cs index 3cd300596..7dbe21ee1 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Labels/Feature.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Labels/Feature.cs @@ -28,7 +28,7 @@ public class EFCoreLabelPersistenceFeature : PersistenceFeatureBase(); - AddStore(); + AddEntityStore(); + AddEntityStore(); } } \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Labels/LabelStore.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Labels/LabelStore.cs index 15faef8eb..c7ca82df6 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Labels/LabelStore.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Labels/LabelStore.cs @@ -8,10 +8,10 @@ namespace Elsa.EntityFrameworkCore.Modules.Labels; public class EFCoreLabelStore : ILabelStore { - private readonly Store _labelStore; - private readonly Store _workflowDefinitionLabelStore; + private readonly EntityStore _labelStore; + private readonly EntityStore _workflowDefinitionLabelStore; - public EFCoreLabelStore(Store labelStore, Store workflowDefinitionLabelStore) + public EFCoreLabelStore(EntityStore labelStore, EntityStore workflowDefinitionLabelStore) { _labelStore = labelStore; _workflowDefinitionLabelStore = workflowDefinitionLabelStore; diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Labels/WorkflowDefinitionLabelStore.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Labels/WorkflowDefinitionLabelStore.cs index 663cc6638..006955574 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Labels/WorkflowDefinitionLabelStore.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Labels/WorkflowDefinitionLabelStore.cs @@ -4,18 +4,30 @@ using Elsa.Labels.Services; namespace Elsa.EntityFrameworkCore.Modules.Labels; +/// public class EFCoreWorkflowDefinitionLabelStore : IWorkflowDefinitionLabelStore { - private readonly Store _store; - public EFCoreWorkflowDefinitionLabelStore(Store store) => _store = store; + private readonly EntityStore _store; + /// + /// Constructor + /// + public EFCoreWorkflowDefinitionLabelStore(EntityStore store) => _store = store; + + /// public async Task SaveAsync(WorkflowDefinitionLabel record, CancellationToken cancellationToken = default) => await _store.SaveAsync(record, cancellationToken); + + /// public async Task SaveManyAsync(IEnumerable records, CancellationToken cancellationToken = default) => await _store.SaveManyAsync(records, cancellationToken); + + /// public async Task DeleteAsync(string id, CancellationToken cancellationToken = default) => await _store.DeleteWhereAsync(x => x.Id == id, cancellationToken) > 0; + /// public async Task> FindByWorkflowDefinitionVersionIdAsync(string workflowDefinitionVersionId, CancellationToken cancellationToken = default) => await _store.FindManyAsync(x => x.WorkflowDefinitionVersionId == workflowDefinitionVersionId, cancellationToken); + /// public async Task ReplaceAsync(IEnumerable removed, IEnumerable added, CancellationToken cancellationToken = default) { var idList = removed.Select(r => r.Id); @@ -23,18 +35,22 @@ public class EFCoreWorkflowDefinitionLabelStore : IWorkflowDefinitionLabelStore await _store.SaveManyAsync(added, cancellationToken); } + /// public async Task DeleteByWorkflowDefinitionIdAsync(string workflowDefinitionId, CancellationToken cancellationToken = default) => await _store.DeleteWhereAsync(x => x.WorkflowDefinitionId == workflowDefinitionId, cancellationToken); + /// public async Task DeleteByWorkflowDefinitionVersionIdAsync(string workflowDefinitionVersionId, CancellationToken cancellationToken = default) => await _store.DeleteWhereAsync(x => x.WorkflowDefinitionVersionId == workflowDefinitionVersionId, cancellationToken); + /// public async Task DeleteByWorkflowDefinitionIdsAsync(IEnumerable workflowDefinitionIds, CancellationToken cancellationToken = default) { var ids = workflowDefinitionIds.ToList(); return await _store.DeleteWhereAsync(x => ids.Contains(x.WorkflowDefinitionId), cancellationToken); } + /// public async Task DeleteByWorkflowDefinitionVersionIdsAsync(IEnumerable workflowDefinitionVersionIds, CancellationToken cancellationToken = default) { var ids = workflowDefinitionVersionIds.ToList(); diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/EFCoreWorkflowManagementPersistenceFeature.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/EFCoreWorkflowManagementPersistenceFeature.cs index 06be22263..e58618bc1 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/EFCoreWorkflowManagementPersistenceFeature.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/EFCoreWorkflowManagementPersistenceFeature.cs @@ -32,7 +32,7 @@ public class EFCoreWorkflowManagementPersistenceFeature : PersistenceFeatureBase { base.Apply(); - AddStore(); - AddStore(); + AddEntityStore(); + AddEntityStore(); } } \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowDefinitionPersistenceFeature.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowDefinitionPersistenceFeature.cs index 03a3555ad..812525368 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowDefinitionPersistenceFeature.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowDefinitionPersistenceFeature.cs @@ -32,6 +32,6 @@ public class EFCoreWorkflowDefinitionPersistenceFeature : PersistenceFeatureBase { base.Apply(); - AddStore(); + AddEntityStore(); } } \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowDefinitionStore.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowDefinitionStore.cs index f09edafd9..f16d20238 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowDefinitionStore.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowDefinitionStore.cs @@ -15,16 +15,16 @@ namespace Elsa.EntityFrameworkCore.Modules.Management; /// public class EFCoreWorkflowDefinitionStore : IWorkflowDefinitionStore { - private readonly Store _store; - private readonly Store _workflowInstanceStore; + private readonly EntityStore _store; + private readonly EntityStore _workflowInstanceStore; private readonly SerializerOptionsProvider _serializerOptionsProvider; /// /// Constructor. /// public EFCoreWorkflowDefinitionStore( - Store store, - Store workflowInstanceStore, + EntityStore store, + EntityStore workflowInstanceStore, SerializerOptionsProvider serializerOptionsProvider) { _store = store; diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowInstancePersistenceFeature.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowInstancePersistenceFeature.cs index 53b681f4c..41c3ac044 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowInstancePersistenceFeature.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowInstancePersistenceFeature.cs @@ -32,6 +32,6 @@ public class EFCoreWorkflowInstancePersistenceFeature : PersistenceFeatureBase(); + AddEntityStore(); } } \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowInstanceStore.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowInstanceStore.cs index 4493b81f7..b75bb13b2 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowInstanceStore.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/WorkflowInstanceStore.cs @@ -17,13 +17,13 @@ namespace Elsa.EntityFrameworkCore.Modules.Management; /// public class EFCoreWorkflowInstanceStore : IWorkflowInstanceStore { - private readonly Store _store; + private readonly EntityStore _store; private readonly SerializerOptionsProvider _serializerOptionsProvider; /// /// Constructor. /// - public EFCoreWorkflowInstanceStore(Store store, SerializerOptionsProvider serializerOptionsProvider) + public EFCoreWorkflowInstanceStore(EntityStore store, SerializerOptionsProvider serializerOptionsProvider) { _store = store; _serializerOptionsProvider = serializerOptionsProvider; diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/DefaultRuntimePersistenceFeature.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/DefaultRuntimePersistenceFeature.cs index cbf38dc25..8ee4139f1 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/DefaultRuntimePersistenceFeature.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/DefaultRuntimePersistenceFeature.cs @@ -30,8 +30,8 @@ public class EFCoreDefaultRuntimePersistenceFeature : PersistenceFeatureBase(); - AddStore(); + AddEntityStore(); + AddEntityStore(); AddStore(); } } \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/ExecutionLogRecordPersistenceFeature.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/ExecutionLogRecordPersistenceFeature.cs index 3126e22b4..b2989c0d9 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/ExecutionLogRecordPersistenceFeature.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/ExecutionLogRecordPersistenceFeature.cs @@ -26,6 +26,6 @@ public class EFCoreExecutionLogRecordPersistenceFeature : PersistenceFeatureBase { base.Apply(); - AddStore(); + AddEntityStore(); } } \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/TriggerStore.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/TriggerStore.cs index a1a91c737..28cb51a37 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/TriggerStore.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/TriggerStore.cs @@ -7,12 +7,12 @@ namespace Elsa.EntityFrameworkCore.Modules.Runtime; /// public class EFCoreTriggerStore : ITriggerStore { - private readonly Store _store; + private readonly EntityStore _store; /// /// Constructor. /// - public EFCoreTriggerStore(Store store) + public EFCoreTriggerStore(EntityStore store) { _store = store; } diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/WorkflowExecutionLogStore.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/WorkflowExecutionLogStore.cs index 5427040e1..63d7805ff 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/WorkflowExecutionLogStore.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/WorkflowExecutionLogStore.cs @@ -6,13 +6,24 @@ using Elsa.Workflows.Runtime.Services; namespace Elsa.EntityFrameworkCore.Modules.Runtime; +/// public class EFCoreWorkflowExecutionLogStore : IWorkflowExecutionLogStore { - private readonly Store _store; - public EFCoreWorkflowExecutionLogStore(Store store) => _store = store; + private readonly EntityStore _store; + + /// + /// Constructor + /// + + public EFCoreWorkflowExecutionLogStore(EntityStore store) => _store = store; + + /// public async Task SaveAsync(WorkflowExecutionLogRecord record, CancellationToken cancellationToken = default) => await _store.SaveAsync(record, cancellationToken); + + /// public async Task SaveManyAsync(IEnumerable records, CancellationToken cancellationToken = default) => await _store.SaveManyAsync(records, cancellationToken); + /// public async Task> FindManyByWorkflowInstanceIdAsync(string workflowInstanceId, PageArgs? pageArgs = default, CancellationToken cancellationToken = default) { var records = await _store.FindManyAsync( diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/WorkflowStateStore.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/WorkflowStateStore.cs index f8bd26e62..7c0347293 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/WorkflowStateStore.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/WorkflowStateStore.cs @@ -17,13 +17,13 @@ public class EFCoreWorkflowStateStore : IWorkflowStateStore private readonly SerializerOptionsProvider _serializerOptionsProvider; private readonly ISystemClock _systemClock; private readonly IDbContextFactory _dbContextFactory; - private readonly Store _store; + private readonly EntityStore _store; /// /// Constructor. /// public EFCoreWorkflowStateStore( - Store store, + EntityStore store, IDbContextFactory dbContextFactory, SerializerOptionsProvider serializerOptionsProvider, ISystemClock systemClock) diff --git a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Post/Endpoint.cs b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Post/Endpoint.cs index 51614b92d..1296e2295 100644 --- a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Post/Endpoint.cs +++ b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Post/Endpoint.cs @@ -9,6 +9,7 @@ using Elsa.Workflows.Management.Materializers; using Elsa.Workflows.Management.Models; using Elsa.Workflows.Management.Services; using JetBrains.Annotations; +using Medallion.Threading; namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Post; @@ -18,15 +19,18 @@ internal class Post : ElsaEndpoint