⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 executionengineimpl.cs

📁 工作流的基本资料(文档资料
💻 CS
📖 第 1 页 / 共 2 页
字号:
			String transitionName = (String) processInvocationData[0];
			IDictionary attributeValues = (IDictionary) processInvocationData[1];

			// store the attributes
			subExecutionContext.CreateLog(subProcessStarterId, EventType.PROCESS_INSTANCE_START);
			subExecutionContext.StoreAttributeValues(attributeValues);
			subExecutionContext.StoreRole(subProcessStarterId, startState);

			// log event & trigger actions 
			RunActionsForEvent(EventType.SUB_PROCESS_INSTANCE_START, processState.Id, subExecutionContext);
			RunActionsForEvent(EventType.PROCESS_INSTANCE_START, subProcessDefinition.Id, subExecutionContext);

			// from here on, we consider the actor as being the previous actor
			subExecutionContext.SetActorAsPrevious();

			// process the start-transition
			TransitionImpl startTransition = subExecutionContext.GetTransition(transitionName, startState, dbSession);
			ProcessTransition(startTransition, subExecutionContext);

			// add the assigned flows of the subContext to the parentContext
			executionContext.AssignedFlows.AddRange(subExecutionContext.AssignedFlows);

			// flush the updates to the db
			dbSession.Update(subProcessInstance);
			dbSession.Flush();
		}

		public void ProcessDecision(DecisionImpl decision, ExecutionContextImpl executionContext)
		{
			// trigger actions, scheduled before the decision actually is made 
			RunActionsForEvent(EventType.BEFORE_DECISION, decision.Id, executionContext);

			// delegate the decision 
			TransitionImpl selectedTransition = delegationHelper.DelegateDecision(decision.DecisionDelegation, executionContext);

			// process the selected transition
			ProcessTransition(selectedTransition, executionContext);

			// trigger actions, scheduled after the decision is made 
			RunActionsForEvent(EventType.AFTER_DECISION, decision.Id, executionContext);
		}

		public void ProcessFork(ForkImpl fork, ExecutionContextImpl executionContext)
		{
			log.Debug("forking flow " + executionContext.GetFlow());

			// First initialize the children of the flow to be forked
			FlowImpl flow = (FlowImpl) executionContext.GetFlow();
			flow.Children = new ListSet();

			// Then initialise the forked flows in the execution context
			executionContext.ForkedFlows = new ArrayList();

			DelegationImpl delegation = fork.ForkDelegation;
			if (delegation != null)
			{
				delegationHelper.DelegateFork(fork.ForkDelegation, executionContext);
			}
			else
			{
				// execute the default fork behaviour
				IEnumerator iter = fork.LeavingTransitions.GetEnumerator();
				while (iter.MoveNext())
				{
					TransitionImpl transition = (TransitionImpl) iter.Current;
					executionContext.ForkFlow(transition, null);
				}
			}

			// create the fork event & remember the parent flow
			FlowImpl parentFlow = (FlowImpl) executionContext.GetFlow();
			executionContext.CreateLog(EventType.FORK);

			// log the event
			executionContext.SetFlow(parentFlow);
			IList forkedFlows = executionContext.ForkedFlows;
			IEnumerator iter2 = forkedFlows.GetEnumerator();
			while (iter2.MoveNext())
			{
				ForkedFlow forkedFlow = (ForkedFlow) iter2.Current;
				log.Debug("adding object reference [" + forkedFlow.Flow + "] to flow [" + parentFlow + "]");
				executionContext.AddLogDetail(new ObjectReferenceImpl(forkedFlow.Flow));
			}

			// loop over all flows that were forked in the ForkHandler implementation
			iter2 = forkedFlows.GetEnumerator();
			while (iter2.MoveNext())
			{
				ForkedFlow forkedFlow = (ForkedFlow) iter2.Current;

				// trigger actions, scheduled after the creation and setting of the attributeValues
				// but before the fork is being processed
				RunActionsForEvent(EventType.FORK, fork.Id, executionContext);

				// then process the forked flow transition
				executionContext.SetFlow(forkedFlow.Flow);
				ProcessTransition(forkedFlow.Transition, executionContext);
			}
		}

		public void ProcessJoin(JoinImpl join, ExecutionContextImpl executionContext)
		{
			// First set the state of the flow to finished
			FlowImpl joiningFlow = (FlowImpl) executionContext.GetFlow();
			joiningFlow.End = DateTime.Now;
			joiningFlow.ActorId = null;
			joiningFlow.Node = join; // setting the node is not necessary if this method is called
			// from processTransition, but it is necessary if this method is
			// called from cancelFlow in the component-impl.

			// if parent-reactivation of the flow is true, this means that the parent-flow
			// not yet has been reactivated.  In that case we have to see if it needs to be 
			// reactivated.  In the other case (parent-reactivation is false) we don't
			// need to do anything because this means that the parent-flow was already 
			// reactivated before.  
			if (!false.Equals(joiningFlow.ParentReactivation))
			{
				// check if the parent needs to be reactivated    
				bool parentReactivation = false;
				IList concurrentFlows = executionContext.GetOtherActiveConcurrentFlows();
				if (concurrentFlows.Count == 0)
				{
					// if no concurrent flows are present any more, reactivation is forced 
					parentReactivation = true;
				}
				else
				{
					// if other concurrent flows are present, the decision to reactivate is left 
					// to the join-delegation (if there is one specified)
					DelegationImpl joinDelegation = join.JoinDelegation;
					// if no joinDelegation was specified, parentReactivation remains false
					// so the behaviour is like an and-join. (=sunchronizing merge)
					if (joinDelegation != null)
					{
						parentReactivation = delegationHelper.DelegateJoin(join.JoinDelegation, executionContext);
					}
				}

				if (parentReactivation)
				{
					// make sure the other concurrent flows will not reactivate the
					// parent again
					IEnumerator iter = concurrentFlows.GetEnumerator();
					while (iter.MoveNext())
					{
						//UPGRADE_TODO: Methode "java.util.Iterator.next" wurde in 'IEnumerator.Current' konvertiert und weist ein anderes Verhalten auf. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_javautilIteratornext"'
						FlowImpl concurrentFlow = (FlowImpl) iter.Current;
						concurrentFlow.ParentReactivation = false;
					}

					// reactivate the parent by first setting the parentflow into the executionContext
					FlowImpl parentFlow = (FlowImpl) joiningFlow.Parent;
					executionContext.SetFlow(parentFlow);
					// and then process the (single, checked at process-archive-parsing-time) leaving transition. 
					ISet leavingTransitions = join.LeavingTransitions;
					iter = leavingTransitions.GetEnumerator();
					if (iter.MoveNext())
					{
						TransitionImpl leavingTransition = (TransitionImpl) iter.Current;
						ProcessTransition(leavingTransition, executionContext);
					} else {
						// no transition throw exception?
					}
				}
			}
		}

		public void ProcessEndState(EndStateImpl endState, ExecutionContextImpl executionContext)
		{
			RunActionsForEvent(EventType.PROCESS_INSTANCE_END, endState.ProcessDefinition.Id, executionContext);
			executionContext.CreateLog(EventType.PROCESS_INSTANCE_END);

			FlowImpl rootFlow = (FlowImpl) executionContext.GetFlow();
			rootFlow.ActorId = null;
			rootFlow.End = DateTime.Now;
			rootFlow.Node = endState; // setting the node is not necessary if this method is called
			// from processTransition, but it is necessary if this method is
			// called from cancelProcessInstance in the component-impl.

			ProcessInstanceImpl processInstance = (ProcessInstanceImpl) executionContext.GetProcessInstance();
			FlowImpl superProcessFlow = (FlowImpl) processInstance.SuperProcessFlow;
			if (superProcessFlow != null)
			{
				log.Debug("reactivating the super process...");

				// create the execution context for the parent-process 
				ExecutionContextImpl superExecutionContext = new ExecutionContextImpl(executionContext.PreviousActorId, superProcessFlow, executionContext.DbSession, executionContext.GetOrganisationComponent());
				superExecutionContext.SetInvokedProcessContext(executionContext);

				// delegate the attributeValues
				ProcessStateImpl processState = (ProcessStateImpl) superProcessFlow.Node;
				Object[] completionData = delegationHelper.DelegateProcessTermination(processState.ProcessInvokerDelegation, superExecutionContext);
				IDictionary attributeValues = (IDictionary) completionData[0];
				String transitionName = (String) completionData[1];
				TransitionImpl transition = superExecutionContext.GetTransition(transitionName, processState, executionContext.DbSession);

				// process the super process transition
				ProcessTransition(transition, superExecutionContext);
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -