Ejemplo n.º 1
0
 void IDbTracingListener.CommandFinished(DbTracingContext context)
 {
     if (onFinished != null)
     {
         onFinished(context);
     }
 }
Ejemplo 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);
        }
Ejemplo 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);
            }
        }
Ejemplo n.º 4
0
 void IDbTracingListener.ReaderFinished(DbTracingContext context)
 {
     if (onReaderFinished != null)
     {
         onReaderFinished(context);
     }
 }
Ejemplo n.º 5
0
 void IDbTracingListener.CommandExecuting(DbTracingContext context)
 {
     if (onExecuting != null)
     {
         onExecuting(context);
     }
 }
Ejemplo 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;
        }
Ejemplo 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;
        }
Ejemplo 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();
            }
        }
Ejemplo 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();
            }
        }
Ejemplo 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);
        }
Ejemplo n.º 12
0
 public virtual void CommandFinished(DbTracingContext context)
 {
 }
 public void CommandExecuted(DbTracingContext context)
 {
 }
 public void ReaderFinished(DbTracingContext context)
 {
 }
Ejemplo n.º 15
0
 public virtual void CommandFailed(DbTracingContext context)
 {
 }
 public void CommandFailed(DbTracingContext context)
 {
 }
Ejemplo n.º 17
0
 void IDbTracingListener.ReaderFinished(DbTracingContext context)
 {
     if (onReaderFinished != null)
         onReaderFinished(context);
 }
Ejemplo n.º 18
0
 public virtual void ReaderFinished(DbTracingContext context)
 {
 }
Ejemplo n.º 19
0
 void IDbTracingListener.CommandExecuting(DbTracingContext context)
 {
     if (onExecuting != null)
         onExecuting(context);
 }
Ejemplo n.º 20
0
 public virtual void CommandFinished(DbTracingContext context)
 {
 }
Ejemplo n.º 21
0
 public virtual void CommandExecuting(DbTracingContext context)
 {
 }
 public void CommandFinished(DbTracingContext context)
 {
     Log.Write("-- time: {0}{1}{2}", context.Duration, Environment.NewLine, context.Command.ToTraceString());
 }
Ejemplo n.º 23
0
 void IDbTracingListener.CommandFinished(DbTracingContext context)
 {
     if (onFinished != null)
         onFinished(context);
 }
Ejemplo n.º 24
0
 public virtual void CommandExecuted(DbTracingContext context)
 {
 }