public override Boolean take(IToken token) { Boolean oldAlive = token.IsAlive; EdgeInstanceEvent e = new EdgeInstanceEvent(this); e.Token = token; e.EventType = EdgeInstanceEventEnum.ON_TAKING_THE_TOKEN; for (int i = 0; this.eventListeners != null && i < this.eventListeners.Count; i++) { IEdgeInstanceEventListener listener = this.eventListeners[i]; listener.onEdgeInstanceEventFired(e); } Boolean newAlive = token.IsAlive; if (!newAlive) {//循环条件不满足,则恢复token的alive标示 token.IsAlive = oldAlive; return(newAlive); } else {//否则流转到下一个节点 INodeInstance nodeInst = this.LeavingNodeInstance; token.Value = this.Weight; nodeInst.fire(token);//触发同步器节点 return(newAlive); } }
/// <summary>节点实例监听器</summary> public void onEdgeInstanceEventFired(EdgeInstanceEvent e) { if (e.EventType == EdgeInstanceEventEnum.ON_TAKING_THE_TOKEN) { IToken token = e.Token; // 计算token的alive值 ILoopInstance transInst = (ILoopInstance)e.getSource(); String condition = transInst.Loop.Condition; calculateTheAliveValue(token, condition); if (this.RuntimeContext.IsEnableTrace && token.IsAlive) { ProcessInstanceTrace trace = new ProcessInstanceTrace(); trace.ProcessInstanceId = e.Token.ProcessInstanceId; trace.StepNumber = e.Token.StepNumber + 1; trace.Type = ProcessInstanceTraceEnum.LOOP_TYPE; trace.FromNodeId = transInst.Loop.FromNode.Id; trace.ToNodeId = transInst.Loop.ToNode.Id; trace.EdgeId = transInst.Loop.Id; //TODO wmj2003 一旦token从当前边上经过,那么就保存流程运行轨迹,这里应该是insert RuntimeContext.PersistenceService.SaveOrUpdateProcessInstanceTrace(trace); } } }
public override Boolean take(IToken token) { EdgeInstanceEvent e = new EdgeInstanceEvent(this); e.Token = token; e.EventType = EdgeInstanceEventEnum.ON_TAKING_THE_TOKEN; for (int i = 0; this.eventListeners != null && i < this.eventListeners.Count; i++) { IEdgeInstanceEventListener listener = this.eventListeners[i]; listener.onEdgeInstanceEventFired(e);//调用TransitionInstanceExtension 来计算弧线上的条件表达式 } INodeInstance nodeInst = this.LeavingNodeInstance; //获取到流向哪个节点 token.Value = this.Weight; //获取到弧线上的权值 Boolean alive = token.IsAlive; nodeInst.fire(token);//节点触发 return(alive); }
/// <summary>节点实例监听器</summary> public void onEdgeInstanceEventFired(EdgeInstanceEvent e) { if (e.EventType == EdgeInstanceEventEnum.ON_TAKING_THE_TOKEN) { IToken token = e.Token; ITransitionInstance transInst = (ITransitionInstance)e.getSource(); String condition = transInst.Transition.Condition; calculateTheAliveValue(token, condition); if (this.RuntimeContext.IsEnableTrace && token.IsAlive) { Transition transition = transInst.Transition; IWFElement fromNode = transition.FromNode; int minorNumber = 1; if (fromNode is Activity) { minorNumber = 2; } else { minorNumber = 1; } ProcessInstanceTrace trace = new ProcessInstanceTrace(); trace.ProcessInstanceId = e.Token.ProcessInstanceId; trace.StepNumber = e.Token.StepNumber; trace.Type = ProcessInstanceTraceEnum.TRANSITION_TYPE; trace.FromNodeId = transInst.Transition.FromNode.Id; trace.ToNodeId = transInst.Transition.ToNode.Id; trace.EdgeId = transInst.Transition.Id; trace.MinorNumber = minorNumber; //TODO wmj2003 这里应该是insert。一旦token从当前边上经过,那么就保存流程运行轨迹. RuntimeContext.PersistenceService.SaveOrUpdateProcessInstanceTrace(trace); } } }