protected internal override void EventNotificationsCompleted(PvmExecutionImpl execution)
        {
            base.EventNotificationsCompleted(execution);

            execution.ActivityInstanceStarted();

            var startContext       = execution.ExecutionStartContext;
            var instantiationStack = startContext.InstantiationStack;

            var propagatingExecution = execution;
            var activity             = execution.Activity;

            if (activity.ActivityBehavior is IModificationObserverBehavior)
            {
                var behavior             = (IModificationObserverBehavior)activity.ActivityBehavior;
                var concurrentExecutions = behavior.InitializeScope(propagatingExecution, 1);
                propagatingExecution = (PvmExecutionImpl)concurrentExecutions[0];
            }

            // if the stack has been instantiated
            if ((instantiationStack.Activities.Count == 0) && (instantiationStack.TargetActivity != null))
            {
                // as if we are entering the target activity instance id via a transition
                propagatingExecution.ActivityInstanceId = null;

                // execute the target activity with this execution
                startContext.ApplyVariables(propagatingExecution);
                propagatingExecution.Activity = (ActivityImpl)(instantiationStack.TargetActivity);
                propagatingExecution.PerformOperation(PvmAtomicOperationFields.ActivityStartCreateScope);
            }
            else if ((instantiationStack.Activities.Count == 0) && (instantiationStack.TargetTransition != null))
            {
                // as if we are entering the target activity instance id via a transition
                propagatingExecution.ActivityInstanceId = null;

                // execute the target transition with this execution
                var transition = instantiationStack.TargetTransition;
                startContext.ApplyVariables(propagatingExecution);
                propagatingExecution.Activity   = (ActivityImpl)(transition.Source);
                propagatingExecution.Transition = ((TransitionImpl)transition);
                propagatingExecution.PerformOperation(PvmAtomicOperationFields.TransitionStartNotifyListenerTake);
            }
            else
            {
                // else instantiate the activity stack further
                propagatingExecution.Activity = (null);
                propagatingExecution.PerformOperation(PvmAtomicOperationFields.ActivityInitStack);
            }
        }
예제 #2
0
        public virtual void Execute(PvmExecutionImpl execution)
        {
            execution.ActivityInstanceStarted();
            execution.ContinueIfExecutionDoesNotAffectNextOperation((e) => {
                if (execution.Activity.IsScope)
                {
                    execution.DispatchEvent(null);
                }
            }, (e) =>
            {
                var activityBehavior = ActivityBehaviorUtil.GetActivityBehavior(e);

                var activity = (ActivityImpl)e.Activity;
                Log.DebugExecutesActivity(e, activity, activityBehavior.GetType().FullName);
                //try
                //{
                Log.LogDebug("activityBehavior类型:", activityBehavior.GetType().Name);
                if (activity.IsTransaction)
                {
                    Log.LogDebug("进入SubProcess,并新建事务", activity.ActivityId);
                    context.Impl.Context.CommandContext.AddTransaction();
                }
                if (activity.IsInTransaction)
                {
                    Log.LogDebug("进入SubProcess子Activity:", activity.ActivityId);
                }
                activityBehavior.Execute(e);
                //}
                //catch (Exception e)
                //{
                //    throw new PvmException(
                //        "couldn't execute activity <" + activity.GetProperty("type") + " id=\"" + activity.Id +
                //        "\" ...>: " + e.Message, e);
                //}
            }, execution);
        }