Exemple #1
0
        private StatusErrorCode SetTraceStatus(TraceStatus status)
        {
            if (traceId == 0)
            {
                throw new NotInitializedProfilerException();
            }

            StatusErrorCode code = StatusErrorCode.IsInvalid;

            try
            {
                SqlCommand cmd = MsSqlUtil.NewStoredProcedure("sp_trace_setstatus");
                MsSqlUtil.AddInParam(cmd, "@traceid", traceId);
                MsSqlUtil.AddInParam(cmd, "@status", status);
                code = (StatusErrorCode)MsSqlUtil.ExecuteStoredProcedure(cmd, connInfo.CreateConnectionObject());
                if (code == StatusErrorCode.NoError)
                {
                    this.traceStatus = status;
                }
            }
            catch (SqlException exc)
            {
                if (exc.Message.Contains("Could not find the requested trace"))
                {
                    return(StatusErrorCode.TraceIsInvalid);
                }

                //throw;
            }

            return(code);
        }
        private bool StopCurrentTrace()
        {
            if (CurrentTrace == null)
            {
                return(true);
            }

            StatusErrorCode errorCode = CurrentTrace.Profiler.Stop();

            if (errorCode != StatusErrorCode.TraceIsInvalid)
            {
                if (errorCode != StatusErrorCode.NoError)
                {
                    MessageBox.Show("Can't stop trace: " + errorCode, "Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return(false);
                }

                errorCode = CurrentTrace.Profiler.Close();
                if (errorCode != StatusErrorCode.NoError)
                {
                    MessageBox.Show("Can't close trace: " + errorCode, "Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return(false);
                }
            }

            CurrentTrace = null;

            return(true);
        }
Exemple #3
0
        public StatusErrorCode Start()
        {
            StatusErrorCode result = SetTraceStatus(TraceStatus.Started);

            if (result == StatusErrorCode.NoError)
            {
                getTraceTimer = new Timer(new TimerCallback(GetTraceTable), null, new TimeSpan(0, 0, 0), RefreshInterval);
            }
            return(result);
        }
        private void PauseCurrentTrace()
        {
            if (CurrentTrace == null)
            {
                return;
            }

            StatusErrorCode errorCode = CurrentTrace.Profiler.Stop();

            if (errorCode == StatusErrorCode.TraceIsInvalid)
            {
                MessageBox.Show("Could not find the trace. Please close the trace and start a new.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (errorCode != StatusErrorCode.NoError)
            {
                MessageBox.Show("Can't pause trace: " + errorCode, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void StartCurrentTrace()
        {
            if (CurrentTrace == null)
            {
                return;
            }

            if (CurrentTrace.Profiler.Status == TraceStatus.Closed)
            {
                SetCurrentTrace(_traceManager.RunProfiler(CurrentTrace.Profiler));
                return;
            }

            StatusErrorCode errorCode = CurrentTrace.Profiler.Start();

            if (errorCode != StatusErrorCode.NoError)
            {
                MessageBox.Show("Can't start trace: " + errorCode, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }