예제 #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="eventArgument"></param>
 protected void RaiseOperationFailedEvent(DbQueryFailedEventArgs eventArgument)
 {
     if (null != OperationFailed)
     {
         OperationFailed(this, eventArgument);
     }
 }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IDbQueryResult Execute()
        {
            var _execution   = new DbQueryExecutingEventArgs();
            var _queryResult = (IDbQueryResult)null;

            if (null != Executing)
            {
                Executing(this, _execution);
            }

            if (!_execution.Cancel)
            {
                if (!_executionOnly)
                {
                    _connection.Open();
                }

                try
                {
                    _queryResult = ExecuteImpl(_command);

                    if (null != Executed)
                    {
                        Executed(this, new DbQueryExecutedEventArgs(_queryResult));
                    }
                }
                catch (SqlException ex)
                {
                    if (null != Failed)
                    {
                        var _exception = new DbQueryException(ex);
                        var _failure   = new DbQueryFailedEventArgs(_exception);

                        Failed(this, _failure);
                    }
                }
                catch (DbQueryException ex)
                {
                    if (null != Failed)
                    {
                        Failed(this, new DbQueryFailedEventArgs(ex));
                    }
                }

                if (!_executionOnly)
                {
                    _connection.Close();
                }
            }


            return(_queryResult);
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        public void Close()
        {
            try
            {
                Connection.Close();

                State = DbQueryOperatingSessionStates.Closed;
            }
            catch (SqlException ex)
            {
                var _exception = new DbQueryException(ex);
                var _arguments = new DbQueryFailedEventArgs(_exception);

                RaiseOperationFailedEvent(_arguments);
            }
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        public void Open()
        {
            try
            {
                if (!Connection.IsAlive)
                {
                    State = DbQueryOperatingSessionStates.ConnectionFaulted;

                    throw new DbQueryException("The connection is unavailable");
                }

                Connection.Open();

                State = DbQueryOperatingSessionStates.Opened;
            }
            catch (SqlException ex)
            {
                var _exception = new DbQueryException(ex);
                var _arguments = new DbQueryFailedEventArgs(_exception);

                RaiseOperationFailedEvent(_arguments);
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void _OnOperationFailed(object sender, DbQueryFailedEventArgs e)
 {
     _innerErrorRepository.Add(e.Error);
 }
예제 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void _OnFailed(object sender, DbQueryFailedEventArgs e)
        {
            RaiseOperationFailedEvent(e);

            State = DbQueryOperatingSessionStates.Failed;
        }