Exemplo n.º 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();
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 3
0
        static void Main()
        {
            Activity workflow = CreateWorkflow();

            using (System.ServiceModel.Activities.WorkflowServiceHost host = new System.ServiceModel.Activities.WorkflowServiceHost(workflow, new Uri(Program.baseAddress)))
            {
                ExternalDataExchangeService dataExchangeService = new ExternalDataExchangeService();
                TaskService taskService = new TaskService();
                dataExchangeService.AddService(taskService);

                WorkflowRuntimeEndpoint workflowRuntimeEndpoint = new WorkflowRuntimeEndpoint();
                workflowRuntimeEndpoint.AddService(dataExchangeService);
                host.AddServiceEndpoint(workflowRuntimeEndpoint);

                host.AddDefaultEndpoints();
                host.Open();

                IWorkflow proxy = ChannelFactory <IWorkflow> .CreateChannel(new BasicHttpBinding(), new EndpointAddress(Program.baseAddress));

                proxy.Start();

                Console.WriteLine("Workflow starting, press enter when workflow completes.\n");
                Console.ReadLine();
            }
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
0
 public OpenAsyncResult(WorkflowServiceHost host, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     this.timeoutHelper = new TimeoutHelper(timeout);
     this.host          = host;
     if (this.HostOpen())
     {
         base.Complete(true);
     }
 }
        public WorkflowDefinitionProvider(WorkflowService workflowService, WorkflowServiceHost wfsh)
        {
            Fx.Assert(workflowService != null, "workflowService cannot be null!");
            Fx.Assert(wfsh != null, "wfsh cannot be null!");

            this.wfsh = wfsh;
            this.defaultWorkflowService = workflowService;
            this.definitionCollection   = new Dictionary <WorkflowIdentityKey, WorkflowService>();
            this.supportedVersions      = new WorkflowServiceVersionsCollection(this);
        }
        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 WorkflowSe



        }
        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 WorkflowSe
        }
Exemplo n.º 9
0
        private void SetupHost()
        {
            WorkflowService service = new WorkflowService
            {
                Name      = "LeadResponse",
                Body      = new WorkAssignment(),
                Endpoints =
                {
                    new Endpoint
                    {
                        ServiceContractName = "CreateAssignment",
                        AddressUri          = new Uri("http://localhost/CreateAssignment"),
                        Binding             = new BasicHttpBinding(),
                    }
                }
            };

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

            SqlWorkflowInstanceStoreBehavior instanceStoreBehavior
                = new SqlWorkflowInstanceStoreBehavior(_connectionString);

            instanceStoreBehavior.InstanceCompletionAction
                = InstanceCompletionAction.DeleteAll;
            instanceStoreBehavior.InstanceLockedExceptionAction
                = InstanceLockedExceptionAction.AggressiveRetry;
            _wsh.Description.Behaviors.Add(instanceStoreBehavior);

            WorkflowIdleBehavior wib = new WorkflowIdleBehavior();

            wib.TimeToUnload = TimeSpan.FromMilliseconds(100);
            _wsh.Description.Behaviors.Add(wib);

            _wsh.Description.Behaviors.Add
                (new DBExtensionBehavior(_connectionString));
            _wsh.Description.Behaviors.Add
                (new PersistAssignmentBehavior(_connectionString));

            // Open the service so it will listen for messages
            _wsh.Open();
        }
        internal void PopulateExtensions(WorkflowServiceHost host, string baseUri)
        {
            Fx.Assert(host != null, "WorkflowServiceHost parameter was null");

            foreach (object service in this.services.Values)
            {
                host.WorkflowExtensions.Add(service);

                ExternalDataExchangeService dataExchangeService = service as ExternalDataExchangeService;
                if (dataExchangeService != null)
                {
                    dataExchangeService.SetEnqueueMessageWrapper(new WorkflowClientDeliverMessageWrapper(baseUri));

                    foreach (object innerService in dataExchangeService.GetAllServices())
                    {
                        host.WorkflowExtensions.Add(innerService);
                    }
                }
            }
        }
Exemplo n.º 11
0
        static void Main()
        {
            Activity workflow = CreateWorkflow();

            using (System.ServiceModel.Activities.WorkflowServiceHost host = new System.ServiceModel.Activities.WorkflowServiceHost(workflow, new Uri(Program.baseAddress)))
            {
                ExternalDataExchangeService dataExchangeService = new ExternalDataExchangeService();
                TaskService taskService = new TaskService();
                dataExchangeService.AddService(taskService);

                WorkflowRuntimeEndpoint workflowRuntimeEndpoint = new WorkflowRuntimeEndpoint();
                workflowRuntimeEndpoint.AddService(dataExchangeService);
                host.AddServiceEndpoint(workflowRuntimeEndpoint);

                host.AddDefaultEndpoints();
                host.Open();

                IWorkflow proxy = ChannelFactory<IWorkflow>.CreateChannel(new BasicHttpBinding(), new EndpointAddress(Program.baseAddress));
                proxy.Start();

                Console.WriteLine("Workflow starting, press enter when workflow completes.\n");
                Console.ReadLine();
            }
        }
        private void SetupHost()
        {
            WorkflowService service = new WorkflowService
            {
                Name = "LeadResponse",
                Body = new WorkAssignment(),
                Endpoints =
                {
                    new Endpoint
                    {
                        ServiceContractName="CreateAssignment",
                        AddressUri = new Uri("http://localhost/CreateAssignment"),
                        Binding = new BasicHttpBinding(),
                    }
                }
            };

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

            SqlWorkflowInstanceStoreBehavior instanceStoreBehavior
                = new SqlWorkflowInstanceStoreBehavior(_connectionString);
            instanceStoreBehavior.InstanceCompletionAction
                = InstanceCompletionAction.DeleteAll;
            instanceStoreBehavior.InstanceLockedExceptionAction
                = InstanceLockedExceptionAction.AggressiveRetry;
            _wsh.Description.Behaviors.Add(instanceStoreBehavior);

            WorkflowIdleBehavior wib = new WorkflowIdleBehavior();
            wib.TimeToUnload = TimeSpan.FromMilliseconds(100);
            _wsh.Description.Behaviors.Add(wib);

            _wsh.Description.Behaviors.Add
                (new DBExtensionBehavior(_connectionString));
            _wsh.Description.Behaviors.Add
                (new PersistAssignmentBehavior(_connectionString));

            // Open the service so it will listen for messages
            _wsh.Open();
        }
Exemplo n.º 13
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();
            }
        }