private static ActivityInfo[] GetCorrelationScopeChildren(CorrelationScope activity) { var children = new List <ActivityInfo>(); if (activity.Body != null) { children.Add(new ActivityInfo(activity.Body, activity, "Body")); } return(children.ToArray()); }
private static ActivityView BuildCorrelationScopeView(CorrelationScope source) { string activityId = ObjectIdManager.GetId(source); string correlatesWidth = ExpressionConvert.ToString(source.CorrelatesWith); var view = new CorrelationScopeView(activityId) { ActivityName = source.DisplayName, CorrelatesWith = correlatesWidth, }; return(view); }
private static Activity GetApprovePO(Variable <PurchaseOrder> po, Variable <bool> replyPO) { Receive approvePO = new Receive { OperationName = "ApprovePurchaseOrder", CanCreateInstance = true, ServiceContractName = "FinanceService", SerializerOption = SerializerOption.XmlSerializer, Content = ReceiveContent.Create(new OutArgument <PurchaseOrder>(po)) }; Activity workflow = new CorrelationScope() { Body = new Sequence { Variables = { po, replyPO }, Activities = { approvePO, new WriteLine { Text = new InArgument <string>(env => ("Purchase order approval request received")) }, new If { Condition = new InArgument <bool> (env => (po.Get(env).RequestedAmount <= 100)), Then = new Assign <bool> { Value = true, To = new OutArgument <bool>(replyPO) }, Else = new Assign <bool> { Value = false, To = new OutArgument <bool>(replyPO) }, }, new If { Condition = new InArgument <bool> (replyPO), Then = new WriteLine { Text = new InArgument <string>("Purchase Order Approved") }, Else = new WriteLine { Text = new InArgument <string>("Purchase Order Cannot be Approved") }, }, new SendReply { Request = approvePO, Content = SendContent.Create(new InArgument <bool>(replyPO)), }, } } }; return(workflow); }
private static Activity GetApproveExpense(Variable <Expense> expense, Variable <bool> reply) { Receive approveExpense = new Receive { OperationName = "ApproveExpense", CanCreateInstance = true, ServiceContractName = "FinanceService", SerializerOption = SerializerOption.DataContractSerializer, Content = ReceiveContent.Create(new OutArgument <Expense>(expense)) }; approveExpense.KnownTypes.Add(typeof(Travel)); approveExpense.KnownTypes.Add(typeof(Meal)); Activity workflow = new CorrelationScope() { Body = new Sequence { Variables = { expense, reply }, Activities = { approveExpense, new WriteLine { Text = new InArgument <string>(env => ("Expense approval request received")) }, new If { Condition = new InArgument <bool> (env => (expense.Get(env).Amount <= 100)), Then = new Assign <bool> { Value = true, To = new OutArgument <bool>(reply) }, Else = new Assign <bool> { Value = false, To = new OutArgument <bool>(reply) }, }, new If { Condition = new InArgument <bool> (reply), Then = new WriteLine { Text = new InArgument <string>("Expense Approved") }, Else = new WriteLine { Text = new InArgument <string>("Expense Cannot be Approved") }, }, new SendReply { Request = approveExpense, Content = SendContent.Create(new InArgument <bool>(reply)), }, }, } }; return(workflow); }
private static Activity GetApprovedVendor(Variable <VendorRequest> vendor, Variable <VendorResponse> replyVendor) { Receive approvedVendor = new Receive { OperationName = "ApprovedVendor", CanCreateInstance = true, ServiceContractName = "FinanceService", Content = ReceiveContent.Create(new OutArgument <VendorRequest>(vendor)) }; Activity workflow = new CorrelationScope() { Body = new Sequence { Variables = { vendor, replyVendor }, Activities = { approvedVendor, new WriteLine { Text = new InArgument <string>(env => ("Query for approved vendor received")) }, new If { Condition = new InArgument <bool> (env => ((vendor.Get(env).requestingDepartment == "Finance")) || Constants.vendors.Contains(vendor.Get(env).Name)), Then = new Assign <VendorResponse> { Value = new InArgument <VendorResponse>((e) => new VendorResponse { isPreApproved = true }), To = new OutArgument <VendorResponse>(replyVendor) }, Else = new Assign <VendorResponse> { Value = new InArgument <VendorResponse>((e) => new VendorResponse { isPreApproved = false }), To = new OutArgument <VendorResponse>(replyVendor) }, }, new If { Condition = new InArgument <bool> (env => replyVendor.Get(env).isPreApproved), Then = new WriteLine { Text = new InArgument <string>("Vendor is pre-approved") }, Else = new WriteLine { Text = new InArgument <string>("Vendor is not pre-approved") }, }, new SendReply { Request = approvedVendor, Content = SendContent.Create(new InArgument <VendorResponse>(replyVendor)), }, } } }; return(workflow); }