Exemple #1
0
        /*
         * 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();
        }
        static void Main(string[] args)
        {
            AutoResetEvent syncEvent = new AutoResetEvent(false);
            AutoResetEvent idleEvent = new AutoResetEvent(false);

            var inputs = new Dictionary<string, object>() { { "MaxNumber", 100 } };

            WorkflowApplication wfApp =
                new WorkflowApplication(new SequentialNumberGuessWorkflow(), inputs);

            wfApp.Completed = (e) =>
            {
                int Turns = Convert.ToInt32(e.Outputs["Turns"]);
                Console.WriteLine("Congratulations, you guessed the number in {0} turns.", Turns);

                syncEvent.Set();
            };

            wfApp.Aborted = (e) =>
            {
                Console.WriteLine(e.Reason);
                syncEvent.Set();
            };

            wfApp.OnUnhandledException = (e) =>
            {
                Console.WriteLine(e.UnhandledException.ToString());
                return UnhandledExceptionAction.Terminate;
            };

            wfApp.Idle = (e) =>
            {
                idleEvent.Set();
            };


            var config = @"{
                                ""WorkflowInstanceQuery"" :
                                                            [{
                                                                ""States"":
                                                                            [
                                                                                ""*""
                                                                            ]
                                                                , ""QueryAnnotations"": {}
                                                            }]
                               , ""ActivityStateQuery"" :
                                                            [{
                                                                ""ActivityName"": ""*""
                                                                , ""Arguments"": []
                                                                , ""Variables"": []
                                                                , ""States"": [""*""]
                                                                , ""QueryAnnotations"": {}
                                                            }]
                                ,
                                ""CustomTrackingQuery"": [{
                                                                ""Name"": ""*"",
                                                                ""ActivityName"": ""*"",
                                                                ""QueryAnnotations"": {}
                                                            }]
                                ,
                                ""FaultPropagationQuery"": [{
                                                                ""FaultHandlerActivityName"": ""*"",
                                                                ""FaultSourceActivityName"": ""*"",
                                                                ""QueryAnnotations"": {}
                                                                }],
                                ""BookmarkResumptionQuery"": [{
                                                                    ""Name"": ""*"",
                                                                    ""QueryAnnotations"": {}
                                                                    }],
                                ""ActivityScheduledQuery"": [{
                                                                ""ActivityName"": ""*"",
                                                                ""ChildActivityName"": ""*"",
                                                                ""QueryAnnotations"": {}
                                                                }],
                                ""CancelRequestedQuery"": [{
                                                                ""ActivityName"": ""*"",
                                                                ""ChildActivityName"": ""*"",
                                                                ""QueryAnnotations"": {}
                                                                }]
                            }";
            var trackingProfile = WorkFlowHelper
                                        .GetTrackingProfileFromJson
                                                (
                                                    config
                                                    , true
                                                );
            var etwTrackingParticipant = new EtwTrackingParticipant();
            etwTrackingParticipant.TrackingProfile = trackingProfile;
            var commonTrackingParticipant = new CommonTrackingParticipant()
            {
                TrackingProfile = trackingProfile
                ,
                OnTrackingRecordReceived = (x, y) =>
                                          {
                                              Console.WriteLine("{1}{0}{2}", ",", x, y);
                                              return true;
                                          }
            };
            
            wfApp
                .Extensions
                .Add
                    (
                        etwTrackingParticipant
                    );
            wfApp
                .Extensions
                .Add
                    (
                        commonTrackingParticipant
                    );

            wfApp.Run();

            // Loop until the workflow completes.
            WaitHandle[] handles = new WaitHandle[] { syncEvent, idleEvent };
            while (WaitHandle.WaitAny(handles) != 0)
            {
                // Gather the user input and resume the bookmark.
                bool validEntry = false;
                while (!validEntry)
                {
                    int Guess;
                    if (!int.TryParse(Console.ReadLine(), out Guess))
                    {
                        Console.WriteLine("Please enter an integer.");
                    }
                    else
                    {
                        validEntry = true;
                        wfApp.ResumeBookmark("EnterGuess", Guess);
                    }
                }
            }
        }
Exemple #3
0
        private void btnStart_Click(object sender, RoutedEventArgs e)
        {
            var projectInfo = new ProjectInformation
            {
                ProjectName = txtProjectName.Text,
                ApplicationInfo = _applicationData.ToList()
            };
            var workflowArgs =
                new Dictionary<string, object> {{"ProjectInfo", projectInfo}};

            _workflow = new WorkflowApplication(new TheWorkflow(),workflowArgs)
            {
                Completed = WorkflowCompletedCallback,
                Idle = WorkflowIdleCallback
            };

            _workflow.Extensions.Add(new List<string>());

            _workflow.Extensions.Add(_wce);

            var trackingParticipant = new EtwTrackingParticipant();

            var trackingProfile = new TrackingProfile
            {
                Name = "SampleTrackingProfile",
                ActivityDefinitionId = "FIB-->FIS"
            };

            trackingProfile.Queries.Add(new WorkflowInstanceQuery {States = {"*"}});

            _workflow.Extensions.Add(trackingParticipant);

            txbOutput.Text += "Starting planning phase...\r\n";

            _workflow.Run();
        }
 private void CreateETWTrackingParticipant()
 {
     _etwTracking = new EtwTrackingParticipant()
     {
         TrackingProfile = new TrackingProfile()
         {
             Name = "EtwTrackingProfile",
             Queries =
                     {
                     new CustomTrackingQuery()
                     {
                     Name = "*",
                     ActivityName = "*"
                     }
                     }
         }
     };
 }