protected override void Execute(CodeActivityContext context)
        {
            // Open the config file and get the Request Address
            Configuration config = ConfigurationManager
                                   .OpenExeConfiguration(ConfigurationUserLevel.None);
            AppSettingsSection app =
                (AppSettingsSection)config.GetSection("appSettings");

            // Create a ReservationRequest class and populate
            // it with the input arguments
            ReservationRequest r = new ReservationRequest
                                   (
                Title.Get(context),
                Author.Get(context),
                ISBN.Get(context),
                new Branch
            {
                BranchName = app.Settings["Branch Name"].Value,
                BranchID   = new Guid(app.Settings["ID"].Value),
                Address    = app.Settings["Address"].Value
            }
                                   );

            // Store the request in the OutArgument
            Request.Set(context, r);

            // Store the address in the OutArgument
            RequestAddress.Set(context, app.Settings["Request Address"].Value);
        }
Exemplo n.º 2
0
        protected override void Execute(CodeActivityContext context)
        {
            string author = Author.Get(context);
            string title  = Title.Get(context);
            string isbn   = ISBN.Get(context);

            BookInfo[] l = new BookInfo[4];

            l[0] = new BookInfo(title, author, isbn, "Available");
            l[1] = new BookInfo(title, author, isbn, "CheckedOut");
            l[2] = new BookInfo(title, author, isbn, "Missing");
            l[3] = new BookInfo(title, author, isbn, "Available");
            BookList.Set(context, l);
        }
Exemplo n.º 3
0
        public SendRequest()
        {
            // Define the variables used by this workflow
            Variable <ReservationRequest> request =
                new Variable <ReservationRequest> {
                Name = "request"
            };
            Variable <string> requestAddress =
                new Variable <string> {
                Name = "RequestAddress"
            };
            Variable <bool> reserved = new Variable <bool> {
                Name = "Reserved"
            };

            // Define the SendRequest workflow
            this.Implementation = () => new Sequence
            {
                DisplayName = "SendRequest",
                Variables   = { request, requestAddress, reserved },
                Activities  =
                {
                    new CreateRequest
                    {
                        Title   = new InArgument <string>(env => Title.Get(env)),
                        Author  = new InArgument <string>(env => Author.Get(env)),
                        ISBN    = new InArgument <string>(env => ISBN.Get(env)),
                        Request = new OutArgument <ReservationRequest>
                                      (env => request.Get(env)),
                        RequestAddress = new OutArgument <string>
                                             (env => requestAddress.Get(env))
                    },
                    new Send
                    {
                        OperationName       = "RequestBook",
                        ServiceContractName = "ILibraryReservation",
                        Content             = SendContent.Create
                                                  (new InArgument <ReservationRequest>(request)),
                        EndpointAddress = new InArgument <Uri>
                                              (env => new Uri("http://localhost:" +
                                                              requestAddress.Get(env) + "/ClientService")),
                        Endpoint = new Endpoint
                        {
                            Binding = new BasicHttpBinding()
                        },
                    },
                    new WriteLine
                    {
                        Text = new InArgument <string>
                                   (env => "Request sent; waiting for response"),
                        TextWriter = new InArgument <TextWriter> (env => Writer.Get(env))
                    },
                    new WaitForInput <ReservationResponse>
                    {
                        BookmarkName = "GetResponse",
                        Input        = new OutArgument <ReservationResponse>
                                           (env => Response.Get(env))
                    },
                    new WriteLine
                    {
                        Text = new InArgument <string>
                                   (env => "Response received from " +
                                   Response.Get(env).Provider.BranchName + " [" +
                                   Response.Get(env).Reserved.ToString() + "]"),
                        TextWriter = new InArgument <TextWriter> (env => Writer.Get(env))
                    },
                }
            };
        }
Exemplo n.º 4
0
        public SendRequest()
        {
            // Define the variables used by this workflow
            Variable <ReservationRequest> request =
                new Variable <ReservationRequest> {
                Name = "request"
            };
            Variable <string> requestAddress =
                new Variable <string> {
                Name = "RequestAddress"
            };

            // Define the Send activity
            Send submitRequest = new Send
            {
                ServiceContractName = "ILibraryReservation",
                EndpointAddress     = new InArgument <Uri>(env => new Uri("http://localhost:" + requestAddress.Get(env) + "/LibraryReservation")),
                Endpoint            = new Endpoint
                {
                    Binding = new BasicHttpBinding()
                },
                OperationName = "RequestBook",
                Content       = SendContent.Create(new InArgument <ReservationRequest>(request))
            };

            // Define the SendRequest workflow
            this.Implementation = () => new Sequence
            {
                DisplayName = "SendRequest",
                Variables   = { request, requestAddress },
                Activities  =
                {
                    new CreateRequest
                    {
                        Title   = new InArgument <string>(env => Title.Get(env)),
                        Author  = new InArgument <string>(env => Author.Get(env)),
                        ISBN    = new InArgument <string>(env => ISBN.Get(env)),
                        Request = new OutArgument <ReservationRequest>
                                      (env => request.Get(env)),
                        RequestAddress = new OutArgument <string>
                                             (env => requestAddress.Get(env))
                    },
                    new CorrelationScope
                    {
                        Body = new Sequence
                        {
                            Activities =
                            {
                                submitRequest,
                                new WriteLine
                                {
                                    Text = new InArgument <string>
                                               (env => "Request sent; waiting for response"),
                                },
                                new ReceiveReply
                                {
                                    Request = submitRequest,
                                    Content = ReceiveContent.Create
                                                  (new OutArgument <ReservationResponse>
                                                      (env => Response.Get(env)))
                                }
                            }
                        }
                    },
                    new WriteLine
                    {
                        Text = new InArgument <string>
                                   (env => "Response received from " +
                                   Response.Get(env).Provider.BranchName),
                    },
                }
            };
        }