• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Activities.WorkflowApplication类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



WorkflowApplication类属于System.Activities命名空间,在下文中一共展示了WorkflowApplication类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Run

        public void Run()
        {
            this.workflowDesigner.Flush();
            MemoryStream ms = new MemoryStream(ASCIIEncoding.Default.GetBytes(this.workflowDesigner.Text));

            DynamicActivity activityToRun = ActivityXamlServices.Load(ms) as DynamicActivity;

            this.workflowApplication = new WorkflowApplication(activityToRun);

            this.workflowApplication.Extensions.Add(this.output);
            this.workflowApplication.Completed = this.WorkflowCompleted;
            this.workflowApplication.Aborted = this.WorkflowAborted;
            this.workflowApplication.OnUnhandledException = this.WorkflowUnhandledException;
            StatusViewModel.SetStatusText(Resources.RunningStatus, this.workflowName);

            try
            {
                this.running = true;
                this.workflowApplication.Run();
            }
            catch (Exception e)
            {
                this.output.WriteLine(ExceptionHelper.FormatStackTrace(e));
                StatusViewModel.SetStatusText(Resources.ExceptionStatus, this.workflowName);
                this.running = false;
            }
        }
开发者ID:yinqunjun,项目名称:WorkflowFoundation.40.45.Development,代码行数:27,代码来源:WorkflowRunner.cs


示例2: LoadAndCompleteInstance

        static void LoadAndCompleteInstance()
        {
            string input = Console.ReadLine();

            WorkflowApplication application = new WorkflowApplication(activity);
            application.InstanceStore = instanceStore;

            application.Completed = (workflowApplicationCompletedEventArgs) =>
            {
                Console.WriteLine("\nWorkflowApplication has Completed in the {0} state.", workflowApplicationCompletedEventArgs.CompletionState);
            };

            application.Unloaded = (workflowApplicationEventArgs) =>
            {
                Console.WriteLine("WorkflowApplication has Unloaded\n");
                instanceUnloaded.Set();
            };

            application.Load(id);

            //this resumes the bookmark setup by readline
            application.ResumeBookmark(readLineBookmark, input);

            instanceUnloaded.WaitOne();
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:25,代码来源:Program.cs


示例3: 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


示例4: 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


示例5: RunWorkflow

        // resume execution of a workflow instance
        static void RunWorkflow(WorkflowApplication application, AutoResetEvent resetEvent)
        {
            application.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
            {
                Console.WriteLine("Workflow completed in state " + e.CompletionState);

                if (e.TerminationException != null)
                {
                    Console.WriteLine("Termination exception: " + e.TerminationException);
                }

                Console.WriteLine("-------------------------------");
                Console.WriteLine("- Input has been written to {0}\\out.txt", Environment.CurrentDirectory);
                Console.WriteLine("-------------------------------");

                resetEvent.Set();
            };
            application.Unloaded = delegate(WorkflowApplicationEventArgs e)
            {
                Console.WriteLine("Workflow unloaded");
                resetEvent.Set();
            };

            application.Run();
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:26,代码来源:Program.cs


示例6: Add

 /// <summary>
 /// Adds a new WorkflowApplication to the cache
 /// </summary>
 /// <param name="application">
 /// The application. 
 /// </param>
 /// <returns>
 /// The WorkflowApplication that was added or updated 
 /// </returns>
 public WorkflowApplication Add(WorkflowApplication application)
 {
     Debug.Assert(this.dictionary != null, "dictionary != null");
     var observer = new WorkflowApplicationObserver(application) { Aborted = this.Aborted };
     return this.dictionary.AddOrUpdate(
         application.Id, guid => application, (guid, workflowApplication) => application);
 }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:16,代码来源:WorkflowApplicationCache.cs


示例7: 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


示例8: AnyActivityInstanceStateFindsClosed

        public void AnyActivityInstanceStateFindsClosed()
        {
            // Arrange
            var activity = new AddToNumOrThrow();
            dynamic args = new WorkflowArguments();
            args.Num = 2;
            var host = new WorkflowApplication(activity, args);
            var tracking = new ListTrackingParticipant();
            host.Extensions.Add(tracking);

            try
            {
                host.RunEpisode();

                // Act
                var any = tracking.Records.Any(ActivityInstanceState.Closed);

                // Assert
                Assert.IsTrue(any);
            }
            finally
            {
                tracking.Trace();
            }
        }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:25,代码来源:ActivityStateRecordEnumerableTest.cs


示例9: 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


示例10: LoadAndExecute

        protected override void LoadAndExecute()
        {
            MemoryStream ms = new MemoryStream(ASCIIEncoding.Default.GetBytes(this.workflowDesigner.Text));
            DynamicActivity workflowToRun = ActivityXamlServices.Load(ms) as DynamicActivity;

            WorkflowInspectionServices.CacheMetadata(workflowToRun);

            this.workflowApplication = new WorkflowApplication(workflowToRun);

            this.workflowApplication.Extensions.Add(this.output);

            this.workflowApplication.Completed = this.WorkflowCompleted;
            this.workflowApplication.OnUnhandledException = this.WorkflowUnhandledException;
            this.workflowApplication.Aborted = this.WorkflowAborted;

            this.workflowApplication.Extensions.Add(this.InitialiseVisualTrackingParticipant(workflowToRun));

            try
            {
                this.running = true;
                this.workflowApplication.Run();
            }
            catch (Exception e)
            {
                this.output.WriteLine(ExceptionHelper.FormatStackTrace(e));
                StatusViewModel.SetStatusText(Resources.ExceptionInDebugStatus, this.workflowName);
            }
        }
开发者ID:yinqunjun,项目名称:WorkflowFoundation.40.45.Development,代码行数:28,代码来源:WorkflowDebugger.cs


示例11: Main

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

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


示例12: 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


示例13: 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


示例14: 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


示例15: Interact

        static void Interact(WorkflowApplication application)
        {
            IList<BookmarkInfo> bookmarks = application.GetBookmarks();

            while (true)
            {
                Console.Write("Bookmarks:");
                foreach (BookmarkInfo info in bookmarks)
                {
                    Console.Write(" '" + info.BookmarkName + "'");
                }
                Console.WriteLine();

                Console.WriteLine("Enter the name of the bookmark to resume");
                string bookmarkName = Console.ReadLine();

                if (bookmarkName != null && !bookmarkName.Equals(string.Empty))
                {
                    Console.WriteLine("Enter the payload for the bookmark '{0}'", bookmarkName);
                    string bookmarkPayload = Console.ReadLine();

                    BookmarkResumptionResult result = application.ResumeBookmark(bookmarkName, bookmarkPayload);
                    if (result == BookmarkResumptionResult.Success)
                    {
                        return;
                    }
                    else
                    {
                        Console.WriteLine("BookmarkResumptionResult: " + result);
                    }
                }
            }
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:33,代码来源:Program.cs


示例16: 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


示例17: Interact

        // single interaction with the user. The user enters a string in the console and that
        // string is used to resume the ReadLine activity bookmark
        static void Interact(WorkflowApplication application, AutoResetEvent resetEvent)
        {
            Console.WriteLine("Workflow is ready for input");
            Console.WriteLine("Special commands: 'unload', 'exit'");

            bool done = false;
            while (!done)
            {
                Console.Write("> ");
                string s = Console.ReadLine();
                if (s.Equals("unload"))
                {
                    try
                    {
                        // attempt to unload will fail if the workflow is idle within a NoPersistZone
                        application.Unload(TimeSpan.FromSeconds(5));
                        done = true;
                    }
                    catch (TimeoutException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
                else if (s.Equals("exit"))
                {
                    application.ResumeBookmark("inputBookmark", s);
                    done = true;
                }
                else
                {
                    application.ResumeBookmark("inputBookmark", s);
                }
            }
            resetEvent.WaitOne();
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:37,代码来源:Program.cs


示例18: RunCheckCheck

 public static void RunCheckCheck(Guid id, ReviewCheckCheck Form)
 {
     SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore(@"server=.\SQLEXPRESS;database=aspnetdb;uid=sa;pwd=123456");
     WorkflowApplication application2 = new WorkflowApplication(new DocumentPublish());
     application2.InstanceStore = instanceStore;
     application2.Completed = (workflowApplicationCompletedEventArgs) =>
     {
         Console.WriteLine("\nWorkflowApplication has Completed in the {0} state.", workflowApplicationCompletedEventArgs.CompletionState);
         instanceUnloaded.Set();
     };
     application2.PersistableIdle = (e) =>
     {
         instanceUnloaded.Set();
         return PersistableIdleAction.Unload;
     };
     application2.Unloaded = (workflowApplicationEventArgs) =>
     {
         Console.WriteLine("WorkflowApplication has Unloaded\n");
         instanceUnloaded.Set();
     };
     application2.Load(id);
     application2.ResumeBookmark("WaitCheckingChecking", Form);
     instanceUnloaded.WaitOne();
     Console.ReadLine();
 }
开发者ID:huaminglee,项目名称:yunshanoa,代码行数:25,代码来源:DocumentWorkFlowProcess.cs


示例19: 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


示例20: CreateAndRun

        // creates a workflow application, binds parameters, links extensions and run it
        public WorkflowApplication CreateAndRun(RequestForProposal rfp)
        {
            // input parameters for the WF program
            IDictionary<string, object> inputs = new Dictionary<string, object>();
            inputs.Add("Rfp", rfp);

            // create and run the WF instance
            Activity wf = new PurchaseProcessWorkflow();
            WorkflowApplication instance = new WorkflowApplication(wf, inputs);
            XmlWorkflowInstanceStore store = new XmlWorkflowInstanceStore(instance.Id);
            instance.InstanceStore = store;
            instance.PersistableIdle += OnIdleAndPersistable;
            instance.Completed += OnWorkflowCompleted;
            instance.Idle += OnIdle;

            //Create the persistence Participant and add it to the workflow instance
            XmlPersistenceParticipant xmlPersistenceParticipant = new XmlPersistenceParticipant(instance.Id);
            instance.Extensions.Add(xmlPersistenceParticipant);

            // add a tracking participant
            instance.Extensions.Add(new SaveAllEventsToTestFileTrackingParticipant());

            // add instance to the host list of running instances
            this.instances.Add(instance.Id, instance);

            // continue executing this instance
            instance.Run();

            return instance;
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:31,代码来源:PurchaseProcessHost.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Presentation.EditingContext类代码示例发布时间:2022-05-26
下一篇:
C# Activities.Variable类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap