static void Main() { CreateRoles(); using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { workflowRuntime.StartRuntime(); // Load the workflow type. Type type = typeof(PurchaseOrderWorkflow); ExternalDataExchangeService dataService = new ExternalDataExchangeService(); workflowRuntime.AddService(dataService); poImpl = new StartPurchaseOrder(); dataService.AddService(poImpl); workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; WorkflowInstance instance = workflowRuntime.CreateWorkflow(type); workflowInstanceId = instance.InstanceId; instance.Start(); SendPORequestMessage(); waitHandle.WaitOne(); workflowRuntime.StopRuntime(); } }
public static void StartWorkflowRuntime() { // Create a new Workflow Runtime for this application runtime = new WorkflowRuntime(); // Create EventHandlers for the WorkflowRuntime //runtime.WorkflowTerminated += new EventHandler<WorkflowTerminatedEventArgs>(Runtime_WorkflowTerminated); //runtime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(Runtime_WorkflowCompleted); //runtime.WorkflowIdled += new EventHandler<WorkflowEventArgs>(Runtime_WorkflowIdled); // Add the External Data Exchange Service ExternalDataExchangeService dataExchangeService = new ExternalDataExchangeService(); runtime.AddService(dataExchangeService); // Add a new instance of the OrderService to the External Data Exchange Service ValuationEvents = new ValuationProcessEvents(); dataExchangeService.AddService(ValuationEvents); // Add Persistance service to the runtime SqlWorkflowPersistenceService sqlPersistenceService = new SqlWorkflowPersistenceService("Data Source=blrserver\\sql2005;Initial Catalog=IGRSS_EF;User ID=sa;Password=trans"); runtime.AddService(sqlPersistenceService); // Start the Workflow services runtime.StartRuntime(); }
protected void Application_Start(object sender, EventArgs e) { // create an instance of workflow runtime, loading settings from web.config WorkflowRuntime workflowRuntime = new WorkflowRuntime(WorkflowManager.WorkflowRuntimeKey); // add the external data exchange service to the runtime to allow for local services ExternalDataExchangeService exchangeService = new ExternalDataExchangeService(WorkflowManager.LocalServicesKey); ////////////// Add Oracel Persistence instead of SQLServer Persistence ConnectionStringSettings connectionStringSetting = ConfigurationManager.ConnectionStrings["Oracle - ODP.NET"]; workflowRuntime.AddService(new AdoPersistenceService( connectionStringSetting, true, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1))); ////////////// CallWorkflowService serv = new CallWorkflowService(); // This is for Sub workflow service workflowRuntime.AddService(exchangeService); workflowRuntime.AddService(serv); // start the workflow runtime workflowRuntime.StartRuntime(); // save the runtime for use by the entire application Application[WorkflowManager.WorkflowRuntimeKey] = workflowRuntime; }
static void Main() { string connectionString = "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;"; using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { ExternalDataExchangeService dataService = new ExternalDataExchangeService(); workflowRuntime.AddService(dataService); dataService.AddService(expenseService); workflowRuntime.AddService(new SqlWorkflowPersistenceService(connectionString)); workflowRuntime.StartRuntime(); workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; workflowRuntime.WorkflowIdled += OnWorkflowIdled; workflowRuntime.WorkflowAborted += OnWorkflowAborted; Type type = typeof(Microsoft.Samples.Workflow.CancelWorkflow.SampleWorkflow); WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(type); workflowInstance.Start(); waitHandle.WaitOne(); workflowRuntime.StopRuntime(); } }
public void AddServices(params object[] services) { foreach (var service in services) { _workflowRuntime.AddService(service); } }
public void Services() { // By default there are no services WorkflowRuntime wr = new WorkflowRuntime(); Assert.AreEqual(0, (wr.GetAllServices(typeof(WorkflowLoaderService))).Count, "C1#1"); //Assert.AreEqual (0, (wr.GetAllServices (typeof (WorkflowPersistenceService))).Count, "C1#2"); //Assert.AreEqual (0, (wr.GetAllServices (typeof (WorkflowQueuingService))).Count, "C1#3"); // Can have to diferent instances of the same class WorkflowRuntime wr3 = new WorkflowRuntime(); WorkflowLoaderServiceTest1 wls = new WorkflowLoaderServiceTest1(); wr3.AddService(wls); Assert.AreEqual(wls, wr3.GetService(typeof(WorkflowLoaderService)), "C1#2"); wr3.AddService(new WorkflowLoaderServiceTest1()); Assert.AreEqual(2, (wr3.GetAllServices(typeof(WorkflowLoaderService))).Count, "C1#3"); Assert.AreEqual(2, wr3.GetAllServices <WorkflowLoaderService> ().Count, "C1#3"); // An non-existant service should return null Assert.AreEqual(null, wr3.GetService(typeof(string)), "C1#4"); wr.AddService(new WorkflowLoaderServiceTest1()); //foreach (object t in wr.GetAllServices (typeof (WorkflowLoaderService))) { // Console.WriteLine ("Types {0}", t.GetType ()); //} }
public Mainform() { InitializeComponent(); this.runtime = new WorkflowRuntime(); runtime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(runtime_WorkflowCompleted); // Set up runtime to unload workflow instance from memory to file using FilePersistenceService FilePersistenceService filePersistence = new FilePersistenceService(true); runtime.AddService(filePersistence); // Add document approval service ExternalDataExchangeService dataService = new ExternalDataExchangeService(); runtime.AddService(dataService); documentService = new DocumentApprovalService(this); dataService.AddService(documentService); // Search for workflows that have previously been persisted to file, and load into the listview control. // These workflows will be reloaded by the runtime when events are raised against them. LoadWorkflowData(); // Start the runtime runtime.StartRuntime(); }
static void Main(string[] args) { Console.WriteLine("Starting Workflow"); using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { // Run SQL scripts: // C:\Windows\Microsoft.NET\Framework\v3.0\Windows Workflow Foundation\SQL\en\SqlPersistenceService_Schema.sql // C:\Windows\Microsoft.NET\Framework\v3.0\Windows Workflow Foundation\SQL\en\SqlPersistenceService_Logic.sql SqlWorkflowPersistenceService sqlPersistenceService = new SqlWorkflowPersistenceService("Server=localhost;Database=NetMeter;User Id=sa;Password=MetraTech1;"); workflowRuntime.AddService(sqlPersistenceService); workflowRuntime.AddService(new ConsoleTrackingService()); 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.ToString()); waitHandle.Set(); }; WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowConsoleApplication2.Workflow1)); instance.Start(); waitHandle.WaitOne(); } Console.WriteLine("Workflow done"); Console.ReadLine(); }
public Mainform() { InitializeComponent(); this.runtime = new WorkflowRuntime(); runtime.WorkflowCompleted += new EventHandler <WorkflowCompletedEventArgs>(runtime_WorkflowCompleted); // Set up runtime to unload workflow instance from memory to file using FilePersistenceService FilePersistenceService filePersistence = new FilePersistenceService(true); runtime.AddService(filePersistence); // Add document approval service ExternalDataExchangeService dataService = new ExternalDataExchangeService(); runtime.AddService(dataService); documentService = new DocumentApprovalService(this); dataService.AddService(documentService); // Search for workflows that have previously been persisted to file, and load into the listview control. // These workflows will be reloaded by the runtime when events are raised against them. LoadWorkflowData(); // Start the runtime runtime.StartRuntime(); }
public void start() { wfRuntime = new WorkflowRuntime(); //--通信 exExchangeService = new ExternalDataExchangeService(); exEvent = new ExternalEvent(); wfRuntime.AddService(exExchangeService); exExchangeService.AddService(exEvent); //- lsWFInfo = new List <string>(); lsWFEvent = new List <string>(); wfRuntime.AddService(lsWFInfo); //事件 this.wfRuntime.WorkflowCompleted += new EventHandler <WorkflowCompletedEventArgs>(wfRuntime_WorkflowCompleted); this.wfRuntime.Started += new EventHandler <WorkflowRuntimeEventArgs>(wfRuntime_Started); this.wfRuntime.WorkflowIdled += new EventHandler <WorkflowEventArgs>(wfRuntime_WorkflowIdled); this.wfRuntime.WorkflowTerminated += new EventHandler <WorkflowTerminatedEventArgs>(wfRuntime_WorkflowTerminated); this.wfRuntime.WorkflowAborted += new EventHandler <WorkflowEventArgs>(wfRuntime_WorkflowAborted); //-启动引擎 wfRuntime.StartRuntime(); }
/// <summary> /// Add any services needed by the runtime engine /// </summary> /// <param name="instance"></param> private void AddServices(WorkflowRuntime instance) { #if CUSTOM_PERSISTENCE //use the custom file based persistence service _persistence = new FileWorkflowPersistenceService(); instance.AddService(_persistence); #else //use the standard SQL Server persistence service String connStringPersistence = String.Format( "Initial Catalog={0};Data Source={1};Integrated Security={2};", "WorkflowPersistence", @"localhost\SQLEXPRESS", "SSPI"); _persistence = new SqlWorkflowPersistenceService(connStringPersistence, true, new TimeSpan(0, 2, 0), new TimeSpan(0, 0, 5)); instance.AddService(_persistence); #endif //add the external data exchange service to the runtime ExternalDataExchangeService exchangeService = new ExternalDataExchangeService(); instance.AddService(exchangeService); //add our local service _persistenceDemoService = new PersistenceDemoService(); exchangeService.AddService(_persistenceDemoService); }
/// <summary> /// 创建工作流运行时 /// </summary> /// <param name="IsPer">是否使用持久化</param> /// <returns></returns> public static WorkflowRuntime CreateWorkFlowRuntime(bool IsPer) { try { WorkflowRuntime WfRuntime = new WorkflowRuntime(); if (IsPer) { String connStringPersistence = ConfigurationManager.ConnectionStrings["SqlPersistenceConnection"].ConnectionString;//Data Source=172.30.50.110;Initial Catalog=WorkflowPersistence;Persist Security Info=True;User ID=sa;Password=fbaz2012;MultipleActiveResultSets=True"; SqlWorkflowPersistenceService persistence = new SqlWorkflowPersistenceService(connStringPersistence, true, new TimeSpan(0, 0, 30), new TimeSpan(0, 1, 0)); WfRuntime.AddService(persistence); WfRuntime.WorkflowPersisted += new EventHandler <WorkflowEventArgs>(WfRuntime_WorkflowPersisted); WfRuntime.ServicesExceptionNotHandled += new EventHandler <ServicesExceptionNotHandledEventArgs>(WfRuntime_ServicesExceptionNotHandled); // ConnectionStringSettings defaultConnectionString = ConfigurationManager.ConnectionStrings["OracleConnection"]; // WfRuntime.AddService(new AdoPersistenceService(defaultConnectionString, true, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(0))); // WfRuntime.AddService(new AdoTrackingService(defaultConnectionString)); // WfRuntime.AddService(new AdoWorkBatchService()); } FlowEvent ExternalEvent = new FlowEvent(); ExternalDataExchangeService objService = new ExternalDataExchangeService(); WfRuntime.AddService(objService); objService.AddService(ExternalEvent); TypeProvider typeProvider = new TypeProvider(null); WfRuntime.AddService(typeProvider); WfRuntime.StartRuntime(); return(WfRuntime); } catch (Exception ex) { LogHelper.WriteLog("CreateWorkFlowRuntime异常信息 :" + ex.ToString()); throw new Exception(ex.Message); } }
/// <summary> /// 从持久化库在恢复实例 /// </summary> /// <param name="WfRuntime"></param> /// <param name="INSTANCEID"></param> /// <returns></returns> public static WorkflowInstance GetWorkflowInstance(WorkflowRuntime WfRuntime, string INSTANCEID) { try { WfRuntime = new WorkflowRuntime(); if (WfRuntime.GetService(typeof(AdoPersistenceService)) == null) { ConnectionStringSettings defaultConnectionString = ConfigurationManager.ConnectionStrings["OracleConnection"]; WfRuntime.AddService(new AdoPersistenceService(defaultConnectionString, true, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(0))); WfRuntime.AddService(new AdoTrackingService(defaultConnectionString)); WfRuntime.AddService(new AdoWorkBatchService()); } FlowEvent ExternalEvent = new FlowEvent(); ExternalDataExchangeService objService = new ExternalDataExchangeService(); WfRuntime.AddService(objService); objService.AddService(ExternalEvent); TypeProvider typeProvider = new TypeProvider(null); WfRuntime.AddService(typeProvider); WfRuntime.StartRuntime(); WorkflowInstance instance = null; try { instance = WfRuntime.GetWorkflow(new Guid(INSTANCEID)); } catch { instance = null; } if (instance == null) //try find instance in sql server persistence { WfRuntime = new WorkflowRuntime(); ExternalEvent = new FlowEvent(); objService = new ExternalDataExchangeService(); WfRuntime.AddService(objService); objService.AddService(ExternalEvent); typeProvider = new TypeProvider(null); WfRuntime.AddService(typeProvider); String connStringPersistence = ConfigurationManager.ConnectionStrings["SqlPersistenceConnection"].ConnectionString;//Data Source=172.30.50.110;Initial Catalog=WorkflowPersistence;Persist Security Info=True;User ID=sa;Password=fbaz2012;MultipleActiveResultSets=True"; SqlWorkflowPersistenceService persistence = new SqlWorkflowPersistenceService(connStringPersistence, true, new TimeSpan(0, 2, 0), new TimeSpan(0, 0, 5)); WfRuntime.AddService(persistence); WfRuntime.StartRuntime(); instance = WfRuntime.GetWorkflow(new Guid(INSTANCEID)); } //WfRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) //{ // instance = null; //}; return(instance); } catch (Exception ex) { LogHelper.WriteLog("GetWorkflowInstance异常信息 :" + ex.ToString()); throw new Exception(ex.Message); } }
public void ThereCanBeOnlyOne () { CustomPersistenceService cp1 = new CustomPersistenceService (); CustomPersistenceService cp2 = new CustomPersistenceService (); WorkflowRuntime wr = new WorkflowRuntime (); wr.AddService (cp1); wr.AddService (cp2); }
public void AddServiceTwice() { WorkflowRuntime wr = new WorkflowRuntime(); WorkflowLoaderServiceTest1 wl = new WorkflowLoaderServiceTest1(); wr.AddService(wl); wr.AddService(wl); }
static void Main(string[] args) { Console.WriteLine("Starting CRySTAL..."); Console.WriteLine("Linking Workflow Runtime Services..."); CRySTAL.WorkflowInterface.WorkflowInterface.CustomerWF = new CRySTAL.WorkflowInterface.CustomerWorkflowInterface(); WorkflowRuntime workflowRuntime = new WorkflowRuntime(); AppDomain.CurrentDomain.SetData("WorkflowRuntime", workflowRuntime); ManualWorkflowSchedulerService manualScheduler = new ManualWorkflowSchedulerService(true); AppDomain.CurrentDomain.SetData("ManualScheduler", manualScheduler); workflowRuntime.AddService(manualScheduler); ExternalDataExchangeService des = new ExternalDataExchangeService(); workflowRuntime.AddService(des); des.AddService(CRySTAL.WorkflowInterface.WorkflowInterface.CustomerWF); TimeSpan reloadIntevral = new TimeSpan(0, 0, 0, 20, 0); TimeSpan ownershipDuration = new TimeSpan(0, 0, 30, 0); string connectionString = @"Data Source=ETHIELE-LENOVO\SQLEXPRESS;Initial Catalog=WFTrackingAndPersistence;Integrated Security=True"; SqlWorkflowPersistenceService sqlPersistenceService = new SqlWorkflowPersistenceService(connectionString, true, ownershipDuration, reloadIntevral); workflowRuntime.AddService(sqlPersistenceService); SqlTrackingService sts = new SqlTrackingService(connectionString); workflowRuntime.AddService(sts); Console.WriteLine("Starting Workflow Runtime..."); workflowRuntime.StartRuntime(); //AppDomain.CurrentDomain.SetData("firstNamestr", "thisisatest"); List<ServiceHost> hosts = new List<ServiceHost>(); hosts.Add(new ServiceHost(typeof(CRySTAL.CookService))); hosts.Add(new ServiceHost(typeof(CRySTAL.BusBoyService))); hosts.Add(new ServiceHost(typeof(CRySTAL.HostService))); hosts.Add(new ServiceHost(typeof(CRySTAL.LoginService))); hosts.Add(new ServiceHost(typeof(CRySTAL.MenuService))); hosts.Add(new ServiceHost(typeof(CRySTAL.WaiterService))); foreach (ServiceHost host in hosts) { host.Open(); Console.WriteLine("CRySTAL: Service Running: " + host.BaseAddresses[0].ToString()); } Console.WriteLine("CRySTAL Ready"); Console.ReadLine(); Console.WriteLine("Shutting down CRySTAL..."); foreach (ServiceHost host in hosts) { host.Close(); Console.WriteLine("CRySTAL: Shutingdown Service :" + host.BaseAddresses[0].ToString()); } Console.WriteLine("Shutting down runtime..."); workflowRuntime.StopRuntime(); Console.WriteLine("CRySTAL shutdown complete"); Console.ReadLine(); }
public void GetServiceWithTwoB() { WorkflowRuntime wr = new WorkflowRuntime(); WorkflowLoaderServiceTest1 wl = new WorkflowLoaderServiceTest1(); WorkflowLoaderServiceTest2 w2 = new WorkflowLoaderServiceTest2(); wr.AddService(wl); wr.AddService(w2); wr.GetService <WorkflowLoaderService> (); }
public void ThereCanBeOnlyOne() { CustomPersistenceService cp1 = new CustomPersistenceService(); CustomPersistenceService cp2 = new CustomPersistenceService(); WorkflowRuntime wr = new WorkflowRuntime(); wr.AddService(cp1); wr.AddService(cp2); }
/// <summary> /// Initialises and created a workflow runtime with the specified services. /// </summary> protected void InitialiseAndStartWorkflowRuntime() { workflowRuntime = new WorkflowRuntime(); if (SchedulerService != null) { workflowRuntime.AddService(SchedulerService); } if (PersistenceService != null) { workflowRuntime.AddService(PersistenceService); } if (TrackingService != null) { workflowRuntime.AddService(TrackingService); } if (ExternalServices != null && ExternalServices.Count > 0) { ExternalDataExchangeService externalDataExchangeService = new ExternalDataExchangeService(); workflowRuntime.AddService(externalDataExchangeService); foreach (object externalService in ExternalServices) { externalDataExchangeService.AddService(externalService); } } if (CustomServices != null && CustomServices.Count > 0) { foreach (object customService in CustomServices) { workflowRuntime.AddService(customService); } } workflowRuntime.Started += new EventHandler <WorkflowRuntimeEventArgs>(workflowRuntime_Started); workflowRuntime.Stopped += new EventHandler <WorkflowRuntimeEventArgs>(workflowRuntime_Stopped); workflowRuntime.ServicesExceptionNotHandled += new EventHandler <ServicesExceptionNotHandledEventArgs>(workflowRuntime_ServicesExceptionNotHandled); workflowRuntime.WorkflowAborted += new EventHandler <WorkflowEventArgs>(workflowRuntime_WorkflowAborted); workflowRuntime.WorkflowCompleted += new EventHandler <WorkflowCompletedEventArgs>(workflowRuntime_WorkflowCompleted); workflowRuntime.WorkflowCreated += new EventHandler <WorkflowEventArgs>(workflowRuntime_WorkflowCreated); workflowRuntime.WorkflowIdled += new EventHandler <WorkflowEventArgs>(workflowRuntime_WorkflowIdled); workflowRuntime.WorkflowLoaded += new EventHandler <WorkflowEventArgs>(workflowRuntime_WorkflowLoaded); workflowRuntime.WorkflowPersisted += new EventHandler <WorkflowEventArgs>(workflowRuntime_WorkflowPersisted); workflowRuntime.WorkflowResumed += new EventHandler <WorkflowEventArgs>(workflowRuntime_WorkflowResumed); workflowRuntime.WorkflowStarted += new EventHandler <WorkflowEventArgs>(workflowRuntime_WorkflowStarted); workflowRuntime.WorkflowSuspended += new EventHandler <WorkflowSuspendedEventArgs>(workflowRuntime_WorkflowSuspended); workflowRuntime.WorkflowTerminated += new EventHandler <WorkflowTerminatedEventArgs>(workflowRuntime_WorkflowTerminated); workflowRuntime.WorkflowUnloaded += new EventHandler <WorkflowEventArgs>(workflowRuntime_WorkflowUnloaded); workflowRuntime.StartRuntime(); }
public void TestInitialize() { _workflowRuntime = new WorkflowRuntime(); _scheduler = new ManualWorkflowSchedulerService(); _workflowRuntime.AddService(_scheduler); _workflowRuntime.AddService(new ExternalDataExchangeService()); _dataExchange = new MockDataExchange(); _dataExchange.Reset(); _workflowRuntime.GetService <ExternalDataExchangeService>().AddService(_dataExchange); _workflowRuntime.StartRuntime(); }
public void TestInitialize() { _workflowRuntime = new WorkflowRuntime(); _scheduler = new ManualWorkflowSchedulerService(); _tracking = new PropertyTrackingService(); _workflowRuntime.AddService(_scheduler); _workflowRuntime.AddService(_tracking); _workflowRuntime.AddService(new ExternalDataExchangeService()); _dataExchange = new MockDataExchange(Delay, 2 * Delay + Delay); _workflowRuntime.GetService <ExternalDataExchangeService>().AddService(_dataExchange); _workflowRuntime.StartRuntime(); }
private static void AddServices() { #region Basic Workflow Services // Add the SqlWorkflowPersistenceService to the runtime engine. SqlWorkflowPersistenceService PersistService = new SqlWorkflowPersistenceService(Settings.Default.AppConnectionString); Runtime.AddService(PersistService); //SqlTrackingService TrackingService = new SqlTrackingService(Settings.Default.AppConnectionString); //Runtime.AddService(TrackingService); // Add ExternalDataExchangeService to communicate with any running Workflow ExternalDataExchangeService DataExchangeService = new ExternalDataExchangeService(); Runtime.AddService(DataExchangeService); #endregion #region Igrss Business Services ComplainServices = new ComplainService(); DataExchangeService.AddService(ComplainServices); LicenseApplicationServices = new LicenseApplicationService(); DataExchangeService.AddService(LicenseApplicationServices); AppealServices = new AppealService(); DataExchangeService.AddService(AppealServices); RefundServices = new RefundService(); DataExchangeService.AddService(RefundServices); AdjudicationServices = new AdjudicationService(); DataExchangeService.AddService(AdjudicationServices); #endregion //ComplainService complainService = new ComplainService(); //DataService.AddService(complainService); //OrderService orderService = OrderService.Instance; //dataService.AddService(orderService); //OrderTransactionService txnService = new OrderTransactionService(); //Runtime.AddService(txnService); //ContextService = new HttpContextWrapper(); }
static void Main() { using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { // Create our local service and add it to the workflow runtime's list of services ExternalDataExchangeService dataService = new ExternalDataExchangeService(); workflowRuntime.AddService(dataService); VotingServiceImpl votingService = new VotingServiceImpl(); dataService.AddService(votingService); // Start up the runtime and hook the creation and completion events workflowRuntime.StartRuntime(); workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; workflowRuntime.WorkflowStarted += OnWorkflowStarted; // Create the workflow's parameters collection Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("Alias", "Jim"); // Create and start the workflow Type type = typeof(HostCommunication.VotingServiceWorkflow); workflowRuntime.CreateWorkflow(type, parameters).Start(); waitHandle.WaitOne(); // Cleanly stop the runtime and all services workflowRuntime.StopRuntime(); } }
static void Main() { using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { try { const string connectString = "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;"; workflowRuntime.AddService(new SqlWorkflowPersistenceService(connectString)); workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; workflowRuntime.WorkflowAborted += OnWorkflowAborted; workflowRuntime.StartRuntime(); Type type = typeof(Compensation.PurchaseOrder); workflowRuntime.CreateWorkflow(type).Start(); waitHandle.WaitOne(); } catch (Exception ex) { if (ex.InnerException != null) Console.WriteLine(ex.InnerException.Message); else Console.WriteLine(ex.Message); } finally { workflowRuntime.StopRuntime(); } } }
static void Main() { using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { try { // engine will unload workflow instance when it is idle workflowRuntime.AddService(new FilePersistenceService(true)); workflowRuntime.WorkflowCreated += OnWorkflowCreated; workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowIdled += OnWorkflowIdle; workflowRuntime.WorkflowUnloaded += OnWorkflowUnload; workflowRuntime.WorkflowLoaded += OnWorkflowLoad; workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; workflowRuntime.ServicesExceptionNotHandled += OnExceptionNotHandled; workflowRuntime.CreateWorkflow(typeof(PersistenceServiceWorkflow)).Start(); waitHandle.WaitOne(); } catch (Exception e) { Console.WriteLine("Exception \n\t Source: {0} \n\t Message: {1}", e.Source, e.Message); } finally { workflowRuntime.StopRuntime(); Console.WriteLine("Workflow runtime stopped, program exiting... \n"); } } }
static void Main() { using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { try { // A workflow is always run asychronously; the main thread waits on this event so the program // doesn't exit before the workflow completes workflowRuntime.AddService(new SqlWorkflowPersistenceService("Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;")); // Listen for the workflow events workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; workflowRuntime.WorkflowAborted += OnWorkflowAborted; // Create an instance of the workflow Type type = typeof(NestedExceptionsWorkflow); workflowRuntime.CreateWorkflow(type).Start(); Console.WriteLine("Workflow Started.\n"); // Wait for the event to be signaled waitHandle.WaitOne(); } catch (Exception ex) { Console.WriteLine("Source: {0}\nMessage: {1}", ex.Source, ex.Message); } finally { workflowRuntime.StopRuntime(); Console.WriteLine("\nWorkflow Complete."); } } }
static void Main() { orderService = new OrderServiceImpl(); // Start the workflow runtime engine. using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { ExternalDataExchangeService dataService = new ExternalDataExchangeService(); workflowRuntime.AddService(dataService); dataService.AddService(orderService); workflowRuntime.StartRuntime(); // Listen for the workflow events workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; workflowRuntime.WorkflowIdled += OnWorkflowIdled; // Start the workflow and wait for it to complete Type type = typeof(PurchaseOrderWorkflow); workflowRuntime.CreateWorkflow(type).Start(); waitHandle.WaitOne(); // Stop the workflow runtime engine. workflowRuntime.StopRuntime(); } }
private static void Main() { using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { poImpl = new StartPurchaseOrder(); ExternalDataExchangeService dataService = new ExternalDataExchangeService(); workflowRuntime.AddService(dataService); dataService.AddService(poImpl); workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; // Load the workflow type. Type type = typeof(PurchaseOrderWorkflow); WorkflowInstance instance = workflowRuntime.CreateWorkflow(type); workflowInstanceId = instance.InstanceId; // Start the workflow runtime engine workflowRuntime.StartRuntime(); instance.Start(); SendPORequestMessage(); waitHandle.WaitOne(); workflowRuntime.StopRuntime(); } }
///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// public MainForm() { InitializeComponent(); #region UI define GenerateButtons(); GenerateAcctions(); #endregion #region Bankomats Init currentAccountCulture = CultureInfo.CurrentCulture; #endregion #region IniT Workflow workflowRuntime = new WorkflowRuntime(); ExternalDataExchangeService des = new ExternalDataExchangeService(); workflowRuntime.AddService(des); des.AddService(this); workflowRuntime.StartRuntime(); workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowTerminated += new EventHandler<WorkflowTerminatedEventArgs>(workflowRuntime_WorkflowTerminated); Type type = typeof(BankomatWorkflowLibrary.BankomatsWorkflow); workflowInstance = workflowRuntime.CreateWorkflow(type); workflowInstance.Start(); #endregion }
static void Main() { // Create WorkflowRuntime using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { // Add ConsoleTrackingService workflowRuntime.AddService(new ConsoleTrackingService()); // Subscribe to Workflow Completed WorkflowRuntime Event workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; // Subscribe to Workflow Terminated WorkflowRuntime Event workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; // Start WorkflowRuntime workflowRuntime.StartRuntime(); // Execute the SampleWorkflow Workflow Console.WriteLine("Executing the workflow..."); workflowRuntime.CreateWorkflow(typeof(SimplePolicyWorkflow)).Start(); // Wait for the Workflow Completion waitHandle.WaitOne(); // Stop Runtime workflowRuntime.StopRuntime(); } }
private void StartWorkflowRuntime() { // Create a new Workflow Runtime for this application workflowRuntime = new WorkflowRuntime(); // Create EventHandlers for the WorkflowRuntime workflowRuntime.WorkflowTerminated += new EventHandler <WorkflowTerminatedEventArgs>(WorkflowRuntime_WorkflowTerminated); workflowRuntime.WorkflowCompleted += new EventHandler <WorkflowCompletedEventArgs>(WorkflowRuntime_WorkflowCompleted); workflowRuntime.WorkflowIdled += new EventHandler <WorkflowEventArgs>(workflowRuntime_WorkflowIdled); // Start the Workflow services workflowRuntime.StartRuntime(); // Add an instance of the External Data Exchange Service ExternalDataExchangeService externalDataExchangeService = new ExternalDataExchangeService(); workflowRuntime.AddService(externalDataExchangeService); // Add a new instance of the OrderService to the externalDataExchangeService speechService = new SpeechService(); externalDataExchangeService.AddService(speechService); // Subscribe to the menu text changed event speechService.PhoneTextChangedEventHandler += new SpeechService.UpdatePhoneTextEventHandler(UpdatePhoneTextEventHandler); }
static void Main() { using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { // Create our local service and add it to the workflow runtime's list of services ExternalDataExchangeService dataService = new ExternalDataExchangeService(); workflowRuntime.AddService(dataService); VotingServiceImpl votingService = new VotingServiceImpl(); dataService.AddService(votingService); // Start up the runtime and hook the creation and completion events workflowRuntime.StartRuntime(); workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; workflowRuntime.WorkflowStarted += OnWorkflowStarted; // Create the workflow's parameters collection Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("Alias", "Jim"); // Create and start the workflow Type type = typeof(HostCommunication.VotingServiceWorkflow); workflowRuntime.CreateWorkflow(type, parameters).Start(); waitHandle.WaitOne(); // Cleanly stop the runtime and all services workflowRuntime.StopRuntime(); } }
public VersaCell() { try { _clsHRecord = new VersaCellHeaderRecord(); _clsPRecord = new VersaCellPatientRecord(); _clsORecord = new VersaCellOrderRecord(); _clsQRecord = new VersaCellQueryRecord(); _clsRRecord = new VersaCellResultRecord(); _clsTRecord = new VersaCellTerminationRecord(); PrvRequestArray = new Queue <List <string> >(); objService = new ExternalDataExchangeService(); InstanceId = Guid.NewGuid(); objWorkFlowRuntime.AddService(objService); objASTM = new clsASTM(); objService.AddService(objASTM); objASTM.SendACKEvent += objASTM_SendACKEvent; objASTM.SendNAKEvent += objASTM_SendNAKEvent; objASTM.SendENQEvent += objASTM_SendENQEvent; objASTM.SendEOTEvent += objASTM_SendEOTEvent; objWorkFlowInstance = objWorkFlowRuntime.CreateWorkflow(typeof(ASTMWorkflow), null, InstanceId); objWorkFlowInstance.Start(); Console.WriteLine(@"Work flow started"); objDataEventArgs = new ExternalDataEventArgs(InstanceId); objDataEventArgs.WaitForIdle = true; DumpStateMachine(objWorkFlowRuntime, InstanceId); } catch (Exception ex) { Log.FatalException("Fatal Error: ", ex); } }
static void Main(string[] args) { using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { // Add ChannelManager. ChannelManagerService channelmgr = new ChannelManagerService(); workflowRuntime.AddService(channelmgr); AutoResetEvent waitHandle = new AutoResetEvent(false); workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) { Console.WriteLine("WorkflowCompleted: " + e.WorkflowInstance.InstanceId.ToString()); waitHandle.Set(); }; workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e) { Console.WriteLine("WorkflowTerminated: " + e.Exception.Message); waitHandle.Set(); }; while (true) { WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(Microsoft.WorkflowServices.Samples.SequentialCalculatorClient)); Console.WriteLine("Start SequentialCalculatorClient."); instance.Start(); waitHandle.WaitOne(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Do another calculation? (Y)"); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Press <enter> to exit."); Console.ResetColor(); string input = Console.ReadLine(); if (input.Length == 0 || input[0] != 'Y') { break; } waitHandle.Reset(); } } }
public TcpIpASTMManager() { try { _prvRequestArray = new Queue <List <string> >(); _currentOrder = new List <string>(); _failSending = 0; _timeoutManager = new Timer(60000); _timeoutManager.Elapsed += _timeoutManager_Elapsed; objService = new ExternalDataExchangeService(); InstanceId = Guid.NewGuid(); objWorkFlowRuntime.AddService(objService); objASTM = new ClsAstm(); objService.AddService(objASTM); objASTM.SendACKEvent += objASTM_SendACKEvent; objASTM.SendNAKEvent += objASTM_SendNAKEvent; objASTM.SendENQEvent += objASTM_SendENQEvent; objASTM.SendEOTEvent += objASTM_SendEOTEvent; //objASTM.ACKTimeoutEvent += new EventHandler(objASTM_ACKTimeoutEvent); objWorkFlowInstance = objWorkFlowRuntime.CreateWorkflow(typeof(ASTMWorkflow), null, InstanceId); objWorkFlowInstance.Start(); Console.WriteLine(string.Format(@"Work flow started")); objDataEventArgs = new ExternalDataEventArgs(InstanceId) { WaitForIdle = true }; DumpStateMachine(objWorkFlowRuntime, InstanceId); } catch (Exception ex) { Log.Error(string.Format("Error: {0}", ex)); } }
static void Main(string[] args) { using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { // Add ChannelManager ChannelManagerService channelmgr = new ChannelManagerService(); workflowRuntime.AddService(channelmgr); AutoResetEvent waitHandle = new AutoResetEvent(false); workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) { Console.WriteLine("WorkflowCompleted: " + e.WorkflowInstance.InstanceId.ToString()); waitHandle.Set(); }; workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e) { Console.WriteLine("WorkflowTerminated: " + e.Exception.Message); waitHandle.Set(); }; while (true) { WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(Microsoft.WorkflowServices.Samples.SequentialCalculatorClient)); Console.WriteLine("Start SequentialCalculatorClient."); instance.Start(); waitHandle.WaitOne(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Do another calculation? (Y)"); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Press <enter> to exit."); Console.ResetColor(); string input = Console.ReadLine(); if (input.Length == 0 || input[0] != 'Y') break; waitHandle.Reset(); } } }
static void Main() { try { waitHandle = new AutoResetEvent(false); CreateAndInsertTrackingProfile(); using (WorkflowRuntime runtime = new WorkflowRuntime()) { SqlTrackingService trackingService = new SqlTrackingService(connectionString); runtime.AddService(trackingService); runtime.StartRuntime(); runtime.WorkflowCompleted += OnWorkflowCompleted; runtime.WorkflowTerminated += OnWorkflowTerminated; runtime.WorkflowAborted += OnWorkflowAborted; WorkflowInstance instance = runtime.CreateWorkflow(typeof(BankMachineWorkflow)); instance.Start(); waitHandle.WaitOne(); runtime.StopRuntime(); OutputTrackedData(instance.InstanceId); } } catch (Exception ex) { if (ex.InnerException != null) Console.WriteLine(ex.InnerException.Message); else Console.WriteLine(ex.Message); } }
public void Echo(string theString) { //Aquire the callback from the current OperationContext callback = OperationContext.Current.GetCallbackChannel <IEchoableCallback>(); //grab the version of the incoming message in case we need to create a fault later version = OperationContext.Current.IncomingMessageVersion; Console.WriteLine("WCF: Got {0}", theString); Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("ReceivedData", theString); WorkflowRuntime workflowRuntime = new WorkflowRuntime(); ManualWorkflowSchedulerService scheduler = new ManualWorkflowSchedulerService(); workflowRuntime.AddService(scheduler); workflowRuntime.StartRuntime(); workflowRuntime.WorkflowCompleted += this.OnWorkflowCompleted; workflowRuntime.WorkflowTerminated += this.OnWorkflowTerminated; WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(Workflow1), parameters); instance.Start(); scheduler.RunWorkflow(instance.InstanceId); }
static void Main(string[] args) { try { // Create the WorkflowRuntime WorkflowRuntime workflowRuntime = new WorkflowRuntime(); workflowRuntime.AddService(new SqlWorkflowPersistenceService("Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;")); // Set up the WorkflowRuntime event handlers workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowIdled += OnWorkflowIdled; workflowRuntime.WorkflowPersisted += OnWorkflowPersisted; workflowRuntime.WorkflowUnloaded += OnWorkflowUnloaded; workflowRuntime.WorkflowLoaded += OnWorkflowLoaded; workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; // Load the workflow type Type type = typeof(Workflow1); // Create an instance of the workflow workflowRuntime.CreateWorkflow(type).Start(); Console.WriteLine("Workflow Started."); // Wait for the event to be signaled waitHandle.WaitOne(); // Stop the runtime workflowRuntime.StopRuntime(); Console.WriteLine("Program Complete."); } catch (Exception exception) { Console.WriteLine("Application exception occured: " + exception.Message); } }
public Window1() { InitializeComponent(); WorkflowRuntime workflowRuntime = new WorkflowRuntime(); SqlWorkflowPersistenceService sqlService = new SqlWorkflowPersistenceService(_settings.SqlPersistenceConnectionString); workflowRuntime.AddService(sqlService); workflowRuntime.StartRuntime(); foreach (SqlPersistenceWorkflowInstanceDescription desc in sqlService.GetAllWorkflows()) { listWorkflows.Items.Add(desc.WorkflowInstanceId.ToString() + " " + desc.Status); Console.WriteLine(desc.WorkflowInstanceId); try { WorkflowInstance workflowInstance = workflowRuntime.GetWorkflow(desc.WorkflowInstanceId); } catch (Exception e) { Console.WriteLine(e.Message); } } workflowRuntime.StopRuntime(); }
static void Main() { try { waitHandle = new AutoResetEvent(false); DataAccess.CreateAndInsertTrackingProfile(); using (WorkflowRuntime runtime = new WorkflowRuntime()) { SqlTrackingService trackingService = new SqlTrackingService(DataAccess.connectionString); /* * Set partitioning settings on Sql Tracking Service and database */ //Turn on PartitionOnCompletion setting-- Default is false trackingService.PartitionOnCompletion = true; //Set partition interval-- Default is 'm' (monthly) DataAccess.SetPartitionInterval('d'); runtime.AddService(trackingService); runtime.StartRuntime(); runtime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) { waitHandle.Set(); }; runtime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e) { Console.WriteLine(e.Exception.Message); waitHandle.Set(); }; WorkflowInstance instance = runtime.CreateWorkflow(typeof(SimpleWorkflow)); instance.Start(); waitHandle.WaitOne(); runtime.StopRuntime(); DataAccess.GetWorkflowTrackingEvents(instance.InstanceId); Console.WriteLine("\nDone running the workflow."); /* * Show tracking partition information and tables */ DataAccess.ShowTrackingPartitionInformation(); DataAccess.ShowPartitionTableInformation(); } } catch (Exception ex) { if (ex.InnerException != null) Console.WriteLine(ex.InnerException.Message); else Console.WriteLine(ex.Message); } }
public void NoCorrelationParameter () { SampleService1 sample = new SampleService1 (); WorkflowRuntime workflow = new WorkflowRuntime (); ExternalDataExchangeService data_change = new ExternalDataExchangeService (); workflow.AddService (data_change); data_change.AddService (sample); }
static void Main() { using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { try { // Set up the runtime to unload the workflow instance from memory to file using FilePersistenceService workflowRuntime.AddService(new FilePersistenceService(true)); // Add document approval service ExternalDataExchangeService dataService = new ExternalDataExchangeService(); workflowRuntime.AddService(dataService); dataService.AddService(documentApprover); workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowIdled += OnWorkflowIdled; workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; workflowRuntime.ServicesExceptionNotHandled += OnExceptionNotHandled; // Start the engine. workflowRuntime.StartRuntime(); // Load the workflow type. Type type = typeof(DocumentApprovalWorkflow); workflowRuntime.CreateWorkflow(type).Start(); // waitHandle blocks so that the program does not exit till workflow completes waitHandle.WaitOne(); } catch (Exception e) { Console.WriteLine("Exception \n\t Source: {0} \n\t Message: {1}", e.Source, e.Message); } finally { workflowRuntime.StopRuntime(); Console.WriteLine("Workflow runtime stopped, program exiting... \n"); } } }
public void AddGetRemoveTest () { SampleService2 sample = new SampleService2 (); WorkflowRuntime workflow = new WorkflowRuntime (); ExternalDataExchangeService data_change = new ExternalDataExchangeService (); workflow.AddService (data_change); data_change.AddService (sample); Assert.AreEqual (sample, data_change.GetService (sample.GetType ()), "C1#1"); data_change.RemoveService (sample); Assert.AreEqual (null, data_change.GetService (sample.GetType ()), "C1#2"); }
private void frmReclamo_Load(object sender, EventArgs e) { workflowRuntime = new WorkflowRuntime(); ExternalDataExchangeService dataExchange = new ExternalDataExchangeService(); workflowRuntime.AddService(dataExchange); dataExchange.AddService(this); workflowRuntime.StartRuntime(); workflowRuntime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(workflowRuntime_WorkflowCompleted); }
/// <summary> /// 创建工作流运行时 /// </summary> /// <param name="IsPer">是否使用持久化</param> /// <returns></returns> public static WorkflowRuntime CreateWorkFlowRuntime(bool IsPer) { try { WorkflowRuntime WfRuntime = new WorkflowRuntime(); if (IsPer) { ConnectionStringSettings defaultConnectionString = ConfigurationManager.ConnectionStrings["OracleConnection"]; WfRuntime.AddService(new AdoPersistenceService(defaultConnectionString, true, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(0))); WfRuntime.AddService(new AdoTrackingService(defaultConnectionString)); WfRuntime.AddService(new AdoWorkBatchService()); } FlowEvent ExternalEvent = new FlowEvent(); ExternalDataExchangeService objService = new ExternalDataExchangeService(); WfRuntime.AddService(objService); objService.AddService(ExternalEvent); ManualWorkflowSchedulerService scheduleService = new ManualWorkflowSchedulerService(); WfRuntime.AddService(scheduleService); TypeProvider typeProvider = new TypeProvider(null); WfRuntime.AddService(typeProvider); WfRuntime.StartRuntime(); return WfRuntime; } catch (Exception ex) { LogHelper.WriteLog("CreateWorkFlowRuntime异常信息 :" + ex.ToString()); throw new Exception(ex.Message); } }
static void Main() { try { // Create WorkflowRuntime using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { // Add SimpleFileTrackingService workflowRuntime.AddService(new SimpleFileTrackingService()); // Subscribe to Workflow Completed, Suspended, and Terminated WorkflowRuntime Event workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowSuspended += OnWorkflowSuspended; workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; // Start WorkflowRuntime workflowRuntime.StartRuntime(); // Execute the SimpleWorkflow Workflow Console.WriteLine("Executing the SimpleWorkflow..."); workflowRuntime.StartRuntime(); WorkflowInstance simpleWorkflowInstance = workflowRuntime.CreateWorkflow(typeof(SimpleWorkflow)); simpleWorkflowInstance.Start(); // Wait for the Workflow Completion waitHandle.WaitOne(); // Execute the SuspendedWorkflow Workflow Console.WriteLine("Executing the SuspendedWorkflow..."); workflowRuntime.StartRuntime(); WorkflowInstance suspendedWorkflowInstance = workflowRuntime.CreateWorkflow(typeof(SuspendedWorkflow)); suspendedWorkflowInstance.Start(); // Wait for the Workflow Suspension waitHandle.WaitOne(); // Execute the ExceptionWorkflow Workflow Console.WriteLine("Executing the ExceptionWorkflow..."); workflowRuntime.StartRuntime(); WorkflowInstance exceptionWorkflowInstance = workflowRuntime.CreateWorkflow(typeof(ExceptionWorkflow)); exceptionWorkflowInstance.Start(); // Wait for the Workflow Termination waitHandle.WaitOne(); // Stop Runtime workflowRuntime.StopRuntime(); } } catch (Exception ex) { Console.WriteLine("\nException:\n\tMessage: {0}\n\tSource: {1}", ex.Message, ex.Source); } }
public Form1() { InitializeComponent(); this.workflowRuntime = new WorkflowRuntime(); exchangeService = new ExternalDataExchangeService(); //This starts the runtime but does not execute any //workflows until the application notifies it to start a workflow. this.workflowRuntime.StartRuntime(); //Enlace entre el workFlow y exchangeService workflowRuntime.AddService(exchangeService); //exchangeService es asociado para que iteractue con el formulario .. ya que implementa la interfaz "IExpenseReportService" que tiene el atributo [ExternalDataExchangeAttribute] exchangeService.AddService(this); workflowRuntime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(workflowRuntime_WorkflowCompleted); }
static void Main() { // Instanciate and configure workflow runtime using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { workflowRuntime.AddService( new SqlWorkflowPersistenceService( ConfigurationManager.AppSettings["ConnectionString"], true, new TimeSpan(0, 10, 0), new TimeSpan(0, 0, 5))); // Subscribe to workflow events workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowIdled += OnWorkflowIdle; workflowRuntime.ServicesExceptionNotHandled += OnExceptionNotHandled; workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; workflowRuntime.WorkflowAborted += OnWorkflowAborted; // Start Workflow Runtime workflowRuntime.StartRuntime(); // // start PO approval workflow with purchase order amount less than $1000 // Console.WriteLine("Workflow 1:"); Int32 poAmount = 750; Type workflowType = typeof(DynamicUpdateWorkflow); Dictionary<string, object> workflow1Parameters = new Dictionary<string, object>(); workflow1Parameters.Add(amountParameter, poAmount); workflowRuntime.CreateWorkflow(workflowType, workflow1Parameters).Start(); waitHandle.WaitOne(); // // start PO approval workflow with purchase order amount greater than $1000 // Console.WriteLine("Workflow 2:"); poAmount = 1200; Dictionary<string, object> workflow2Parameters = new Dictionary<string, object>(); workflow2Parameters.Add(amountParameter, poAmount); workflowRuntime.CreateWorkflow(workflowType, workflow2Parameters).Start(); waitHandle.WaitOne(); //Wait for dynamically created workflow to finish waitHandle.WaitOne(); // After workflows have completed, stop runtime and report to command line workflowRuntime.StopRuntime(); Console.WriteLine("Workflow runtime stopped, program exiting... \n"); } }
static void Main() { // Create WorkflowRuntime using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { try { // Add SqlTrackingService SqlTrackingService sqlTrackingService = new SqlTrackingService(connectionString); sqlTrackingService.IsTransactional = false; workflowRuntime.AddService(sqlTrackingService); // Subscribe to Workflow Suspended WorkflowRuntime Event workflowRuntime.WorkflowSuspended += OnWorkflowSuspended; // Subscribe to Workflow Terminated WorkflowRuntime Event workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; // Start WorkflowRuntime workflowRuntime.StartRuntime(); // Execute the ExceptionWorkflow Workflow WriteTitle("Executing the exception workflow"); WorkflowInstance exceptionWorkflowInstance = workflowRuntime.CreateWorkflow(typeof(ExceptionWorkflow)); exceptionWorkflowInstance.Start(); waitHandle.WaitOne(); QueryAndWriteTrackingInformationToConsole(exceptionWorkflowInstance.InstanceId, TrackingWorkflowEvent.Exception); QueryAndWriteTrackingInformationToConsole(exceptionWorkflowInstance.InstanceId, TrackingWorkflowEvent.Terminated); // Execute the SuspendedWorkflow Workflow WriteTitle("Executing the suspended workflow"); WorkflowInstance suspendedWorkflowInstance = workflowRuntime.CreateWorkflow(typeof(SuspendedWorkflow)); suspendedWorkflowInstance.Start(); waitHandle.WaitOne(); QueryAndWriteTrackingInformationToConsole(suspendedWorkflowInstance.InstanceId, TrackingWorkflowEvent.Suspended); // Stop Runtime workflowRuntime.StopRuntime(); } catch (Exception e) { Console.WriteLine("Encountered an exception. Exception Source: {0}, Exception Message: {1} ", e.Source, e.Message); } finally { workflowRuntime.StopRuntime(); } } }
static void Main() { try { // Create the WorkflowRuntime using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { // Add the SqlWorkflowPersistenceService service WorkflowPersistenceService persistenceService = new SqlWorkflowPersistenceService( "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;", false, new TimeSpan(1, 0, 0), new TimeSpan(0, 0, 5)); workflowRuntime.AddService(persistenceService); // Set up the WorkflowRuntime event handlers workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowIdled += OnWorkflowIdled; workflowRuntime.WorkflowPersisted += OnWorkflowPersisted; workflowRuntime.WorkflowUnloaded += OnWorkflowUnloaded; workflowRuntime.WorkflowLoaded += OnWorkflowLoaded; workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; workflowRuntime.WorkflowAborted += OnWorkflowAborted; // Load the workflow type Type type = typeof(PersistenceServicesWorkflow); // Create an instance of the workflow Console.WriteLine("Workflow Started."); workflowRuntime.CreateWorkflow(type).Start(); // Wait for the event to be signaled waitHandle.WaitOne(); // Stop the runtime workflowRuntime.StopRuntime(); Console.WriteLine("Program Complete."); } } catch (Exception exception) { Console.WriteLine("Application exception occurred: " + exception.Message); } }
static void Main(string[] args) { WorkflowRuntime workflowRuntime = new WorkflowRuntime(); workflowRuntime.AddService(new Microsoft.Samples.Rules.ExternalRuleSetService.ExternalRuleSetService()); 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(); }; WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(GuestPassWorkflow)); instance.Start(); waitHandle.WaitOne(); }
static void Main() { using (WorkflowRuntime runtime = new WorkflowRuntime()) { runtime.AddService(new FileWatcherService(runtime)); runtime.WorkflowCompleted += OnWorkflowCompleted; runtime.WorkflowTerminated += OnWorkflowTerminated; runtime.StartRuntime(); Type type = typeof(Microsoft.Samples.Workflow.FileWatcher.FileWatcherWorkflow); runtime.CreateWorkflow(type).Start(); waitHandle.WaitOne(); runtime.StopRuntime(); Console.WriteLine("The workflow is complete."); } }
private void StartWorkflowRuntime() { // Create a new Workflow Runtime for this application runtime = new WorkflowRuntime(); // Create EventHandlers for the WorkflowRuntime runtime.WorkflowTerminated += new EventHandler<WorkflowTerminatedEventArgs>(Runtime_WorkflowTerminated); runtime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(Runtime_WorkflowCompleted); runtime.WorkflowIdled += new EventHandler<WorkflowEventArgs>(Runtime_WorkflowIdled); // Add the External Data Exchange Service ExternalDataExchangeService dataExchangeService = new ExternalDataExchangeService(); runtime.AddService(dataExchangeService); // Add a new instance of the OrderService to the External Data Exchange Service orderService = new OrderService(); dataExchangeService.AddService(orderService); // Start the Workflow services runtime.StartRuntime(); }
static void Main() { try { // Create the tracking profile to track user track points CreateAndInsertTrackingProfile(); using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { // Add the SQL tracking service to the run time workflowRuntime.AddService(new SqlTrackingService(connectionString)); workflowRuntime.StartRuntime(); workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(typeof(SimpleWorkflow)); workflowInstance.Start(); Guid workflowInstanceId = workflowInstance.InstanceId; // Wait for the workflow to complete waitHandle.WaitOne(); workflowRuntime.StopRuntime(); // Get the tracking events from the database GetUserTrackingEvents(workflowInstanceId); Console.WriteLine("Done Running The workflow."); } } catch (Exception ex) { if (ex.InnerException != null) Console.WriteLine(ex.InnerException.Message); else Console.WriteLine(ex.Message); } }