Example #1
0
        private RouteInformation GetRouteInformation(string strContent, CtripRegexExpression ctripRegex)
        {
            if (string.IsNullOrEmpty(strContent))
            {
                return(null);
            }

            string strTbodyData = RegexOperation.GetValueByRegex(ctripRegex.GetTbodyDataRegex(), strContent);

            if (string.IsNullOrEmpty(strTbodyData))
            {
                return(null);
            }

            RouteInformation routeInformation = new RouteInformation();
            IList <string>   valueList;

            valueList = RegexOperation.GetValuesByRegex(ctripRegex.GetCityRegex(), strContent);
            if (valueList != null && valueList.Count == 2)
            {
                routeInformation.OriginalAirport    = valueList[0];
                routeInformation.DestinationAirport = valueList[1];
            }

            valueList = RegexOperation.GetValuesByRegex(ctripRegex.GetDateRegex(), strContent);
            if (valueList != null && valueList.Count == 2)
            {
                if (!string.IsNullOrEmpty(valueList[0]))
                {
                    routeInformation.DepartureTime = DateTime.Parse(valueList[0]);
                }

                if (!string.IsNullOrEmpty(valueList[1]))
                {
                    routeInformation.ArriveTime = DateTime.Parse(valueList[1]);
                }
            }

            routeInformation.AirDate = routeInformation.DepartureTime;

            string strDiscount = RegexOperation.GetValueByRegex(ctripRegex.GetDiscountRegex(), strTbodyData);

            if (!string.IsNullOrEmpty(strDiscount))
            {
                routeInformation.Discount = double.Parse(strDiscount);
            }

            string strTicketPrice = RegexOperation.GetValueByRegex(ctripRegex.GetTicketPriceRegex(), strTbodyData);

            if (!string.IsNullOrEmpty(strTicketPrice))
            {
                routeInformation.TicketPrice = double.Parse(strTicketPrice);
            }

            routeInformation.Meal    = RegexOperation.GetValueByRegex(ctripRegex.GetMealRegex(), strTbodyData);
            routeInformation.AirLine = RegexOperation.GetValueByRegex(ctripRegex.GetAirLineRegex(), strTbodyData);

            routeInformation.ChangeRule     = RegexOperation.GetValueByRegex(ctripRegex.GetChangeRuleRegex(), strContent);
            routeInformation.FlightInterval = RegexOperation.GetValueByRegex(ctripRegex.GetFlightIntervalRegex(), strContent);
            routeInformation.FlightNO       = RegexOperation.GetValueByRegex(ctripRegex.GetFlightNORegex(), strContent);
            routeInformation.FlightType     = RegexOperation.GetValueByRegex(ctripRegex.GetFlightTypeRegex(), strContent);
            routeInformation.ChangeRule     = RegexOperation.GetValueByRegex(ctripRegex.GetChangeRuleRegex(), strContent);
            routeInformation.Cabin          = RegexOperation.GetValueByRegex(ctripRegex.GetCabinRegex(), strContent);


            string strYprice = RegexOperation.GetValueByRegex(ctripRegex.GetYpriceRegex(), strContent);

            if (!string.IsNullOrEmpty(strYprice))
            {
                routeInformation.Yprice = double.Parse(strYprice);
            }

            string strAirportFuelTax = RegexOperation.GetValueByRegex(ctripRegex.GetAirportFuelRegex(), strContent);

            if (!string.IsNullOrEmpty(strAirportFuelTax))
            {
                string[] strDatas = strAirportFuelTax.Split('+');

                if (!string.IsNullOrEmpty(strDatas[0]))
                {
                    routeInformation.AirportTax = double.Parse(strDatas[0]);
                }

                if (!string.IsNullOrEmpty(strDatas[1]))
                {
                    routeInformation.FuelTax = double.Parse(strDatas[1]);
                }
            }

            return(routeInformation);
        }