コード例 #1
0
        public async Task <WorkflowInstance> SaveAsync(
            WorkflowInstance instance,
            CancellationToken cancellationToken = default)
        {
            var existingEntity = await dbContext
                                 .WorkflowInstances
                                 .Include(x => x.Activities)
                                 .Include(x => x.BlockingActivities)
                                 .FirstOrDefaultAsync(x => x.InstanceId == instance.Id, cancellationToken: cancellationToken);

            if (existingEntity == null)
            {
                var entity = Map(instance);

                await dbContext.WorkflowInstances.AddAsync(entity, cancellationToken);

                await dbContext.SaveChangesAsync(cancellationToken);

                return(Map(entity));
            }
            else
            {
                dbContext.ActivityInstances.RemoveRange(existingEntity.Activities);
                dbContext.BlockingActivities.RemoveRange(existingEntity.BlockingActivities);
                existingEntity.Activities.Clear();
                existingEntity.BlockingActivities.Clear();

                var entity = mapper.Map(instance, existingEntity);

                dbContext.WorkflowInstances.Update(entity);
                await dbContext.SaveChangesAsync(cancellationToken);

                return(Map(entity));
            }
        }
コード例 #2
0
        public async Task <WorkflowDefinitionVersion> AddAsync(WorkflowDefinitionVersion definition, CancellationToken cancellationToken = default)
        {
            var entity = Map(definition);
            await dbContext.WorkflowDefinitionVersions.AddAsync(entity, cancellationToken);

            await dbContext.SaveChangesAsync(cancellationToken);

            return(Map(entity));
        }
コード例 #3
0
        public async Task SaveAsync(
            WorkflowInstance instance,
            CancellationToken cancellationToken = default)
        {
            var document = Map(instance);

            await dbContext.WorkflowInstances.Upsert(document)
            .On(x => new { x.Id })
            .RunAsync(cancellationToken);

            await dbContext.SaveChangesAsync(cancellationToken);
        }
コード例 #4
0
        public async Task <WorkflowDefinitionVersion> SaveAsync(
            WorkflowDefinitionVersion definition,
            CancellationToken cancellationToken = default)
        {
            var document = Map(definition);

            await dbContext.WorkflowDefinitionVersions.Upsert(document)
            .On(x => new { x.Id })
            .RunAsync(cancellationToken);

            await dbContext.SaveChangesAsync(cancellationToken);

            return(definition);
        }