private static void CreateService() { Variable<Expense> expense = new Variable<Expense> { Name = "expense" }; Variable<VendorRequest> vendor = new Variable<VendorRequest> { Name = "vendor" }; Variable<PurchaseOrder> po = new Variable<PurchaseOrder> { Name = "po" }; Variable<bool> reply = new Variable<bool> { Name = "reply" }; Variable<bool> replyPO = new Variable<bool> { Name = "reply" }; Variable<VendorResponse> replyVendor = new Variable<VendorResponse> { Name = "reply" }; Parallel workflow = new Parallel { Branches = { GetApproveExpense(expense, reply), GetApprovePO(po, replyPO), GetApprovedVendor(vendor, replyVendor), } }; service = new WorkflowService { Name = "FinanceService", Body = workflow, Endpoints = { new Endpoint { ServiceContractName="FinanceService", AddressUri = new Uri(Constants.EchoServiceAddress), Binding = new BasicHttpBinding(), } } }; }
private static Activity OutputToConsoleParallel(string v1, string v2) { Console.ForegroundColor = ConsoleColor.Green; var p = new System.Activities.Statements.Parallel { Branches = { new WriteLine { Text = v1 }, new WriteLine { Text = v2 } } }; return(p); }
/// <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; } }
public Activity Create(DependencyObject target) { var parallel = new Parallel(); parallel.DisplayName = ""; return parallel; }
public MyParallelStep(XElement e) { _elem = e; _activity = new Parallel(); _activity.DisplayName = _elem.Attribute("name").Value; }