/// <summary> /// 根据Transition,获取下一步节点列表 /// </summary> /// <param name="forwardTransition">转移实体</param> /// <param name="conditionKeyValuePair">条件kv对</param> /// <param name="resultType">结果类型</param> protected NextActivityComponent GetNextActivityListFromGatewayCore(TransitionEntity forwardTransition, IDictionary <string, string> conditionKeyValuePair, out NextActivityMatchedType resultType) { NextActivityComponent child = null; if (XPDLHelper.IsSimpleComponentNode(forwardTransition.ToActivity.ActivityType) == true) //可流转简单类型节点 { child = NextActivityComponentFactory.CreateNextActivityComponent(forwardTransition, forwardTransition.ToActivity); resultType = NextActivityMatchedType.Successed; } else if (forwardTransition.ToActivity.ActivityType == ActivityTypeEnum.GatewayNode) { child = GetNextActivityListFromGateway(forwardTransition, forwardTransition.ToActivity, conditionKeyValuePair, out resultType); } else { resultType = NextActivityMatchedType.Failed; throw new XmlDefinitionException(string.Format("未知的节点类型:{0}", forwardTransition.ToActivity.ActivityType.ToString())); } return(child); }
/// <summary> /// 创建下一步活动的节点 /// </summary> /// <param name="activity"></param> /// <returns></returns> internal static NextActivityComponent CreateNextActivityComponent(TransitionEntity transition, ActivityEntity activity) { NextActivityComponent component = null; if (XPDLHelper.IsSimpleComponentNode(activity.ActivityType) == true) //可流转简单类型节点 { string name = "单一节点"; component = new NextActivityItem(name, transition, activity); } else if (activity.ActivityType == ActivityTypeEnum.SubProcessNode) { string name = "子流程节点"; component = new NextActivityItem(name, transition, activity); } else { string name = string.Empty; if (activity.GatewayDirectionType == NETBPMFlow.Engine.Common.GatewayDirectionEnum.AndSplit) { name = "必全选节点"; } else if (activity.GatewayDirectionType == GatewayDirectionEnum.AndSplitMI) { name = "并行多实例节点"; } else { name = "或多选节点"; } component = new NextActivityGateway(name, transition, activity); } return(component); }
public override void Add(NextActivityComponent nextActivity) { nextActivityList.Add(nextActivity); if (hasChildren == false) { hasChildren = true; } }
public override bool Remove(NextActivityComponent nextActivity) { bool isRemoved = nextActivityList.Remove(nextActivity); if (nextActivityList.Count == 0) { hasChildren = false; } return(isRemoved); }
/// <summary> /// 把子节点添加到网关路由节点,根据网关节点和子节点是否为空处理 /// </summary> /// <param name="fromTransition">起始转移</param> /// <param name="currentGatewayActivity">当前网关节点</param> /// <param name="gatewayComponent">网关Component</param> /// <param name="child">子节点</param> /// <returns>下一步Component</returns> protected NextActivityComponent AddChildToGatewayComponent(TransitionEntity fromTransition, ActivityEntity currentGatewayActivity, NextActivityComponent gatewayComponent, NextActivityComponent child) { if ((gatewayComponent == null) && (child != null)) { gatewayComponent = NextActivityComponentFactory.CreateNextActivityComponent(fromTransition, currentGatewayActivity); } if ((gatewayComponent != null) && (child != null)) { gatewayComponent.Add(child); } return(gatewayComponent); }
/// <summary> /// 创建跳转节点(强制拉取跳转方式,后续节点状态可以强制拉取前置节点到当前节点[后续节点]) /// </summary> /// <param name="fromActivity">要拉取的节点</param> /// <param name="toActivity">拉取到节点</param> /// <returns></returns> internal static NextActivityComponent CreateNextActivityComponent(ActivityEntity fromActivity, ActivityEntity toActivity) { NextActivityComponent component = null; if (XPDLHelper.IsSimpleComponentNode(fromActivity.ActivityType) == true) //可流转简单类型节点 { string name = "单一节点"; var transition = TransitionBuilder.CreateJumpforwardEmptyTransition(fromActivity, toActivity); component = new NextActivityItem(name, transition, fromActivity); //强制拉取跳转类型的transition 为空类型 } else { throw new ApplicationException(string.Format("不能跳转到其它非任务类型的节点!当前节点:{0}", fromActivity.ActivityType)); } return(component); }
/// <summary> /// 获取下一步节点列表 /// </summary> /// <param name="processInstanceID"></param> /// <param name="fromTransition"></param> /// <param name="currentGatewayActivity"></param> /// <param name="conditionKeyValuePair"></param> /// <returns></returns> internal override NextActivityComponent GetNextActivityListFromGateway(TransitionEntity fromTransition, ActivityEntity currentGatewayActivity, IDictionary <string, string> conditionKeyValuePair, out NextActivityMatchedType resultType) { NextActivityComponent child = null; NextActivityComponent gatewayComponent = null; resultType = NextActivityMatchedType.Unknown; //直接取出下步列表,运行时再根据条件执行 List <TransitionEntity> transitionList = base.ProcessModel.GetForwardTransitionList(currentGatewayActivity.ActivityGUID).ToList(); foreach (TransitionEntity transition in transitionList) { child = GetNextActivityListFromGatewayCore(transition, conditionKeyValuePair, out resultType); gatewayComponent = AddChildToGatewayComponent(fromTransition, currentGatewayActivity, gatewayComponent, child); } return(gatewayComponent); }
/// <summary> /// 获取下一步节点列表 /// </summary> /// <param name="processInstanceID"></param> /// <param name="fromTransition"></param> /// <param name="currentGatewayActivity"></param> /// <param name="conditionKeyValuePair"></param> /// <returns></returns> internal override NextActivityComponent GetNextActivityListFromGateway(TransitionEntity fromTransition, ActivityEntity currentGatewayActivity, IDictionary <string, string> conditionKeyValuePair, out NextActivityMatchedType resultType) { NextActivityComponent child = null; NextActivityComponent gatewayComponent = null; resultType = NextActivityMatchedType.Unknown; var transitionList = this.ProcessModel.GetForwardTransitionList(currentGatewayActivity.ActivityGUID).ToList(); if (currentGatewayActivity.GatewayDirectionType == GatewayDirectionEnum.AndSplit || currentGatewayActivity.GatewayDirectionType == GatewayDirectionEnum.AndSplitMI) { //判读连线上的条件是否都满足,如果都满足才可以取出后续节点列表 bool isCheckedOk = base.ProcessModel.CheckAndSplitOccurrenceCondition(transitionList, conditionKeyValuePair); if (isCheckedOk) { //获取AndSplit的每一条后续连线上的To节点 foreach (TransitionEntity transition in transitionList) { child = GetNextActivityListFromGatewayCore(transition, conditionKeyValuePair, out resultType); gatewayComponent = AddChildToGatewayComponent(fromTransition, currentGatewayActivity, gatewayComponent, child); } } if (gatewayComponent == null) { resultType = NextActivityMatchedType.WaitingForSplitting; } } else if (currentGatewayActivity.GatewayDirectionType == GatewayDirectionEnum.OrSplit) { //获取OrSplit的,满足条件的后续连线上的To节点 foreach (TransitionEntity transition in transitionList) { bool isValidTransition = base.ProcessModel.IsValidTransition(transition, conditionKeyValuePair); if (isValidTransition) { child = GetNextActivityListFromGatewayCore(transition, conditionKeyValuePair, out resultType); gatewayComponent = AddChildToGatewayComponent(fromTransition, currentGatewayActivity, gatewayComponent, child); } if (gatewayComponent == null) { resultType = NextActivityMatchedType.NoneTransitionMatchedToSplit; } } } else if (currentGatewayActivity.GatewayDirectionType == GatewayDirectionEnum.XOrSplit) { //按连线定义的优先级排序 transitionList.Sort(new TransitionPriorityCompare()); //获取XOrSplit的,第一条满足条件的后续连线上的To节点 foreach (TransitionEntity transition in transitionList) { bool isValidTransitionXOr = base.ProcessModel.IsValidTransition(transition, conditionKeyValuePair); if (isValidTransitionXOr) { child = GetNextActivityListFromGatewayCore(transition, conditionKeyValuePair, out resultType); gatewayComponent = AddChildToGatewayComponent(fromTransition, currentGatewayActivity, gatewayComponent, child); //退出循环 break; } } if (gatewayComponent == null) { resultType = NextActivityMatchedType.NoneTransitionMatchedToSplit; } } else if (currentGatewayActivity.GatewayDirectionType == GatewayDirectionEnum.ComplexSplit) { resultType = NextActivityMatchedType.Failed; throw new Exception("ComplexSplit 没有具体实现!"); } else { resultType = NextActivityMatchedType.Failed; throw new Exception("Split 分支节点的类型不明确!"); } return(gatewayComponent); }
/// <summary> /// 根据现有下一步节点列表,创建新的下一步节点列表对象 /// </summary> /// <param name="c"></param> /// <returns></returns> internal static NextActivityComponent CreateNextActivityComponent(NextActivityComponent c) { NextActivityComponent newComp = CreateNextActivityComponent(c.Transition, c.Activity); return(newComp); }
/// <summary> /// 创建方法 /// </summary> /// <param name="scheduleStatus"></param> /// <param name="root"></param> /// <returns></returns> internal static NextActivityMatchedResult CreateNextActivityMatchedResultObject(NextActivityMatchedType matchedType, NextActivityComponent root) { NextActivityMatchedResult result = new NextActivityMatchedResult(matchedType, root); switch (matchedType) { case NextActivityMatchedType.Unknown: result.Message = NextActivityMatchedResult.Unkonwn; break; case NextActivityMatchedType.Failed: result.Message = NextActivityMatchedResult.Exceptional; break; case NextActivityMatchedType.Successed: result.Message = NextActivityMatchedResult.Successed; break; case NextActivityMatchedType.NoneTransitionFilteredByCondition: result.Message = NextActivityMatchedResult.NoneTransitionFilteredByCondition; break; case NextActivityMatchedType.WaitingForSplitting: result.Message = NextActivityMatchedResult.NoneTransitionAsBeingFiltered; break; case NextActivityMatchedType.NoneTransitionMatchedToSplit: result.Message = NextActivityMatchedResult.NoneWayMatchedToSplit; break; case NextActivityMatchedType.WaitingForOthersJoin: result.Message = NextActivityMatchedResult.WaitingForOthersJoin; break; case NextActivityMatchedType.NotMadeItselfToJoin: result.Message = NextActivityMatchedResult.NotMadeItselfToJoin; break; } return(result); }
private NextActivityMatchedResult(NextActivityMatchedType matchedType, NextActivityComponent root) { MatchedType = matchedType; Root = root; }
/// <summary> /// 删除子节点 /// </summary> /// <param name="nextActivity"></param> /// <returns></returns> public virtual bool Remove(NextActivityComponent nextActivity) { throw new InvalidOperationException("非组合节点,无子项可以删除!"); }
/// <summary> /// 添加子节点 /// </summary> /// <param name="nextActivity"></param> public virtual void Add(NextActivityComponent nextActivity) { throw new InvalidOperationException("非组合节点,不能添加子项!"); }