public async Task <WorkflowInstanceEntity> Add(WorkflowInstanceEntity entity)
 {
     entity.Id = Guid.NewGuid();
     foreach (var item in entity.Activities)
     {
         item.WorkflowInstance = entity.Id;
     }
     foreach (var item in entity.BlockingActivities)
     {
         item.WorkflowInstance = entity.Id;
     }
     using var uow = _elsaDbContext.NewUnitOfWork();
     if (!await _repository.AddAsync(entity, uow))
     {
         throw new Exception("Ìí¼Óʧ°Ü");
     }
     if (entity.Activities.Any())
     {
         if (!await _activityInstanceRepository.BatchInsertAsync(entity.Activities.ToList(), uow))
         {
             throw new Exception("Ìí¼Óʧ°Ü");
         }
     }
     if (entity.BlockingActivities.Any())
     {
         if (!await _blockingActivityRepository.BatchInsertAsync(entity.BlockingActivities.ToList(), uow))
         {
             throw new Exception("Ìí¼Óʧ°Ü");
         }
     }
     uow.Commit();
     return(entity);
 }
Пример #2
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);
 }