using(WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { AutoResetEvent waitHandle = new AutoResetEvent(false); workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) {waitHandle.Set();}; workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e) { Console.WriteLine(e.Exception.Message); waitHandle.Set(); }; ExternalDataExchangeService ExDateExchService = new ExternalDataExchangeService(); workflowRuntime.AddService(ExDateExchService); POService poServiceInstance = new POService(); ExDateExchService.AddService(poServiceInstance); WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(FirstWFStateMachine.POWorkflow)); instance.Start(); PO newPO = new PO(); Console.WriteLine("Please Enter Item Code to be sent Purchase Order of"); string ItemCode = Console.ReadLine(); Console.WriteLine("Please Enter Due Delivery Date of Purchase Order of"); DateTime DueDeliveryDate = Convert.ToDateTime(Console.ReadLine()); newPO.ItemCode = ItemCode; newPO.PODueDeliveryDate = DueDeliveryDate; poServiceInstance.CreatePO(instance.InstanceId, newPO); Console.WriteLine("New PO created for item: " + newPO.ItemCode + " with Due Delivery Date: " + newPO.PODueDeliveryDate.Date); Console.WriteLine("Do you want to approve Purchase Order"); while ( (Console.ReadLine().ToLower()) != "y") { Console.WriteLine("Current status of Purchase Order : Created"); Console.WriteLine("Waiting to be Authorised"); DumpStateMachine(workflowRuntime, instance.InstanceId); Console.WriteLine("Do you want to approve Purchase Order"); } poServiceInstance.AuthorisePO(instance.InstanceId, newPO); Console.WriteLine("Do you want to send Purchase Order"); while ((Console.ReadLine().ToLower()) != "y") { Console.WriteLine("Current status of Purchase Order : Created"); Console.WriteLine("Waiting to be Sent"); DumpStateMachine(workflowRuntime, instance.InstanceId); Console.WriteLine("Do you want to send Purchase Order"); } poServiceInstance.SendPO(instance.InstanceId, newPO); DumpStateMachine(workflowRuntime, instance.InstanceId); System.Console.ReadKey(); waitHandle.WaitOne(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)