Esempio n. 1
0
 void IDbTracingListener.CommandFinished(DbTracingContext context)
 {
     if (onFinished != null)
     {
         onFinished(context);
     }
 }
Esempio n. 2
0
        public override object ExecuteScalar()
        {
            if (!DbTracing.IsEnabled)
            {
                return(command.ExecuteScalar());
            }

            var context = new DbTracingContext(DbTracingType.Scalar, connection, command);

            object result = null;

            DbTracing.FireCommandExecuting(context);
            try
            {
                context.OnStarted();
                result = command.ExecuteScalar();
                context.OnFinished(result);
            }
            catch (Exception ex)
            {
                context.OnFailed(ex);

                DbTracing.FireCommandFailed(context);
                throw;
            }

            DbTracing.FireCommandFinished(context);

            return(result);
        }
Esempio n. 3
0
        internal static void FireCommandFinished(DbTracingContext context)
        {
            if (!enabled)
            {
                return;
            }

            rwLock.EnterReadLock();
            try
            {
                foreach (var listener in listeners)
                {
                    listener.CommandFinished(context);
                }
            }
            finally
            {
                rwLock.ExitReadLock();
            }

            if (context.Type != DbTracingType.Reader)
            {
                FireCommandExecuted(context);
            }
        }
Esempio n. 4
0
 void IDbTracingListener.ReaderFinished(DbTracingContext context)
 {
     if (onReaderFinished != null)
     {
         onReaderFinished(context);
     }
 }
Esempio n. 5
0
 void IDbTracingListener.CommandExecuting(DbTracingContext context)
 {
     if (onExecuting != null)
     {
         onExecuting(context);
     }
 }
Esempio n. 6
0
        protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
        {
            if (!DbTracing.IsEnabled)
            {
                return(command.ExecuteReader(behavior));
            }

            var context = new DbTracingContext(DbTracingType.Reader, connection, command);

            DbTracing.FireCommandExecuting(context);
            DbTracingDataReader result = null;

            try
            {
                context.OnStarted();
                result = new DbTracingDataReader(command.ExecuteReader(behavior), context);
                context.OnFinished(result.UnderlyingReader);
            }
            catch (Exception ex)
            {
                context.OnFailed(ex);

                DbTracing.FireCommandFailed(context);
                throw;
            }

            DbTracing.FireCommandFinished(context);

            return(result);
        }
        public DbTracingDataReader(DbDataReader reader, DbTracingContext context)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");
            if (context == null)
                throw new ArgumentNullException("context");
            if (reader is DbTracingDataReader)
                throw new InvalidOperationException("Reader is already wrapped");

            this.reader = reader;
            this.context = context;
        }
Esempio n. 8
0
        public DbTracingDataReader(DbDataReader reader, DbTracingContext context)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (reader is DbTracingDataReader)
            {
                throw new InvalidOperationException("Reader is already wrapped");
            }

            this.reader  = reader;
            this.context = context;
        }
Esempio n. 9
0
        private static void FireCommandExecuted(DbTracingContext context)
        {
            if (!enabled)
            {
                return;
            }

            rwLock.EnterReadLock();
            try
            {
                foreach (var listener in listeners)
                {
                    listener.CommandExecuted(context);
                }
            }
            finally
            {
                rwLock.ExitReadLock();
            }
        }
Esempio n. 10
0
        internal static void FireCommandExecuting(DbTracingContext context)
        {
            if (!enabled)
                return;

            rwLock.EnterReadLock();
            try
            {
                foreach (var listener in listeners)
                    listener.CommandExecuting(context);
            }
            finally
            {
                rwLock.ExitReadLock();
            }
        }
Esempio n. 11
0
        internal static void FireCommandFinished(DbTracingContext context)
        {
            if (!enabled)
                return;

            rwLock.EnterReadLock();
            try
            {
                foreach (var listener in listeners)
                    listener.CommandFinished(context);
            }
            finally
            {
                rwLock.ExitReadLock();
            }

            if (context.Type != DbTracingType.Reader)
                FireCommandExecuted(context);
        }
Esempio n. 12
0
 public virtual void CommandFinished(DbTracingContext context)
 {
 }
 public void CommandExecuted(DbTracingContext context)
 {
 }
 public void ReaderFinished(DbTracingContext context)
 {
 }
Esempio n. 15
0
 public virtual void CommandFailed(DbTracingContext context)
 {
 }
 public void CommandFailed(DbTracingContext context)
 {
 }
 void IDbTracingListener.ReaderFinished(DbTracingContext context)
 {
     if (onReaderFinished != null)
         onReaderFinished(context);
 }
Esempio n. 18
0
 public virtual void ReaderFinished(DbTracingContext context)
 {
 }
 void IDbTracingListener.CommandExecuting(DbTracingContext context)
 {
     if (onExecuting != null)
         onExecuting(context);
 }
 public virtual void CommandFinished(DbTracingContext context)
 {
 }
 public virtual void CommandExecuting(DbTracingContext context)
 {
 }
 public void CommandFinished(DbTracingContext context)
 {
     Log.Write("-- time: {0}{1}{2}", context.Duration, Environment.NewLine, context.Command.ToTraceString());
 }
 void IDbTracingListener.CommandFinished(DbTracingContext context)
 {
     if (onFinished != null)
         onFinished(context);
 }
Esempio n. 24
0
 public virtual void CommandExecuted(DbTracingContext context)
 {
 }