Example #1
0
        /// <summary>
        /// OrJoin合并时的节点完成方法
        /// 1. 如果有满足条件的OrJoin前驱转移,则会重新生成新的OrJoin节点实例
        /// </summary>
        /// <param name="processInstance"></param>
        /// <param name="fromTransition"></param>
        /// <param name="fromActivityInstance"></param>
        /// <param name="activityResource"></param>
        /// <param name="wfLinqDataContext"></param>
        public GatewayExecutedResult CompleteAutomaticlly(ProcessInstanceEntity processInstance,
                                                          TransitionEntity fromTransition,
                                                          ActivityInstanceEntity fromActivityInstance,
                                                          ActivityResource activityResource,
                                                          ISession session)
        {
            var toActivityInstance = base.CreateActivityInstanceObject(processInstance, activityResource.LogonUser);

            base.InsertActivityInstance(toActivityInstance,
                                        session);

            base.CompleteActivityInstance(toActivityInstance.ActivityInstanceGUID,
                                          activityResource,
                                          session);

            SyncActivityInstanceObjectState(NodeStateEnum.Completed);

            base.InsertTransitionInstance(processInstance,
                                          fromTransition,
                                          fromActivityInstance,
                                          toActivityInstance,
                                          TransitionTypeEnum.Forward,
                                          activityResource.LogonUser,
                                          session);

            GatewayExecutedResult result = GatewayExecutedResult.CreateGatewayExecutedResult(GatewayExecutedStatus.Successed);

            return(result);
        }
Example #2
0
        public GatewayExecutedResult CompleteAutomaticlly(ProcessInstanceEntity processInstance,
                                                          TransitionEntity fromTransition,
                                                          ActivityInstanceEntity fromActivityInstance,
                                                          ActivityResource activityResource,
                                                          ISession session)
        {
            GatewayExecutedResult result = GatewayExecutedResult.CreateGatewayExecutedResult(GatewayExecutedStatus.Unknown);

            bool canRenewInstance = false;

            //检查是否有运行中的合并节点实例
            ActivityInstanceEntity joinNode = base.ActivityInstanceManager.GetActivityWithRunningState(
                processInstance.ProcessInstanceGUID,
                base.Activity.ActivityGUID,
                session);

            if (joinNode == null)
            {
                canRenewInstance = true;
            }
            else
            {
                //判断是否可以激活下一步节点
                canRenewInstance = (joinNode.CanRenewInstance == 1);
                if (!canRenewInstance)
                {
                    result = GatewayExecutedResult.CreateGatewayExecutedResult(GatewayExecutedStatus.FallBehindOfXOrJoin);
                    return(result);
                }
            }

            if (canRenewInstance)
            {
                var toActivityInstance = base.CreateActivityInstanceObject(processInstance, activityResource.LogonUser);
                base.InsertActivityInstance(toActivityInstance,
                                            session);

                base.CompleteActivityInstance(toActivityInstance.ActivityInstanceGUID,
                                              activityResource,
                                              session);

                base.SyncActivityInstanceObjectState(NodeStateEnum.Completed);

                //写节点转移实例数据
                base.InsertTransitionInstance(processInstance,
                                              fromTransition,
                                              fromActivityInstance,
                                              toActivityInstance,
                                              TransitionTypeEnum.Forward,
                                              activityResource.LogonUser,
                                              session);

                result = GatewayExecutedResult.CreateGatewayExecutedResult(GatewayExecutedStatus.Successed);
            }
            return(result);
        }
Example #3
0
        public GatewayExecutedResult CompleteAutomaticlly(ProcessInstanceEntity processInstance,
                                                          TransitionEntity fromTransition,
                                                          ActivityInstanceEntity fromActivityInstance,
                                                          ActivityResource activityResource,
                                                          ISession session)
        {
            //检查是否有运行中的合并节点实例
            ActivityInstanceEntity joinNode = base.ActivityInstanceManager.GetActivityWithRunningState(processInstance.ProcessInstanceGUID,
                                                                                                       base.Activity.ActivityGUID,
                                                                                                       session);

            if (joinNode == null)
            {
                var aiEntity = base.CreateActivityInstanceObject(processInstance, activityResource.LogonUser);
                base.InsertActivityInstance(aiEntity,
                                            session);
            }
            else
            {
                //更新节点的活动实例属性
                base.ActivityInstance = joinNode;
                int tokensRequired = base.ActivityInstance.TokensRequired;
                int tokensHad      = base.ActivityInstance.TokensHad;

                //更新Token数目
                base.ActivityInstanceManager.IncreaseTokensHad(base.ActivityInstance.ActivityInstanceGUID,
                                                               activityResource.LogonUser,
                                                               session);

                if ((tokensHad + 1) == tokensRequired)
                {
                    //如果达到完成节点的Token数,则设置该节点状态为完成
                    base.CompleteActivityInstance(base.ActivityInstance.ActivityInstanceGUID,
                                                  activityResource,
                                                  session);

                    SyncActivityInstanceObjectState(NodeStateEnum.Completed);
                }
            }

            GatewayExecutedResult result = GatewayExecutedResult.CreateGatewayExecutedResult(GatewayExecutedStatus.Successed);

            return(result);
        }