Example #1
0
        static void Main(string[] args)
        {
            Activity element = new ApprovalRouteAndExecute();

            WorkflowService shservice = new WorkflowService
            {
                Name = "ApprovalManager",
                ConfigurationName = "Microsoft.Samples.DocumentApprovalProcess.ApprovalManager.ApprovalManager",
                Body = element
            };

            // Cleanup old table of users from previous run
            UserManager.DeleteAllUsers();

            ServiceHost sh = new ServiceHost(typeof(Microsoft.Samples.DocumentApprovalProcess.ApprovalManager.SubscriptionManager), new Uri("http://localhost:8732/Design_Time_Addresses/service/SubscriptionManager/"));
            sh.Open();

            System.ServiceModel.Activities.WorkflowServiceHost wsh = new System.ServiceModel.Activities.WorkflowServiceHost(shservice, new Uri("http://localhost:8732/Design_TimeAddress/service/ApprovalManager"));

            // Setup persistence
            wsh.Description.Behaviors.Add(new SqlWorkflowInstanceStoreBehavior(ApprovalProcessDBConnectionString));
            WorkflowIdleBehavior wib = new WorkflowIdleBehavior();
            wib.TimeToUnload = new TimeSpan(0, 0, 2);
            wsh.Description.Behaviors.Add(wib);

            wsh.Open();

            Console.WriteLine("All services ready, press any key to close the services and exit.");

            Console.ReadLine();
            wsh.Close();
            sh.Close();
        }
Example #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting up...");
            CreateService();

            Uri address = new Uri(Constants.ServiceBaseAddress);

            System.ServiceModel.Activities.WorkflowServiceHost host = new System.ServiceModel.Activities.WorkflowServiceHost(service, address);

            try
            {
                Console.WriteLine("Opening service...");
                host.Open();

                Console.WriteLine("Service is listening on {0}...", address);
                Console.WriteLine("To terminate press ENTER");
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Service treminated with exception {0}", ex.ToString());
            }
            finally
            {
                host.Close();
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            Activity element = new ApprovalRouteAndExecute();

            WorkflowService shservice = new WorkflowService
            {
                Name = "ApprovalManager",
                ConfigurationName = "Microsoft.Samples.DocumentApprovalProcess.ApprovalManager.ApprovalManager",
                Body = element
            };

            // Cleanup old table of users from previous run
            UserManager.DeleteAllUsers();

            ServiceHost sh = new ServiceHost(typeof(Microsoft.Samples.DocumentApprovalProcess.ApprovalManager.SubscriptionManager), new Uri("http://localhost:8732/Design_Time_Addresses/service/SubscriptionManager/"));

            sh.Open();

            System.ServiceModel.Activities.WorkflowServiceHost wsh = new System.ServiceModel.Activities.WorkflowServiceHost(shservice, new Uri("http://localhost:8732/Design_TimeAddress/service/ApprovalManager"));

            // Setup persistence
            wsh.Description.Behaviors.Add(new SqlWorkflowInstanceStoreBehavior(ApprovalProcessDBConnectionString));
            WorkflowIdleBehavior wib = new WorkflowIdleBehavior();

            wib.TimeToUnload = new TimeSpan(0, 0, 2);
            wsh.Description.Behaviors.Add(wib);

            wsh.Open();

            Console.WriteLine("All services ready, press any key to close the services and exit.");

            Console.ReadLine();
            wsh.Close();
            sh.Close();
        }
Example #4
0
        static void Main(string[] args)
        {
            // Open the config file and get the name for this branch
            // and its network address
            Configuration config = ConfigurationManager
                                   .OpenExeConfiguration(ConfigurationUserLevel.None);
            AppSettingsSection app =
                (AppSettingsSection)config.GetSection("appSettings");

            string adr = app.Settings["Address"].Value;

            Console.WriteLine(app.Settings["Branch Name"].Value);

            // Create a service to handle incoming requests
            WorkflowService service = new WorkflowService
            {
                Name      = "LibraryReservation",
                Body      = new ProcessRequest(),
                Endpoints =
                {
                    new Endpoint
                    {
                        ServiceContractName = "ILibraryReservation",
                        AddressUri          = new Uri("http://localhost:" + adr +
                                                      "/LibraryReservation"),
                        Binding = new BasicHttpBinding(),
                    }
                }
            };

            // Create a WorkflowServiceHost that listens for incoming messages
            System.ServiceModel.Activities.WorkflowServiceHost wsh =
                new System.ServiceModel.Activities.WorkflowServiceHost(service);

            wsh.Open();

            Console.WriteLine
                ("Waiting for requests, press ENTER to send a request.");
            Console.ReadLine();

            // Create dictionary with input arguments for the workflow
            IDictionary <string, object> input = new Dictionary <string, object>
            {
                { "Title", "Gone with the Wind" },
                { "Author", "Margaret Mitchell" },
                { "ISBN", "9781416548898" }
            };

            // Invoke the SendRequest workflow
            IDictionary <string, object> output =
                WorkflowInvoker.Invoke(new SendRequest(), input);
            ReservationResponse resp = (ReservationResponse)output["Response"];

            // Display the response
            Console.WriteLine("Response received from the {0} branch",
                              resp.Provider.BranchName);

            Console.WriteLine();
            Console.WriteLine("Press ENTER to exit");
            Console.ReadLine();

            // Close the WorkflowServiceHost
            wsh.Close();
        }
Example #5
0
 private void Window_Unloaded(object sender, RoutedEventArgs e)
 {
     // Close the WorkflowServiceHost
     _wsh.Close();
 }
Example #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting up...");
            CreateService();

            Uri address = new Uri(Constants.ServiceBaseAddress);
            System.ServiceModel.Activities.WorkflowServiceHost host = new System.ServiceModel.Activities.WorkflowServiceHost(service, address);

            try
            {
                Console.WriteLine("Opening service...");
                host.Open();

                Console.WriteLine("Service is listening on {0}...", address);
                Console.WriteLine("To terminate press ENTER");
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Service treminated with exception {0}", ex.ToString());
            }
            finally
            {
                host.Close();
            }
        }