/// <summary> /// 获取下一步节点列表,伴随运行时条件信息 /// </summary> /// <param name="currentActivity"></param> /// <param name="conditionKeyValuePair"></param> /// <returns></returns> internal NextActivityMatchedResult GetNextActivityList(string currentActivityGUID, IDictionary <string, string> conditionKeyValuePair = null) { try { NextActivityMatchedResult result = null; NextActivityMatchedType resultType = NextActivityMatchedType.Unknown; //创建“下一步节点”的根节点 NextActivityComponent root = NextActivityComponentFactory.CreateNextActivityComponent(); NextActivityComponent child = null; List <TransitionEntity> transitionList = GetForwardTransitionList(currentActivityGUID, conditionKeyValuePair).ToList(); if (transitionList.Count > 0) { //遍历连线,获取下一步节点的列表 foreach (TransitionEntity transition in transitionList) { if (transition.ToActivity.ActivityType == ActivityTypeEnum.EndNode || transition.ToActivity.ActivityType == ActivityTypeEnum.TaskNode || transition.ToActivity.ActivityType == ActivityTypeEnum.SubProcessNode) { child = NextActivityComponentFactory.CreateNextActivityComponent(transition, transition.ToActivity); } else if (transition.ToActivity.ActivityType == ActivityTypeEnum.GatewayNode) { NextActivityScheduleBase activitySchedule = NextActivityScheduleFactory.CreateActivitySchedule(this, transition.ToActivity.GatewaySplitJoinType); child = activitySchedule.GetNextActivityListFromGateway(transition, transition.ToActivity, conditionKeyValuePair, out resultType); } else { throw new XmlDefinitionException(string.Format("未知的节点类型:{0}", transition.ToActivity.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="newRoot"></param> /// <param name="root"></param> /// <param name="child"></param> /// <returns></returns> private NextActivityComponent AddChildToNewGatewayComponent(NextActivityComponent newRoot, NextActivityComponent root, NextActivityComponent child) { if ((newRoot == null) && (child != null)) { newRoot = NextActivityComponentFactory.CreateNextActivityComponent(root); } if ((newRoot != null) && (child != null)) { newRoot.Add(child); } return(newRoot); }
/// <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="currentActivity"></param> /// <param name="conditionKeyValuePair"></param> /// <returns></returns> internal NextActivityMatchedResult GetNextActivityList(string currentActivityGUID, IDictionary <string, string> conditionKeyValuePair, ActivityResource activityResource, Expression <Func <ActivityResource, ActivityEntity, bool> > expression) { NextActivityComponent newRoot = NextActivityComponentFactory.CreateNextActivityComponent(); //先获取未加运行时表达式过滤的下一步节点列表 NextActivityMatchedResult result = GetNextActivityList(currentActivityGUID, conditionKeyValuePair); foreach (NextActivityComponent c in result.Root) { if (c.HasChildren) { NextActivityComponent child = GetNextActivityListByExpressionRecurisivly(c, activityResource, expression); if (child != null) { newRoot.Add(child); } } else { if (expression.Compile().Invoke(activityResource, c.Activity))///TODO { newRoot.Add(c); } } } NextActivityMatchedResult newResult = null; if (newRoot.HasChildren) { newResult = NextActivityMatchedResult.CreateNextActivityMatchedResultObject(result.MatchedType, newRoot); } else { newResult = NextActivityMatchedResult.CreateNextActivityMatchedResultObject(NextActivityMatchedType.NoneTransitionFilteredByCondition, newRoot); } return(newResult); }