/// <summary> /// 创建下一步活动的节点 /// </summary> /// <param name="activity"></param> /// <returns></returns> internal static NextActivityComponent CreateNextActivityComponent(TransitionEntity transition, ActivityEntity activity) { NextActivityComponent component = null; if (XPDLHelper.IsSimpleComponentNode(activity.ActivityType)) //可流转简单类型节点 { 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 == GatewayDirectionEnum.AndSplit) { name = "必全选节点"; } else { name = "或多选节点"; } component = new NextActivityGateway(name, transition, activity); } return(component); }
/// <summary> /// 根据Transition,获取下一步节点列表 /// </summary> /// <param name="forwardTransition">转移实体</param> /// <param name="conditionKeyValuePair">条件kv对</param> /// <param name="resultType">结果类型</param> protected NextActivityComponent GetNextActivityListFromGatewayCore(TransitionEntity forwardTransition, out NextActivityMatchedType resultType) { NextActivityComponent child = null; if (XPDLHelper.IsSimpleComponentNode(forwardTransition.TargetActivity.ActivityType) == true) //可流转简单类型节点 { child = NextActivityComponentFactory.CreateNextActivityComponent(forwardTransition, forwardTransition.TargetActivity); resultType = NextActivityMatchedType.Successed; } else if (forwardTransition.TargetActivity.ActivityType == ActivityTypeEnum.GatewayNode) { child = GetNextActivityListFromGateway(forwardTransition, forwardTransition.TargetActivity, out resultType); } else { resultType = NextActivityMatchedType.Failed; throw new XmlDefinitionException(string.Format("未知的节点类型:{0}", forwardTransition.TargetActivity.ActivityType.ToString())); } return(child); }
/// <summary> /// 获取下一步节点列表,满足运行时条件信息 /// </summary> /// <param name="currentActivityGUID"></param> /// <returns></returns> public NextActivityMatchedResult GetNextActivityList(string currentActivityID) { try { NextActivityMatchedResult result = null; NextActivityMatchedType resultType = NextActivityMatchedType.Unknown; //创建“下一步节点”的根节点 NextActivityComponent root = NextActivityComponentFactory.CreateNextActivityComponent(); NextActivityComponent child = null; List <TransitionEntity> transitionList = GetForwardTransitionList(currentActivityID).ToList(); if (transitionList.Count > 0) { //遍历连线,获取下一步节点的列表 foreach (TransitionEntity transition in transitionList) { if (XPDLHelper.IsWorkItem(transition.TargetActivity.ActivityType)) //可流转简单类型节点 || 子流程节点 { child = NextActivityComponentFactory.CreateNextActivityComponent(transition, transition.TargetActivity); } else if (transition.TargetActivity.ActivityType == ActivityTypeEnum.GatewayNode) { NextActivityScheduleBase activitySchedule = NextActivityScheduleFactory.CreateActivitySchedule(this as IProcessModel, transition.TargetActivity.GatewaySplitJoinType); child = activitySchedule.GetNextActivityListFromGateway(transition, transition.TargetActivity, out resultType); } else { throw new XmlDefinitionException(string.Format("未知的节点类型:{0}", transition.TargetActivity.ActivityType.ToString())); } if (child != null) { root.Add(child); resultType = NextActivityMatchedType.Successed; } } } else { resultType = NextActivityMatchedType.NoneTransitionFilteredByCondition; } result = NextActivityMatchedResult.CreateNextActivityMatchedResultObject(resultType, root); return(result); } catch (System.Exception e) { throw new WfXpdlException(string.Format("解析流程定义文件发生异常,异常描述:{0}", e.Message), e); } }
/// <summary> /// 创建跳转节点(强制拉取跳转方式,后续节点状态可以强制拉取前置节点到当前节点[后续节点]) /// </summary> /// <param name="sourceActivity">要拉取的节点</param> /// <param name="targetActivity">拉取到节点</param> /// <returns></returns> internal static NextActivityComponent CreateNextActivityComponent(ActivityEntity sourceActivity, ActivityEntity targetActivity) { NextActivityComponent component = null; if (XPDLHelper.IsSimpleComponentNode(sourceActivity.ActivityType) == true) //可流转简单类型节点 { string name = "单一节点"; var transition = TransitionBuilder.CreateJumpforwardEmptyTransition(sourceActivity, targetActivity); component = new NextActivityItem(name, transition, sourceActivity); //强制拉取跳转类型的transition 为空类型 } else { throw new ApplicationException(string.Format("不能跳转到其它非任务类型的节点!当前节点:{0}", sourceActivity.ActivityType)); } return(component); }