protected virtual ICollection <string> GetNextFlowNodeIds(BPMNExecutionContext executionContext, BaseFlowNode flowNode)
        {
            var outgoing         = executionContext.Instance.GetOutgoingSequenceFlows(flowNode.Id);
            var filteredOutgoing = outgoing.Where(_ => executionContext.Instance.IsIncomingSatisfied(_, executionContext.Pointer.Incoming));

            return(filteredOutgoing.Select(_ => _.TargetRef).ToList());
        }
Esempio n. 2
0
        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);
                }
            }
        }
 public async Task Execute(ProcessInstanceAggregate processInstance, CancellationToken token)
 {
     foreach (var executionPath in processInstance.ExecutionPathLst)
     {
         var activePointers = executionPath.Pointers.Where(_ => _.IsActive).ToList();
         foreach (var activePointer in activePointers)
         {
             var executionContext = new BPMNExecutionContext
             {
                 Instance = processInstance,
                 Path     = executionPath,
                 Pointer  = activePointer
             };
             await Execute(executionContext, token);
         }
     }
 }
Esempio n. 5
0
        public async Task <bool> Execute(ProcessInstanceAggregate processInstance, CancellationToken token)
        {
            var isRestarted = false;

            foreach (var executionPath in processInstance.ExecutionPathLst)
            {
                var activePointers = executionPath.Pointers.Where(_ => _.IsActive).ToList();
                foreach (var activePointer in activePointers)
                {
                    var executionContext = new BPMNExecutionContext
                    {
                        Instance = processInstance,
                        Path     = executionPath,
                        Pointer  = activePointer
                    };
                    var secondResult = await Execute(executionContext, token);

                    isRestarted = secondResult || isRestarted;
                }
            }

            return(isRestarted);
        }
 protected virtual ICollection <string> GetIncomingFlowNodeIds(BPMNExecutionContext executionContext, BaseFlowNode flowNode)
 {
     return(executionContext.Instance.GetIncomingSequenceFlows(flowNode.Id).Select(_ => _.SourceRef).ToList());
 }
 protected abstract Task <BPMNExecutionResult> Handle(BPMNExecutionContext executionContext, TElt elt, CancellationToken cancellationToken);
 public async Task <ExecutionResult> Execute(BPMNExecutionContext executionContext, TElt elt, CancellationToken cancellationToken)
 {
     return(await Handle(executionContext, elt, cancellationToken));
 }
 protected virtual ICollection <string> GetOutgoingFlowNodeIds(BPMNExecutionContext executionContext, BaseFlowNode flowNode)
 {
     return(executionContext.Instance.GetOutgoingSequenceFlows(flowNode.EltId).Select(_ => _.TargetRef).ToList());
 }