Ejemplo n.º 1
0
        protected internal virtual bool ActivatesGateway(IActivityExecution execution, IPvmActivity gatewayActivity)
        {
            var numExecutionsGuaranteedToActivate = gatewayActivity.IncomingTransitions.Count;
            var scopeExecution = execution.IsScope ? execution : execution.Parent;

            var executionsAtGateway = execution.FindInactiveConcurrentExecutions(gatewayActivity);

            if (executionsAtGateway.Count >= numExecutionsGuaranteedToActivate)
            {
                return(true);
            }
            var executionsNotAtGateway = GetLeafExecutions(scopeExecution);

            foreach (var it in executionsAtGateway)
            {
                executionsNotAtGateway.Remove(it);
            }

            foreach (var executionNotAtGateway in executionsNotAtGateway)
            {
                if (CanReachActivity(executionNotAtGateway, gatewayActivity))
                {
                    return(false);
                }
            }

            // if no more token may arrive, then activate
            return(true);
        }
Ejemplo n.º 2
0
        public override void Execute(IActivityExecution execution)
        {
            execution.InActivate();
            LockConcurrentRoot(execution);

            var activity = execution.Activity;

            if (ActivatesGateway(execution, activity))
            {
                Log.ActivityActivation(activity.Id);

                var joinedExecutions    = execution.FindInactiveConcurrentExecutions(activity);
                var defaultSequenceFlow = (string)execution.Activity.GetProperty("default");
                IList <IPvmTransition> transitionsToTake = new List <IPvmTransition>();

                // find matching non-default sequence flows
                foreach (var outgoingTransition in execution.Activity.OutgoingTransitions)
                {
                    if (ReferenceEquals(defaultSequenceFlow, null) || !outgoingTransition.Id.Equals(defaultSequenceFlow))
                    {
                        var condition = (ICondition)outgoingTransition.GetProperty(BpmnParse.PropertynameCondition);
                        if ((condition == null) || condition.Evaluate(execution))
                        {
                            transitionsToTake.Add(outgoingTransition);
                        }
                    }
                }

                // if none found, add default flow
                if (transitionsToTake.Count == 0)
                {
                    if (!ReferenceEquals(defaultSequenceFlow, null))
                    {
                        var defaultTransition = execution.Activity.FindOutgoingTransition(defaultSequenceFlow);
                        if (defaultTransition == null)
                        {
                            throw Log.MissingDefaultFlowException(execution.Activity.Id, defaultSequenceFlow);
                        }

                        transitionsToTake.Add(defaultTransition);
                    }
                    else
                    {
                        // No sequence flow could be found, not even a default one
                        throw Log.StuckExecutionException(execution.Activity.Id);
                    }
                }
                // take the flows found
                execution.LeaveActivityViaTransitions(transitionsToTake, joinedExecutions);
            }
            else
            {
                Log.NoActivityActivation(activity.Id);
            }
        }
        protected internal virtual bool AllExecutionsEnded(IActivityExecution scopeExecution,
                                                           IActivityExecution endedExecution)
        {
            var numberOfInactiveConcurrentExecutions =
                endedExecution.FindInactiveConcurrentExecutions(endedExecution.Activity).Count;
            var concurrentExecutions = scopeExecution.Executions.Count;

            // no active instances exist and all concurrent executions are inactive
            return((GetLocalLoopVariable(scopeExecution, NumberOfActiveInstances) <= 0) &&
                   (numberOfInactiveConcurrentExecutions == concurrentExecutions));
        }
Ejemplo n.º 4
0
//private static Logger LOG = ProcessEngineLogger.TEST_LOGGER.GetLogger();

        public void Execute(IActivityExecution execution)
        {
            var activity = execution.Activity;

            var outgoingTransitions = execution.Activity.OutgoingTransitions;

            execution.InActivate();

            var joinedExecutions = execution.FindInactiveConcurrentExecutions(activity);

            var nbrOfExecutionsToJoin = execution.Activity.IncomingTransitions.Count;
            var nbrOfExecutionsJoined = joinedExecutions.Count;

            if (nbrOfExecutionsJoined == nbrOfExecutionsToJoin)
            {
                Debug.WriteLine("parallel gateway '" + activity.Id + "' activates: " + nbrOfExecutionsJoined + " of " + nbrOfExecutionsToJoin + " joined");
                execution.LeaveActivityViaTransitions(outgoingTransitions, joinedExecutions);
            }
        }
Ejemplo n.º 5
0
        public override void Execute(IActivityExecution execution)
        {
            // Join
            var activity            = execution.Activity;
            var outgoingTransitions = execution.Activity.OutgoingTransitions;

            execution.InActivate();
            LockConcurrentRoot(execution);

            var joinedExecutions      = execution.FindInactiveConcurrentExecutions(activity);
            var nbrOfExecutionsToJoin = execution.Activity.IncomingTransitions.Count;
            var nbrOfExecutionsJoined = joinedExecutions.Count;

            if (nbrOfExecutionsJoined == nbrOfExecutionsToJoin)
            {
                // Fork
                Log.ActivityActivation(activity.Id, nbrOfExecutionsJoined, nbrOfExecutionsToJoin);
                execution.LeaveActivityViaTransitions(outgoingTransitions, joinedExecutions);
            }
            else
            {
                Log.NoActivityActivation(activity.Id, nbrOfExecutionsJoined, nbrOfExecutionsToJoin);
            }
        }