Ejemplo n.º 1
0
        /// <summary>
        ///     Rollback transaction.
        /// </summary>
        /// <exception cref="InvalidOperationException">
        ///     Transaction is not active.
        /// </exception>
        /// <remarks>
        ///     It is possible to rollback owned transaction, but using exception handling and managed owning transaction
        ///     is preferrable.
        /// </remarks>
        /// <exception cref="StorageTransactionException">
        ///		Call to KTM API failed.
        /// </exception>
        public void Rollback()
        {
            Check.DoCheckOperationValid(IsHandleValid, "Transaction is not active");

            try
            {
                _status = TransactionStatus.Aborted;
                try
                {
                    _ktmHandle.Rollback();
                }
                catch (Win32Exception e)
                {
                    _log.ErrorFormat("KtmTransaction Rollback failed: {0}", e);
                    throw new StorageTransactionException(
                              message: string.Format("Failed to roll back KTM transaction - {0}", e.Message)
                              , technicalInfo: string.Empty
                              , innerException: e);
                }
            }
            finally
            {
                // exceptions ok to flow through if any
                NotifyCompletion(false);
            }
        }