Example #1
0
        protected VisualTrackingParticipant InitialiseVisualTrackingParticipant(Activity workflowToRun)
        {
            // Mapping between the object and Line No.
            Dictionary <object, SourceLocation> elementToSourceLocationMap = this.UpdateSourceLocationMappingInDebuggerService(workflowToRun);

            // Mapping between the object and the Instance Id
            Dictionary <string, Activity> activityIdToElementMap = this.BuildactivityIdToElementMap(elementToSourceLocationMap);

            // Setup custom tracking
            const string All = "*";
            VisualTrackingParticipant simTracker = new VisualTrackingParticipant()
            {
                TrackingProfile = new TrackingProfile()
                {
                    Name    = "CustomTrackingProfile",
                    Queries =
                    {
                        new CustomTrackingQuery()
                        {
                            Name         = All,
                            ActivityName = All
                        },
                        new WorkflowInstanceQuery()
                        {
                            // Limit workflow instance tracking records for started and completed workflow states
                            States ={ WorkflowInstanceStates.Started,              WorkflowInstanceStates.Completed },
                        },
                        new ActivityStateQuery()
                        {
                            // Subscribe for track records from all activities for all states
                            ActivityName = All,
                            States       = { All },

                            // Extract workflow variables and arguments as a part of the activity tracking record
                            // VariableName = "*" allows for extraction of all variables in the scope
                            // of the activity
                            Variables =
                            {
                                { All }
                            }
                        }
                    }
                }
            };

            simTracker.ActivityIdToWorkflowElementMap = activityIdToElementMap;

            // As the tracking events are received
            simTracker.TrackingRecordReceived += (trackingParticpant, trackingEventArgs) =>
            {
                if (trackingEventArgs.Activity != null)
                {
                    ShowDebug(elementToSourceLocationMap[trackingEventArgs.Activity]);

                    Thread.Sleep(this.pauseBetweenDebugStepsInMilliseconds);

                    SourceLocationDebugItem debugItem = new SourceLocationDebugItem()
                    {
                        ActivityName = trackingEventArgs.Activity.DisplayName,
                        Id           = trackingEventArgs.Activity.Id,
                        State        = ((ActivityStateRecord)trackingEventArgs.Record).State,
                        StepCount    = sourceLocationSteppedCount,
                        InstanceId   = ((ActivityStateRecord)trackingEventArgs.Record).InstanceId
                    };

                    this.debugTraceSource.TraceData(
                        TraceEventType.Information,
                        0,
                        trackingEventArgs.Activity.DisplayName,
                        trackingEventArgs.Activity.Id,
                        ((ActivityStateRecord)trackingEventArgs.Record).State,
                        sourceLocationSteppedCount,
                        ((ActivityStateRecord)trackingEventArgs.Record).InstanceId);

                    this.allDebugTraceSource.TraceData(
                        TraceEventType.Information,
                        0,
                        Path.GetFileNameWithoutExtension(this.workflowName),
                        trackingEventArgs.Activity.DisplayName,
                        trackingEventArgs.Activity.Id,
                        ((ActivityStateRecord)trackingEventArgs.Record).State,
                        sourceLocationSteppedCount,
                        ((ActivityStateRecord)trackingEventArgs.Record).InstanceId);

                    sourceLocationSteppedCount++;

                    if (!this.disableDebugViewOutput)
                    {
                        this.textLineToSourceLocationMap.Add(this.sourceLocations.Count, elementToSourceLocationMap[trackingEventArgs.Activity]);
                        this.sourceLocations.Add(debugItem);

                        DispatcherService.Dispatch(() =>
                        {
                            debugView.ItemsSource = this.SourceLocations;
                            debugView.Items.Refresh();
                        });
                    }
                }
            };

            return(simTracker);
        }
        protected VisualTrackingParticipant InitialiseVisualTrackingParticipant(Activity workflowToRun)
        {
            // Mapping between the object and Line No.
            Dictionary<object, SourceLocation> elementToSourceLocationMap = this.UpdateSourceLocationMappingInDebuggerService(workflowToRun);

            // Mapping between the object and the Instance Id
            Dictionary<string, Activity> activityIdToElementMap = this.BuildactivityIdToElementMap(elementToSourceLocationMap);

            // Setup custom tracking
            const string All = "*";
            VisualTrackingParticipant simTracker = new VisualTrackingParticipant()
            {
                TrackingProfile = new TrackingProfile()
                {
                    Name = "CustomTrackingProfile",
                    Queries = 
                        {
                            new CustomTrackingQuery() 
                            {
                                Name = All,
                                ActivityName = All
                            },
                            new WorkflowInstanceQuery()
                            {
                                // Limit workflow instance tracking records for started and completed workflow states
                                States = { WorkflowInstanceStates.Started, WorkflowInstanceStates.Completed },
                            },
                            new ActivityStateQuery()
                            {
                                // Subscribe for track records from all activities for all states
                                ActivityName = All,
                                States = { All },

                                // Extract workflow variables and arguments as a part of the activity tracking record
                                // VariableName = "*" allows for extraction of all variables in the scope
                                // of the activity
                                Variables = 
                                {                                
                                    { All }   
                                }
                            }   
                        }
                }
            };

            simTracker.ActivityIdToWorkflowElementMap = activityIdToElementMap;

            // As the tracking events are received
            simTracker.TrackingRecordReceived += (trackingParticpant, trackingEventArgs) =>
            {
                if (trackingEventArgs.Activity != null)
                {
                    ShowDebug(elementToSourceLocationMap[trackingEventArgs.Activity]);

                    Thread.Sleep(this.pauseBetweenDebugStepsInMilliseconds);

                    SourceLocationDebugItem debugItem = new SourceLocationDebugItem()
                    {
                        ActivityName = trackingEventArgs.Activity.DisplayName,
                        Id = trackingEventArgs.Activity.Id,
                        State = ((ActivityStateRecord)trackingEventArgs.Record).State,
                        StepCount = sourceLocationSteppedCount,
                        InstanceId = ((ActivityStateRecord)trackingEventArgs.Record).InstanceId
                    };

                    this.debugTraceSource.TraceData(
                        TraceEventType.Information,
                        0,
                        trackingEventArgs.Activity.DisplayName,
                        trackingEventArgs.Activity.Id,
                            ((ActivityStateRecord)trackingEventArgs.Record).State,
                        sourceLocationSteppedCount,
                        ((ActivityStateRecord)trackingEventArgs.Record).InstanceId);

                    this.allDebugTraceSource.TraceData(
                        TraceEventType.Information,
                        0,
                        Path.GetFileNameWithoutExtension(this.workflowName),
                        trackingEventArgs.Activity.DisplayName,
                        trackingEventArgs.Activity.Id,
                            ((ActivityStateRecord)trackingEventArgs.Record).State,
                        sourceLocationSteppedCount,
                        ((ActivityStateRecord)trackingEventArgs.Record).InstanceId);

                    sourceLocationSteppedCount++;

                    if (!this.disableDebugViewOutput)
                    {
                        this.textLineToSourceLocationMap.Add(this.sourceLocations.Count, elementToSourceLocationMap[trackingEventArgs.Activity]);
                        this.sourceLocations.Add(debugItem);

                        DispatcherService.Dispatch(() =>
                        {
                            debugView.ItemsSource = this.SourceLocations;
                            debugView.Items.Refresh();
                        });
                    }
                }
            };

            return simTracker;
        }