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); }
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); }
private WorkflowDefinitionVersion Map(WorkflowDefinitionVersionEntity source) => mapper.Map <WorkflowDefinitionVersion>(source);
private void DeleteConnections(WorkflowDefinitionVersionEntity entity) { dbContext.ConnectionDefinitions.RemoveRange(entity.Connections); entity.Connections.Clear(); }
private void DeleteActivities(WorkflowDefinitionVersionEntity entity) { dbContext.ActivityDefinitions.RemoveRange(entity.Activities); entity.Activities.Clear(); }