コード例 #1
0
 public async Task <WorkflowDefinitionVersionEntity> Add(WorkflowDefinitionVersionEntity entity)
 {
     entity.Id = Guid.NewGuid();
     foreach (var item in entity.Activities)
     {
         item.WorkflowDefinitionVersion = entity.Id;
     }
     foreach (var item in entity.Connections)
     {
         item.WorkflowDefinitionVersion = entity.Id;
     }
     using var uow = _elsaDbContext.NewUnitOfWork();
     if (!await _repository.AddAsync(entity, uow))
     {
         throw new Exception("Ìí¼Óʧ°Ü");
     }
     if (!await _activityDefinitionRepository.BatchInsertAsync(entity.Activities.ToList(), uow))
     {
         throw new Exception("Ìí¼Óʧ°Ü");
     }
     if (!await _connectionDefinitionRepository.BatchInsertAsync(entity.Connections.ToList(), uow))
     {
         throw new Exception("Ìí¼Óʧ°Ü");
     }
     uow.Commit();
     return(entity);
 }
コード例 #2
0
        public async Task <WorkflowDefinitionVersionEntity> Update(WorkflowDefinitionVersionEntity definition)
        {
            var entity = await GetByVersionId(definition.VersionId);

            var id = entity.Id;

            using var uow = _elsaDbContext.NewUnitOfWork();
            if (!await _activityDefinitionRepository.BatchDeleteByWorkflowDefinitionVersionAsync(id, uow))
            {
                throw new Exception("¸üÐÂʧ°Ü");
            }
            if (!await _connectionDefinitionRepository.BatchDeleteByWorkflowDefinitionVersionAsync(id, uow))
            {
                throw new Exception("¸üÐÂʧ°Ü");
            }
            entity    = _mapper.Map(definition, entity);
            entity.Id = id;
            foreach (var item in entity.Activities)
            {
                item.WorkflowDefinitionVersion = id;
            }
            foreach (var item in entity.Connections)
            {
                item.WorkflowDefinitionVersion = id;
            }
            if (!await _repository.UpdateAsync(entity, uow))
            {
                throw new Exception("¸üÐÂʧ°Ü");
            }
            if (!await _activityDefinitionRepository.BatchInsertAsync(entity.Activities.ToList(), uow))
            {
                throw new Exception("¸üÐÂʧ°Ü");
            }
            if (!await _connectionDefinitionRepository.BatchInsertAsync(entity.Connections.ToList(), uow))
            {
                throw new Exception("¸üÐÂʧ°Ü");
            }
            uow.Commit();
            return(entity);
        }
コード例 #3
0
 private WorkflowDefinitionVersion Map(WorkflowDefinitionVersionEntity source) => mapper.Map <WorkflowDefinitionVersion>(source);
コード例 #4
0
 private void DeleteConnections(WorkflowDefinitionVersionEntity entity)
 {
     dbContext.ConnectionDefinitions.RemoveRange(entity.Connections);
     entity.Connections.Clear();
 }
コード例 #5
0
 private void DeleteActivities(WorkflowDefinitionVersionEntity entity)
 {
     dbContext.ActivityDefinitions.RemoveRange(entity.Activities);
     entity.Activities.Clear();
 }