public GatewayExecutedResult CompleteAutomaticlly(WfProcessInstance processInstance, string transitionGUID, WfActivityInstance fromActivityInstance) { var gatewayActivityInstance = base.CreateActivityInstanceObject(base.GatewayActivity, processInstance); gatewayActivityInstance.DirectionType = GatewayDirectionEnum.OrSplit.ToString(); base.InsertActivityInstance(gatewayActivityInstance); base.CompleteActivityInstance(gatewayActivityInstance.Fid); gatewayActivityInstance.ActivityState = ActivityStateEnum.Completed.ToString(); base.GatewayActivityInstance = gatewayActivityInstance; //写节点转移实例数据 base.InsertTransitionInstance(processInstance, transitionGUID, fromActivityInstance, gatewayActivityInstance, TransitionTypeEnum.Forward, TransitionFlyingTypeEnum.NotFlying); GatewayExecutedResult result = GatewayExecutedResult.CreateGatewayExecutedResult(GatewayExecutedStatus.Successed); return(result); }
/// <summary> /// OrJoin合并时的节点完成方法 /// 1. 如果有满足条件的OrJoin前驱转移,则会重新生成新的OrJoin节点实例 /// </summary> /// <param name="processInstance">流程实例</param> /// <param name="transitionGUID">转移GUID</param> /// <param name="fromActivityInstance">起始活动实例</param> /// <param name="activityResource">活动资源</param> /// <param name="session">会话</param> public GatewayExecutedResult CompleteAutomaticlly(WfProcessInstance processInstance, string transitionGUID, WfActivityInstance fromActivityInstance) { //检查是否有运行中的合并节点实例 WfActivityInstance joinNode = base.ActivityInstanceManager.GetActivityInstanceRunning( processInstance.Fid, base.GatewayActivity.ActivityID); int tokensRequired = 0; int tokensHad = 0; if (joinNode == null) { var joinActivityInstance = base.CreateActivityInstanceObject(base.GatewayActivity, processInstance); //计算总需要的Token数目 joinActivityInstance.TokensRequired = GetTokensRequired(processInstance.Fid); joinActivityInstance.TokensHad = 1; tokensRequired = joinActivityInstance.TokensRequired; //进入运行状态 joinActivityInstance.ActivityState = ActivityStateEnum.Running.ToString(); //joinActivityInstance.DirectionType =GatewayDirectionEnum.AndJoin.ToString(); base.InsertActivityInstance(joinActivityInstance); base.InsertTransitionInstance(processInstance, transitionGUID, fromActivityInstance, joinActivityInstance, TransitionTypeEnum.Forward, TransitionFlyingTypeEnum.NotFlying); } else { //更新节点的活动实例属性 base.GatewayActivityInstance = joinNode; tokensRequired = base.GatewayActivityInstance.TokensRequired; tokensHad = base.GatewayActivityInstance.TokensHad; //更新Token数目 base.ActivityInstanceManager.IncreaseTokensHad(base.GatewayActivityInstance.Fid, base._runner); base.InsertTransitionInstance(processInstance, transitionGUID, fromActivityInstance, joinNode, TransitionTypeEnum.Forward, TransitionFlyingTypeEnum.NotFlying); } if ((tokensHad + 1) == tokensRequired) { //如果达到完成节点的Token数,则设置该节点状态为完成 base.CompleteActivityInstance(base.GatewayActivityInstance.Fid); base.GatewayActivityInstance.ActivityState = ActivityStateEnum.Completed.ToString(); } GatewayExecutedResult result = GatewayExecutedResult.CreateGatewayExecutedResult(GatewayExecutedStatus.Successed); return(result); }
public GatewayExecutedResult CompleteAutomaticlly(WfProcessInstance processInstance, string transitionGUID, WfActivityInstance fromActivityInstance) { GatewayExecutedResult result = GatewayExecutedResult.CreateGatewayExecutedResult(GatewayExecutedStatus.Unknown); bool canRenewInstance = false; //检查是否有运行中的合并节点实例 WfActivityInstance joinNode = base.ActivityInstanceManager.GetActivityInstanceRunning( processInstance.Fid, base.GatewayActivity.ActivityID); if (joinNode == null) { canRenewInstance = true; } else { //判断是否可以激活下一步节点 canRenewInstance = (joinNode.CanRenewInstance == 1); if (!canRenewInstance) { result = GatewayExecutedResult.CreateGatewayExecutedResult(GatewayExecutedStatus.FallBehindOfXOrJoin); return(result); } } if (canRenewInstance) { var gatewayActivityInstance = base.CreateActivityInstanceObject(base.GatewayActivity, processInstance); gatewayActivityInstance.DirectionType = GatewayDirectionEnum.XOrJoin.ToString(); base.InsertActivityInstance(gatewayActivityInstance); base.CompleteActivityInstance(gatewayActivityInstance.Fid); gatewayActivityInstance.ActivityState = ActivityStateEnum.Completed.ToString(); base.GatewayActivityInstance = gatewayActivityInstance; //写节点转移实例数据 base.InsertTransitionInstance(processInstance, transitionGUID, fromActivityInstance, gatewayActivityInstance, TransitionTypeEnum.Forward, TransitionFlyingTypeEnum.NotFlying); result = GatewayExecutedResult.CreateGatewayExecutedResult(GatewayExecutedStatus.Successed); } return(result); }