Exemplo n.º 1
0
        /// <summary>
        /// Get the hall state which is a collection of occupied seats. 
        /// </summary>
        /// <param name="eventID"></param>
        /// <returns></returns>
        public SeatIndex[] GetHallState(Guid eventID)
        {

            LoggingManager.Logger.Log(LoggingCategory.Info,
                 string.Format(StringsResource.AsyncExecution, "GetHallState", Thread.CurrentThread.ManagedThreadId));
 
           var result = new List<SeatIndex>();
           List<Contracts.Reservation> reservations;
           
            //If the hall state is in the cache read it from the cache.   
           rwl.AcquireReaderLock(new TimeSpan(1, 0, 0));
                reservations = (HallCache.Get(eventID.ToString()) as List<Contracts.Reservation>);
            rwl.ReleaseReaderLock();
           
           // if the info is not in the cache read it from the database and put it in the cache.
           if (reservations == null)
           {
              
               ReservationDal Dal = new ReservationDal();
               reservations = Dal.GetReservationsByCriteria(
                   new ReservationCriteria() { EventID = eventID }).ToList();

               rwl.AcquireWriterLock(new TimeSpan(1,0,0));
            		HallCache[eventID.ToString()] = reservations;
               rwl.ReleaseWriterLock();
           }

           foreach (var rs in reservations)
           {
               foreach (var si in rs.Seats)
               {
                   result.Add(si);
               } 
           }
                  
       
           return result.ToArray();
        }
Exemplo n.º 2
0
        public Contracts.Reservation[] FindReservations(ReservationCriteria criteria)
        {
            ReservationDal reservationDal = new ReservationDal();

            return reservationDal.GetReservationsByCriteria(criteria);
        }