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(); } }
static void Main(string[] args) { System.ServiceModel.Activities.WorkflowServiceHost host = null; try { waitEvent = new AutoResetEvent(false); string baseAddr = "net.pipe://localhost/GuessingGame"; host = new System.ServiceModel.Activities.WorkflowServiceHost( new GuessingGame35Interop(), new Uri(baseAddr)); System.Workflow.Activities.ExternalDataExchangeService des = new System.Workflow.Activities.ExternalDataExchangeService(); ggService = new GuessingGameService(); ggService.MessageReceived += new EventHandler <MessageReceivedEventArgs>( Service_MessageReceived); des.AddService(ggService); WorkflowRuntimeEndpoint endpoint = new WorkflowRuntimeEndpoint(); endpoint.AddService(des); host.AddServiceEndpoint(endpoint); host.AddDefaultEndpoints(); ////configure persistence //string connectionString = ConfigurationManager.ConnectionStrings // ["InstanceStore"].ConnectionString; //SqlWorkflowInstanceStoreBehavior storeBehavior = // new SqlWorkflowInstanceStoreBehavior(connectionString); //host.Description.Behaviors.Add(storeBehavior); //WorkflowIdleBehavior idleBehavior = new WorkflowIdleBehavior(); //idleBehavior.TimeToUnload = TimeSpan.FromSeconds(0); //host.Description.Behaviors.Add(idleBehavior); host.Open(); IServiceStarter client = ChannelFactory <IServiceStarter> .CreateChannel( new NetNamedPipeBinding(), new EndpointAddress(baseAddr)); client.Start(); waitEvent.WaitOne(TimeSpan.FromMinutes(2)); Console.WriteLine("Program exiting..."); } catch (Exception exception) { Console.WriteLine("Unhandled exception: {0}", exception.Message); } finally { if (host != null) { host.Close(); } } }
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(); } }