Esempio n. 1
0
        protected internal override void EventNotificationsCompleted(PvmExecutionImpl execution)
        {
            IPvmActivity activity = execution.Activity;

            if (execution.IsScope && (ExecutesNonScopeActivity(execution) || IsAsyncBeforeActivity(execution)) &&
                !CompensationBehavior.executesNonScopeCompensationHandler(execution))
            {
                // case this is a scope execution and the activity is not a scope
                execution.LeaveActivityInstance();
                execution.Activity = (GetFlowScopeActivity(activity));
                execution.PerformOperation(PvmAtomicOperationFields.DeleteCascadeFireActivityEnd);
            }
            else
            {
                if (execution.IsScope)
                {
                    execution.Destroy();
                }

                // remove this execution and its concurrent parent (if exists)
                execution.Remove();

                var continueRemoval = !execution.IsDeleteRoot;

                if (continueRemoval)
                {
                    var propagatingExecution = execution.Parent;
                    if ((propagatingExecution != null) && !propagatingExecution.IsScope &&
                        !propagatingExecution.HasChildren())
                    {
                        propagatingExecution.Remove();
                        continueRemoval      = !propagatingExecution.IsDeleteRoot;
                        propagatingExecution = propagatingExecution.Parent;
                    }

                    if (continueRemoval)
                    {
                        if (propagatingExecution != null)
                        {
                            // continue deletion with the next scope execution
                            // set activity on parent in case the parent is an inactive scope execution and activity has been set to 'null'.
                            if ((propagatingExecution.Activity == null) && (activity != null) &&
                                (activity.FlowScope != null))
                            {
                                propagatingExecution.Activity = (GetFlowScopeActivity(activity));
                            }
                            ((PvmExecutionImpl)propagatingExecution).PerformOperation(PvmAtomicOperationFields.DeleteCascade);
                        }
                    }
                }
            }
        }
        protected internal override void EventNotificationsCompleted(PvmExecutionImpl execution)
        {
            IPvmActivity activity = execution.Activity;

            if (execution.IsScope && (activity != null) && !activity.IsScope)
            {
                execution.Activity = (ActivityImpl)activity.FlowScope;
                execution.PerformOperation(this);
            }
            else
            {
                if (execution.IsScope)
                {
                    execution.Destroy();
                }

                execution.Remove();
            }
        }
Esempio n. 3
0
        protected internal override void EventNotificationsCompleted(PvmExecutionImpl execution)
        {
            execution.LeaveActivityInstance();

            PvmExecutionImpl superExecution = (PvmExecutionImpl)execution.SuperExecution;

            ISubProcessActivityBehavior subProcessActivityBehavior = null;

            // copy variables before destroying the ended sub process instance
            if (superExecution != null)
            {
                IPvmActivity activity = superExecution.Activity;
                Log.LogDebug("-----------------ActivityBehavior类型异常", activity.GetType().Name);
                subProcessActivityBehavior = (ISubProcessActivityBehavior)activity.ActivityBehavior;

                try
                {
                    subProcessActivityBehavior.PassOutputVariables(superExecution, execution);
                }
                catch (System.Exception e)
                {
                    Log.ExceptionWhileCompletingSupProcess(execution, e);
                    throw new ProcessEngineException("Error while completing sub process of execution " + execution, e);
                }
            }
            //else if (superCaseExecution != null)
            //{
            //    CmmnActivity activity = superCaseExecution.Activity;
            //    transferVariablesBehavior = (TransferVariablesActivityBehavior)activity.ActivityBehavior;
            //    try
            //    {
            //        transferVariablesBehavior.transferVariables(execution, superCaseExecution);
            //    }
            //    catch (Exception e)
            //    {
            //        LOG.exceptionWhileCompletingSupProcess(execution, e);
            //        throw e;
            //    }
            //    catch (Exception e)
            //    {
            //        LOG.exceptionWhileCompletingSupProcess(execution, e);
            //        throw new ProcessEngineException("Error while completing sub process of execution " + execution, e);
            //    }
            //}

            execution.Destroy();
            execution.Remove();

            // and trigger execution afterwards
            if (superExecution != null)
            {
                superExecution.SubProcessInstance = null;
                try
                {
                    subProcessActivityBehavior.Completed(superExecution);
                }
                catch (System.Exception e)
                {
                    Log.ExceptionWhileCompletingSupProcess(execution, e);
                    throw new ProcessEngineException("Error while completing sub process of execution " + execution, e);
                }
            }
            //else if (superCaseExecution != null)
            //{
            //    superCaseExecution.complete();
            //}
        }
Esempio n. 4
0
        public virtual void Execute(PvmExecutionImpl execution)
        {
            // calculate the propagating execution
            var propagatingExecution = execution;

            IPvmActivity activity          = execution.Activity;
            var          transitionsToTake = execution.TransitionsToTake;

            execution.TransitionsToTake = null;

            // check whether the current scope needs to be destroyed
            if (execution.IsScope && activity.IsScope)
            {
                if (!LegacyBehavior.DestroySecondNonScope(execution))
                {
                    if (execution.IsConcurrent)
                    {
                        // legacy behavior
                        LegacyBehavior.DestroyConcurrentScope(execution);
                    }
                    else
                    {
                        propagatingExecution            = (PvmExecutionImpl)execution.Parent;
                        propagatingExecution.Activity   = (execution.Activity);
                        propagatingExecution.Transition = (execution.Transition);
                        propagatingExecution.IsActive   = true;
                        Log.DebugDestroyScope(execution, propagatingExecution);
                        execution.Destroy();
                        execution.Remove();
                    }
                }
            }
            else
            {
                // activity is not scope => nothing to do
                propagatingExecution = execution;
            }

            // take the specified transitions
            if (transitionsToTake == null || transitionsToTake.Count == 0)
            {
                throw new ProcessEngineException(execution + ": No outgoing transitions from " + "activity " + activity);
            }
            if (transitionsToTake.Count == 1)
            {
                propagatingExecution.Transition = (transitionsToTake[0]);
                propagatingExecution.Take();
            }
            else
            {
                propagatingExecution.InActivate();

                IList <OutgoingExecution> outgoingExecutions = new List <OutgoingExecution>();

                for (var i = 0; i < transitionsToTake.Count; i++)
                {
                    var transition = transitionsToTake[i];

                    var scopeExecution = propagatingExecution.IsScope ? propagatingExecution : propagatingExecution.Parent;

                    // reuse concurrent, propagating execution for first transition
                    IActivityExecution concurrentExecution = null;
                    if (i == 0)
                    {
                        concurrentExecution = propagatingExecution;
                    }
                    else
                    {
                        concurrentExecution = scopeExecution.CreateConcurrentExecution();

                        if ((i == 1) && !propagatingExecution.IsConcurrent)
                        {
                            outgoingExecutions.RemoveAt(0);
                            // get a hold of the concurrent execution that replaced the scope propagating execution
                            IActivityExecution replacingExecution = null;
                            foreach (var concurrentChild in scopeExecution.NonEventScopeExecutions)
                            {
                                if (!(concurrentChild == propagatingExecution))
                                {
                                    replacingExecution = concurrentChild;
                                    break;
                                }
                            }

                            outgoingExecutions.Add(new OutgoingExecution(replacingExecution, transitionsToTake[0]));
                        }
                    }

                    outgoingExecutions.Add(new OutgoingExecution(concurrentExecution, transition));
                }

                // start executions in reverse order (order will be reversed again in command context with the effect that they are
                // actually be started in correct order :) )
                outgoingExecutions = outgoingExecutions.Reverse().ToList();

                foreach (var outgoingExecution in outgoingExecutions)
                {
                    outgoingExecution.Take();
                }
            }
        }
Esempio n. 5
0
        public virtual void Execute(PvmExecutionImpl execution)
        {
            // restore activity instance id
            if (execution.ActivityInstanceId == null)
            {
                execution.ActivityInstanceId = execution.ParentActivityInstanceId;
            }

            IPvmActivity activity = execution.Activity;
            var          activityExecutionMapping = execution.CreateActivityExecutionMapping();

            var propagatingExecution = execution;

            if (execution.IsScope && activity.IsScope)
            {
                if (!LegacyBehavior.DestroySecondNonScope(execution))
                {
                    execution.Destroy();
                    if (!execution.IsConcurrent)
                    {
                        execution.Remove();
                        propagatingExecution          = (PvmExecutionImpl)execution.Parent;
                        propagatingExecution.Activity = (execution.Activity);
                    }
                }
            }

            propagatingExecution = (PvmExecutionImpl)LegacyBehavior.DeterminePropagatingExecutionOnEnd(propagatingExecution,
                                                                                                       activityExecutionMapping);
            IPvmScope flowScope = activity.FlowScope;

            // 1. flow scope = Process Definition
            if (flowScope == activity.ProcessDefinition)
            {
                // 1.1 concurrent execution => end + tryPrune()
                if (propagatingExecution.IsConcurrent)
                {
                    propagatingExecution.Remove();
                    propagatingExecution.Parent.TryPruneLastConcurrentChild();
                    propagatingExecution.Parent.ForceUpdate();
                }
                else
                {
                    // 1.2 Process End
                    if (!propagatingExecution.PreserveScope)
                    {
                        propagatingExecution.PerformOperation(PvmAtomicOperationFields.ProcessEnd);
                    }
                }
            }
            else
            {
                // 2. flowScope != process definition
                var flowScopeActivity = (IPvmActivity)flowScope;

                var activityBehavior = flowScopeActivity.ActivityBehavior;
                if (activityBehavior is ICompositeActivityBehavior)
                {
                    var compositeActivityBehavior = (ICompositeActivityBehavior)activityBehavior;
                    // 2.1 Concurrent execution => composite behavior.concurrentExecutionEnded()
                    if (propagatingExecution.IsConcurrent && !LegacyBehavior.IsConcurrentScope(propagatingExecution))
                    {
                        compositeActivityBehavior.ConcurrentChildExecutionEnded(propagatingExecution.Parent,
                                                                                propagatingExecution);
                    }
                    else
                    {
                        // 2.2 Scope Execution => composite behavior.complete()
                        propagatingExecution.Activity = (ActivityImpl)(flowScopeActivity);
                        compositeActivityBehavior.Complete(propagatingExecution);
                    }
                }
                else
                {
                    // activity behavior is not composite => this is unexpected
                    throw new ProcessEngineException("Expected behavior of composite scope " + activity +
                                                     " to be a CompositeActivityBehavior but got " + activityBehavior);
                }
            }
        }