Ejemplo n.º 1
0
        protected void TryRollBack(SqlTransaction transaction, SqlException sqlEx)
        {
            try
            {
                transaction.Rollback();
            }
            catch (Exception)
            {
                throw new Exception("Add failed. Error during transaction, then error during rollback. Rollback was NOT successfully executed", sqlEx);
            }

            if (TransientErrorDetector.IsTransient(sqlEx))
            {
                throw new TransientException("A transient exception has occurred. Add failed. Error during transaction. Rollback successfully executed", sqlEx);
            }

            throw new Exception("Add failed. Error during transaction. Rollback successfully executed", sqlEx);
        }
Ejemplo n.º 2
0
        protected SqlConnection CreateNewConnection(TaskId taskId)
        {
            try
            {
                var connection = new SqlConnection(ConnectionStore.Instance.GetConnection(taskId).ConnectionString);
                connection.Open();

                return(connection);
            }
            catch (SqlException sqlEx)
            {
                if (TransientErrorDetector.IsTransient(sqlEx))
                {
                    throw new TransientException("A transient exception has occurred", sqlEx);
                }

                throw;
            }
        }
Ejemplo n.º 3
0
        protected async Task <SqlConnection> CreateNewConnectionAsync(TaskId taskId)
        {
            try
            {
                var connection = new SqlConnection(ConnectionStore.Instance.GetConnection(taskId).ConnectionString);
                await connection.OpenAsync().ConfigureAwait(false);

                return(connection);
            }
            catch (SqlException sqlEx)
            {
                if (TransientErrorDetector.IsTransient(sqlEx))
                {
                    throw new TransientException("A transient exception has occurred", sqlEx);
                }

                throw;
            }
        }