Esempio n. 1
0
        static void Main(string[] args)
        {
            var trackingProfile = new TrackingProfile();

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

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

            trackingProfile.Queries.Add(new CustomTrackingQuery
            {
                ActivityName = "*",
                Name         = "*"
            });

            var etwTrackingParticipant = new EtwTrackingParticipant {
                TrackingProfile = trackingProfile
            };
            var waitHandler = new AutoResetEvent(initialState: false);

            var wfApp = new WorkflowApplication(new Workflow1());

            wfApp.Completed = (arg) => { waitHandler.Set(); };
            wfApp.Extensions.Add(etwTrackingParticipant);
            wfApp.Run();
            waitHandler.WaitOne();
        }
 private void CreateETWTrackingParticipant()
 {
     _etwTracking = new EtwTrackingParticipant()
     {
         TrackingProfile = new TrackingProfile()
         {
             Name    = "EtwTrackingProfile",
             Queries =
             {
                 new CustomTrackingQuery()
                 {
                     Name         = "*",
                     ActivityName = "*"
                 }
             }
         }
     };
 }
Esempio n. 3
0
        static void Main(string[] args)
        {
            //var waitHandler = new AutoResetEvent(false);
            //var bookmarkName = "inputBookmark";
            //var sqlPersistenceDbConnectionString = @"Server=.\SQLEXPRESS;Initial Catalog=PersistenceDatabase;Integrated Security=True";
            //var sqlWFInstanceStore = new SqlWorkflowInstanceStore(sqlPersistenceDbConnectionString);
            //var wfApp = new WorkflowApplication(new HolidayRequestWf()
            //{
            //    bookmarkName = bookmarkName
            //});
            //wfApp.InstanceStore = sqlWFInstanceStore;
            //wfApp.Completed = (arg) => { waitHandler.Set(); };
            //wfApp.Run();
            //wfApp.ResumeBookmark(bookmarkName, Console.ReadLine());
            //waitHandler.WaitOne();
            var trackingProfile = new TrackingProfile();

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

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

            trackingProfile.Queries.Add(new CustomTrackingQuery
            {
                ActivityName = "*",
                Name         = "*"
            });

            var etwTrackingParticipant = new EtwTrackingParticipant {
                TrackingProfile = trackingProfile
            };
        }
        static void ProcessOnce(int i)
        {
            var wfApp = WorkFlowHelper
                        .CreateApplication
                        (
                "a:" + (i % 4).ToString()
                , () =>
            {
                return
                (_xaml);
            }
                        );

            wfApp.Completed = (e) =>
            {
                //Console.WriteLine(e.InstanceId);
            };

            wfApp.Aborted = (e) =>
            {
            };

            //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);
            //        }
            //    }
            //}
        }
        static void Main()
        {
            DynamicJson dj = DynamicJson.Parse("{\"F1\":10}");

            var xx     = dj["F1"].GetValue <int>();
            var inputs = new Dictionary <string, object>()
            {
                { "Inputs", dj }
            };

            var wfApp = WorkFlowHelper
                        .CreateApplication
                        (
                "aa"
                , () =>
            {
                return
                (_xaml);
            }
                , 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();
            };

            wfApp.Run();

            Console.ReadLine();
            return;


            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();

            Console.ReadLine();

            //// 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);
            //        }
            //    }
            //}
        }
Esempio n. 6
0
        private static void ETWTrackingWithProfile(Int32 profileNumber)
        {
            UpdateInventory wf = new UpdateInventory();

            wf.ArgSalesOrderId = 43687;
            WorkflowInvoker instance = new WorkflowInvoker(wf);

            EtwTrackingParticipant tp = new EtwTrackingParticipant();

            switch (profileNumber)
            {
            case 1:
                //select workflow instance states
                tp.TrackingProfile = new TrackingProfile
                {
                    Name    = "MyTrackingProfile",
                    Queries =
                    {
                        new WorkflowInstanceQuery
                        {
                            States =
                            {
                                WorkflowInstanceStates.Started,
                                WorkflowInstanceStates.Completed,
                            }
                        }
                    }
                };
                break;

            case 2:
                //all workflow instance states
                tp.TrackingProfile = new TrackingProfile
                {
                    Name    = "MyTrackingProfile",
                    Queries =
                    {
                        new WorkflowInstanceQuery
                        {
                            States ={ "*"              }
                        }
                    }
                };
                break;

            case 3:
                //selected activity states
                tp.TrackingProfile = new TrackingProfile
                {
                    Name    = "MyTrackingProfile",
                    Queries =
                    {
                        new WorkflowInstanceQuery
                        {
                            States ={ "*"              }
                        },
                        new ActivityStateQuery
                        {
                            States =
                            {
                                ActivityStates.Executing,
                                ActivityStates.Closed
                            }
                        }
                    }
                };
                break;

            case 4:
                //Activity states for selected activities with
                //argument extraction
                tp.TrackingProfile = new TrackingProfile
                {
                    Name    = "MyTrackingProfile",
                    Queries =
                    {
                        new WorkflowInstanceQuery
                        {
                            States =
                            {
                                WorkflowInstanceStates.Started,
                                WorkflowInstanceStates.Completed,
                            }
                        },
                        new ActivityStateQuery
                        {
                            ActivityName = "UpdateInventory",
                            States       = { ActivityStates.Executing     },
                            Arguments    = { "*"                          }
                        },
                        new ActivityStateQuery
                        {
                            ActivityName = "InsertTranHistory",
                            States       = { "*"                          }
                        },
                        new ActivityStateQuery
                        {
                            ActivityName     = "UpdateProductInventory",
                            States           = { ActivityStates.Executing },
                            Arguments        = { "SalesDetail"            },
                            QueryAnnotations =
                            {
                                { "Threading Model", "Asynchronous update"}
                            }
                        },
                        new ActivityStateQuery
                        {
                            ActivityName = "UpdateProductInventory",
                            States       = { ActivityStates.Closed        }
                        }
                    }
                };
                break;

            case 5:
                //Activity states for selected activities with
                //argument extraction and selected activity scheduled query
                tp.TrackingProfile = new TrackingProfile
                {
                    Name    = "MyTrackingProfile",
                    Queries =
                    {
                        new WorkflowInstanceQuery
                        {
                            States =
                            {
                                WorkflowInstanceStates.Started,
                                WorkflowInstanceStates.Completed,
                            }
                        },
                        new ActivityStateQuery
                        {
                            ActivityName = "UpdateInventory",
                            States       = { ActivityStates.Executing     },
                            Arguments    = { "*"                          }
                        },
                        new ActivityStateQuery
                        {
                            ActivityName = "InsertTranHistory",
                            States       = { "*"                          }
                        },
                        new ActivityStateQuery
                        {
                            ActivityName     = "UpdateProductInventory",
                            States           = { ActivityStates.Executing },
                            Arguments        = { "SalesDetail"            },
                            QueryAnnotations =
                            {
                                { "Threading Model", "Asynchronous update"}
                            }
                        },
                        new ActivityStateQuery
                        {
                            ActivityName = "UpdateProductInventory",
                            States       = { ActivityStates.Closed        }
                        },
                        new ActivityScheduledQuery
                        {
                            ChildActivityName = "UpdateProductInventory"
                        }
                    }
                };
                break;

            case 6:
                //Activity states for selected activities with
                //argument extraction and selected activity scheduled query
                //also adds Custom Tracking Records
                tp.TrackingProfile = new TrackingProfile
                {
                    Name    = "MyTrackingProfile",
                    Queries =
                    {
                        new WorkflowInstanceQuery
                        {
                            States =
                            {
                                WorkflowInstanceStates.Started,
                                WorkflowInstanceStates.Completed,
                            }
                        },
                        new ActivityStateQuery
                        {
                            ActivityName = "UpdateInventory",
                            States       = { ActivityStates.Executing     },
                            Arguments    = { "*"                          }
                        },
                        new ActivityStateQuery
                        {
                            ActivityName = "InsertTranHistory",
                            States       = { "*"                          }
                        },
                        new ActivityStateQuery
                        {
                            ActivityName     = "UpdateProductInventory",
                            States           = { ActivityStates.Executing },
                            Arguments        = { "SalesDetail"            },
                            QueryAnnotations =
                            {
                                { "Threading Model", "Asynchronous update"}
                            }
                        },
                        new ActivityStateQuery
                        {
                            ActivityName = "UpdateProductInventory",
                            States       = { ActivityStates.Closed        }
                        },
                        new ActivityScheduledQuery
                        {
                            ChildActivityName = "UpdateProductInventory"
                        },
                        new CustomTrackingQuery
                        {
                            ActivityName = "*",
                            Name         = "*"
                        }
                    }
                };
                break;

            default:
                break;
            }

            instance.Extensions.Add(tp);
            instance.Invoke();
        }