private void cmdOK_Click(System.Object sender, System.EventArgs e) { System.ComponentModel.CancelEventArgs CancelEventArgs = new System.ComponentModel.CancelEventArgs(false); try { //Force validation on the TraceFile... txtTraceFile_Validating(txtTraceFile, CancelEventArgs); if (CancelEventArgs.Cancel) { return; } iTraceOptions = 0; if (this.chkApplication.CheckState == CheckState.Checked) { iTraceOptions |= clsTrace.trcOption.trcApplication; } if (this.chkBinding.CheckState == CheckState.Checked) { iTraceOptions |= clsTrace.trcOption.trcBinding; } if (this.chkCL.CheckState == CheckState.Checked) { iTraceOptions |= clsTrace.trcOption.trcCL; } if (this.chkControls.CheckState == CheckState.Checked) { iTraceOptions |= clsTrace.trcOption.trcControls; } if (this.chkDB.CheckState == CheckState.Checked) { iTraceOptions |= clsTrace.trcOption.trcDB; } if (this.chkLogon.CheckState == CheckState.Checked) { iTraceOptions |= clsTrace.trcOption.trcLogon; } if (this.chkMemory.CheckState == CheckState.Checked) { iTraceOptions |= clsTrace.trcOption.trcMemory; } if (this.chkReports.CheckState == CheckState.Checked) { iTraceOptions |= clsTrace.trcOption.trcReports; } if (this.chkSupport.CheckState == CheckState.Checked) { iTraceOptions |= clsTrace.trcOption.trcSupport; } this.Hide(); } catch (Exception ex) { } }
internal clsTrace(clsSupport objSupport, string TracePath = null, clsTrace.trcOption toTraceOptions = trcOption.trcNone, bool bTraceMode = false) : base() { const string EntryName = "New"; mSupport = objSupport; mMyModuleName = "clsTrace"; mMyTraceID = string.Format("{0}.{1}.{2}", mSupport.ApplicationName, mSupport.ExecutingComponentName, mMyModuleName); TraceIndent = 0; mTraceOptions = toTraceOptions; mTraceUnit = 0; mTraceFile = (string)Microsoft.VisualBasic.Interaction.IIf((TracePath == null), bpeNullString, TracePath); mInitialTraceMessage = bpeNullString; mThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; TraceMode = bTraceMode; Trace(string.Format("{0}.{1}(objSupport:={{clsSupport}}, TracePath:=\"{2}\", toTraceOptions:={3}, bTraceMode:={4})", new object[] { mMyTraceID, EntryName, mTraceFile, toTraceOptions, bTraceMode }), trcOption.trcSupport); }
public void Trace(clsTrace.trcType trcTraceType, string Message, clsTrace.trcOption trcTraceOptions = trcOption.trcNone, System.Diagnostics.Process ceProcess = null) { string TraceFile = bpeNullString; lock (TraceLock) { //Override Trace Parameters if trcAll... if (trcTraceOptions == trcOption.trcAll && !fTraceMode) { TraceFile = mSupport.LogFile; } else { if (!fTraceMode || trcTraceOptions == 0) { return; } if (((mTraceOptions & trcTraceOptions) == 0)) { return; } TraceFile = mTraceFile; } mThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; //Debug.WriteLine("Trace Options: " & CType(trcTraceOptions, trcOption).ToString) //Make sure we allocate a new TraceIndent for this ThreadID... clsIndentByThread objIBT = null; objIBT = ThreadIndents[Convert.ToString(mThreadID)]; if (trcTraceType == trcType.trcExit && objIBT.TraceIndent > 0) { objIBT.TraceIndent -= 1; } switch (trcTraceType) { case trcType.trcEnter: Message = "Entering " + Message; break; case trcType.trcExit: Message = "Exiting " + Message; break; } if ((mTraceOptions & trcOption.trcMemory) == trcOption.trcMemory) { long TotalMemory = GC.GetTotalMemory(false); Message += MemoryStats(TotalMemory, Process.GetCurrentProcess()); switch (trcTraceType) { case trcType.trcExit: if ((ceProcess != null)) { Message += MemoryConsumed(TotalMemory, ceProcess, Process.GetCurrentProcess()); } break; } } this.LogMessage(TraceFile, Message, objIBT.TraceIndent, false); if (trcTraceType == trcType.trcEnter) { objIBT.TraceIndent += 1; } } }
public void Trace(string Message, clsTrace.trcOption trcTraceOption) { Trace(trcType.trcBody, Message, trcTraceOption); }
public clsTrace.trcOption ParseTraceOptions(string strTraceOptions) { clsTrace.trcOption functionReturnValue = default(clsTrace.trcOption); int i = 0; string Options = null; functionReturnValue = 0; while (Strings.Len(strTraceOptions) > 0) { i = Strings.InStr(strTraceOptions, "+"); if (i == 0) { Options = Strings.Trim(Strings.UCase(strTraceOptions)); strTraceOptions = bpeNullString; } else { Options = Strings.Trim(Strings.UCase(Strings.Left(strTraceOptions, i - 1))); strTraceOptions = Strings.Trim(Strings.Mid(strTraceOptions, i + 1)); } switch (Options) { case "TRCALL": functionReturnValue = trcOption.trcAll; break; case "TRCAPPLICATION": functionReturnValue &= trcOption.trcApplication; break; case "TRCREPORTS": functionReturnValue &= trcOption.trcReports; break; case "TRCSQL": functionReturnValue &= trcOption.trcDB; break; case "TRCADO": functionReturnValue &= trcOption.trcDB; break; case "TRCSUPPORT": functionReturnValue &= trcOption.trcSupport; break; case "TRCCL": functionReturnValue &= trcOption.trcCL; break; case "TRCCONTROLS": functionReturnValue &= trcOption.trcControls; break; case "TRCMEMORY": functionReturnValue &= trcOption.trcMemory; break; case "TRCEVERYTHINGBUTMEMORY": functionReturnValue &= trcOption.trcEverythingButMemory; break; } } return(functionReturnValue); }
public clsSupport(System.Reflection.Assembly objAssembly = null, string OverrideApplicationName = bpeNullString, string TracePath = bpeNullString, clsTrace.trcOption toTraceOptions = trcOption.trcNone, bool bTraceMode = false) : base() { const string EntryName = "New"; System.Diagnostics.Process enterProcess = null; //Try if ((TracePath == null)) { TracePath = bpeNullString; } string strAssembly = null; if ((objAssembly == null)) { strAssembly = "Nothing"; } else { strAssembly = "{" + objAssembly.GetType().ToString() + "}"; } string Arguments = string.Format("objAssembly:={0},OverrideApplicationName:=\"{1}\",TracePath:=\"{2}\",toTraceOptions:={3},TraceMode:={4}", new object[] { strAssembly, OverrideApplicationName, TracePath, toTraceOptions.ToString(), bTraceMode.ToString() }); mOverrideApplicationName = OverrideApplicationName; mThread = System.Threading.Thread.CurrentThread; mThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; mAssemblyInfo = new AssemblyInfo(objAssembly); mTraceID = mAssemblyInfo.Product + "." + mAssemblyInfo.Name + "." + ModuleName; mTrace = new clsTrace(this, TracePath, toTraceOptions, bTraceMode); //Must be first so we can trace the rest... mRegionalTimeFormat = DateTimeFormatInfo.CurrentInfo.LongTimePattern; //GetRegionalSetting(Win.WinNLS.LOCALE_STIMEFORMAT) //Changing from tt to AMPM screws up grid formatting relying on fmrShortDateTime... //If Right(strRegionalTimeFormat, 3) = " tt" Then strRegionalTimeFormat = Mid(strRegionalTimeFormat, 1, Len(strRegionalTimeFormat) - 2) + "AMPM" mShortDate = DateTimeFormatInfo.CurrentInfo.ShortDatePattern; //GetRegionalSetting(Win.WinNLS.LOCALE_SSHORTDATE) mLongDate = DateTimeFormatInfo.CurrentInfo.LongDatePattern; //GetRegionalSetting(Win.WinNLS.LOCALE_SLONGDATE) string strMessage = mTraceID + "." + EntryName + "(" + Arguments + ")"; if ((mTrace.TraceOptions & trcOption.trcMemory) == trcOption.trcMemory) { enterProcess = Process.GetCurrentProcess(); } mTrace.Trace(trcType.trcEnter, strMessage, trcOption.trcSupport); //mErrors = New clsErrors(Me) //'Force an allocation of a new clsError object for this thread... //Dim i As Integer = mErrors.LastError(Threading.Thread.CurrentThread.ManagedThreadId).Number //'Allocate a CallStack for this (main) thread... Others will be created as necessary in SetupNewThread()... //mCallStackCollection.Add(New clsCallStack(Me), CStr(Threading.Thread.CurrentThread.ManagedThreadId)) //'Allocate a String for this (main) thread... Others will be created as necessary in SetupNewThread()... //mStringCollection.Add(New clsString(Me), CStr(Threading.Thread.CurrentThread.ManagedThreadId)) //Do more stuff, if necessary... //Catch ex As Exception // If Not IsNothing(mErrors) Then mErrors.RaiseError(Threading.Thread.CurrentThread.ManagedThreadId, mTraceID, EntryName, ex, Nothing) Else Throw ex //End Try if ((mTrace != null)) { mTrace.Trace(trcType.trcExit, mTraceID + "." + EntryName, trcOption.trcSupport | trcOption.trcMemory, enterProcess); } enterProcess = null; mLogFile = string.Format("{0}\\{1}.log", this.ApplicationPath, this.ApplicationName); }