private async Task <bool> Execute(BPMNExecutionContext context, CancellationToken token) { var pointer = context.Pointer; var nodeDef = context.Instance.GetDefinition(pointer.FlowNodeId); var res = await _processorFactory.Execute(context, nodeDef, token); var result = res as BPMNExecutionResult; var isRestarted = result.IsRestarted; if (result.IsNext) { var ids = context.Instance.CompleteExecutionPointer(pointer, result.NextFlowNodeIds, result.Tokens.ToList()); if (result.IsEltInstanceCompleted) { context.Instance.CompleteFlowNodeInstance(pointer.InstanceFlowNodeId); } if (result.IsNewExecutionPointerRequired) { context.Instance.LaunchNewExecutionPointer(pointer); } foreach (var id in ids) { var executionPointer = context.Instance.GetExecutionPointer(pointer.ExecutionPathId, id); var newExecutionContext = context.New(executionPointer); var secondResult = await Execute(newExecutionContext, token); isRestarted = isRestarted || secondResult; } } return(isRestarted); }
private async Task Execute(BPMNExecutionContext context, CancellationToken token) { var pointer = context.Pointer; var nodeDef = context.Instance.GetDefinition(pointer.FlowNodeId); var result = (await _processorFactory.Execute(context, nodeDef, token)) as BPMNExecutionResult; if (result.IsNext) { var ids = context.Instance.CompleteExecutionPointer(pointer, result.NextFlowNodeIds, result.Tokens); if (result.IsEltInstanceCompleted) { context.Instance.CompleteFlowNodeInstance(pointer.InstanceFlowNodeId); } if (result.IsNewExecutionPointerRequired) { context.Instance.LaunchNewExecutionPointer(pointer); } foreach (var id in ids) { var executionPointer = context.Instance.GetExecutionPointer(pointer.ExecutionPathId, id); var newExecutionContext = context.New(executionPointer); await Execute(newExecutionContext, token); } } }