public async Task CreateByDefinitionIdAsync(string id) { var workDefinitionEntity = await _workflowDefinitionVersionRepository.GetAsync(id); var workDefinition = ObjectMapper.Map <WorkflowDefinitionVersion, ElsaWorkflowDefinitionVersion>(workDefinitionEntity); await _workflowInvoker.StartAsync(workDefinition); }
public async Task UpdateAsync(string id, WorkflowDefinitionUpdateDto input) { var workflowDefinition = await _workflowDefinitionVersionRepository.GetAsync(id); if (workflowDefinition == null) { throw new UserFriendlyException("未找到工作流定义!"); } workflowDefinition.Activities = input.Activities .Select(x => new ActivityDefinition(x.Id, x.Type, x.State, x.Left, x.Top)) .ToList(); workflowDefinition.Connections = input.Connections.Select( x => new ConnectionDefinition(GuidGenerator.Create().ToString(), x.SourceActivityId, x.DestinationActivityId, x.Outcome)).ToList(); workflowDefinition.Description = input.Description; workflowDefinition.Name = input.Name; workflowDefinition.IsDisabled = input.IsDisabled; workflowDefinition.IsSingleton = input.IsSingleton; await _workflowDefinitionVersionRepository.UpdateAsync(workflowDefinition); }