示例#1
0
        protected VisualTrackingParticipant InitialiseVisualTrackingParticipant(Activity activityToRun)
        {
            // Mapping between the object and Line No.
            var elementToSourceLocationMap = UpdateSourceLocationMappingInDebuggerService(activityToRun);

            // Mapping between the object and the Instance Id
            var activityIdToElementMap = elementToSourceLocationMap
                                         .Keys
                                         .OfType <Activity>()
                                         .ToDictionary(workflowElement => workflowElement.Id);

            // Setup custom tracking
            var participant = new VisualTrackingParticipant
            {
                ActivityIdToWorkflowElementMap = activityIdToElementMap,
                TrackingProfile = new TrackingProfile
                {
                    Name    = "VisualTrackingProfile",
                    Queries =
                    {
                        new CustomTrackingQuery
                        {
                            Name         = "*",
                            ActivityName = "*"
                        },
                        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 = "*",
                            States       = { "*" },

                            // 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 ={ "*" }
                        }
                    }
                }
            };

            var debugInterval = Settings.Default.MillisecondsBetweenDebugSteps > 0
                                    ? Settings.Default.MillisecondsBetweenDebugSteps
                                    : 1000;

            // As the tracking events are received
            participant.TrackingRecordReceived += (trackingParticipant, trackingEventArgs) =>
            {
                if (trackingEventArgs.Activity != null)
                {
                    DispatcherService.Dispatch(() =>
                    {
                        WorkflowDesigner.DebugManagerView.CurrentLocation =
                            elementToSourceLocationMap[trackingEventArgs.Activity];
                    });

                    Thread.Sleep(debugInterval);

                    var debugItem = new DebugStep(
                        stepCount++,
                        trackingEventArgs.Record.EventTime,
                        trackingEventArgs.Activity.DisplayName,
                        trackingEventArgs.Activity.Id,
                        trackingEventArgs.Record.InstanceId,
                        ((ActivityStateRecord)trackingEventArgs.Record).State);

                    stepSourceLocationMapping.Add((int)stepCount - 1, elementToSourceLocationMap[trackingEventArgs.Activity]);
                    OnDebugStepAdded(debugItem);
                }
            };

            return(participant);
        }
示例#2
0
        protected VisualTrackingParticipant InitialiseVisualTrackingParticipant(Activity activityToRun)
        {
            // Mapping between the object and Line No.
            var elementToSourceLocationMap = UpdateSourceLocationMappingInDebuggerService(activityToRun);

            // Mapping between the object and the Instance Id
            var activityIdToElementMap = elementToSourceLocationMap
                .Keys
                .OfType<Activity>()
                .ToDictionary(workflowElement => workflowElement.Id);

            // Setup custom tracking
            var participant = new VisualTrackingParticipant
            {
                ActivityIdToWorkflowElementMap = activityIdToElementMap,
                TrackingProfile = new TrackingProfile
                {
                    Name = "VisualTrackingProfile",
                    Queries =
                    {
                        new CustomTrackingQuery
                        {
                            Name = "*",
                            ActivityName = "*"
                        },
                        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 = "*",
                            States = { "*" },

                            // 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 = { "*" }
                        }
                    }
                }
            };

            var debugInterval = Settings.Default.MillisecondsBetweenDebugSteps > 0
                                    ? Settings.Default.MillisecondsBetweenDebugSteps
                                    : 1000;

            // As the tracking events are received
            participant.TrackingRecordReceived += (trackingParticipant, trackingEventArgs) =>
            {
                if (trackingEventArgs.Activity != null)
                {
                    DispatcherService.Dispatch(() =>
                    {
                        WorkflowDesigner.DebugManagerView.CurrentLocation =
                            elementToSourceLocationMap[trackingEventArgs.Activity];
                    });

                    Thread.Sleep(debugInterval);

                    var debugItem = new DebugStep(
                        stepCount++,
                        trackingEventArgs.Record.EventTime,
                        trackingEventArgs.Activity.DisplayName,
                        trackingEventArgs.Activity.Id,
                        trackingEventArgs.Record.InstanceId,
                        ((ActivityStateRecord) trackingEventArgs.Record).State);

                    stepSourceLocationMapping.Add((int)stepCount - 1, elementToSourceLocationMap[trackingEventArgs.Activity]);
                    OnDebugStepAdded(debugItem);
                }
            };

            return participant;
        }