Example #1
0
        private IList <Seat> GetSeatInformation(RouteInformation routeInformation, CtripRegexExpression ctripRegex)
        {
            IList <Seat> seatList = new List <Seat>();
            Seat         seat;

            string strUrl = GetUrl(routeInformation.OriginalAirport, routeInformation.DestinationAirport, routeInformation.DepartureTime, routeInformation.FlightNO);

            IList <string> resultList = RegexOperation.GetValuesByRegex(string.Format(ctripRegex.GetAllCabinInfomation(), routeInformation.FlightNO.Trim()), DownHtmlSource(strUrl));

            if (resultList == null)
            {
                return(seatList);
            }

            string strPrice = string.Empty;

            foreach (string strResult in resultList)
            {
                seat       = new Seat();
                seat.Cabin = RegexOperation.GetValueByRegex(ctripRegex.GetOtherCanbin(), strResult);

                strPrice = RegexOperation.GetValueByRegex(ctripRegex.GetOtherCanbinPrice(), strResult);
                if (!string.IsNullOrEmpty(strPrice))
                {
                    seat.Price = double.Parse(strPrice);
                }

                seat.Count = 9;

                seatList.Add(seat);
            }

            return(seatList);
        }