예제 #1
0
        public async Task <FlowResult <FlowInstance> > DoAsync(InitFlowModel model)
        {
            var taskResult = await InstanceService.CreateFlowInstanceAsync(model);

            var transitionSet   = _stateManager.GetFlowSet <FlowTransition>();
            var startTransition = await transitionSet
                                  .FirstOrDefaultAsync(x => x.TypeId.Equals(taskResult.Result.TypeId) &&
                                                       x.TransitionType == FlowTransitionTypes.Start);

            if (startTransition == null)
            {
                return(FlowResult <FlowInstance>
                       .Failed(new FlowError(FlowErrors.ItemNotFound, "Start transition")));
            }

            var stepResult = await StepService.CreateFlowStepAsync(new MoveModel()
            {
                Comment      = null,
                IdentityId   = model.InitializerId,
                InstanceId   = taskResult.Result.Id,
                Payload      = null,
                TransitionId = startTransition.Id
            });

            return(taskResult.Merge(stepResult));
        }