コード例 #1
0
        /// <summary>
        /// Ends the transaction and close the reader by passing the object to DBDataAccess
        /// </summary>
        /// <param name="destinationDatabase"></param>
        /// <param name="givenTransaction">The given transaction.</param>
        /// <param name="readerToClose">The reader to close.</param>
        /// <returns>Error Object</returns>
        public ErrorObj EndTransaction(DestinationDatabase destinationDatabase, SqlTransaction givenTransaction, SqlDataReader readerToClose)
        {
            string   ModuleName = GetModuleNameByDestinationDB(destinationDatabase);
            ErrorObj err        = new ErrorObj();

            this.GetConnectionDetails(Settings.BusinessUnit, "", ModuleName);
            Settings.ModuleName = ModuleName;
            DBDataAccess DBDataAccessEntity = new DBDataAccess();

            DBDataAccessEntity.Settings       = Settings;
            DBDataAccessEntity.CommandElement = _commandElements;
            DBDataAccessEntity.EndTransaction(destinationDatabase, ref err, givenTransaction, readerToClose);
            return(err);
        }
コード例 #2
0
        /// <summary>
        /// Use this for Insert, Update and Delete
        /// Functionality to provide the gateway to access the Data Access Layer with Transaction object
        /// If any exception transaction will be rollbacked here
        /// </summary>
        /// <param name="destinationDatabase"></param>
        /// <param name="givenTransaction">The given transaction.</param>
        /// <param name="allowSerialize">To allow serialization of TalentDataAccess instance </param>
        /// <returns></returns>
        public ErrorObj SQLAccess(DestinationDatabase destinationDatabase, SqlTransaction givenTransaction, bool allowSerialize = true)
        {
            string   ModuleName = GetModuleNameByDestinationDB(destinationDatabase);
            ErrorObj err        = new ErrorObj();

            this.GetConnectionDetails(Settings.BusinessUnit, "", ModuleName);
            Settings.ModuleName = ModuleName;
            DBDataAccess DBDataAccessEntity = new DBDataAccess();

            DBDataAccessEntity.Settings       = Settings;
            DBDataAccessEntity.CommandElement = _commandElements;
            err = DBDataAccessEntity.AccessWithTransaction(givenTransaction);
            if (!err.HasError && !(DBDataAccessEntity.ResultDataSet == null))
            {
                ResultDataSet = DBDataAccessEntity.ResultDataSet;
                // Serialize the transaction
                if (allowSerialize && this.CommandElements.CommandExecutionType == CommandExecution.ExecuteNonQuery)
                {
                    SetConnectionStringParameters();
                    Utilities.SerializeTransaction(this, Settings);
                }
            }
            else
            {
                givenTransaction.Rollback();
                //before call this get the previous error details
                string errMessage = err.ErrorMessage;
                err = EndTransaction(destinationDatabase, givenTransaction);
                if (err.HasError)
                {
                    errMessage = errMessage + ";" + err.ErrorMessage;
                }
                //whether end transaction gives error or not
                //always assign err object has error
                err.HasError     = true;
                err.ErrorMessage = errMessage;
            }
            return(err);
        }