コード例 #1
0
        void ShowDebug(SourceLocation srcLoc)
        {
            try
            {
                dispatcher.Invoke(DispatcherPriority.Render, (Action)(() =>
                {
                    SelectHelper._wfDesigner.DebugManagerView.CurrentLocation = srcLoc;
                }));
                //Check if this is where any BP is set
                bool isBreakpointHit = false;


                foreach (SourceLocation src in breakpointList)
                {
                    if (src.StartLine == srcLoc.StartLine && src.EndLine == srcLoc.EndLine)
                    {
                        isBreakpointHit = true;
                    }
                }

                //**************************STEP OVER************************************************************
                if (DebugType.Equals("stepover") && ChildCount == 0)
                {
                    isBreakpointHit = true;
                }
                //**************************STEP OVER************************************************************

                if (isBreakpointHit == true)
                {
                    resumeRuntimeFromHost.WaitOne();
                }
                else if (DebugType.Equals("stepinto"))
                {
                    resumeRuntimeFromHost.WaitOne();
                }
                //**************************STEP OVER************************************************************
                else if (DebugType.Equals("stepover"))
                {
                    ChildCount--;

                    // resumeRuntimeFromHost.WaitOne();
                }
                //**************************STEP OVER************************************************************
                else if (DebugType.Equals("continue"))
                {
                }
            }
            catch (Exception ex)
            {
                Log.Logger.LogData(ex.Message, LogLevel.Error);
            }
        }
コード例 #2
0
        public void StartDebuggingForWorkflow()
        {
            resumeRuntimeFromHost       = new AutoResetEvent(false);
            textLineToSourceLocationMap = new Dictionary <int, SourceLocation>();
            //Mapping between the Object and Line No.
            //Mapping between the Object and the Instance Id
            _executionLog = new Helpers.CustomTrackingParticipant();
            _wfApp.Extensions.Add(_executionLog);
            wfElementToSourceLocationMap = UpdateSourceLocationMappingInDebuggerService(activityExecute);
            activityIdToWfElementMap     = BuildActivityIdToWfElementMap(wfElementToSourceLocationMap);

            #region Set up 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 ActivityScheduledQuery()
                        {
                            // Subscribe for track records from all activities for all states
                            ActivityName = 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
                        },
                        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 = activityIdToWfElementMap;
            #endregion


            //As the tracking events are received
            simTracker.TrackingRecordReceived += (trackingParticpant, trackingEventArgs) =>
            {
                if (trackingEventArgs.Activity != null)
                {
                    System.Diagnostics.Debug.WriteLine(
                        String.Format("<+=+=+=+> Activity Tracking Record Received for ActivityId: {0}, record: {1} ",
                                      trackingEventArgs.Activity.Id,
                                      trackingEventArgs.Record
                                      )
                        );

                    //&& ChildCount==0
                    //****************************************STEP OVER SERVICE******************************************************************
                    if (!(trackingEventArgs.Record.GetType().ToString().Equals("System.Activities.Tracking.ActivityScheduledRecord")))
                    {
                        if (DebugType.Equals("stepover") && (((ActivityStateRecord)trackingEventArgs.Record).State).Equals("Executing"))
                        {
                            IEnumerable <Activity> children = null;
                            children = System.Activities.WorkflowInspectionServices.GetActivities(trackingEventArgs.Activity);
                            int count = 0;
                            foreach (Activity child in children)
                            {
                                //  children = children.Concat();
                                //  ActivityScheduledRecord abc = trackingEventArgs.Record as ActivityScheduledRecord;
                                if (!(child.DisplayName.Contains("Literal")) && !(child.DisplayName.Contains("VisualBasicValue")))
                                {
                                    //foreach(var abc in child)
                                    count++;
                                }
                            }
                            // children.OfType<Activity>();
                            ChildCount = ChildCount + count;
                        }
                    }
                    //****************************************STEP OVER SERVICE******************************************************************



                    if ((trackingEventArgs.Record.GetType().ToString().Equals("System.Activities.Tracking.ActivityScheduledRecord")))
                    {
                        ShowDebug(wfElementToSourceLocationMap[trackingEventArgs.Activity]);
                    }

                    dispatcher.Invoke(DispatcherPriority.SystemIdle, (Action)(() =>
                    {
                        if (!(trackingEventArgs.Record.GetType().ToString().Equals("System.Activities.Tracking.ActivityScheduledRecord")))
                        {
                            //Textbox Updates
                            consoleExecutionLog.AppendText(trackingEventArgs.Activity.DisplayName + " " + ((ActivityStateRecord)trackingEventArgs.Record).State + "\n");
                            consoleExecutionLog.AppendText("******************\n");
                            textLineToSourceLocationMap.Add(i, wfElementToSourceLocationMap[trackingEventArgs.Activity]);
                            i = i + 2;

                            dgInfoErrorWarnings.DataContext = Logger.Log.Logger.DatatableLog;
                            dgInfoErrorWarnings.ItemsSource = null;
                            dgInfoErrorWarnings.ItemsSource = Logger.Log.Logger.DatatableLog.DefaultView;
                        }
                        //Add a sleep so that the debug adornments are visible to the user
                        System.Threading.Thread.Sleep(1000);
                    }));
                }
            };

            _wfApp.Extensions.Add(simTracker);
            ThreadPool.QueueUserWorkItem(new WaitCallback((context) =>
            {
                try
                {
                    //Invoking the Workflow Instance with Input Arguments
                    _wfApp.Run();
                }
                catch (Exception ex)
                {
                    Log.Logger.LogData(ex.Message, LogLevel.Error);
                }
                //This is to remove the final debug adornment
                dispatcher.Invoke(DispatcherPriority.Render
                                  , (Action)(() =>
                {
                    SelectHelper._wfDesigner.DebugManagerView.CurrentLocation = new SourceLocation(_currentWorkflowFile, 1, 1, 1, 10);
                }));
            }));
        }