public EntityFrameworkCoreWorkflowInstanceStore( ElsaContext dbContext, IMapper mapper) { this.dbContext = dbContext; this.mapper = mapper; }
protected override void OnLoading(ElsaContext dbContext, WorkflowInstance entity) { var data = new { entity.Input, entity.Output, entity.Variables, entity.ActivityData, entity.Metadata, entity.BlockingActivities, entity.ScheduledActivities, entity.Scopes, entity.Fault, entity.CurrentActivity }; var json = (string)dbContext.Entry(entity).Property("Data").CurrentValue; if (!string.IsNullOrWhiteSpace(json)) { data = JsonConvert.DeserializeAnonymousType(json, data, DefaultContentSerializer.CreateDefaultJsonSerializationSettings()) !; } entity.Input = data.Input; entity.Output = data.Output; entity.Variables = data.Variables; entity.ActivityData = data.ActivityData; entity.Metadata = data.Metadata; entity.BlockingActivities = data.BlockingActivities; entity.ScheduledActivities = data.ScheduledActivities; entity.Scopes = data.Scopes; entity.Fault = data.Fault; entity.CurrentActivity = data.CurrentActivity; }
protected override void OnSaving(ElsaContext dbContext, WorkflowDefinition entity) { var data = new { entity.Activities, entity.Connections, entity.Variables, entity.ContextOptions, entity.CustomAttributes }; var json = _contentSerializer.Serialize(data); dbContext.Entry(entity).Property("Data").CurrentValue = json; }
public AWFDefinitionService( ElsaContext elsaDBContext, IWorkflowDefinitionStore workflowDefinitionStore, IWorkflowInstanceStore workflowInstanceStore, IWorkflowPublisher publisher, IWorkflowSerializer serializer, AutoMapper.IMapper mapper, IOptions <ElsaDashboardOptions> options) { _elsaDBContext = (ElsaDBContext)elsaDBContext; _workflowDefinitionStore = workflowDefinitionStore; _workflowInstanceStore = workflowInstanceStore; _publisher = publisher; _serializer = serializer; _mapper = mapper; _options = options; }
protected override void OnSaving(ElsaContext dbContext, WorkflowInstance entity) { var data = new { entity.Output, entity.Variables, entity.ActivityData, entity.BlockingActivities, entity.ScheduledActivities, entity.Scopes, entity.Fault, entity.CurrentActivity }; var json = _contentSerializer.Serialize(data); dbContext.Entry(entity).Property("Data").CurrentValue = json; }
protected override void OnLoading(ElsaContext dbContext, WorkflowDefinition entity) { var data = new { entity.Activities, entity.Connections, entity.Variables, entity.ContextOptions, entity.CustomAttributes }; var json = (string)dbContext.Entry(entity).Property("Data").CurrentValue; data = JsonConvert.DeserializeAnonymousType(json, data, DefaultContentSerializer.CreateDefaultJsonSerializationSettings()); entity.Activities = data.Activities; entity.Connections = data.Connections; entity.Variables = data.Variables; entity.ContextOptions = data.ContextOptions; entity.CustomAttributes = data.CustomAttributes; }
public void DbContextShouldNotBeCreatedFromPoolWhenSetUpWithoutPooling( ServiceCollection serviceCollection, [StubElsaContext] ElsaContext pooledContext, IDbContextPool <ElsaContext> pool) { serviceCollection .AddElsa(elsa => { elsa .UseNonPooledEntityFrameworkPersistence((services, opts) => { opts.UseSqlite("Data Source=:memory:;Mode=Memory;"); }, ServiceLifetime.Transient); }) .AddSingleton(pool); Mock.Get(pool).Setup(x => x.Rent()).Returns(pooledContext); var serviceProvider = serviceCollection.BuildServiceProvider(); var contextFactory = serviceProvider.GetRequiredService <IDbContextFactory <ElsaContext> >(); using var context = contextFactory.CreateDbContext(); Assert.NotSame(pooledContext, context); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ElsaContext elsaDbcontext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); elsaDbcontext.Database.EnsureCreated(); } else { app.UseExceptionHandler("/Error"); } app.UseStaticFiles(); app.UseHttpActivities(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapBlazorHub(); endpoints.MapFallbackToPage("/_Host"); endpoints.MapControllers(); }); }
public EntityFrameworkCoreWorkflowDefinitionStore(ElsaContext dbContext, IMapper mapper) { this.dbContext = dbContext; this.mapper = mapper; }
public static async Task <int> BatchDeleteWithWorkAroundAsync <T>(this IQueryable <T> queryable, ElsaContext elsaContext, CancellationToken cancellationToken = default) where T : class { if (elsaContext.Database.IsPostgres()) { // Need this workaround until https://github.com/borisdj/EFCore.BulkExtensions/issues/67 is solved. var records = await queryable.ToListAsync(cancellationToken); foreach (var @record in records) { elsaContext.Remove(@record); } return(records.Count); } return(await queryable.BatchDeleteAsync(cancellationToken)); }