Esempio n. 1
0
        public static SyosReservation ReserveSyos(SyosReservation reservation)
        {
            SyosReservation unreserved = new SyosReservation(reservation.PerfId);
            foreach (SyosReservationSection section in reservation.Sections)
            {
                foreach (SyosReservationZone zone in section.Zones)
                {
                    if (zone.Seats.Count == 0)
                        continue;
                    StringBuilder priceTypeParam = new StringBuilder();
                    StringBuilder requestedSeatsParam = new StringBuilder();
                    foreach (SyosReservationSeat seat in zone.Seats)
                    {
                        priceTypeParam.Append("," + seat.PriceTypeId.ToString());
                        requestedSeatsParam.Append("," + seat.Id.ToString());
                    }
                    priceTypeParam.Remove(0, 1);
                    requestedSeatsParam.Remove(0, 1);
                    int seatsReserved = 0;
                    try
                    {
                        seatsReserved =
                            unsecuredClient.ReserveTicketsSpecifiedSeats(
                                sWebSessionID:
                                    HttpContext.Current.Session[TessSessionKeySessionKey].ToString(),
                                sPriceType: priceTypeParam.ToString(),
                                iPerformanceNumber: reservation.PerfId,
                                iNumberOfSeats: reservation.SeatCount,
                                iZone: zone.Id,
                                sSpecialRequests: "LeaveSingleSeats=Y",
                                RequestedSeats: requestedSeatsParam.ToString());
                        if (seatsReserved > 0)
                        {
                            Dictionary<int, List<int>> syosReservedSeats;
                            if (HttpContext.Current.Session[SyosReservedSeatsSessionKey] == null)
                            {
                                syosReservedSeats = new Dictionary<int, List<int>>();
                            }
                            else
                            {
                                syosReservedSeats =
                                    (Dictionary<int, List<int>>)HttpContext.Current.Session[
                                    SyosReservedSeatsSessionKey];
                            }
                            if (!syosReservedSeats.ContainsKey(reservation.PerfId))
                            {
                                syosReservedSeats.Add(reservation.PerfId, new List<int>());
                            }
                            List<int> seatList = syosReservedSeats[reservation.PerfId];
                            foreach (SyosReservationSeat seat in zone.Seats)
                            {
                                seatList.Add(seat.Id);
                            }
                            HttpContext.Current.Session[SyosReservedSeatsSessionKey] =
                                syosReservedSeats;
                        }
                    }
                    catch (Exception e)
                    {
                        if (!e.Message.Contains("TESSITURA_SEAT_LIMIT_EXCEPTION")
                            && !e.Message.Contains("One or more"))
                            throw e;
                    }

                    if (seatsReserved < zone.Seats.Count)
                    {
                        foreach (SyosReservationSeat seat in zone.Seats)
                        {
                            unreserved.AddSeat(section.Id, zone.Id, seat.PriceTypeId, seat.Id);
                        }
                    }
                }
            }
            if (unreserved.SeatCount < reservation.SeatCount)
            {
                checkExpireTime();
            }
            return unreserved;
        }
Esempio n. 2
0
 protected void AddSeatsToCart(object sender, EventArgs e)
 {
     if (SelectionModeViews.GetActiveView() == BestSeatingModeView)
     {
         Reservation res = new Reservation(Int32.Parse(PerfField.SelectedValue));
         foreach (string key in Request.Form.AllKeys)
         {
             if (key.StartsWith("seats_"))
             {
                 string[] queryKeyParts = key.Split('_');
                 int sectionId = Int32.Parse(queryKeyParts[1]);
                 int priceTypeId = Int32.Parse(queryKeyParts[2]);
                 int numOfSeats = Int32.Parse(Request.Form[key]);
                 if (numOfSeats > 0)
                 {
                     res.AddPriceTypeSeats(sectionId, priceTypeId, numOfSeats);
                 }
             }
         }
         Reservation unreserved = WebClient.ReserveBestSeating(res);
         if (unreserved.Sections.Count == res.Sections.Count)
         {
             ReservationErrorFlag.Value = "1";
         }
         else
         {
             ViewState.Remove("perfs");
             if (unreserved.Sections.Count == 0)
             {
                 FailedResPanel.Visible = false;
             }
             else
             {
                 ViewState.Add("unreserved", unreserved);
                 res.RemoveSections(unreserved.Sections);
             }
             ViewState.Add("reserved", res);
             OrderWizardViews.SetActiveView(ConfirmationView);
         }
     }
     else if (SelectionModeViews.GetActiveView() == SyosModeView)
     {
         if (syosRequestProcessed)
             return;
         SyosReservation res = new SyosReservation(Int32.Parse(PerfField.SelectedValue));
         foreach (string key in Request.Form.AllKeys)
         {
             if (key.StartsWith("SyosSeat_"))
             {
                 string[] queryKeyParts = key.Split('_');
                 int sectionId = Int32.Parse(queryKeyParts[2]);
                 int zoneId = Int32.Parse(queryKeyParts[4]);
                 int priceTypeId = Int32.Parse(queryKeyParts[6]);
                 int seatId = Int32.Parse(queryKeyParts[8]);
                 res.AddSeat(sectionId, zoneId, priceTypeId, seatId);
             }
         }
         SyosReservation unreserved = WebClient.ReserveSyos(res);
         if (res.SeatCount == 0)
         {
             ReservationErrorFlag.Value = "1";
         }
         else if (res.SeatCount == 1)
         {
             if (unreserved.SeatCount == 1)
                 FailedSeatAddFlag.Value = "1";
             else
                 SeatAddSuccessFlag.Value = "1";
         }
         else
         {
             if (unreserved.SeatCount == res.SeatCount)
                 ReservationErrorFlag.Value = "1";
             else
             {
                 SeatsAddSuccessFlag.Value = "1";
                 // TODO: add successful reservations to list
                 if (unreserved.SeatCount > 0)
                 {
                     FailedSeatsAddFlag.Value = "1";
                     // TODO: add failed reservations to list
                 }
             }
         }
         syosRequestProcessed = true;
     }
 }