private static void OnCloseComplete(IAsyncResult result)
 {
     if (result.CompletedSynchronously)
     {
         return;
     }
     RefcountedCommunicationObject.CloseAsyncResult asyncState = (RefcountedCommunicationObject.CloseAsyncResult)result.AsyncState;
     using (Activity activity = ServiceModelActivity.BoundOperation(null))
     {
         Exception exception = null;
         try
         {
             asyncState.HandleCloseComplete(result);
         }
         catch (Exception exception2)
         {
             Exception exception1 = exception2;
             if (Fx.IsFatal(exception1))
             {
                 throw;
             }
             exception = exception1;
             if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTraceWarning)
             {
                 DiagnosticTrace diagnosticTrace = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.DiagnosticTrace;
                 string          traceCodeCommunicationObjectCloseFailed = Resources.TraceCodeCommunicationObjectCloseFailed;
                 object[]        str = new object[] { asyncState.communicationObject.GetCommunicationObjectType().ToString() };
                 diagnosticTrace.TraceEvent(TraceEventType.Warning, TraceCode.CommunicationObjectCloseFailed, Microsoft.ServiceBus.SR.GetString(traceCodeCommunicationObjectCloseFailed, str), null, null, asyncState);
             }
             asyncState.communicationObject.Abort();
         }
         asyncState.Complete(false, exception);
     }
 }
Exemplo n.º 2
0
 private void Cleanup()
 {
     if (this.cleanupConnection)
     {
         if (this.newConnection)
         {
             if (this.currentConnection != null)
             {
                 this.currentConnection.Abort();
                 this.currentConnection = null;
             }
         }
         else if (this.rawConnection != null)
         {
             if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTraceInformation)
             {
                 DiagnosticTrace diagnosticTrace = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.DiagnosticTrace;
                 string          traceCodeFailedAcceptFromPool = Resources.TraceCodeFailedAcceptFromPool;
                 object[]        objArray = new object[] { this.timeoutHelper.RemainingTime() };
                 diagnosticTrace.TraceEvent(TraceEventType.Information, TraceCode.FailedAcceptFromPool, Microsoft.ServiceBus.SR.GetString(traceCodeFailedAcceptFromPool, objArray));
             }
             this.parent.connectionPool.ReturnConnection(this.parent.connectionKey, this.rawConnection, false, this.timeoutHelper.RemainingTime());
             this.currentConnection = null;
             this.rawConnection     = null;
         }
         this.cleanupConnection = false;
     }
 }
        protected virtual void OnOpening()
        {
            this.onOpeningCalled = true;
            if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTraceVerbose)
            {
                DiagnosticTrace diagnosticTrace = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.DiagnosticTrace;
                string          traceCodeCommunicationObjectOpening = Resources.TraceCodeCommunicationObjectOpening;
                object[]        objArray = new object[] { DiagnosticTrace.CreateSourceString(this) };
                diagnosticTrace.TraceEvent(TraceEventType.Verbose, TraceCode.CommunicationObjectOpening, Microsoft.ServiceBus.SR.GetString(traceCodeCommunicationObjectOpening, objArray), null, null, this);
            }
            EventHandler eventHandler = this.Opening;

            if (eventHandler != null)
            {
                try
                {
                    eventHandler(this.eventSender, EventArgs.Empty);
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    if (!Fx.IsFatal(exception))
                    {
                        throw Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(exception);
                    }
                    throw;
                }
            }
        }
Exemplo n.º 4
0
        private void ReuseConnectionCallback(object state)
        {
            Microsoft.ServiceBus.Channels.ConnectionDemuxer.ReuseConnectionState reuseConnectionState = (Microsoft.ServiceBus.Channels.ConnectionDemuxer.ReuseConnectionState)state;
            bool flag = false;

            lock (this.ThisLock)
            {
                if (this.pooledConnectionCount < this.maxPooledConnections)
                {
                    Microsoft.ServiceBus.Channels.ConnectionDemuxer connectionDemuxer = this;
                    connectionDemuxer.pooledConnectionCount = connectionDemuxer.pooledConnectionCount + 1;
                }
                else
                {
                    flag = true;
                }
            }
            if (!flag)
            {
                if (this.pooledConnectionDequeuedCallback == null)
                {
                    this.pooledConnectionDequeuedCallback = new Action(this.PooledConnectionDequeuedCallback);
                }
                reuseConnectionState.ModeReader.StartReading(this.idleTimeout, this.pooledConnectionDequeuedCallback);
                return;
            }
            if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTraceWarning)
            {
                DiagnosticTrace diagnosticTrace = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.DiagnosticTrace;
                string          traceCodeServerMaxPooledConnectionsQuotaReached = Resources.TraceCodeServerMaxPooledConnectionsQuotaReached;
                object[]        objArray = new object[] { this.maxPooledConnections };
                diagnosticTrace.TraceEvent(TraceEventType.Warning, TraceCode.ServerMaxPooledConnectionsQuotaReached, Microsoft.ServiceBus.SR.GetString(traceCodeServerMaxPooledConnectionsQuotaReached, objArray), new StringTraceRecord("MaxOutboundConnectionsPerEndpoint", this.maxPooledConnections.ToString(CultureInfo.InvariantCulture)), null, this);
            }
            reuseConnectionState.ModeReader.CloseFromPool(reuseConnectionState.CloseTimeout);
        }
 internal static bool HandledExceptionWarningIsEnabled(DiagnosticTrace trace)
 {
     if (!trace.ShouldTrace(TraceEventLevel.Warning))
     {
         return(IsEtwEventEnabled(trace, 11));
     }
     return(true);
 }
 internal static bool UnhandledExceptionIsEnabled(DiagnosticTrace trace)
 {
     if (!trace.ShouldTrace(TraceEventLevel.Error))
     {
         return(IsEtwEventEnabled(trace, 4));
     }
     return(true);
 }
 internal static bool TraceCodeEventLogWarningIsEnabled(DiagnosticTrace trace)
 {
     if (!trace.ShouldTrace(TraceEventLevel.Warning))
     {
         return(IsEtwEventEnabled(trace, 10));
     }
     return(true);
 }
 internal static bool AppDomainUnloadIsEnabled(DiagnosticTrace trace)
 {
     if (!trace.ShouldTrace(TraceEventLevel.Informational))
     {
         return(IsEtwEventEnabled(trace, 0));
     }
     return(true);
 }
 internal static bool TraceCodeEventLogCriticalIsEnabled(DiagnosticTrace trace)
 {
     if (!trace.ShouldTrace(TraceEventLevel.Critical))
     {
         return(IsEtwEventEnabled(trace, 6));
     }
     return(true);
 }
Exemplo n.º 10
0
        private static bool WriteEtwEvent(DiagnosticTrace trace, int eventIndex, string eventParam0, string eventParam1)
        {
            TraceCore.EnsureEventDescriptors();
            EtwProvider etwProvider = trace.EtwProvider;

            object[] objArray = new object[] { eventParam0, eventParam1 };
            return(etwProvider.WriteEvent(ref TraceCore.eventDescriptors[eventIndex], objArray));
        }
 internal static bool TraceCodeEventLogInfoIsEnabled(DiagnosticTrace trace)
 {
     if (!trace.ShouldTrace(TraceEventLevel.Informational))
     {
         return(IsEtwEventEnabled(trace, 8));
     }
     return(true);
 }
 internal static bool TraceCodeEventLogVerboseIsEnabled(DiagnosticTrace trace)
 {
     if (!trace.ShouldTrace(TraceEventLevel.Verbose))
     {
         return(IsEtwEventEnabled(trace, 9));
     }
     return(true);
 }
 internal static bool ShipAssertExceptionMessageIsEnabled(DiagnosticTrace trace)
 {
     if (!trace.ShouldTrace(TraceEventLevel.Error))
     {
         return(IsEtwEventEnabled(trace, 2));
     }
     return(true);
 }
 internal static bool MaxInstancesExceededIsEnabled(DiagnosticTrace trace)
 {
     if (!trace.ShouldTrace(TraceEventLevel.Warning))
     {
         return(IsEtwEventEnabled(trace, 5));
     }
     return(true);
 }
 internal static bool TraceCodeEventLogErrorIsEnabled(DiagnosticTrace trace)
 {
     if (!trace.ShouldTrace(TraceEventLevel.Error))
     {
         return(IsEtwEventEnabled(trace, 7));
     }
     return(true);
 }
Exemplo n.º 16
0
 internal static bool HandledExceptionIsEnabled(DiagnosticTrace trace)
 {
     if (trace.ShouldTrace(TraceEventLevel.Informational))
     {
         return(true);
     }
     return(TraceCore.IsEtwEventEnabled(trace, 1));
 }
Exemplo n.º 17
0
        internal static bool BookmarkResumptionRecord(DiagnosticTrace trace, Guid InstanceId, long RecordNumber, long EventTime, string Name, Guid SubInstanceID, string OwnerActivityName, string OwnerActivityId, string OwnerActivityInstanceId, string OwnerActivityTypeName, string Annotations, string ProfileName, string reference)
        {
            bool         flag    = true;
            TracePayload payload = trace.GetSerializedPayload(null, null, null);

            if (IsEtwEventEnabled(trace, 2))
            {
                flag = WriteEtwEvent(trace, 2, InstanceId, RecordNumber, EventTime, Name, SubInstanceID, OwnerActivityName, OwnerActivityId, OwnerActivityInstanceId, OwnerActivityTypeName, Annotations, ProfileName, reference, payload.AppDomainFriendlyName);
            }
            return(flag);
        }
Exemplo n.º 18
0
        internal static bool CustomTrackingRecordError(DiagnosticTrace trace, Guid InstanceId, long RecordNumber, long EventTime, string Name, string ActivityName, string ActivityId, string ActivityInstanceId, string ActivityTypeName, string Data, string Annotations, string ProfileName, string reference)
        {
            bool         flag    = true;
            TracePayload payload = trace.GetSerializedPayload(null, null, null);

            if (IsEtwEventEnabled(trace, 6))
            {
                flag = WriteEtwEvent(trace, 6, InstanceId, RecordNumber, EventTime, Name, ActivityName, ActivityId, ActivityInstanceId, ActivityTypeName, Data, Annotations, ProfileName, reference, payload.AppDomainFriendlyName);
            }
            return(flag);
        }
Exemplo n.º 19
0
        internal static bool ActivityStateRecord(DiagnosticTrace trace, Guid InstanceId, long RecordNumber, long EventTime, string State, string Name, string ActivityId, string ActivityInstanceId, string ActivityTypeName, string Arguments, string Variables, string Annotations, string ProfileName, string reference)
        {
            bool         flag    = true;
            TracePayload payload = trace.GetSerializedPayload(null, null, null);

            if (IsEtwEventEnabled(trace, 1))
            {
                flag = WriteEtwEvent(trace, 1, InstanceId, RecordNumber, EventTime, State, Name, ActivityId, ActivityInstanceId, ActivityTypeName, Arguments, Variables, Annotations, ProfileName, reference, payload.AppDomainFriendlyName);
            }
            return(flag);
        }
Exemplo n.º 20
0
        internal static bool WorkflowInstanceUnhandledExceptionRecord(DiagnosticTrace trace, Guid InstanceId, long RecordNumber, long EventTime, string ActivityDefinitionId, string SourceName, string SourceId, string SourceInstanceId, string SourceTypeName, string Exception, string Annotations, string ProfileName, string reference)
        {
            bool         flag    = true;
            TracePayload payload = trace.GetSerializedPayload(null, null, null);

            if (IsEtwEventEnabled(trace, 10))
            {
                flag = WriteEtwEvent(trace, 10, InstanceId, RecordNumber, EventTime, ActivityDefinitionId, SourceName, SourceId, SourceInstanceId, SourceTypeName, Exception, Annotations, ProfileName, reference, payload.AppDomainFriendlyName);
            }
            return(flag);
        }
Exemplo n.º 21
0
        internal static bool FaultPropagationRecord(DiagnosticTrace trace, Guid InstanceId, long RecordNumber, long EventTime, string FaultSourceActivityName, string FaultSourceActivityId, string FaultSourceActivityInstanceId, string FaultSourceActivityTypeName, string FaultHandlerActivityName, string FaultHandlerActivityId, string FaultHandlerActivityInstanceId, string FaultHandlerActivityTypeName, string Fault, bool IsFaultSource, string Annotations, string ProfileName, string reference)
        {
            bool         flag    = true;
            TracePayload payload = trace.GetSerializedPayload(null, null, null);

            if (IsEtwEventEnabled(trace, 4))
            {
                flag = WriteEtwEvent(trace, 4, InstanceId, RecordNumber, EventTime, FaultSourceActivityName, FaultSourceActivityId, FaultSourceActivityInstanceId, FaultSourceActivityTypeName, FaultHandlerActivityName, FaultHandlerActivityId, FaultHandlerActivityInstanceId, FaultHandlerActivityTypeName, Fault, IsFaultSource, Annotations, ProfileName, reference, payload.AppDomainFriendlyName);
            }
            return(flag);
        }
 private static void UpdateLevel()
 {
     level                  = DiagnosticTrace.Level;
     tracingEnabled         = DiagnosticTrace.TracingEnabled;
     shouldTraceCritical    = DiagnosticTrace.ShouldTrace(TraceEventType.Critical);
     shouldTraceError       = DiagnosticTrace.ShouldTrace(TraceEventType.Error);
     shouldTraceInformation = DiagnosticTrace.ShouldTrace(TraceEventType.Information);
     shouldTraceWarning     = DiagnosticTrace.ShouldTrace(TraceEventType.Warning);
     shouldTraceVerbose     = DiagnosticTrace.ShouldTrace(TraceEventType.Verbose);
     shouldUseActivity      = DiagnosticTrace.ShouldUseActivity;
 }
Exemplo n.º 23
0
        internal static Activity CreateActivity(Guid newGuid, bool emitTransfer)
        {
            Activity retval = null;

            if (DiagnosticTrace.ShouldCorrelate &&
                (newGuid != Guid.Empty) &&
                (newGuid != DiagnosticTrace.GetActivityId()))
            {
                retval = new Activity(ref newGuid, emitTransfer);
            }
            return(retval);
        }
Exemplo n.º 24
0
 public void Dispose()
 {
     if (_mustDispose)
     {
         _mustDispose = false;
         if (_emitTransfer)
         {
             DiagnosticTrace.TraceTransfer(_oldGuid);
         }
         DiagnosticTrace.SetActivityId(_oldGuid);
     }
 }
                private bool ReturnToPool(TItem connection)
                {
                    bool flag = this.idleConnections.Return(connection);

                    if (!flag && Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTraceInformation)
                    {
                        DiagnosticTrace diagnosticTrace = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.DiagnosticTrace;
                        string          traceCodeConnectionPoolMaxOutboundConnectionsPerEndpointQuotaReached = Resources.TraceCodeConnectionPoolMaxOutboundConnectionsPerEndpointQuotaReached;
                        object[]        objArray = new object[] { this.maxCount };
                        diagnosticTrace.TraceEvent(TraceEventType.Information, TraceCode.ConnectionPoolMaxOutboundConnectionsPerEndpointQuotaReached, Microsoft.ServiceBus.SR.GetString(traceCodeConnectionPoolMaxOutboundConnectionsPerEndpointQuotaReached, objArray), null, null, this);
                    }
                    return(flag);
                }
        internal static void ShipAssertExceptionMessage(DiagnosticTrace trace, string param0)
        {
            TracePayload payload = trace.GetSerializedPayload(null, null, null);

            if (IsEtwEventEnabled(trace, 2))
            {
                WriteEtwEvent(trace, 2, param0, payload.AppDomainFriendlyName);
            }
            if (trace.ShouldTraceToTraceSource(TraceEventLevel.Error))
            {
                string description = string.Format(Culture, ResourceManager.GetString("ShipAssertExceptionMessage", Culture), new object[] { param0 });
                WriteTraceSource(trace, 2, description, payload);
            }
        }
        internal static void HandledExceptionWarning(DiagnosticTrace trace, Exception exception)
        {
            TracePayload payload = trace.GetSerializedPayload(null, null, exception);

            if (IsEtwEventEnabled(trace, 11))
            {
                WriteEtwEvent(trace, 11, payload.SerializedException, payload.AppDomainFriendlyName);
            }
            if (trace.ShouldTraceToTraceSource(TraceEventLevel.Warning))
            {
                string description = string.Format(Culture, ResourceManager.GetString("HandledExceptionWarning", Culture), new object[0]);
                WriteTraceSource(trace, 11, description, payload);
            }
        }
        internal static void TraceCodeEventLogWarning(DiagnosticTrace trace, TraceRecord traceRecord)
        {
            TracePayload payload = trace.GetSerializedPayload(null, traceRecord, null);

            if (IsEtwEventEnabled(trace, 10))
            {
                WriteEtwEvent(trace, 10, payload.ExtendedData, payload.AppDomainFriendlyName);
            }
            if (trace.ShouldTraceToTraceSource(TraceEventLevel.Warning))
            {
                string description = string.Format(Culture, ResourceManager.GetString("TraceCodeEventLogWarning", Culture), new object[0]);
                WriteTraceSource(trace, 10, description, payload);
            }
        }
        internal static void ThrowingException(DiagnosticTrace trace, string param0, Exception exception)
        {
            TracePayload payload = trace.GetSerializedPayload(null, null, exception);

            if (IsEtwEventEnabled(trace, 3))
            {
                WriteEtwEvent(trace, 3, param0, payload.SerializedException, payload.AppDomainFriendlyName);
            }
            if (trace.ShouldTraceToTraceSource(TraceEventLevel.Error))
            {
                string description = string.Format(Culture, ResourceManager.GetString("ThrowingException", Culture), new object[] { param0 });
                WriteTraceSource(trace, 3, description, payload);
            }
        }
        internal static void AppDomainUnload(DiagnosticTrace trace, string param0, string param1, string param2)
        {
            TracePayload payload = trace.GetSerializedPayload(null, null, null);

            if (IsEtwEventEnabled(trace, 0))
            {
                WriteEtwEvent(trace, 0, param0, param1, param2, payload.AppDomainFriendlyName);
            }
            if (trace.ShouldTraceToTraceSource(TraceEventLevel.Informational))
            {
                string description = string.Format(Culture, ResourceManager.GetString("AppDomainUnload", Culture), new object[] { param0, param1, param2 });
                WriteTraceSource(trace, 0, description, payload);
            }
        }
Exemplo n.º 31
0
 public EventLogger(string eventLogSourceName, DiagnosticTrace diagnosticTrace)
 {
     try
     {
         this.diagnosticTrace = diagnosticTrace;
         //set diagnostics trace prior to calling SafeSetLogSourceName
         if (canLogEvent)
         {
             SafeSetLogSourceName(eventLogSourceName);
         }
     }
     catch (SecurityException)
     {
         // running in PT, do not try to log events anymore
         canLogEvent = false;
         // not throwing exception on purpose
     }
 }
Exemplo n.º 32
0
 void SetLogSourceName(string updatedEventLogSourceName, DiagnosticTrace updatedDiagnosticTrace)
 {
     this.eventLogSourceName = updatedEventLogSourceName;
     this.diagnosticTrace = updatedDiagnosticTrace;
 }
Exemplo n.º 33
0
 public static EventLogger UnsafeCreateEventLogger(string eventLogSourceName, DiagnosticTrace diagnosticTrace)
 {
     EventLogger logger = new EventLogger();
     logger.SetLogSourceName(eventLogSourceName, diagnosticTrace);
     return logger;
 }