Exemplo n.º 1
0
 /// <summary>节点实例监听器</summary>
 public virtual void onNodeInstanceEventFired(NodeInstanceEvent e)
 {
     //同步器节点的监听器触发条件,是在离开这个节点的时候
     if (e.EventType == NodeInstanceEventEnum.NODEINSTANCE_LEAVING)
     {
         ISynchronizerInstance syncInst           = (ISynchronizerInstance)e.getSource();
         IPersistenceService   persistenceService = this.RuntimeContext.PersistenceService;
         //删除同步器节点的token
         persistenceService.DeleteTokensForNode(e.Token.ProcessInstanceId, syncInst.Synchronizer.Id);
     }
 }
Exemplo n.º 2
0
 /// <summary>节点实例监听器</summary>
 public override void onNodeInstanceEventFired(NodeInstanceEvent e)
 {
     //同步器节点的监听器触发条件,是在离开这个节点的时候
     if (e.EventType == NodeInstanceEventEnum.NODEINSTANCE_LEAVING)
     {
         ISynchronizerInstance syncInst           = (ISynchronizerInstance)e.getSource();
         IPersistenceService   persistenceService = this.RuntimeContext.PersistenceService;
         //删除同步器节点的token
         persistenceService.DeleteTokensForNode(e.Token.ProcessInstanceId, syncInst.Synchronizer.Id);
     }
     //如果节点实例结束,就触发
     if (e.EventType == NodeInstanceEventEnum.NODEINSTANCE_COMPLETED)
     {
         // 执行ProcessInstance的complete操作
         IToken          tk = e.Token;
         ProcessInstance currentProcessInstance = (ProcessInstance)tk.ProcessInstance;
         currentProcessInstance.complete();
     }
 }
Exemplo n.º 3
0
        /// <summary>生成joinPoint</summary>
        /// <param name="synchInst"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public IJoinPoint createJoinPoint(ISynchronizerInstance synchInst, IToken token)// throws EngineException
        {
            int enterTransInstanceCount = synchInst.EnteringTransitionInstances.Count;

            if (enterTransInstanceCount == 0)//检查流程定义是否合法,同步器节点必须有输入边
            {
                throw new EngineException(this.Id, this.WorkflowProcess,
                                          synchInst.Synchronizer.Id, "The process definition [" + this.Name + "] is invalid,the synchronizer[" + synchInst.Synchronizer + "] has no entering transition");
            }
            IPersistenceService persistenceService = this.RuntimeContext.PersistenceService;

            //保存到数据库
            persistenceService.SaveOrUpdateToken(token);

            IJoinPoint resultJoinPoint = null;

            resultJoinPoint = new JoinPoint();
            resultJoinPoint.ProcessInstance = this;
            resultJoinPoint.SynchronizerId  = synchInst.Synchronizer.Id;
            if (enterTransInstanceCount == 1)
            {
                // 生成一个不存储到数据库中的JoinPoint
                resultJoinPoint.addValue(token.Value);

                if (token.IsAlive)
                {
                    resultJoinPoint.Alive          = true;
                    resultJoinPoint.FromActivityId = token.FromActivityId;
                }
                resultJoinPoint.StepNumber = token.StepNumber + 1;

                return(resultJoinPoint);
            }
            else
            {
                int stepNumber = 0;

                List <IToken> tokensList_0            = persistenceService.FindTokensForProcessInstance(this.Id, synchInst.Synchronizer.Id);
                Dictionary <String, IToken> tokensMap = new Dictionary <String, IToken>();
                for (int i = 0; i < tokensList_0.Count; i++)
                {
                    IToken tmpToken          = (IToken)tokensList_0[i];
                    String tmpFromActivityId = tmpToken.FromActivityId;
                    if (!tokensMap.ContainsKey(tmpFromActivityId))
                    {
                        tokensMap.Add(tmpFromActivityId, tmpToken);
                    }
                    else
                    {
                        //TODO  ====下面的代码有意义吗?===start===wmj2003
                        IToken tmpToken2 = (IToken)tokensMap[tmpFromActivityId];
                        if (tmpToken2.StepNumber > tmpToken.StepNumber)
                        {
                            tokensMap[tmpFromActivityId] = tmpToken2;
                        }
                        //TODO  ====下面的代码有意义吗?===end===wmj2003
                    }
                }

                List <IToken> tokensList = new List <IToken>(tokensMap.Values);

                for (int i = 0; i < tokensList.Count; i++)
                {
                    IToken _token = (IToken)tokensList[i];
                    resultJoinPoint.addValue(_token.Value);
                    if (_token.IsAlive)//如果token的状态是alive
                    {
                        resultJoinPoint.Alive = true;
                        String oldFromActivityId = resultJoinPoint.FromActivityId;
                        if (String.IsNullOrEmpty(oldFromActivityId))
                        {
                            resultJoinPoint.FromActivityId = _token.FromActivityId;
                        }
                        else
                        {
                            resultJoinPoint.FromActivityId = oldFromActivityId + TokenFrom.FROM_ACTIVITY_ID_SEPARATOR + _token.FromActivityId;
                        }
                    }
                    if (token.StepNumber > stepNumber)
                    {
                        stepNumber = token.StepNumber;
                    }
                }

                resultJoinPoint.StepNumber = stepNumber + 1;

                return(resultJoinPoint);
            }
        }
Exemplo n.º 4
0
        // throws EngineException
        /// <summary>生成joinPoint</summary>
        /// <param name="synchInst"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public IJoinPoint createJoinPoint(ISynchronizerInstance synchInst, IToken token)
        {
            int enterTransInstanceCount = synchInst.EnteringTransitionInstances.Count;
            if (enterTransInstanceCount == 0)//检查流程定义是否合法,同步器节点必须有输入边
            {
                throw new EngineException(this.Id, this.WorkflowProcess,
                        synchInst.Synchronizer.Id, "The process definition [" + this.Name + "] is invalid,the synchronizer[" + synchInst.Synchronizer + "] has no entering transition");
            }
            IPersistenceService persistenceService = this.RuntimeContext.PersistenceService;
            //保存到数据库
            persistenceService.SaveOrUpdateToken(token);

            IJoinPoint resultJoinPoint = null;
            resultJoinPoint = new JoinPoint();
            resultJoinPoint.ProcessInstance=this;
            resultJoinPoint.SynchronizerId=synchInst.Synchronizer.Id;
            if (enterTransInstanceCount == 1)
            {
                // 生成一个不存储到数据库中的JoinPoint
                resultJoinPoint.addValue(token.Value);

                if (token.IsAlive)
                {
                    resultJoinPoint.Alive=true;
                    resultJoinPoint.FromActivityId=token.FromActivityId;
                }
                resultJoinPoint.StepNumber=token.StepNumber + 1;

                return resultJoinPoint;
            }
            else
            {
                int stepNumber = 0;

                List<IToken> tokensList_0 = persistenceService.FindTokensForProcessInstance(this.Id, synchInst.Synchronizer.Id);
                Dictionary<String, IToken> tokensMap = new Dictionary<String, IToken>();
                for (int i = 0; i < tokensList_0.Count; i++)
                {
                    IToken tmpToken = (IToken)tokensList_0[i];
                    String tmpFromActivityId = tmpToken.FromActivityId;
                    if (!tokensMap.ContainsKey(tmpFromActivityId))
                    {
                        tokensMap.Add(tmpFromActivityId, tmpToken);
                    }
                    else
                    {
                        //TODO  ====下面的代码有意义吗?===start===wmj2003
                        IToken tmpToken2 = (IToken)tokensMap[tmpFromActivityId];
                        if (tmpToken2.StepNumber > tmpToken.StepNumber)
                        {
                            tokensMap[tmpFromActivityId] = tmpToken2;
                        }
                        //TODO  ====下面的代码有意义吗?===end===wmj2003
                    }
                }

                List<IToken> tokensList = new List<IToken>(tokensMap.Values);

                for (int i = 0; i < tokensList.Count; i++)
                {
                    IToken _token = (IToken)tokensList[i];
                    resultJoinPoint.addValue(_token.Value);
                    if (_token.IsAlive)//如果token的状态是alive
                    {
                        resultJoinPoint.Alive=true;
                        String oldFromActivityId = resultJoinPoint.FromActivityId;
                        if (String.IsNullOrEmpty(oldFromActivityId))
                        {
                            resultJoinPoint.FromActivityId=_token.FromActivityId;
                        }
                        else
                        {
                            resultJoinPoint.FromActivityId=oldFromActivityId + TokenFrom.FROM_ACTIVITY_ID_SEPARATOR + _token.FromActivityId;
                        }
                    }
                    if (token.StepNumber > stepNumber)
                    {
                        stepNumber = token.StepNumber;
                    }
                }

                resultJoinPoint.StepNumber=stepNumber + 1;

                return resultJoinPoint;
            }
        }