예제 #1
0
        static void CreateClientWorkflow()
        {
            Variable<string> message = new Variable<string>("message", "Hello!");
            Variable<string> result = new Variable<string> { Name = "result" };

            Endpoint endpoint = new Endpoint
            {
                AddressUri = new Uri(Microsoft.Samples.WorkflowServicesSamples.Common.Constants.ServiceBaseAddress),
                Binding = new BasicHttpBinding(),
            };

            Send requestEcho = new Send
            {
                ServiceContractName = XName.Get("Echo", "http://tempuri.org/"),
                Endpoint = endpoint,
                OperationName = "Echo",
                //parameters for send
                Content = new SendParametersContent
                {
                    Parameters =
                        {
                            { "message", new InArgument<string>(message) }
                        }
                }
            };
            workflow = new CorrelationScope
            {
                Body = new Sequence
                {
                    Variables = { message, result },
                    Activities =
                    {
                        new WriteLine {
                            Text = new InArgument<string>("Client is ready!")
                        },
                        requestEcho,

                        new WriteLine {
                            Text = new InArgument<string>("Message sent: Hello!")
                        },

                        new ReceiveReply
                        {
                            Request = requestEcho,
                            //parameters for the reply
                            Content = new ReceiveParametersContent
                            {
                                Parameters =
                                {
                                    { "echo", new OutArgument<string>(result) }
                                }
                            }
                        },
                        new WriteLine {
                            Text = new InArgument<string>(env => "Message received: "+result.Get(env))
                        }
                    }
                }
            };
        }
예제 #2
0
        static Activity GetClientWorkflow()
        {
            Variable<PurchaseOrder> po = new Variable<PurchaseOrder>();
            Variable<OrderStatus> orderStatus = new Variable<OrderStatus>();

            Endpoint clientEndpoint = new Endpoint
            {
                Binding = Constants.Binding,
                AddressUri = new Uri(Constants.ServiceAddress)
            };

            Send submitPO = new Send
            {
                Endpoint = clientEndpoint,
                ServiceContractName = Constants.POContractName,
                OperationName = Constants.SubmitPOName,
                Content = SendContent.Create(new InArgument<PurchaseOrder>(po))
            };

            return new Sequence
            {
                Variables = { po, orderStatus },
                Activities =
                {
                    new WriteLine { Text = "Sending order for 150 widgets." },
                    new Assign<PurchaseOrder> { To = po, Value = new InArgument<PurchaseOrder>( (e) => new PurchaseOrder() { PartName = "Widget", Quantity = 150 } ) },
                    new CorrelationScope
                    {
                        Body = new Sequence
                        {
                            Activities =
                            {
                                submitPO,
                                new ReceiveReply
                                {
                                    Request = submitPO,
                                    Content = ReceiveContent.Create(new OutArgument<int>( (e) => po.Get(e).Id ))
                                }
                            }
                        }
                    },
                    new WriteLine { Text = new InArgument<string>( (e) => string.Format("Got PoId: {0}", po.Get(e).Id) ) },
                    new Assign<OrderStatus> { To = orderStatus, Value = new InArgument<OrderStatus>( (e) => new OrderStatus() { Id = po.Get(e).Id, Confirmed = true }) },
                    new Send
                    {
                        Endpoint = clientEndpoint,
                        ServiceContractName = Constants.POContractName,
                        OperationName = Constants.ConfirmPurchaseOrder,
                        Content = SendContent.Create(new InArgument<OrderStatus>(orderStatus))
                    },
                    new WriteLine { Text = "The order was confirmed." },
                    new WriteLine { Text = "Client completed." }
                }
            };
        }
예제 #3
0
        static void CreateClientWorkflow()
        {
            Variable<string> message = new Variable<string>("message", "client");
            Variable<string> result = new Variable<string> { Name = "result" };

            Endpoint endpoint = new Endpoint
            {
                AddressUri = new Uri(Common.Constants.ServiceBaseAddress),
                Binding = new BasicHttpBinding(),
            };

            Send requestEcho = new Send
            {
                ServiceContractName = XName.Get("Echo", "http://tempuri.org/"),
                Endpoint = endpoint,
                OperationName = "Echo",
                Content = new SendParametersContent
                {
                    Parameters =
                        {
                            { "message", new InArgument<string>(message) }
                        }
                }
            };
            workflow = new CorrelationScope
            {
                Body = new Sequence
                {
                    Variables = { message, result },
                    Activities =
                    {
                        new WriteLine {
                            Text = new InArgument<string>("Hello")
                        },
                        requestEcho,
                        new ReceiveReply
                        {
                            Request = requestEcho,
                            Content = new ReceiveParametersContent
                            {
                                Parameters =
                                {
                                    { "echo", new OutArgument<string>(result) }
                                }
                            }
                        },
                        new WriteLine {
                            Text = new InArgument<string>(result)
                        }
                    }
                }
            };
        }
예제 #4
0
 static void CreateClientWorkflow()
 {
     Endpoint endpoint = new Endpoint
     {
         AddressUri = new Uri(Microsoft.Samples.WorkflowServicesSamples.Common.Constants.EchoServiceAddress),
         Binding = new BasicHttpBinding(),
     };
     workflow = new CorrelationScope
     {
         Body = new Sequence
         {
             Activities =
             {
                 ExpenseRequest(endpoint),
                 PurchaseOrderRequest(endpoint),
                 VendorApprovalRequest(endpoint)
             }
         }
     };
 }
예제 #5
0
        static Activity GetClientWorkflow()
        {
            Variable<PurchaseOrder> po = new Variable<PurchaseOrder>();
            Variable<Customer> customer = new Variable<Customer>();

            Endpoint clientEndpoint = new Endpoint
            {
                Binding = Constants.Binding,
                AddressUri = new Uri(Constants.ServiceAddress)
            };

            Send submitPO = new Send
            {
                Endpoint = clientEndpoint,
                ServiceContractName = Constants.POContractName,
                OperationName = Constants.SubmitPOName,
                Content = SendContent.Create(new InArgument<PurchaseOrder>(po))
            };

            return new Sequence
            {
                Variables = { po, customer },
                Activities =
                {
                    new Assign<PurchaseOrder>
                    {
                        To = po,
                        Value = new InArgument<PurchaseOrder>( (e) => new PurchaseOrder() { PartName = "Widget", Quantity = 150 } )
                    },
                    new Assign<Customer>
                    {
                        To = customer,
                        Value = new InArgument<Customer>( (e) => new Customer() { Id = 12345678, Name = "John Smith" } )
                    },
                    new WriteLine { Text = new InArgument<string>( (e) => string.Format("Submitting new PurchaseOrder for {0} {1}s", po.Get(e).Quantity, po.Get(e).PartName) ) },
                    new CorrelationScope
                    {
                        Body = new Sequence
                        {
                            Activities =
                            {
                                submitPO,
                                new ReceiveReply
                                {
                                    Request = submitPO,
                                    Content = ReceiveContent.Create(new OutArgument<int>( (e) => po.Get(e).Id ))
                                }
                            }
                        }
                    },
                    new WriteLine { Text = new InArgument<string>( (e) => string.Format("Received ID for new PO: {0}", po.Get(e).Id) ) },
                    new Assign<int> { To = new OutArgument<int>( (e) => po.Get(e).Quantity ), Value = 250 },
                    new WriteLine { Text = "Updated PO with new quantity: 250.  Resubmitting updated PurchaseOrder based on POId." },
                    new Send
                    {
                        Endpoint = clientEndpoint,
                        ServiceContractName = Constants.POContractName,
                        OperationName = Constants.UpdatePOName,
                        Content = SendContent.Create(new InArgument<PurchaseOrder>(po))
                    },
                    new Assign<int>
                    {
                        To = new OutArgument<int>( (e) => po.Get(e).CustomerId ),
                        Value = new InArgument<int>( (e) => customer.Get(e).Id )
                    },
                    new WriteLine { Text = "Updating customer data based on CustomerId." },
                    new Send
                    {
                        Endpoint = clientEndpoint,
                        ServiceContractName = Constants.POContractName,
                        OperationName = Constants.AddCustomerInfoName,
                        Content = SendContent.Create(new InArgument<PurchaseOrder>(po))
                    },
                    new Send
                    {
                        Endpoint = clientEndpoint,
                        ServiceContractName = Constants.POContractName,
                        OperationName = Constants.UpdateCustomerName,
                        Content = SendContent.Create(new InArgument<Customer>(customer))
                    },
                    new WriteLine { Text = "Client completed." }
                }
            };
        }
예제 #6
0
        static Sequence ExpenseRequest(Endpoint endpoint)
        {
            Variable<Expense> mealExpense = new Variable<Expense>
            {
                Name = "mealExpense",
            };
            Variable<bool> result = new Variable<bool>
            {
                Name = "result"
            };

            Send approveExpense = new Send
            {
                ServiceContractName = XName.Get("FinanceService", "http://tempuri.org/"),
                Endpoint = endpoint,
                OperationName = "ApproveExpense",
                Content = SendContent.Create(new InArgument<Expense>(mealExpense))
            };
            approveExpense.KnownTypes.Add(typeof(Travel));
            approveExpense.KnownTypes.Add(typeof(Meal));

            Sequence workflow = new Sequence
            {
                Variables = { mealExpense, result },
                Activities =
                    {
                        new Assign<Expense>
                        {
                           Value = new InArgument<Expense>( (e) => new Meal { Amount = 50, Location = "Redmond", Vendor = "KFC" }),
                           To = new OutArgument<Expense>(mealExpense)
                        },
                        new WriteLine
                        {
                            Text = new InArgument<string>("Hello")
                        },
                        approveExpense,
                        new ReceiveReply
                        {
                            Request = approveExpense,
                            Content = ReceiveContent.Create(new OutArgument<bool>(result))
                        },

                        new If
                        {
                           Condition = new InArgument<bool> (result),
                           Then =
                                new WriteLine
                                {
                                    Text = new InArgument<string>("Expense Approved")
                                },
                           Else =
                                new WriteLine
                                {
                                    Text = new InArgument<string>("Expense Cannot be Approved")
                                },
                        },

                    }
            };
            return workflow;
        }
예제 #7
0
        static Sequence VendorApprovalRequest(Endpoint endpoint)
        {
            Variable<VendorRequest> vendor = new Variable<VendorRequest>
            {
                Name = "vendor",
            };
            Variable<VendorResponse> result = new Variable<VendorResponse>
            {
                Name = "result"
            };

            Send approvedVendor = new Send
            {
                ServiceContractName = XName.Get("FinanceService", "http://tempuri.org/"),
                Endpoint = endpoint,
                OperationName = "ApprovedVendor",
                Content = SendContent.Create(new InArgument<VendorRequest>(vendor)),
            };

            Sequence workflow = new Sequence
            {
                Variables = { vendor, result },
                Activities =
                    {
                        new Assign<VendorRequest>
                        {
                           Value = new InArgument<VendorRequest>( (e) => new VendorRequest { Name = "Vendor1", requestingDepartment = "HR" }),
                           To = new OutArgument<VendorRequest>(vendor)
                        },
                        new WriteLine
                        {
                            Text = new InArgument<string>("Hello")
                        },
                        approvedVendor,
                        new ReceiveReply
                        {
                            Request = approvedVendor,
                            Content = ReceiveContent.Create(new OutArgument<VendorResponse>(result))
                        },

                        new If
                        {
                           Condition = new InArgument<bool> (env => result.Get(env).isPreApproved),
                           Then =
                                new WriteLine
                                {
                                    Text = new InArgument<string>("Vendor Approved")
                                },
                           Else =
                                new WriteLine
                                {
                                    Text = new InArgument<string>("Vendor is not Approved")
                                },
                        },

                    }
            };
            return workflow;
        }
예제 #8
0
        static Sequence PurchaseOrderRequest(Endpoint endpoint)
        {
            Variable<PurchaseOrder> po = new Variable<PurchaseOrder>
            {
                Name = "po"
            };
            Variable<bool> result = new Variable<bool>
            {
                Name = "result"
            };

            Send approveExpense = new Send
            {
                ServiceContractName = XName.Get("FinanceService", "http://tempuri.org/"),
                Endpoint = endpoint,
                OperationName = "ApprovePurchaseOrder",
                Content = SendContent.Create(new InArgument<PurchaseOrder>(po)),
                SerializerOption = SerializerOption.XmlSerializer
            };

            Sequence workflow = new Sequence
            {
                Variables = { po, result },
                Activities =
                    {
                        new Assign<PurchaseOrder>
                        {
                           Value = new InArgument<PurchaseOrder>( (e) => new PurchaseOrder { RequestedAmount = 500, Description = "New PC" }),
                           To = new OutArgument<PurchaseOrder>(po)
                        },
                        new WriteLine
                        {
                            Text = new InArgument<string>("Hello")
                        },
                        approveExpense,
                        new ReceiveReply
                        {
                            Request = approveExpense,
                            Content = ReceiveContent.Create(new OutArgument<bool>(result))
                        },

                        new If
                        {
                           Condition = new InArgument<bool> (result),
                           Then =
                                new WriteLine
                                {
                                    Text = new InArgument<string>("Purchase order Approved")
                                },
                           Else =
                                new WriteLine
                                {
                                    Text = new InArgument<string>("Purchase order Cannot be Approved")
                                },
                        },

                    }
            };
            return workflow;
        }