IEnumerable<IDev2Activity> ParseTools(FlowNode startNode, List<IDev2Activity> seenActivities) { if (startNode == null) return null; FlowStep step = startNode as FlowStep; if (step != null) { return ParseFlowStep(step, seenActivities); // ReSharper disable RedundantIfElseBlock } else { FlowDecision node = startNode as FlowDecision; if (node != null) return ParseDecision(node, seenActivities); else { FlowSwitch<string> @switch = startNode as FlowSwitch<string>; if (@switch != null) return ParseSwitch(@switch, seenActivities); } } return null; // ReSharper restore RedundantIfElseBlock }
internal bool Execute(NativeActivityContext context, CompletionCallback onCompleted, out FlowNode nextNode) { if ((this.Next == null) && TD.FlowchartNextNullIsEnabled()) { TD.FlowchartNextNull(base.Owner.DisplayName); } if (this.Action == null) { nextNode = this.Next; return true; } context.ScheduleActivity(this.Action, onCompleted); nextNode = null; return false; }
public static ActivityBuilder GetActivityBuilder(string templateName, FlowNode startNode, Dictionary<string, FlowNode> resultListNodes, int numofParallelBranches) { var body = new Flowchart() { DisplayName = templateName, StartNode = startNode }; GetWfNodes(resultListNodes, ref body); body.Variables.Add(new Variable<int>("ParallelBranchesCount") { Default = numofParallelBranches }); var activityBuilder = new ActivityBuilder(); activityBuilder.Name = "WfXamlTemplate"; activityBuilder.Properties.Add(new DynamicActivityProperty { Name = "FlowDataParm", Type = typeof(InArgument<FlowData>) }); activityBuilder.Properties.Add(new DynamicActivityProperty { Name = "NextDeptType", Type = typeof(InArgument<string>) }); activityBuilder.Properties.Add(new DynamicActivityProperty { Name = "DealWay", Type = typeof(InArgument<string>) }); activityBuilder.Implementation = body; return activityBuilder; }
//得到自定义流程图 public static flowcharStruct getFlowcharStruct(string xaml) { char[] sp = { ',' }; char[] sl = { ' ' }; //(1) WorkflowStruct.flowcharStruct flowcharStruct = new WorkflowStruct.flowcharStruct(); //(2) DynamicActivity dynamicActivity = tool.activityByXaml(xaml) as DynamicActivity; Activity activity = tool.getImplementation(dynamicActivity); Flowchart flowchar = activity as Flowchart; if (flowchar == null) { return(null); } //(3)===================================== //(3.1)---------------------------------------------------------------------------------- flowcharStruct.beginNode.DisplayName = "开始"; flowcharStruct.beginNode.id = "begin"; //(3.1.1) if (WorkflowViewStateService.GetViewState(flowchar)["ShapeLocation"] != null) { string ShapeLocation = WorkflowViewStateService.GetViewState(flowchar)["ShapeLocation"].ToString(); flowcharStruct.beginNode.ShapeSize.x = double.Parse(ShapeLocation.Split(sp)[0]); flowcharStruct.beginNode.ShapeSize.y = double.Parse(ShapeLocation.Split(sp)[1]); } //(3.1.2) if (WorkflowViewStateService.GetViewState(flowchar)["ShapeSize"] != null) { string ShapeSize = WorkflowViewStateService.GetViewState(flowchar)["ShapeSize"].ToString(); flowcharStruct.beginNode.ShapeSize.width = double.Parse(ShapeSize.Split(sp)[0]); flowcharStruct.beginNode.ShapeSize.height = double.Parse(ShapeSize.Split(sp)[1]); } //(3.1.3) if (WorkflowViewStateService.GetViewState(flowchar)["ConnectorLocation"] != null) { string ConnectorLocation = WorkflowViewStateService.GetViewState(flowchar)["ConnectorLocation"].ToString(); string[] points = ConnectorLocation.Split(sl); WorkflowStruct.line oneline = new WorkflowStruct.line(); oneline.beginNodeID = flowchar.Id; oneline.text = flowchar.DisplayName; foreach (string item in points) { double x = double.Parse(item.Split(sp)[0]); double y = double.Parse(item.Split(sp)[1]); oneline.connectorPoint.Add(new WorkflowStruct.point() { x = x, y = y }); } flowcharStruct.lineList.Add(oneline); } //(3.2)-------------------------------------------------------------------------------- foreach (FlowNode flowNode in flowchar.Nodes) { FlowStep flowStep = flowNode as FlowStep; if (flowStep != null) { WorkflowStruct.node node = new WorkflowStruct.node(); node.DisplayName = flowStep.Action.DisplayName; node.id = flowStep.Action.Id; //(3.2.1) if (WorkflowViewStateService.GetViewState(flowStep)["ShapeLocation"] != null) { string ShapeLocation = WorkflowViewStateService.GetViewState(flowStep)["ShapeLocation"].ToString(); node.ShapeSize.x = double.Parse(ShapeLocation.Split(sp)[0]); node.ShapeSize.y = double.Parse(ShapeLocation.Split(sp)[1]); } //(3.2.2) if (WorkflowViewStateService.GetViewState(flowStep)["ShapeSize"] != null) { string ShapeSize = WorkflowViewStateService.GetViewState(flowStep)["ShapeSize"].ToString(); node.ShapeSize.width = double.Parse(ShapeSize.Split(sp)[0]); node.ShapeSize.height = double.Parse(ShapeSize.Split(sp)[1]); } //(3.2.3) if (WorkflowViewStateService.GetViewState(flowStep).Count(p => p.Key == "ConnectorLocation") == 1) { string ConnectorLocation = WorkflowViewStateService.GetViewState(flowStep)["ConnectorLocation"].ToString(); string[] points = ConnectorLocation.Split(sl); WorkflowStruct.line line = new WorkflowStruct.line(); line.beginNodeID = flowStep.Action.Id; line.text = flowStep.Action.DisplayName; foreach (string item in points) { double x = double.Parse(item.Split(sp)[0]); double y = double.Parse(item.Split(sp)[1]); line.connectorPoint.Add(new WorkflowStruct.point() { x = x, y = y }); } flowcharStruct.lineList.Add(line); } flowcharStruct.nodeList.Add(node); } } //(3.3)------------------------------------------------------------- foreach (FlowNode flowNode in flowchar.Nodes) { FlowSwitch <string> flowSwitch = flowNode as FlowSwitch <string>; if (flowSwitch != null) { WorkflowStruct.node node = new WorkflowStruct.node(); node.DisplayName = flowSwitch.Expression.DisplayName; node.id = flowSwitch.Expression.Id; //(3.3.1) if (WorkflowViewStateService.GetViewState(flowSwitch)["ShapeLocation"] != null) { string ShapeLocation = WorkflowViewStateService.GetViewState(flowSwitch)["ShapeLocation"].ToString(); node.ShapeSize.x = double.Parse(ShapeLocation.Split(sp)[0]); node.ShapeSize.y = double.Parse(ShapeLocation.Split(sp)[1]); } //(3.3.2) if (WorkflowViewStateService.GetViewState(flowSwitch)["ShapeSize"] != null) { string ShapeSize = WorkflowViewStateService.GetViewState(flowSwitch)["ShapeSize"].ToString(); node.ShapeSize.width = double.Parse(ShapeSize.Split(sp)[0]); node.ShapeSize.height = double.Parse(ShapeSize.Split(sp)[1]); } //(3.3.3) if (WorkflowViewStateService.GetViewState(flowSwitch).Count(p => p.Key == "Default") == 1) { string ConnectorLocation = WorkflowViewStateService.GetViewState(flowSwitch)["Default"].ToString(); string[] points = ConnectorLocation.Split(sl); WorkflowStruct.line line = new WorkflowStruct.line(); line.beginNodeID = flowSwitch.Expression.Id; line.text = flowSwitch.Expression.DisplayName; foreach (string item in points) { double x = double.Parse(item.Split(sp)[0]); double y = double.Parse(item.Split(sp)[1]); line.connectorPoint.Add(new WorkflowStruct.point() { x = x, y = y }); } flowcharStruct.lineList.Add(line); } //(3.3.4) foreach (var v in flowSwitch.Cases) { System.Activities.Statements.FlowNode next = v.Value; System.Console.WriteLine(v.Key); string caseValue = v.Key + "Connector"; if (WorkflowViewStateService.GetViewState(flowSwitch).Count(p => p.Key == caseValue) == 1) { string ConnectorLocation = WorkflowViewStateService.GetViewState(flowSwitch)[caseValue].ToString(); string[] points = ConnectorLocation.Split(sl); WorkflowStruct.line line = new WorkflowStruct.line(); line.beginNodeID = flowSwitch.Expression.Id; line.text = flowSwitch.Expression.DisplayName; foreach (string item in points) { double x = double.Parse(item.Split(sp)[0]); double y = double.Parse(item.Split(sp)[1]); line.connectorPoint.Add(new WorkflowStruct.point() { x = x, y = y }); } flowcharStruct.lineList.Add(line); } } flowcharStruct.nodeList.Add(node); } } return(flowcharStruct); }//end
//This does a shallow copy of all the public properties with getter and setter. //It also replicates Xaml Attached properties. FlowNode CloneFlowElement(FlowNode flowElement, Predicate<AttachableMemberIdentifier> allowAttachableProperty = null) { Type flowElementType = flowElement.GetType(); FlowNode clonedObject = (FlowNode)Activator.CreateInstance(flowElementType); foreach (PropertyInfo propertyInfo in flowElementType.GetProperties()) { if (propertyInfo.GetGetMethod() != null && propertyInfo.GetSetMethod() != null) { propertyInfo.SetValue(clonedObject, propertyInfo.GetValue(flowElement, null), null); } } //Replicate any Xaml Attached Property. KeyValuePair<AttachableMemberIdentifier, object>[] attachedProperties = new KeyValuePair<AttachableMemberIdentifier, object>[AttachablePropertyServices.GetAttachedPropertyCount(flowElement)]; AttachablePropertyServices.CopyPropertiesTo(flowElement, attachedProperties, 0); foreach (KeyValuePair<AttachableMemberIdentifier, object> attachedProperty in attachedProperties) { if (allowAttachableProperty != null && !allowAttachableProperty(attachedProperty.Key)) { continue; } AttachablePropertyServices.SetProperty(clonedObject, attachedProperty.Key, attachedProperty.Value); } return clonedObject; }
// The logic is similar to UpdateCloneReferences. // the difference is in this function, we need to set reference by Property. void UpdateCloneReferenceByModelItem (FlowNode currentFlowElement, Dictionary<FlowNode, ModelItem> modelItems, Dictionary<FlowNode, FlowNode> clonedFlowElements) { if (typeof(FlowStep).IsAssignableFrom(currentFlowElement.GetType())) { FlowStep currentFlowStep = (FlowStep)currentFlowElement; FlowStep clonedFlowStep = (FlowStep)clonedFlowElements[currentFlowElement]; ModelItem modelItem = modelItems[clonedFlowStep]; FlowNode nextFlowElement = currentFlowStep.Next; if (nextFlowElement != null && clonedFlowElements.ContainsKey(nextFlowElement)) { modelItem.Properties["Next"].SetValue(clonedFlowElements[nextFlowElement]); } else { modelItem.Properties["Next"].SetValue(null); } } else if (typeof(FlowDecision).IsAssignableFrom(currentFlowElement.GetType())) { if (!modelItems.ContainsKey(currentFlowElement)) { Fx.Assert("Should not happen."); } FlowDecision currentFlowDecision = (FlowDecision)currentFlowElement; FlowDecision clonedFlowDecision = (FlowDecision)clonedFlowElements[currentFlowElement]; Fx.Assert(currentFlowDecision == clonedFlowDecision, "should not happen"); ModelItem modelItem = modelItems[currentFlowElement]; Fx.Assert(modelItem != null, "should not happen"); FlowNode trueElement = currentFlowDecision.True; FlowNode falseElement = currentFlowDecision.False; if (trueElement != null && clonedFlowElements.ContainsKey(trueElement)) { modelItem.Properties["True"].SetValue(clonedFlowElements[trueElement]); } else { modelItem.Properties["True"].SetValue(null); } if (falseElement != null && clonedFlowElements.ContainsKey(falseElement)) { modelItem.Properties["False"].SetValue(clonedFlowElements[falseElement]); } else { modelItem.Properties["False"].SetValue(null); } } else if (GenericFlowSwitchHelper.IsGenericFlowSwitch(currentFlowElement.GetType())) { GenericFlowSwitchHelper.ReferenceCopy(currentFlowElement.GetType().GetGenericArguments()[0], currentFlowElement, modelItems, clonedFlowElements); } else { Debug.Fail("Unknown FlowNode"); } }
//This method updates the clone of currentFlowElement to reference cloned FlowElements. void UpdateCloneReferences(FlowNode currentFlowElement, Dictionary<FlowNode, FlowNode> clonedFlowElements) { if (typeof(FlowStep).IsAssignableFrom(currentFlowElement.GetType())) { FlowStep currentFlowStep = (FlowStep)currentFlowElement; FlowStep clonedFlowStep = (FlowStep)clonedFlowElements[currentFlowElement]; FlowNode nextFlowElement = currentFlowStep.Next; if (nextFlowElement != null && clonedFlowElements.ContainsKey(nextFlowElement)) { clonedFlowStep.Next = clonedFlowElements[nextFlowElement]; } else { clonedFlowStep.Next = null; } } else if (typeof(FlowDecision).IsAssignableFrom(currentFlowElement.GetType())) { FlowDecision currentFlowDecision = (FlowDecision)currentFlowElement; FlowDecision clonedFlowDecision = (FlowDecision)clonedFlowElements[currentFlowElement]; FlowNode trueElement = currentFlowDecision.True; FlowNode falseElement = currentFlowDecision.False; if (trueElement != null && clonedFlowElements.ContainsKey(trueElement)) { clonedFlowDecision.True = clonedFlowElements[trueElement]; } else { clonedFlowDecision.True = null; } if (falseElement != null && clonedFlowElements.ContainsKey(falseElement)) { clonedFlowDecision.False = clonedFlowElements[falseElement]; } else { clonedFlowDecision.False = null; } } else if (GenericFlowSwitchHelper.IsGenericFlowSwitch(currentFlowElement.GetType())) { GenericFlowSwitchHelper.Copy(currentFlowElement.GetType().GetGenericArguments()[0], currentFlowElement, clonedFlowElements); } else { Debug.Fail("Unknown FlowNode"); } }
private static void GetNextNodeofFlowSwitch(IEnumerable<XElement> wfslElements, XElement currentXmlNode, FlowNode currentFlowNode, Dictionary<string, FlowNode> resultListNodes, Guid templateId) { try { var branches = GetXElementAttribute(currentXmlNode, "Branches"); ((FlowSwitch<string>)currentFlowNode).Expression = new VisualBasicValue<string> { ExpressionText = "DealWay" }; if (!string.IsNullOrEmpty(branches)) { var pairs = branches.Split(','); var dealWayCondtionCount = 0; foreach (var branch in pairs) { var dealWayName = branch.Split('$')[0]; var nextStateId = branch.Split('$')[1]; var dealformId = branch.Split('$')[2]; var resultiXmlNode = GetXmlNode(wfslElements, "UniqueID", nextStateId); var dealWayType = 0; foreach (XElement element in wfslElements) { if (GetXElementAttribute(element, "Title") == dealWayName && GetXElementAttribute(element, "PointStateId") == nextStateId) { int.TryParse(GetXElementAttribute(element, "DealWayType"), out dealWayType); } } if (resultiXmlNode != null) { dealWayCondtionCount++; var dealwayId = Guid.NewGuid(); if (!resultListNodes.ContainsKey(GetXElementAttribute(resultiXmlNode, "UniqueID"))) { var resultiXmlNodeType = GetXElementAttribute(resultiXmlNode, "WFSLElementType"); FlowNode nextFlowNode = new FlowStep(); if (resultiXmlNodeType == "WFSLActivity") { nextFlowNode = GetFlowStep(resultiXmlNode); if (dealWayCondtionCount == 1) { ((FlowSwitch<string>)currentFlowNode).Default = nextFlowNode; } else { // ((FlowSwitch<string>)currentFlowNode).Cases.Add(GetXElementAttribute(currentXmlNode,"DealWay" + i), nextFlowNode); ((FlowSwitch<string>)currentFlowNode).Cases.Add(dealwayId.ToString().ToUpper(), nextFlowNode); } SaveStateInfo(resultiXmlNode, templateId, false); if (!string.IsNullOrEmpty(GetXElementAttribute(resultiXmlNode, "DealWayName"))) { var resultDealWayType = 0; IEnumerable<XElement> resultDeal = from s in wfslElements where s.Attribute("Title").Value == GetXElementAttribute(resultiXmlNode, "DealWayName") && s.Attribute("PointStateId").Value == GetXElementAttribute(resultiXmlNode, "NextNodeID") select s; if (resultDeal != null && resultDeal.ToList<XElement>().Count > 0) { int.TryParse(GetXElementAttribute(resultDeal.ToList<XElement>()[0], "DealWayType"), out resultDealWayType); } SaveDealWay(new Guid(GetXElementAttribute(resultiXmlNode, "UniqueID")), Guid.NewGuid(), GetXElementAttribute(resultiXmlNode, "DealWayName"), resultiXmlNode, templateId, resultDealWayType); } resultListNodes.Add(GetXElementAttribute(resultiXmlNode, "UniqueID"), nextFlowNode); GetNextNode(wfslElements, resultiXmlNode, nextFlowNode, ref resultListNodes, templateId); } if (resultiXmlNodeType == "WFSLCondition") { nextFlowNode = new FlowSwitch<string>(); if (dealWayCondtionCount == 1) { ((FlowSwitch<string>)currentFlowNode).Default = nextFlowNode; } else { // ((FlowSwitch<string>)currentFlowNode).Cases.Add(GetXElementAttribute(currentXmlNode,"DealWay" + i), nextFlowNode); ((FlowSwitch<string>)currentFlowNode).Cases.Add(dealwayId.ToString().ToUpper(), nextFlowNode); } GetNextNode(wfslElements, resultiXmlNode, nextFlowNode, ref resultListNodes, templateId); } if (resultiXmlNodeType == "WFSLFinish") { nextFlowNode = GetEndNode(GetXElementAttribute(resultiXmlNode, "Title"), GetXElementAttribute(resultiXmlNode, "UniqueID")); if (dealWayCondtionCount == 1) { ((FlowSwitch<string>)currentFlowNode).Default = nextFlowNode; } else { //((FlowSwitch<string>)currentFlowNode).Cases.Add(GetXElementAttribute(currentXmlNode, "DealWay" + i), nextFlowNode); ((FlowSwitch<string>)currentFlowNode).Cases.Add(dealwayId.ToString().ToUpper(), nextFlowNode); } SaveStateInfo(resultiXmlNode, templateId, false); //保存流程结束 2012年9月21日 } SaveDealWay(dealwayId, dealWayName, currentXmlNode, templateId, dealformId, nextStateId, dealWayType); } else { if (dealWayCondtionCount == 1) { ((FlowSwitch<string>)currentFlowNode).Default = resultListNodes[GetXElementAttribute(resultiXmlNode, "UniqueID")]; } else { // ((FlowSwitch<string>)currentFlowNode).Cases.Add(GetXElementAttribute(currentXmlNode, "DealWay" + i), resultListNodes[GetXElementAttribute(resultiXmlNode, "UniqueID")]); ((FlowSwitch<string>)currentFlowNode).Cases.Add(dealwayId.ToString().ToUpper(), resultListNodes[GetXElementAttribute(resultiXmlNode, "UniqueID")]); } SaveDealWay(dealwayId, dealWayName, currentXmlNode, templateId, dealformId, nextStateId, dealWayType); } } } } } catch (Exception ex) { LogWritter.WriteSystemExceptionLog(ex); } }
/// <summary> /// 获取并发状态 /// </summary> /// <param name="wfslElements"></param> /// <param name="currentXmlNode"></param> /// <param name="currentFlowNode"></param> /// <param name="resultListNodes"></param> /// <param name="templateId"></param> /// <returns></returns> public static int GetNextNodeofActivityWithParallel(IEnumerable<XElement> wfslElements, XElement currentXmlNode, FlowNode currentFlowNode, Dictionary<string, FlowNode> resultListNodes, Guid templateId) { try { var num = 0; var para = new Parallel(); var flowNode = new FlowStep(); var endParallelNodeId = ""; var nextNodes = GetXElementAttribute(currentXmlNode, "NextNodes"); if (!string.IsNullOrEmpty(nextNodes)) { var nextNodeIds = nextNodes.Split(','); if (nextNodeIds.Length > 0) { var varable = new Variable<int>("branchesNum"); para.Variables.Add(varable); para.CompletionCondition = new VisualBasicValue<bool>() { ExpressionText = "branchesNum=ParallelBranchesCount" }; foreach (var nextNodeId in nextNodeIds) { num++; if (!resultListNodes.ContainsKey(nextNodeId)) //避免有回路,已经添加过的节点不用再添加,否则会死循环 { var nextXmlNode = GetXmlNode(wfslElements, "UniqueID", nextNodeId); var nextNodeType = GetXElementAttribute(nextXmlNode, "WFSLElementType"); endParallelNodeId = GetXElementAttribute(nextXmlNode, "NextNodeID"); if (nextNodeType == "WFSLActivity") { // var nextFlowNode = GetFlowStep(nextXmlNode); var nextAcitivity = GetAcitivityForParallel(nextXmlNode); var seq = new Sequence(); seq.DisplayName = "seq" + num; seq.Activities.Add(nextAcitivity); var assgin = new Assign(); assgin.DisplayName = "assgin" + num; assgin.Value = new InArgument<int>() { Expression = new VisualBasicValue<int> { ExpressionText = "branchesNum+1" } }; assgin.To = new OutArgument<int>() { Expression = new VisualBasicReference<int> { ExpressionText = "branchesNum" } }; seq.Activities.Add(assgin); para.Branches.Add(seq); // resultListNodes.Add(GetXElementAttribute(nextXmlNode, "UniqueID"), nextFlowNode); SaveStateInfo(nextXmlNode, templateId, false); } } //else //该节点已经包含在内,只需要画上连线即可,即表明关系即可 //{ // //((FlowStep)currentFlowNode).Next = resultListNodes[nextNodeId]; //} } } } var afterParalleXmlNode = GetXmlNode(wfslElements, "UniqueID", endParallelNodeId); var afterParalleWfNode = GetFlowStep(afterParalleXmlNode); flowNode.Action = para; flowNode.Next = afterParalleWfNode; ((FlowStep)currentFlowNode).Next = flowNode; resultListNodes.Add(Guid.Empty.ToString(), flowNode); GetNextNode(wfslElements, afterParalleXmlNode, afterParalleWfNode, ref resultListNodes, templateId); return num; } catch (Exception ex) { LogWritter.WriteSystemExceptionLog(ex); throw ex; } }
private static void GetNextNodeofActivityWithoutParallel(IEnumerable<XElement> wfslElements, XElement currentXmlNode, FlowNode currentFlowNode, Dictionary<string, FlowNode> resultListNodes, Guid templateId) { try { var nextNodeId = GetXElementAttribute(currentXmlNode, "NextNodeID"); if (!string.IsNullOrEmpty(nextNodeId)) { if (!resultListNodes.ContainsKey(nextNodeId)) //避免有回路,已经添加过的节点不用再添加,否则会死循环 { var nextXmlNode = GetXmlNode(wfslElements, "UniqueID", GetXElementAttribute(currentXmlNode, "NextNodeID")); var nextNodeType = GetXElementAttribute(nextXmlNode, "WFSLElementType"); if (nextNodeType == "WFSLActivity") { var nextFlowNode = GetFlowStep(nextXmlNode); ((FlowStep)currentFlowNode).Next = nextFlowNode; resultListNodes.Add(GetXElementAttribute(nextXmlNode, "UniqueID"), nextFlowNode); SaveStateInfo(nextXmlNode, templateId, false); if (!string.IsNullOrEmpty(GetXElementAttribute(nextXmlNode, "DealWayName"))) { var dealWayType = 0; IEnumerable<XElement> result = from s in wfslElements where s.Attribute("Title").Value == nextXmlNode.Attribute("DealWayName").Value && s.Attribute("PointStateId").Value == nextXmlNode.Attribute("NextNodeID").Value select s; if (result != null) { int.TryParse(GetXElementAttribute(result.ToList<XElement>()[0], "DealWayType"), out dealWayType); } SaveDealWay(new Guid(GetXElementAttribute(nextXmlNode, "UniqueID")), Guid.NewGuid(), GetXElementAttribute(nextXmlNode, "DealWayName"), nextXmlNode, templateId, dealWayType); } GetNextNode(wfslElements, nextXmlNode, nextFlowNode, ref resultListNodes, templateId); } if (nextNodeType == "WFSLCondition") { var nextFlowNode = new FlowSwitch<string>(); resultListNodes.Add(GetXElementAttribute(nextXmlNode, "UniqueID"), nextFlowNode); ((FlowStep)currentFlowNode).Next = nextFlowNode; GetNextNode(wfslElements, nextXmlNode, nextFlowNode, ref resultListNodes, templateId); } if (nextNodeType == "WFSLFinish") { var nextFlowNode = GetEndNode(GetXElementAttribute(nextXmlNode, "Title"), GetXElementAttribute(nextXmlNode, "UniqueID")); ((FlowStep)currentFlowNode).Next = nextFlowNode; SaveStateInfo(nextXmlNode, templateId, false); resultListNodes.Add(GetXElementAttribute(nextXmlNode, "UniqueID"), nextFlowNode); } } else //该节点已经包含在内,只需要画上连线即可,即表明关系即可 { ((FlowStep)currentFlowNode).Next = resultListNodes[nextNodeId]; } } } catch (Exception ex) { LogWritter.WriteSystemExceptionLog(ex); } }
/// <summary> /// 递归提取下一个节点 /// </summary> /// <param name="wfslElements"></param> /// <param name="currentXmlNode"></param> /// <param name="currentFlowNode"></param> /// <param name="resultListNodes"></param> /// <param name="templateId"></param> private static int GetNextNode(IEnumerable<XElement> wfslElements, XElement currentXmlNode, FlowNode currentFlowNode, ref Dictionary<string, FlowNode> resultListNodes, Guid templateId) { try { var num = 0; var wfslType = GetXElementAttribute(currentXmlNode, "WFSLElementType"); if (wfslType == "WFSLActivity") //当前节点是Activity,直接找下一个 { var nextnodeType = GetXElementAttribute(currentXmlNode, "NextNodeType"); if (!string.IsNullOrEmpty(nextnodeType)) { if (nextnodeType == "Activity") //下一个节点不是会签 { GetNextNodeofActivityWithoutParallel(wfslElements, currentXmlNode, currentFlowNode, resultListNodes, templateId); } else if (nextnodeType == "Parallel") //下一个节点会签 { num = GetNextNodeofActivityWithParallel(wfslElements, currentXmlNode, currentFlowNode, resultListNodes, templateId); } } } if (wfslType == "WFSLCondition") //当前节点是Condition,有好几个节点 { GetNextNodeofFlowSwitch(wfslElements, currentXmlNode, currentFlowNode, resultListNodes, templateId); } return num; } catch (Exception ex) { LogWritter.WriteSystemExceptionLog(ex); throw ex; } }
public void SetNextActivity(string name, FlowNode fNext) { _nextName = name; _activity.Next = fNext; }
internal bool Execute(NativeActivityContext context, CompletionCallback onCompleted, out FlowNode nextNode) { if (Next == null) { if (TD.FlowchartNextNullIsEnabled()) { TD.FlowchartNextNull(this.Owner.DisplayName); } } if (Action == null) { nextNode = Next; return(true); } else { context.ScheduleActivity(Action, onCompleted); nextNode = null; return(false); } }
internal void OnSwitchCompleted <T>(NativeActivityContext context, System.Activities.ActivityInstance completedInstance, T result) { FlowNode nextNode = (this.GetCurrentNode(context) as IFlowSwitch).GetNextNode(result); this.ExecuteNodeChain(context, nextNode, completedInstance); }