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


C# WorkflowApplication.Run方法代码示例

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


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

示例1: Button1_Click

    protected void Button1_Click(object sender, EventArgs e)

    {
     
           //设置参数
            Dictionary<string,object> para=new  Dictionary<string, object>();
            CrowdTask task = new CrowdTask(TextBox1.Text,TextBox2.Text);
            para.Add("task", task);

            //启动工作流
           WorkflowApplication crowdsourcing = new WorkflowApplication(new mainTask1(),para);
           task.taskType= TaskType.mainTask;
           crowdsourcing.Run();
           task.taskWorkflowId = crowdsourcing.Id.ToString();
           try
           {
               crowdTaskService = new CrowdTaskService();
               int result = crowdTaskService.insert(task);
               if(result==1){
                   //插入成功,保存对应的工作流实例
                   MyWorkflowInstance.setWorkflowApplication(crowdsourcing.Id.ToString(),crowdsourcing);
                   crowdTaskService.mainTaskSetCrowdTaskMainTaskIdByWorkflowId(crowdsourcing.Id.ToString());
                   Server.Transfer("viewMyTask.aspx?workflowId=" + task.taskWorkflowId);
               }
           }
           catch (Exception exception)
           {
               throw exception ;
           }
          
        
    }
开发者ID:ThinerZQ,项目名称:CrowdSourcingWithWWF,代码行数:32,代码来源:deployTask.aspx.cs

示例2: StartInternal

        protected override void StartInternal()
        {
            DynamicActivity activity;

            using (var stream = new MemoryStream(Encoding.Default.GetBytes(WorkflowDesigner.Text)))
            {
                activity = ActivityXamlServices.Load(stream) as DynamicActivity;
            }

            if (activity == null)
            {
                return;
            }

            WorkflowInspectionServices.CacheMetadata(activity);

            workflowApplication = new WorkflowApplication(activity);

            workflowApplication.Extensions.Add(OutputWriter);
            workflowApplication.Extensions.Add(InitialiseVisualTrackingParticipant(activity));

            workflowApplication.Completed += Completed;
            workflowApplication.OnUnhandledException += OnUnhandledException;
            workflowApplication.Aborted += Aborted;

            try
            {
                workflowApplication.Run();
                OnRunningStateChanged(new WorkflowExecutingStateEventArgs(true));
            }
            catch (Exception e)
            {
                OutputWriter.WriteLine(e.StackTrace);
            }
        }
开发者ID:joaope,项目名称:flowstudio,代码行数:35,代码来源:ActivityDebugger.cs

示例3: WorkflowArgumentsCanPassToWorkflowApplication

        public void WorkflowArgumentsCanPassToWorkflowApplication()
        {
            // Arrange
            var activity = new ArgTest();
            dynamic input = new WorkflowArguments();
            dynamic output = null;
            var completed = new AutoResetEvent(false);
            // Act
            input.Num1 = 2;
            input.Num2 = 3;

            var host = new WorkflowApplication(activity, input);
            host.Completed += args =>
                {
                    output = WorkflowArguments.FromDictionary(args.Outputs);
                    completed.Set();
                };

            host.Run();

            // Wait for complete
            Assert.IsTrue(completed.WaitOne(1000));

            // Assert
            Assert.AreEqual(5, output.Result);
        }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:26,代码来源:WorkflowArgumentsTest.cs

示例4: Run

        static void Run()
        {
            AutoResetEvent applicationUnloaded = new AutoResetEvent(false);
            WorkflowApplication application = new WorkflowApplication(workflow);
            application.InstanceStore = instanceStore;
            SetupApplication(application, applicationUnloaded);

            StepCountExtension stepCountExtension = new StepCountExtension();
            application.Extensions.Add(stepCountExtension);

            application.Run();
            Guid id = application.Id;
            applicationUnloaded.WaitOne();

            while (stepCountExtension.CurrentCount < totalSteps)
            {
                application = new WorkflowApplication(workflow);
                application.InstanceStore = instanceStore;
                SetupApplication(application, applicationUnloaded);

                stepCountExtension = new StepCountExtension();
                application.Extensions.Add(stepCountExtension);
                application.Load(id);

                string input = Console.ReadLine();

                application.ResumeBookmark(echoPromptBookmark, input);
                applicationUnloaded.WaitOne();
            }
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:30,代码来源:Program.cs

示例5: Main

        static void Main(string[] args)
        {
            _event = new AutoResetEvent(false);
            bool more = true;
            int result = 0;
            var activity = new AccumulatorActivity();
            var accumulator = new WorkflowApplication(activity);
            accumulator.Completed = new Action<WorkflowApplicationCompletedEventArgs>((e) =>
            {
                result = (int)e.Outputs["Sum"];
                more = false;
                _event.Set();
            });
            accumulator.Extensions.Add(new Notification(NotifySum));
            accumulator.Run();

            while (more)
            {
                Console.Write("Enter number: ");
                int number = int.Parse(Console.ReadLine());
                accumulator.ResumeBookmark("GetNumber", number);
                _event.WaitOne();
            }

            Console.WriteLine("Result is " + result);
        }
开发者ID:object,项目名称:CloudWorkflows,代码行数:26,代码来源:Program.cs

示例6: Main

        private static void Main(string[] args)
        {
            const int workflowCompleted = 0;
            const int workflowIdle = 1;

            var syncEvents = new[]
                                 {
                                     new AutoResetEvent(false),
                                     new AutoResetEvent(false),
                                 };
            var wfApp = new WorkflowApplication(new TestReadLine());
            string bookmarkName = string.Empty;
            bool workflowComplete = false;

            // Signal the main thread we are done
            wfApp.Completed = (e) => syncEvents[workflowCompleted].Set();

            // When the host detects an idle
            wfApp.Idle = (e) =>
                             {
                                 // Search the bookmarks
                                 foreach (
                                     var bi in
                                         e.Bookmarks.Where(
                                             bi => bi.BookmarkName == "FirstName" || bi.BookmarkName == "LastName"))
                                 {
                                     Console.WriteLine("Found bookmark {0}", bi.BookmarkName);
                                     // For FirstName or LastName bookmarks prompt with a readline
                                     bookmarkName = bi.BookmarkName;
                                     syncEvents[workflowIdle].Set();
                                 }
                             };

            wfApp.Run();

            while (!workflowComplete)
            {
                // Wait for events
                switch (WaitHandle.WaitAny(syncEvents, TimeSpan.FromSeconds(5)))
                {
                    case WaitHandle.WaitTimeout:
                        Console.WriteLine("Sorry you took too long");
                        wfApp.Terminate("Timeout");
                        break;

                    case workflowCompleted:
                        workflowComplete = true;
                        break;

                    case workflowIdle:
                        Console.WriteLine("Reading response for bookmark {0}", bookmarkName);
                        // Resume with the response from the user
                        wfApp.ResumeBookmark(bookmarkName, Console.ReadLine());
                        break;
                }
            }

            Console.WriteLine("Sample Completed - press any key to exit");
            Console.ReadKey(true);
        }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:60,代码来源:Program.cs

示例7: Main

        static void Main(string[] args)
        {
            Console.WriteLine("***** Welcome to this amazing WF application *****");

            // Get data from user, to pass to workflow.
            Console.Write("Please enter the data to pass the workflow: ");
            string wfData = Console.ReadLine();

            // Package up the data as a dictionary.
            Dictionary<string, object> wfArgs = new Dictionary<string, object>();
            wfArgs.Add("MessageToShow", wfData);

            // Used to inform primary thread to wait!
            AutoResetEvent waitHandle = new AutoResetEvent(false);

            // Pass to the workflow.
            WorkflowApplication app = new WorkflowApplication(new Workflow1(), wfArgs);

            // Hook up an event with this app.
            // When I’m done, notifiy other thread I’m done,
            // and print a message.
            app.Completed = (completedArgs) =>
            {
                waitHandle.Set();
                Console.WriteLine("The workflow is done!");
            };

            // Start the workflow!
            app.Run();

            // Wait until I am notified the workflow is done.
            waitHandle.WaitOne();

            Console.WriteLine("Thanks for playing");
        }
开发者ID:usedflax,项目名称:flaxbox,代码行数:35,代码来源:Program.cs

示例8: Main

        static void Main(string[] args)
        {
            var connStr = @"Data Source=.\sqlexpress;Initial Catalog=WorkflowInstanceStore;Integrated Security=True;Pooling=False";
            SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore(connStr);

            Workflow1 w = new Workflow1();

            //instanceStore.
            //IDictionary<string, object> xx=WorkflowInvoker.Invoke(new Workflow1());
            //ICollection<string> keys=xx.Keys;

            WorkflowApplication a = new WorkflowApplication(w);
            a.InstanceStore = instanceStore;
            a.GetBookmarks();
            //a.ResumeBookmark("Final State", new object());

            a.Run();
            //a.ResumeBookmark(

            //a.Persist();
            //a.Unload();
            //Guid id = a.Id;
            //WorkflowApplication b = new WorkflowApplication(w);
            //b.InstanceStore = instanceStore;
            //b.Load(id);
            //WorkflowApplication a=new WorkflowApplication(
        }
开发者ID:cpm2710,项目名称:cellbank,代码行数:27,代码来源:Program.cs

示例9: Main

        /*
         * Enable Analytic and Debug Logs:
         * Event Viewer -> Applications and Services Logs ->
         * Microsoft -> Windows -> Application Server-Applications
         * Right-click "Application Server-Applications" -> select View ->
         * Show Analytic and Debug Logs -> Refresh
         * */
        static void Main(string[] args)
        {
            //Tracking Configuration
            TrackingProfile trackingProfile = new TrackingProfile();
            trackingProfile.Queries.Add(new WorkflowInstanceQuery
            {
                States = { "*" }
            });
            trackingProfile.Queries.Add(new ActivityStateQuery
            {
                States = { "*" }
            });
            trackingProfile.Queries.Add(new CustomTrackingQuery
            {
                ActivityName = "*",
                Name = "*"
            });
            EtwTrackingParticipant etwTrackingParticipant =
                new EtwTrackingParticipant();
            etwTrackingParticipant.TrackingProfile = trackingProfile;

            // Run workflow app "Workflow1.xaml"
            AutoResetEvent waitHandler = new AutoResetEvent(false);
            WorkflowApplication wfApp =
                new WorkflowApplication(new Workflow1());
            wfApp.Completed = (arg) => { waitHandler.Set(); };
            wfApp.Extensions.Add(etwTrackingParticipant);
            wfApp.Run();
            waitHandler.WaitOne();
        }
开发者ID:0xack13,项目名称:WF45Persistence,代码行数:37,代码来源:Program.cs

示例10: Start

        public override void Start()
        {
            if (IsRunning)
            {
                return;
            }

            using (var stream = new MemoryStream(Encoding.Default.GetBytes(Xaml)))
            {
                workflowApplication = new WorkflowApplication(ActivityXamlServices.Load(stream));
            }

            workflowApplication.Extensions.Add(OutputWriter);

            workflowApplication.Completed += OnWorkflowCompleted;
            workflowApplication.Aborted += OnWorkflowAborted;
            workflowApplication.OnUnhandledException += OnWorkflowUnhandledException;

            try
            {
                OnExecutingStateChanged(new WorkflowExecutingStateEventArgs(true));
                workflowApplication.Run();
            }
            catch (Exception e)
            {
                OutputWriter.WriteLine(e.StackTrace);
                OnExecutingStateChanged(new WorkflowExecutingStateEventArgs(false));
            }
        }
开发者ID:joaope,项目名称:flowstudio,代码行数:29,代码来源:ActivityRunner.cs

示例11: Main

        static void Main(string[] args)
        {
            WorkflowApplication wfApplication = new WorkflowApplication(new Activity1());

            SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore(ConfigurationManager.ConnectionStrings["ZhuangBPM"].ToString());
            wfApplication.InstanceStore = instanceStore;


            InstanceView view = instanceStore.Execute(instanceStore.CreateInstanceHandle(), new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30));
            instanceStore.DefaultInstanceOwner = view.InstanceOwner;
 


            wfApplication.PersistableIdle = (e) => {
                System.Console.WriteLine("persistableIdle:{0}", e.InstanceId); 

                return PersistableIdleAction.Unload;
            };

            wfApplication.Run();



            Console.ReadKey();
        }
开发者ID:weibin268,项目名称:Zhuang.BPM,代码行数:25,代码来源:Program.cs

示例12: Main

        static void Main(string[] args)
        {
            var process = new WorkflowApplication(new Process());
            process.Run();

            System.Console.ReadKey();
        }
开发者ID:bejubi,项目名称:MmapMan,代码行数:7,代码来源:Program.cs

示例13: Main

        static void Main(string[] args)
        {
            AutoResetEvent syncEvent = new AutoResetEvent(false);

            // create the workflow app and add handlers for the Idle and Completed actions
            WorkflowApplication app = new WorkflowApplication(new Sequence1());
            app.Idle = delegate(WorkflowApplicationIdleEventArgs e)
            {
                syncEvent.Set();
            };
            app.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
            {
                syncEvent.Set();
            };

            // start the application
            app.Run();
            syncEvent.WaitOne();

            // read some text from the console and resume the readText bookmark (created in the first WaitForInput activity)
            string text = Console.ReadLine();
            app.ResumeBookmark("readText", text);
            syncEvent.WaitOne();

            // read some text from the console, convert it to number, and resume the readNumber bookmark (created in the second WaitForInput activity)
            int number = ReadNumberFromConsole();
            app.ResumeBookmark("readNumber", number);
            syncEvent.WaitOne();

            Console.WriteLine("");
            Console.WriteLine("Press [ENTER] to exit...");
            Console.ReadLine();
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:33,代码来源:Program.cs

示例14: Main

        static void Main(string[] args)
        {
            AutoResetEvent syncEvent = new AutoResetEvent(false);
            IDictionary<string, object> input = new Dictionary<string, object>()
            {
                {"Number1", 123},
                {"Number2", 456}
            };

            IDictionary<string, object> output = null;

            WorkflowApplication wfApp = new WorkflowApplication(new Workflow1(), input);
            wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
            {
                Console.WriteLine("Workflow thread id:" + Thread.CurrentThread.ManagedThreadId);
                output = e.Outputs;
                syncEvent.Set();
            };

            wfApp.Run();
            syncEvent.WaitOne();
            Console.WriteLine(output["Result"].ToString());
            Console.WriteLine("Host thread id:" + Thread.CurrentThread.ManagedThreadId);

            WorkflowInvoker.Invoke(new Workflow1());
            Console.WriteLine("Presione una letra para continuar...");
            Console.ReadKey();
        }
开发者ID:vvalotto,项目名称:PlataformaNET,代码行数:28,代码来源:Program.cs

示例15: btnEdit_ServerClick

    //end
    protected void btnEdit_ServerClick(object sender, EventArgs e)
    {
        if (((this.txtName.Value.Length == 0) || (this.uploadurl.Value.Length == 0)) || (this.selWorkFlow.SelectedValue.Length == 0))
        {
            MessageBox.Show(this, "请您填写完整的信息");
        }
        else
        {
            Model.SelectRecord selectRecord = new Model.SelectRecord("WorkFlow", "", "*", "where id='" + this.selWorkFlow.SelectedValue + "'");
            DataTable table = BLL.SelectRecord.SelectRecordData(selectRecord).Tables[0];
            string content = File.ReadAllText(System.Web.HttpContext.Current.Request.MapPath("../") + table.Rows[0]["URL"].ToString());

            //ziyunhx add 2013-8-5 workflow Persistence
            //old code
            //WorkFlowTracking.instance = engineManager.createInstance(content, null, null);
            //WorkFlowTracking.instance.Run();
            //new code
            instance = engineManager.createInstance(content, null, null);
            if (instanceStore == null)
            {
                instanceStore = new SqlWorkflowInstanceStore(SqlHelper.strconn);
                view = instanceStore.Execute(instanceStore.CreateInstanceHandle(), new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30));
                instanceStore.DefaultInstanceOwner = view.InstanceOwner;
            }
            instance.InstanceStore = instanceStore;
            instance.Run();
            //end

            Model.Document documents = new Model.Document
            {
                ID = id.Trim(),
                Name = this.txtName.Value.Trim(),
                URL = this.uploadurl.Value.Trim(),
                Remark = this.txtReMark.Value.Trim(),
                WID = this.selWorkFlow.SelectedValue,
                WStep = "0",
                Result = "0",
                UID = this.Session["admin"].ToString(),
                //ziyunhx add 2013-8-5 workflow Persistence
                //old code
                //FlowInstranceID = WorkFlowTracking.instance.Id,
                //new code
                FlowInstranceID = instance.Id,
                //end
            };

            if (BLL.Document.DocumentUpdate(documents) == 1)
            {
                UserOperatingManager.InputUserOperating(this.Session["admin"].ToString(), "工作流管理", "编辑工作流" + documents.Name + "的信息成功");
                MessageBox.ShowAndRedirect(this, "编辑公文成功!", "/document/DocumentList.aspx");
            }
            else
            {
                UserOperatingManager.InputUserOperating(this.Session["admin"].ToString(), "工作流管理", "编辑工作流" + documents.Name + "的信息失败");
                MessageBox.Show(this, "编辑工作流失败");
            }
        }
    }
开发者ID:rensy,项目名称:DocumentManage,代码行数:59,代码来源:EditDocument.aspx.cs


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