Esempio n. 1
0
        /// <summary>
        /// stop tracing command
        /// </summary>
        internal void StopTracing()
        {
            if (this.CaptureScreenShots) // create html report also if no tracing was active perhaps someone finds this functionality in itself useful
            {
                var htmlReportGenerator = new HtmlReportGenerator(this.ScreenshotDirectory);
                htmlReportGenerator.GenerateReport();
            }

            StopData = new ViewModelFrozenData(this)
            {
                TraceStopFullCommandLine = LocalTraceSettings.TraceStopFullCommandLine,
                TraceStopNotExpanded     = LocalTraceSettings.TraceStop,
                TraceFileName            = TraceFileName,
                TraceStartTime           = this._TraceStartTime,
            };

            if (this.LocalTraceEnabled)
            {
                LocalTraceSettings.TraceStates = TraceStates.Stopping;
                // stop tracing asynchronously so we do not need to wait until local trace collection has stopped (while blocking the UI)
                Task.Factory.StartNew <Tuple <int, string> >(() => LocalTraceControler.ExecuteWPRCommand(StopData.TraceStopFullCommandLine))
                .ContinueWith((t) => LocalTraceSettings.ProcessStopCommand(t.Result), UISheduler);
            }
            if (this.ServerTraceEnabled)
            {
                ServerTraceSettings.TraceStates = TraceStates.Stopping;
                var command = WCFHost.CreateExecuteWPRCommand(StopData.TraceStopFullCommandLine);
                command.Completed = (output) => ServerTraceSettings.ProcessStopCommand(output);
                command.Execute();
            }

            this.TraceFileCounter++;
        }
Esempio n. 2
0
 /// <summary>
 /// Cancel Tracing command
 /// </summary>
 private void CancelTracing()
 {
     if (this.LocalTraceEnabled)
     {
         var output = LocalTraceControler.ExecuteWPRCommand(LocalTraceSettings.TraceCancel);
         LocalTraceSettings.ProcessCancelCommand(output);
     }
     if (this.ServerTraceEnabled)
     {
         var command = WCFHost.CreateExecuteWPRCommand(ServerTraceSettings.TraceCancel);
         command.Completed = (output) => ServerTraceSettings.ProcessCancelCommand(output);
         command.Execute();
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Start Tracing
        /// </summary>
        private void StartTracing()
        {
            if (!this.LocalTraceEnabled && !this.ServerTraceEnabled)
            {
                MessageBoxDisplay.ShowMessage("Please enable tracing at the remote host and/or on your local machine.", "Warning");
                return;
            }

            this.Hooker.ResetId();

            if (this.LocalTraceEnabled) // start async to allow the web service to start tracing simultanously on the target host
            {
                _TraceStartTime = DateTime.Now;
                LocalTraceSettings.TraceStates = TraceStates.Starting;

                if (File.Exists(TraceFileName))
                {
                    try
                    {
                        File.Delete(TraceFileName);
                    }
                    catch (Exception ex)
                    {
                        MessageBoxDisplay.ShowMessage($"Could not delete old trace file {TraceFileName}. Is the file still open in WPA? Full error: {ex}", "Error");
                        LocalTraceSettings.TraceStates = TraceStates.Stopped;
                        return;
                    }
                }

                Task.Factory.StartNew <Tuple <int, string> >(() => LocalTraceControler.ExecuteWPRCommand(LocalTraceSettings.TraceStartFullCommandLine))
                .ContinueWith(t => LocalTraceSettings.ProcessStartCommand(t.Result), UISheduler);
            }

            if (this.ServerTraceEnabled)
            {
                ServerTraceSettings.TraceStates = TraceStates.Starting;
                var command = WCFHost.CreateExecuteWPRCommand(ServerTraceSettings.TraceStartFullCommandLine);
                command.Completed = (output) => ServerTraceSettings.ProcessStartCommand(output);
                command.Execute();
            }
        }