static void OnTimerElapsed(object sender, ElapsedEventArgs e) { Console.WriteLine("Looking for dead reservations at {0}", DateTime.Now.ToString()); var rentalManager = new RentalManager(); var reservations = rentalManager.GetDeadReservations(); if (reservations != null) { foreach (var reservation in reservations) { using (var scope = new TransactionScope()) { try { rentalManager.CancelReservation(reservation.ReservationId); Console.WriteLine("Cancel reservation '{0}'", reservation.ReservationId); scope.Complete(); } catch (Exception) { Console.WriteLine( "There was an excetion when attmpting to cancel reservation '{0}'.", reservation.ReservationId); } } } } }
private static void Timer_Elapsed(object sender, ElapsedEventArgs e) { Console.WriteLine("Looking for dead reservations at {0}", DateTime.Now.ToString()); RentalManager rentalManager = new RentalManager(); Reservation[] reservations = rentalManager.GetDeadReservations(); if (reservations != null) { foreach (Reservation reservation in reservations) { try { using (TransactionScope scope = new TransactionScope()) { rentalManager.CancelReservation(reservation.ReservationId); Console.WriteLine("Cancelling reservation '{0}'", reservation.ReservationId); scope.Complete(); } } catch (Exception ex) { Console.WriteLine("There was an exception when attempting to cancel reservantion '{0}'", reservation.ReservationId); } } } }
private static void OnTimerElapsed(object sender, ElapsedEventArgs e) { System.Console.WriteLine("Looking for dead reservation started at " + DateTime.Now.ToString()); RentalManager rentalManager = new RentalManager(); Reservation[] reservations = rentalManager.GetDeadReservations(); if (reservations != null) { foreach (var reservation in reservations) { using (TransactionScope scope = new TransactionScope()) { try { rentalManager.CancelReservation(reservation.ReservationId); System.Console.WriteLine("Canceling reservation " + reservation.ReservationId); scope.Complete(); } catch (Exception ex) { System.Console.WriteLine($"There was an exception {ex.Message} when attempting cancel reservation"); } } } } }
private static void OnTimerElapsed(Object sender, ElapsedEventArgs e) { System.Console.WriteLine("Looking for dead reservation at {0}", DateTime.Now.ToString()); RentalManager rentalManager = new RentalManager(); Reservation[] reservations = rentalManager.GetDeadReservations(); if (reservations != null) { foreach (Reservation reservation in reservations) { //Aádimos referencia Syste.Transactions using (TransactionScope scope = new TransactionScope()) { try { rentalManager.CancelReservation(reservation.ReservationId); System.Console.WriteLine("Canceling reservation '{0}'.", reservation.ReservationId); scope.Complete(); } catch (Exception ex) { System.Console.WriteLine("There was an exception when attempting to cancel reservation '{0}.'", reservation.ReservationId); System.Console.WriteLine(ex.Message.ToString()); } } } } }
static void OnTimerElapsed(object sender, ElapsedEventArgs e) { RentalManager rentalManager = new RentalManager(); Reservation[] reservations = rentalManager.GetDeadReservations(); if (reservations != null) { foreach (Reservation reservation in reservations) { rentalManager.CancelReservation(reservation.ReservationId); } } }
static void OnTimerElapsed(object sender, ElapsedEventArgs e) { RentalManager rentalManager = new RentalManager(); Reservation[] reservations = rentalManager.GetDeadReservations(); if (reservations != null) { foreach (Reservation reservation in reservations) { using (TransactionScope scope = new TransactionScope()) { rentalManager.CancelReservation(reservation.ReservationId); scope.Complete(); } } } }