void CallEtwMileStoneEvent(TraceEventType type, DictionaryTraceRecord record) { switch (type) { case TraceEventType.Start: if (TD.StartSignpostEventIsEnabled()) { TD.StartSignpostEvent(record); } break; case TraceEventType.Stop: if (TD.StopSignpostEventIsEnabled()) { TD.StopSignpostEvent(record); } break; case TraceEventType.Suspend: if (TD.SuspendSignpostEventIsEnabled()) { TD.SuspendSignpostEvent(record); } break; case TraceEventType.Resume: if (TD.ResumeSignpostEventIsEnabled()) { TD.ResumeSignpostEvent(record); } break; } }
public void UnsafeLogEvent(TraceEventType type, ushort eventLogCategory, uint eventId, bool shouldTrace, params string[] values) { if (logCountForPT >= 5) { return; } try { int num = 0; string[] logValues = new string[values.Length + 2]; for (int i = 0; i < values.Length; i++) { string str = values[i]; if (!string.IsNullOrEmpty(str)) { str = NormalizeEventLogParameter(str); } else { str = string.Empty; } logValues[i] = str; num += str.Length + 1; } string str2 = NormalizeEventLogParameter(this.UnsafeGetProcessName()); logValues[logValues.Length - 2] = str2; num += str2.Length + 1; string str3 = this.UnsafeGetProcessId().ToString(CultureInfo.InvariantCulture); logValues[logValues.Length - 1] = str3; num += str3.Length + 1; if (num > 0x6400) { int length = (0x6400 / logValues.Length) - 1; for (int j = 0; j < logValues.Length; j++) { if (logValues[j].Length > length) { logValues[j] = logValues[j].Substring(0, length); } } } SecurityIdentifier user = WindowsIdentity.GetCurrent().User; byte[] binaryForm = new byte[user.BinaryLength]; user.GetBinaryForm(binaryForm, 0); IntPtr[] ptrArray = new IntPtr[logValues.Length]; GCHandle stringsRootHandle = new GCHandle(); GCHandle[] handleArray = null; try { stringsRootHandle = GCHandle.Alloc(ptrArray, GCHandleType.Pinned); handleArray = new GCHandle[logValues.Length]; for (int k = 0; k < logValues.Length; k++) { handleArray[k] = GCHandle.Alloc(logValues[k], GCHandleType.Pinned); ptrArray[k] = handleArray[k].AddrOfPinnedObject(); } this.UnsafeWriteEventLog(type, eventLogCategory, eventId, logValues, binaryForm, stringsRootHandle); } finally { if (stringsRootHandle.AddrOfPinnedObject() != IntPtr.Zero) { stringsRootHandle.Free(); } if (handleArray != null) { foreach (GCHandle handle2 in handleArray) { handle2.Free(); } } } if ((shouldTrace && (this.diagnosticTrace != null)) && ((TraceCore.TraceCodeEventLogCriticalIsEnabled(this.diagnosticTrace) || TraceCore.TraceCodeEventLogVerboseIsEnabled(this.diagnosticTrace)) || ((TraceCore.TraceCodeEventLogInfoIsEnabled(this.diagnosticTrace) || TraceCore.TraceCodeEventLogWarningIsEnabled(this.diagnosticTrace)) || TraceCore.TraceCodeEventLogErrorIsEnabled(this.diagnosticTrace)))) { Dictionary<string, string> dictionary = new Dictionary<string, string>(logValues.Length + 4); dictionary["CategoryID.Name"] = "EventLogCategory"; dictionary["CategoryID.Value"] = eventLogCategory.ToString(CultureInfo.InvariantCulture); dictionary["InstanceID.Name"] = "EventId"; dictionary["InstanceID.Value"] = eventId.ToString(CultureInfo.InvariantCulture); for (int m = 0; m < values.Length; m++) { dictionary.Add("Value" + m.ToString(CultureInfo.InvariantCulture), (values[m] == null) ? string.Empty : DiagnosticTrace.XmlEncode(values[m])); } TraceRecord traceRecord = new DictionaryTraceRecord(dictionary); switch (type) { case TraceEventType.Critical: TraceCore.TraceCodeEventLogCritical(this.diagnosticTrace, traceRecord); goto Label_035C; case TraceEventType.Error: TraceCore.TraceCodeEventLogError(this.diagnosticTrace, traceRecord); goto Label_035C; case (TraceEventType.Error | TraceEventType.Critical): goto Label_035C; case TraceEventType.Warning: TraceCore.TraceCodeEventLogWarning(this.diagnosticTrace, traceRecord); goto Label_035C; case TraceEventType.Information: TraceCore.TraceCodeEventLogInfo(this.diagnosticTrace, traceRecord); goto Label_035C; case TraceEventType.Verbose: TraceCore.TraceCodeEventLogVerbose(this.diagnosticTrace, traceRecord); goto Label_035C; } } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } } Label_035C: if (this.isInPartialTrust) { logCountForPT++; } }
private void CallEtwMileStoneEvent(TraceEventType type, DictionaryTraceRecord record) { TraceEventType type2 = type; if (type2 <= TraceEventType.Stop) { if (type2 != TraceEventType.Start) { if (type2 == TraceEventType.Stop) { if (!TD.StopSignpostEventIsEnabled()) { return; } TD.StopSignpostEvent(record); } return; } } else { switch (type2) { case TraceEventType.Suspend: if (TD.SuspendSignpostEventIsEnabled()) { TD.SuspendSignpostEvent(record); } return; case TraceEventType.Resume: if (TD.ResumeSignpostEventIsEnabled()) { TD.ResumeSignpostEvent(record); } return; } return; } if (TD.StartSignpostEventIsEnabled()) { TD.StartSignpostEvent(record); } }
void PerformOpen(TimeSpan timeout) { string lowerCaseConnectionString = this.connectionString.ToUpper(CultureInfo.InvariantCulture); if (!lowerCaseConnectionString.Contains("CONNECTION TIMEOUT") && !lowerCaseConnectionString.Contains("CONNECTIONTIMEOUT")) { this.canonicalConnectionString = this.connectionString.Trim(); if (this.canonicalConnectionString.EndsWith(";", StringComparison.Ordinal)) { this.canonicalConnectionString += "Connection Timeout="; } else { this.canonicalConnectionString += ";Connection Timeout="; } } // Check that the connection string is valid using (SqlConnection connection = new SqlConnection(GetConnectionString(timeout))) { if (DiagnosticUtility.ShouldTraceInformation) { Dictionary<string, string> openParameters = new Dictionary<string, string>(2) { { "IsLocking", this.IsLockingTurnedOn ? "True" : "False" }, { "LockTimeout", this.lockTimeout.ToString() } }; TraceRecord record = new DictionaryTraceRecord(openParameters); TraceUtility.TraceEvent(TraceEventType.Information, TraceCode.SqlPersistenceProviderOpenParameters, SR.GetString(SR.TraceCodeSqlPersistenceProviderOpenParameters), record, this, null); } connection.Open(); } this.activeCommands = new List<SqlCommand>(); this.hostId = Guid.NewGuid(); }
internal static void TraceExtensionTypeNotFound(ExtensionElement extensionElement) { if (DiagnosticUtility.ShouldTraceWarning) { Dictionary<string, string> values = new Dictionary<string, string>(2); values.Add("ExtensionName", extensionElement.Name); values.Add("ExtensionType", extensionElement.Type); DictionaryTraceRecord traceRecord = new DictionaryTraceRecord(values); TraceUtility.TraceEvent(TraceEventType.Warning, TraceCode.ExtensionTypeNotFound, SR.GetString(SR.TraceCodeExtensionTypeNotFound), traceRecord, null, (Exception)null); } }
static void DatagramSentOrReceived(NativeMsmqMessage.BufferProperty messageId, Message message, int traceCode, string traceDescription) { if (DiagnosticUtility.ShouldTraceVerbose) { Guid msmqId = MessageIdToGuid(messageId); UniqueId indigoId = message.Headers.MessageId; TraceRecord record = null; if (null == indigoId) { record = new StringTraceRecord("MSMQMessageId", msmqId.ToString()); } else { Dictionary<string, string> dictionary = new Dictionary<string, string>(2) { { "MSMQMessageId", msmqId.ToString() }, { "WCFMessageId", indigoId.ToString() } }; record = new DictionaryTraceRecord(dictionary); } TraceUtility.TraceEvent(TraceEventType.Verbose, traceCode, traceDescription, record, null, null); } }
private static void DatagramSentOrReceived(NativeMsmqMessage.BufferProperty messageId, Message message, int traceCode, string traceDescription) { if (DiagnosticUtility.ShouldTraceVerbose) { Guid guid = MessageIdToGuid(messageId); UniqueId id = message.Headers.MessageId; TraceRecord extendedData = null; if (null == id) { extendedData = new StringTraceRecord("MSMQMessageId", guid.ToString()); } else { Dictionary<string, string> dictionary2 = new Dictionary<string, string>(2); dictionary2.Add("MSMQMessageId", guid.ToString()); dictionary2.Add("WCFMessageId", id.ToString()); Dictionary<string, string> dictionary = dictionary2; extendedData = new DictionaryTraceRecord(dictionary); } TraceUtility.TraceEvent(TraceEventType.Verbose, traceCode, traceDescription, extendedData, null, null); } }
public void UnsafeLogEvent(TraceEventType type, ushort eventLogCategory, uint eventId, bool shouldTrace, params string[] values) { if (logCountForPT >= 5) { return; } try { int num = 0; string[] logValues = new string[values.Length + 2]; for (int i = 0; i < values.Length; i++) { string str = values[i]; if (!string.IsNullOrEmpty(str)) { str = NormalizeEventLogParameter(str); } else { str = string.Empty; } logValues[i] = str; num += str.Length + 1; } string str2 = NormalizeEventLogParameter(this.UnsafeGetProcessName()); logValues[logValues.Length - 2] = str2; num += str2.Length + 1; string str3 = this.UnsafeGetProcessId().ToString(CultureInfo.InvariantCulture); logValues[logValues.Length - 1] = str3; num += str3.Length + 1; if (num > 0x6400) { int length = (0x6400 / logValues.Length) - 1; for (int j = 0; j < logValues.Length; j++) { if (logValues[j].Length > length) { logValues[j] = logValues[j].Substring(0, length); } } } SecurityIdentifier user = WindowsIdentity.GetCurrent().User; byte[] binaryForm = new byte[user.BinaryLength]; user.GetBinaryForm(binaryForm, 0); IntPtr[] ptrArray = new IntPtr[logValues.Length]; GCHandle stringsRootHandle = new GCHandle(); GCHandle[] handleArray = null; try { stringsRootHandle = GCHandle.Alloc(ptrArray, GCHandleType.Pinned); handleArray = new GCHandle[logValues.Length]; for (int k = 0; k < logValues.Length; k++) { handleArray[k] = GCHandle.Alloc(logValues[k], GCHandleType.Pinned); ptrArray[k] = handleArray[k].AddrOfPinnedObject(); } this.UnsafeWriteEventLog(type, eventLogCategory, eventId, logValues, binaryForm, stringsRootHandle); } finally { if (stringsRootHandle.AddrOfPinnedObject() != IntPtr.Zero) { stringsRootHandle.Free(); } if (handleArray != null) { foreach (GCHandle handle2 in handleArray) { handle2.Free(); } } } if ((shouldTrace && (this.diagnosticTrace != null)) && ((TraceCore.TraceCodeEventLogCriticalIsEnabled(this.diagnosticTrace) || TraceCore.TraceCodeEventLogVerboseIsEnabled(this.diagnosticTrace)) || ((TraceCore.TraceCodeEventLogInfoIsEnabled(this.diagnosticTrace) || TraceCore.TraceCodeEventLogWarningIsEnabled(this.diagnosticTrace)) || TraceCore.TraceCodeEventLogErrorIsEnabled(this.diagnosticTrace)))) { Dictionary <string, string> dictionary = new Dictionary <string, string>(logValues.Length + 4); dictionary["CategoryID.Name"] = "EventLogCategory"; dictionary["CategoryID.Value"] = eventLogCategory.ToString(CultureInfo.InvariantCulture); dictionary["InstanceID.Name"] = "EventId"; dictionary["InstanceID.Value"] = eventId.ToString(CultureInfo.InvariantCulture); for (int m = 0; m < values.Length; m++) { dictionary.Add("Value" + m.ToString(CultureInfo.InvariantCulture), (values[m] == null) ? string.Empty : DiagnosticTrace.XmlEncode(values[m])); } TraceRecord traceRecord = new DictionaryTraceRecord(dictionary); switch (type) { case TraceEventType.Critical: TraceCore.TraceCodeEventLogCritical(this.diagnosticTrace, traceRecord); goto Label_035C; case TraceEventType.Error: TraceCore.TraceCodeEventLogError(this.diagnosticTrace, traceRecord); goto Label_035C; case (TraceEventType.Error | TraceEventType.Critical): goto Label_035C; case TraceEventType.Warning: TraceCore.TraceCodeEventLogWarning(this.diagnosticTrace, traceRecord); goto Label_035C; case TraceEventType.Information: TraceCore.TraceCodeEventLogInfo(this.diagnosticTrace, traceRecord); goto Label_035C; case TraceEventType.Verbose: TraceCore.TraceCodeEventLogVerbose(this.diagnosticTrace, traceRecord); goto Label_035C; } } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } } Label_035C: if (this.isInPartialTrust) { logCountForPT++; } }
internal static void TraceExtensionTypeNotFound(ExtensionElement extensionElement) { if (DiagnosticUtility.ShouldTraceWarning) { Dictionary<string, string> dictionary = new Dictionary<string, string>(2); dictionary.Add("ExtensionName", extensionElement.Name); dictionary.Add("ExtensionType", extensionElement.Type); DictionaryTraceRecord extendedData = new DictionaryTraceRecord(dictionary); TraceUtility.TraceEvent(TraceEventType.Warning, 0x80045, System.ServiceModel.SR.GetString("TraceCodeExtensionTypeNotFound"), extendedData, null, null); } }