コード例 #1
0
        /// <summary>
        /// Crea un ámbito de transacción en base a la configuración del servicio de negocio.
        /// </summary>
        /// <param name="serviceConfiguration">configuración del servicio de negocio.</param>
        /// <returns>ámbito de transacción. <see cref="TransactionScopeHandler"/> </returns>
        /// <date>2008-04-07T00:00:00</date>
        /// <author>moviedo</author>
        private static TransactionScopeHandler CreateTransactionScopeHandler(ServiceConfiguration serviceConfiguration)
        {
            //Creación del ámbito de la transacción.
            TransactionScopeHandler wResult = new TransactionScopeHandler(serviceConfiguration.TransactionalBehaviour, serviceConfiguration.IsolationLevel, new TimeSpan(0, 0, 0));

            return(wResult);
        }
コード例 #2
0
        /// <summary>
        /// Ejecuta un servicio de negocio dentro de un ámbito transaccional.
        /// </summary>
        /// <param name="pRequest">XML con datos de entrada.</param>
        /// <param name="serviceConfiguration">configuración del servicio.</param>
        /// <returns>XML con datos de salida del servicio.</returns>
        /// <date>2008-04-07T00:00:00</date>
        /// <author>moviedo</author>
        public static IServiceContract RunTransactionalProcess(IServiceContract pRequest, ServiceConfiguration serviceConfiguration)
        {
            IServiceContract        wResult;
            TransactionScopeHandler wTransactionScopeHandler = CreateTransactionScopeHandler(serviceConfiguration);
            ServiceError            wServiceError            = null;

            //  ejecución del servicio.
            wTransactionScopeHandler.InitScope();
            wResult = RunService(pRequest, serviceConfiguration, out wServiceError);

            if (wServiceError == null)
            {
                wTransactionScopeHandler.Complete();
            }
            else
            {
                wTransactionScopeHandler.Abort();
            }


            wTransactionScopeHandler.Dispose();
            wTransactionScopeHandler = null;

            return(wResult);
        }
コード例 #3
0
        public async Task WithTransactionAsyncWithResult_TransactionAborted_CommitTransactionExceptionRaised()
        {
            var sut = new TransactionScopeHandler(EmptyLogFactory.Instance);

            await Assert.ThrowsAsync <CommitTransactionException>(() =>
                                                                  sut.WithTransactionAsync <object>(() => throw new TransactionAbortedException()));
        }
        public async Task WithTransactionAsync_TransactionAborted_Rethrown()
        {
            var sut = new TransactionScopeHandler(EmptyLogFactory.Instance);

            await Assert.ThrowsAsync <TransactionAbortedException>(() =>
                                                                   sut.WithTransactionAsync(() => throw new TransactionAbortedException()));
        }
 public TransactionLogDecodingService(
     IDecodingService decodingService,
     IEventRepository eventRepository,
     ILogFactory logFactory,
     ITransactionRepository transactionRepository,
     TransactionScopeHandler transactionScopeHandler)
 {
     _decodingService         = decodingService;
     _eventRepository         = eventRepository;
     _log                     = logFactory.CreateLog(this);
     _transactionRepository   = transactionRepository;
     _transactionScopeHandler = transactionScopeHandler;
 }
コード例 #6
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (filterContext.Controller.ViewData.ModelState.IsValid && filterContext.HttpContext.Error == null)
            {
                if (Behaviour == null)
                {
                    Behaviour = TransactionalBehaviour.RequiresNew;
                }

                if (IsolationLevel == null)
                {
                    IsolationLevel = IsolationLevel.ReadCommitted;
                }
                transactionScopeHandler = new TransactionScopeHandler(Behaviour, IsolationLevel, new TimeSpan(0, 0, 0));
                transactionScopeHandler.InitScope();
            }
            base.OnActionExecuting(filterContext);
        }