Ejemplo n.º 1
0
        /// <summary>
        /// Rollbacks the transaction.
        /// </summary>
        public SqlContextResult RollbackTransaction()
        {
            SqlContextResult isok = SqlContextResult.Ok;

            try
            {
                if (mTransaction != null)
                {
                    mTransaction.Rollback();
                }
                else
                {
                    isok = SqlContextResult.NoTransactionToRollback;
                }
            }
            catch (Exception ex)
            {
                EventLogger.SendMsg(ex);
                isok = SqlContextResult.TransactionRollbackError;
            }
            finally
            {
                mTransaction.Dispose();
                mTransaction = null;
                mConnection.Close();
            }
            return(isok);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Opens the transaction.
        /// </summary>
        /// <param name="isolationLevel">The isolation level.</param>
        /// <returns></returns>
        public SqlContextResult OpenTransaction(IsolationLevel isolationLevel = IsolationLevel.RepeatableRead)
        {
            SqlContextResult isok = SqlContextResult.Ok;

            if (mIsTransactional)
            {
                try
                {
                    mConnection.Open();
                    try
                    {
                        mTransaction = mConnection.BeginTransaction(isolationLevel, Guid.NewGuid().ToString().XDwLeft(32).ToString());
                    }
                    catch (Exception ex)
                    {
                        EventLogger.SendMsg(ex);
                        isok = SqlContextResult.ErrorOpeningTransaction;
                    }
                }
                catch (Exception ex)
                {
                    EventLogger.SendMsg(ex);
                    isok = SqlContextResult.ErrorOpeningConnection;
                }
            }
            else
            {
                isok = SqlContextResult.ContextNotTransactional;
            }
            return(isok);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Commits the transaction.
        /// </summary>
        public SqlContextResult CommitTransaction()
        {
            SqlContextResult isok = SqlContextResult.Ok;

            try
            {
                if (mTransaction != null)
                {
                    this.mTransaction.Commit();
                }
                else
                {
                    isok = SqlContextResult.NoTransactionToCommit;
                }
            }
            catch (Exception ex)
            {
                EventLogger.SendMsg(ex);
                isok = SqlContextResult.CommitTransactionError;
            }
            finally
            {
                mTransaction.Dispose();
                mTransaction = null;
                mConnection.Close();
            }
            return(isok);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Closes the connection.
        /// </summary>
        /// <returns></returns>
        public SqlContextResult CloseConnection()
        {
            SqlContextResult isok = SqlContextResult.Ok;

            try
            {
                mConnection.Close();
            }
            catch (Exception ex)
            {
                EventLogger.SendMsg(ex);
                isok = SqlContextResult.ConnectionCloseError;
            }
            return(isok);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Opens the connection.
        /// </summary>
        /// <returns></returns>
        public SqlContextResult OpenConnection()
        {
            SqlContextResult isok = SqlContextResult.Ok;

            try
            {
                if (!ConnectionIsOpen)
                {
                    mConnection.Open();
                }
                else
                {
                    isok = SqlContextResult.ConnectionAlreadyOpened;
                }
            }
            catch (Exception ex)
            {
                EventLogger.SendMsg(ex);
                isok = SqlContextResult.ErrorOpeningConnection;
            }
            return(isok);
        }