protected internal virtual void PrepareScopeExecution(IActivityExecution scopeExecution, int nrOfInstances)
 {
     // set the MI-body scoped variables
     SetLoopVariable(scopeExecution, NumberOfInstances, nrOfInstances);
     SetLoopVariable(scopeExecution, NumberOfCompletedInstances, 0);
     SetLoopVariable(scopeExecution, NumberOfActiveInstances, nrOfInstances);
     scopeExecution.Activity = null;
     scopeExecution.InActivate();
 }
Beispiel #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);
            }
        }
Beispiel #3
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);
            }
        }
        public override void ConcurrentChildExecutionEnded(IActivityExecution scopeExecution,
                                                           IActivityExecution endedExecution)
        {
            int nrOfCompletedInstances = GetLoopVariable(scopeExecution, NumberOfCompletedInstances) + 1;

            SetLoopVariable(scopeExecution, NumberOfCompletedInstances, nrOfCompletedInstances);
            int nrOfActiveInstances = GetLoopVariable(scopeExecution, NumberOfActiveInstances) - 1;

            SetLoopVariable(scopeExecution, NumberOfActiveInstances, nrOfActiveInstances);

            // inactivate the concurrent execution
            endedExecution.InActivate();
            endedExecution.ActivityInstanceId = null;

            // join
            scopeExecution.ForceUpdate();
            // TODO: should the completion condition be evaluated on the scopeExecution or on the endedExecution?
            if (CompletionConditionSatisfied(endedExecution) || AllExecutionsEnded(scopeExecution, endedExecution))
            {
                var childExecutions =
                    new List <IActivityExecution>(((PvmExecutionImpl)scopeExecution).NonEventScopeExecutions);
                foreach (var childExecution in childExecutions)
                {
                    if (childExecution.IsActive || (childExecution.Activity == null))
                    {
                        ((PvmExecutionImpl)childExecution).DeleteCascade(
                            "Multi instance completion condition satisfied.");
                    }
                    else
                    {
                        childExecution.Remove();
                    }
                }

                scopeExecution.Activity = (IPvmActivity)endedExecution.Activity.FlowScope;
                scopeExecution.IsActive = true;
                Leave(scopeExecution);
            }
        }
Beispiel #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);
            }
        }