当前位置: 首页>>代码示例>>C#>>正文


C# WorkflowRuntime.CreateWorkflow方法代码示例

本文整理汇总了C#中WorkflowRuntime.CreateWorkflow方法的典型用法代码示例。如果您正苦于以下问题:C# WorkflowRuntime.CreateWorkflow方法的具体用法?C# WorkflowRuntime.CreateWorkflow怎么用?C# WorkflowRuntime.CreateWorkflow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WorkflowRuntime的用法示例。


在下文中一共展示了WorkflowRuntime.CreateWorkflow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        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();
            }
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:31,代码来源:Program.cs

示例2: Main

        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);
            }
        }
开发者ID:ssickles,项目名称:archive,代码行数:51,代码来源:Program.cs

示例3: Main

        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");
            }
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:50,代码来源:Program.cs

示例4: Main

        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();
                }
            }
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:48,代码来源:Program.cs

示例5: Main

        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.");
                }
            }
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:34,代码来源:Program.cs

示例6: Main

        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");
                }
            }
        }
开发者ID:ssickles,项目名称:archive,代码行数:32,代码来源:Program.cs

示例7: Main

        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();
            }
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:27,代码来源:Program.cs

示例8: Main

        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();
                }
            }
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:33,代码来源:Program.cs

示例9: Main

        static void Main(string[] args)
        {
            using(WorkflowRuntime workflowRuntime = new WorkflowRuntime())
            {
                AutoResetEvent waitHandle = new AutoResetEvent(false);
                workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) 
                {
                    Console.WriteLine("Workflow completed.");
                    waitHandle.Set();
                };
                workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
                {
                    Console.WriteLine(e.Exception.Message);
                    waitHandle.Set();
                };

                WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(StateInitialization.SampleWorkflow));
                Console.WriteLine("Starting workflow.");
                instance.Start();

                waitHandle.WaitOne();

                workflowRuntime.StopRuntime();
            }
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:25,代码来源:Program.cs

示例10: Main

        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();
            }
        }
开发者ID:ssickles,项目名称:archive,代码行数:31,代码来源:Program.cs

示例11: Main

        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);
            }
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:32,代码来源:Program.cs

示例12: MainForm

        /////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////
        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
        }
开发者ID:SiTox,项目名称:07-SK-K-B,代码行数:35,代码来源:MainForm.cs

示例13: Main

        static void Main()
        {
            using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
            {
                try
                {
                    // Start the engine
                    workflowRuntime.StartRuntime();

                    // Subscribe to events
                    workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;
                    workflowRuntime.WorkflowTerminated += OnWorkflowTerminated;

                    workflowRuntime.WorkflowIdled += OnWorkflowIdled;
                    workflowRuntime.ServicesExceptionNotHandled += OnServicesExceptionNotHandled;

                    // Start PO approval workflow with purchase less than $1000
                    System.Int32 poAmount = 750;
                    Type workflowType = typeof(Microsoft.Samples.Workflow.DynamicUpdateFromHost.DynamicUpdateWorkflow);
                    Dictionary<string, object> inputParameters = new Dictionary<string, object>();
                    inputParameters.Add("Amount", poAmount);
                    workflowRuntime.CreateWorkflow(workflowType, inputParameters).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");
                }
            }
        }
开发者ID:ssickles,项目名称:archive,代码行数:35,代码来源:Program.cs

示例14: Main

        static void Main()
        {
            // Start the engine.
            using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
            {
                workflowRuntime.StartRuntime();

                // Load the workflow type.
                Type type = typeof(SuspendAndTerminateWorkflow);

                workflowRuntime.WorkflowCompleted += OnWorkflowCompletion;
                workflowRuntime.WorkflowSuspended += OnWorkflowSuspend;
                workflowRuntime.WorkflowResumed += OnWorkflowResume;
                workflowRuntime.WorkflowTerminated += OnWorkflowTerminate;

                WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(type);
                workflowInstance.Start();

                waitHandle.WaitOne();

                if (workflowSuspended)
                {
                    Console.WriteLine("\r\nResuming Workflow Instance");
                    workflowInstance.Resume();
                    waitHandle.WaitOne();
                }

                workflowRuntime.StopRuntime();
            }

        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:31,代码来源:Program.cs

示例15: Main

        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();
            }
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:28,代码来源:Program.cs


注:本文中的WorkflowRuntime.CreateWorkflow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。