10 changed files with 378 additions and 1 deletions
@ -0,0 +1,50 @@ |
|||
using AutoMapper; |
|||
using Elsa.Models; |
|||
using Elsa.Persistence.EntityFramework.Core.Services; |
|||
using Elsa.Persistence.EntityFramework.Core.Stores; |
|||
using Elsa.Persistence.Specifications; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.Logging; |
|||
using System.Linq; |
|||
using System.Linq.Dynamic.Core; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace LINGYUN.Abp.Elsa.EntityFrameworkCore.Stores; |
|||
public class FixedEntityFrameworkBookmarkStore : EntityFrameworkBookmarkStore |
|||
{ |
|||
public FixedEntityFrameworkBookmarkStore( |
|||
IElsaContextFactory dbContextFactory, |
|||
IMapper mapper, |
|||
ILogger<EntityFrameworkBookmarkStore> logger) |
|||
: base(dbContextFactory, mapper, logger) |
|||
{ |
|||
} |
|||
|
|||
public async override Task<int> DeleteManyAsync(ISpecification<Bookmark> specification, CancellationToken cancellationToken = default) |
|||
{ |
|||
var filter = MapSpecification(specification); |
|||
return await DoWork(async dbContext => |
|||
{ |
|||
#if NET7_0_OR_GREATER
|
|||
return await dbContext.Set<Bookmark>().Where(filter).ExecuteDeleteAsync(cancellationToken).ConfigureAwait(false); |
|||
#else
|
|||
var tuple = dbContext.Set<Bookmark>().Where(filter).Select(x => x.Id).ToParametrizedSql(); |
|||
var entityLetter = dbContext.Set<Bookmark>().EntityType.GetTableName()!.ToLowerInvariant()[0]; |
|||
var helper = dbContext.GetService<ISqlGenerationHelper>(); |
|||
var whereClause = tuple.Item1 |
|||
.Substring(tuple.Item1.IndexOf("WHERE", StringComparison.OrdinalIgnoreCase)) |
|||
.Replace($"{helper.DelimitIdentifier(entityLetter.ToString())}.", string.Empty); |
|||
|
|||
for (var i = 0; i < tuple.Item2.Count(); i++) |
|||
{ |
|||
var sqlParameter = tuple.Item2.ElementAt(i); |
|||
whereClause = whereClause.Replace(sqlParameter.ParameterName, "{" +$"{i}" + "}"); |
|||
} |
|||
|
|||
var parameters = tuple.Item2.Select(x => x.Value).ToArray(); |
|||
return await dbContext.Database.ExecuteSqlRawAsync($"DELETE FROM {dbContext.Set<Bookmark>().EntityType.GetSchemaQualifiedTableNameWithQuotes(helper)} {whereClause}", parameters, cancellationToken); |
|||
#endif
|
|||
}, cancellationToken); |
|||
} |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
using AutoMapper; |
|||
using Elsa.Models; |
|||
using Elsa.Persistence.EntityFramework.Core.Services; |
|||
using Elsa.Persistence.EntityFramework.Core.Stores; |
|||
using Elsa.Persistence.Specifications; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.Logging; |
|||
using System.Linq; |
|||
using System.Linq.Dynamic.Core; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace LINGYUN.Abp.Elsa.EntityFrameworkCore.Stores; |
|||
public class FixedEntityFrameworkTriggerStore : EntityFrameworkTriggerStore |
|||
{ |
|||
public FixedEntityFrameworkTriggerStore( |
|||
IElsaContextFactory dbContextFactory, |
|||
IMapper mapper, |
|||
ILogger<EntityFrameworkTriggerStore> logger) |
|||
: base(dbContextFactory, mapper, logger) |
|||
{ |
|||
} |
|||
|
|||
public async override Task<int> DeleteManyAsync(ISpecification<Trigger> specification, CancellationToken cancellationToken = default) |
|||
{ |
|||
var filter = MapSpecification(specification); |
|||
return await DoWork(async dbContext => |
|||
{ |
|||
#if NET7_0_OR_GREATER
|
|||
return await dbContext.Set<Trigger>().Where(filter).ExecuteDeleteAsync(cancellationToken).ConfigureAwait(false); |
|||
#else
|
|||
var tuple = dbContext.Set<Trigger>().Where(filter).Select(x => x.Id).ToParametrizedSql(); |
|||
var entityLetter = dbContext.Set<Trigger>().EntityType.GetTableName()!.ToLowerInvariant()[0]; |
|||
var helper = dbContext.GetService<ISqlGenerationHelper>(); |
|||
var whereClause = tuple.Item1 |
|||
.Substring(tuple.Item1.IndexOf("WHERE", StringComparison.OrdinalIgnoreCase)) |
|||
.Replace($"{helper.DelimitIdentifier(entityLetter.ToString())}.", string.Empty); |
|||
|
|||
for (var i = 0; i < tuple.Item2.Count(); i++) |
|||
{ |
|||
var sqlParameter = tuple.Item2.ElementAt(i); |
|||
whereClause = whereClause.Replace(sqlParameter.ParameterName, "{" +$"{i}" + "}"); |
|||
} |
|||
|
|||
var parameters = tuple.Item2.Select(x => x.Value).ToArray(); |
|||
return await dbContext.Database.ExecuteSqlRawAsync($"DELETE FROM {dbContext.Set<Trigger>().EntityType.GetSchemaQualifiedTableNameWithQuotes(helper)} {whereClause}", parameters, cancellationToken); |
|||
#endif
|
|||
}, cancellationToken); |
|||
} |
|||
} |
|||
@ -0,0 +1,52 @@ |
|||
using AutoMapper; |
|||
using Elsa.Persistence.Specifications; |
|||
using Elsa.Serialization; |
|||
using Elsa.Webhooks.Models; |
|||
using Elsa.Webhooks.Persistence.EntityFramework.Core.Services; |
|||
using Elsa.Webhooks.Persistence.EntityFramework.Core.Stores; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.Logging; |
|||
using System.Linq; |
|||
using System.Linq.Dynamic.Core; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace LINGYUN.Abp.Elsa.EntityFrameworkCore.Stores; |
|||
public class FixedEntityFrameworkWebhookDefinitionStore : EntityFrameworkWebhookDefinitionStore |
|||
{ |
|||
public FixedEntityFrameworkWebhookDefinitionStore( |
|||
IWebhookContextFactory dbContextFactory, |
|||
IMapper mapper, |
|||
IContentSerializer contentSerializer, |
|||
ILogger<FixedEntityFrameworkWebhookDefinitionStore> logger) |
|||
: base(dbContextFactory, mapper, contentSerializer, logger) |
|||
{ |
|||
} |
|||
|
|||
public async override Task<int> DeleteManyAsync(ISpecification<WebhookDefinition> specification, CancellationToken cancellationToken = default) |
|||
{ |
|||
var filter = MapSpecification(specification); |
|||
return await DoWork(async dbContext => |
|||
{ |
|||
#if NET7_0_OR_GREATER
|
|||
return await dbContext.Set<WebhookDefinition>().Where(filter).ExecuteDeleteAsync(cancellationToken).ConfigureAwait(false); |
|||
#else
|
|||
var tuple = dbContext.Set<WebhookDefinition>().Where(filter).Select(x => x.Id).ToParametrizedSql(); |
|||
var entityLetter = dbContext.Set<WebhookDefinition>().EntityType.GetTableName()!.ToLowerInvariant()[0]; |
|||
var helper = dbContext.GetService<ISqlGenerationHelper>(); |
|||
var whereClause = tuple.Item1 |
|||
.Substring(tuple.Item1.IndexOf("WHERE", StringComparison.OrdinalIgnoreCase)) |
|||
.Replace($"{helper.DelimitIdentifier(entityLetter.ToString())}.", string.Empty); |
|||
|
|||
for (var i = 0; i < tuple.Item2.Count(); i++) |
|||
{ |
|||
var sqlParameter = tuple.Item2.ElementAt(i); |
|||
whereClause = whereClause.Replace(sqlParameter.ParameterName, "{" +$"{i}" + "}"); |
|||
} |
|||
|
|||
var parameters = tuple.Item2.Select(x => x.Value).ToArray(); |
|||
return await dbContext.Database.ExecuteSqlRawAsync($"DELETE FROM {dbContext.Set<WebhookDefinition>().EntityType.GetSchemaQualifiedTableNameWithQuotes(helper)} {whereClause}", parameters, cancellationToken); |
|||
#endif
|
|||
}, cancellationToken); |
|||
} |
|||
} |
|||
@ -0,0 +1,52 @@ |
|||
using AutoMapper; |
|||
using Elsa.Models; |
|||
using Elsa.Persistence.EntityFramework.Core.Services; |
|||
using Elsa.Persistence.EntityFramework.Core.Stores; |
|||
using Elsa.Persistence.Specifications; |
|||
using Elsa.Serialization; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.Logging; |
|||
using System.Linq; |
|||
using System.Linq.Dynamic.Core; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace LINGYUN.Abp.Elsa.EntityFrameworkCore.Stores; |
|||
public class FixedEntityFrameworkWorkflowDefinitionStore : EntityFrameworkWorkflowDefinitionStore |
|||
{ |
|||
public FixedEntityFrameworkWorkflowDefinitionStore( |
|||
IElsaContextFactory dbContextFactory, |
|||
IMapper mapper, |
|||
IContentSerializer contentSerializer, |
|||
ILogger<EntityFrameworkWorkflowDefinitionStore> logger) |
|||
: base(dbContextFactory, mapper, contentSerializer, logger) |
|||
{ |
|||
} |
|||
|
|||
public async override Task<int> DeleteManyAsync(ISpecification<WorkflowDefinition> specification, CancellationToken cancellationToken = default) |
|||
{ |
|||
var filter = MapSpecification(specification); |
|||
return await DoWork(async dbContext => |
|||
{ |
|||
#if NET7_0_OR_GREATER
|
|||
return await dbContext.Set<WorkflowDefinition>().Where(filter).ExecuteDeleteAsync(cancellationToken).ConfigureAwait(false); |
|||
#else
|
|||
var tuple = dbContext.Set<WorkflowDefinition>().Where(filter).Select(x => x.Id).ToParametrizedSql(); |
|||
var entityLetter = dbContext.Set<WorkflowDefinition>().EntityType.GetTableName()!.ToLowerInvariant()[0]; |
|||
var helper = dbContext.GetService<ISqlGenerationHelper>(); |
|||
var whereClause = tuple.Item1 |
|||
.Substring(tuple.Item1.IndexOf("WHERE", StringComparison.OrdinalIgnoreCase)) |
|||
.Replace($"{helper.DelimitIdentifier(entityLetter.ToString())}.", string.Empty); |
|||
|
|||
for (var i = 0; i < tuple.Item2.Count(); i++) |
|||
{ |
|||
var sqlParameter = tuple.Item2.ElementAt(i); |
|||
whereClause = whereClause.Replace(sqlParameter.ParameterName, "{" +$"{i}" + "}"); |
|||
} |
|||
|
|||
var parameters = tuple.Item2.Select(x => x.Value).ToArray(); |
|||
return await dbContext.Database.ExecuteSqlRawAsync($"DELETE FROM {dbContext.Set<WorkflowDefinition>().EntityType.GetSchemaQualifiedTableNameWithQuotes(helper)} {whereClause}", parameters, cancellationToken); |
|||
#endif
|
|||
}, cancellationToken); |
|||
} |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
using AutoMapper; |
|||
using Elsa.Models; |
|||
using Elsa.Persistence.EntityFramework.Core.Services; |
|||
using Elsa.Persistence.EntityFramework.Core.Stores; |
|||
using Elsa.Persistence.Specifications; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.Logging; |
|||
using System.Linq; |
|||
using System.Linq.Dynamic.Core; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace LINGYUN.Abp.Elsa.EntityFrameworkCore.Stores; |
|||
public class FixedEntityFrameworkWorkflowExecutionLogRecordStore : EntityFrameworkWorkflowExecutionLogRecordStore |
|||
{ |
|||
public FixedEntityFrameworkWorkflowExecutionLogRecordStore( |
|||
IElsaContextFactory dbContextFactory, |
|||
IMapper mapper, |
|||
ILogger<EntityFrameworkWorkflowExecutionLogRecordStore> logger) |
|||
: base(dbContextFactory, mapper, logger) |
|||
{ |
|||
} |
|||
|
|||
public async override Task<int> DeleteManyAsync(ISpecification<WorkflowExecutionLogRecord> specification, CancellationToken cancellationToken = default) |
|||
{ |
|||
var filter = MapSpecification(specification); |
|||
return await DoWork(async dbContext => |
|||
{ |
|||
#if NET7_0_OR_GREATER
|
|||
return await dbContext.Set<WorkflowExecutionLogRecord>().Where(filter).ExecuteDeleteAsync(cancellationToken).ConfigureAwait(false); |
|||
#else
|
|||
var tuple = dbContext.Set<WorkflowExecutionLogRecord>().Where(filter).Select(x => x.Id).ToParametrizedSql(); |
|||
var entityLetter = dbContext.Set<WorkflowExecutionLogRecord>().EntityType.GetTableName()!.ToLowerInvariant()[0]; |
|||
var helper = dbContext.GetService<ISqlGenerationHelper>(); |
|||
var whereClause = tuple.Item1 |
|||
.Substring(tuple.Item1.IndexOf("WHERE", StringComparison.OrdinalIgnoreCase)) |
|||
.Replace($"{helper.DelimitIdentifier(entityLetter.ToString())}.", string.Empty); |
|||
|
|||
for (var i = 0; i < tuple.Item2.Count(); i++) |
|||
{ |
|||
var sqlParameter = tuple.Item2.ElementAt(i); |
|||
whereClause = whereClause.Replace(sqlParameter.ParameterName, "{" +$"{i}" + "}"); |
|||
} |
|||
|
|||
var parameters = tuple.Item2.Select(x => x.Value).ToArray(); |
|||
return await dbContext.Database.ExecuteSqlRawAsync($"DELETE FROM {dbContext.Set<WorkflowExecutionLogRecord>().EntityType.GetSchemaQualifiedTableNameWithQuotes(helper)} {whereClause}", parameters, cancellationToken); |
|||
#endif
|
|||
}, cancellationToken); |
|||
} |
|||
} |
|||
@ -0,0 +1,52 @@ |
|||
using AutoMapper; |
|||
using Elsa.Models; |
|||
using Elsa.Persistence.EntityFramework.Core.Services; |
|||
using Elsa.Persistence.EntityFramework.Core.Stores; |
|||
using Elsa.Persistence.Specifications; |
|||
using Elsa.Serialization; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.Logging; |
|||
using System.Linq; |
|||
using System.Linq.Dynamic.Core; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace LINGYUN.Abp.Elsa.EntityFrameworkCore.Stores; |
|||
public class FixedEntityFrameworkWorkflowInstanceStore : EntityFrameworkWorkflowInstanceStore |
|||
{ |
|||
public FixedEntityFrameworkWorkflowInstanceStore( |
|||
IElsaContextFactory dbContextFactory, |
|||
IMapper mapper, |
|||
IContentSerializer contentSerializer, |
|||
ILogger<EntityFrameworkWorkflowInstanceStore> logger) |
|||
: base(dbContextFactory, mapper, contentSerializer, logger) |
|||
{ |
|||
} |
|||
|
|||
public async override Task<int> DeleteManyAsync(ISpecification<WorkflowInstance> specification, CancellationToken cancellationToken = default) |
|||
{ |
|||
var filter = MapSpecification(specification); |
|||
return await DoWork(async dbContext => |
|||
{ |
|||
#if NET7_0_OR_GREATER
|
|||
return await dbContext.Set<WorkflowInstance>().Where(filter).ExecuteDeleteAsync(cancellationToken).ConfigureAwait(false); |
|||
#else
|
|||
var tuple = dbContext.Set<WorkflowInstance>().Where(filter).Select(x => x.Id).ToParametrizedSql(); |
|||
var entityLetter = dbContext.Set<WorkflowInstance>().EntityType.GetTableName()!.ToLowerInvariant()[0]; |
|||
var helper = dbContext.GetService<ISqlGenerationHelper>(); |
|||
var whereClause = tuple.Item1 |
|||
.Substring(tuple.Item1.IndexOf("WHERE", StringComparison.OrdinalIgnoreCase)) |
|||
.Replace($"{helper.DelimitIdentifier(entityLetter.ToString())}.", string.Empty); |
|||
|
|||
for (var i = 0; i < tuple.Item2.Count(); i++) |
|||
{ |
|||
var sqlParameter = tuple.Item2.ElementAt(i); |
|||
whereClause = whereClause.Replace(sqlParameter.ParameterName, "{" +$"{i}" + "}"); |
|||
} |
|||
|
|||
var parameters = tuple.Item2.Select(x => x.Value).ToArray(); |
|||
return await dbContext.Database.ExecuteSqlRawAsync($"DELETE FROM {dbContext.Set<WorkflowInstance>().EntityType.GetSchemaQualifiedTableNameWithQuotes(helper)} {whereClause}", parameters, cancellationToken); |
|||
#endif
|
|||
}, cancellationToken); |
|||
} |
|||
} |
|||
@ -0,0 +1,52 @@ |
|||
using AutoMapper; |
|||
using Elsa.Persistence.Specifications; |
|||
using Elsa.Serialization; |
|||
using Elsa.WorkflowSettings.Models; |
|||
using Elsa.WorkflowSettings.Persistence.EntityFramework.Core.Services; |
|||
using Elsa.WorkflowSettings.Persistence.EntityFramework.Core.Stores; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.Logging; |
|||
using System.Linq; |
|||
using System.Linq.Dynamic.Core; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace LINGYUN.Abp.Elsa.EntityFrameworkCore.Stores; |
|||
public class FixedEntityFrameworkWorkflowSettingsStore : EntityFrameworkWorkflowSettingsStore |
|||
{ |
|||
public FixedEntityFrameworkWorkflowSettingsStore( |
|||
IWorkflowSettingsContextFactory dbContextFactory, |
|||
IMapper mapper, |
|||
IContentSerializer contentSerializer, |
|||
ILogger<FixedEntityFrameworkWorkflowSettingsStore> logger) |
|||
: base(dbContextFactory, mapper, contentSerializer, logger) |
|||
{ |
|||
} |
|||
|
|||
public async override Task<int> DeleteManyAsync(ISpecification<WorkflowSetting> specification, CancellationToken cancellationToken = default) |
|||
{ |
|||
var filter = MapSpecification(specification); |
|||
return await DoWork(async dbContext => |
|||
{ |
|||
#if NET7_0_OR_GREATER
|
|||
return await dbContext.Set<WorkflowSetting>().Where(filter).ExecuteDeleteAsync(cancellationToken).ConfigureAwait(false); |
|||
#else
|
|||
var tuple = dbContext.Set<WorkflowSetting>().Where(filter).Select(x => x.Id).ToParametrizedSql(); |
|||
var entityLetter = dbContext.Set<WorkflowSetting>().EntityType.GetTableName()!.ToLowerInvariant()[0]; |
|||
var helper = dbContext.GetService<ISqlGenerationHelper>(); |
|||
var whereClause = tuple.Item1 |
|||
.Substring(tuple.Item1.IndexOf("WHERE", StringComparison.OrdinalIgnoreCase)) |
|||
.Replace($"{helper.DelimitIdentifier(entityLetter.ToString())}.", string.Empty); |
|||
|
|||
for (var i = 0; i < tuple.Item2.Count(); i++) |
|||
{ |
|||
var sqlParameter = tuple.Item2.ElementAt(i); |
|||
whereClause = whereClause.Replace(sqlParameter.ParameterName, "{" +$"{i}" + "}"); |
|||
} |
|||
|
|||
var parameters = tuple.Item2.Select(x => x.Value).ToArray(); |
|||
return await dbContext.Database.ExecuteSqlRawAsync($"DELETE FROM {dbContext.Set<WorkflowSetting>().EntityType.GetSchemaQualifiedTableNameWithQuotes(helper)} {whereClause}", parameters, cancellationToken); |
|||
#endif
|
|||
}, cancellationToken); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue