Пример #1
0
        /// <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);
                }
            }
        }
        /// <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);
                }
            }
        }