public FlightResponse SearchDmstFlightInResults(string dFlight, string aFlight) { FlightResponseData data = new FlightResponseData(); XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(AppDomain.CurrentDomain.BaseDirectory + "/CtripData/D_FlightData.xml"); XmlNodeList routes = xmldoc.SelectNodes("/FlightResponses/FlightRoute"); FlightResponse response = new FlightResponse(); bool flag = true; foreach(XmlNode route in routes) { XmlNodeList li = route.SelectNodes("FlightResponse"); foreach (XmlNode xn in li) { if (xn.InnerText == dFlight && flag) { XmlNode parent = xn.ParentNode; data.adultOilFee = System.Convert.ToDecimal(parent.SelectSingleNode("AdultOilFee").InnerText); data.adultTax = System.Convert.ToDecimal(parent.SelectSingleNode("AdultTax").InnerText); data.standardPrice = System.Convert.ToDecimal(parent.SelectSingleNode("StandardPrice").InnerText); response.SetFlightResponseData(data); } else if (xn.InnerText == aFlight && !flag) { XmlNode parent = xn.ParentNode; data.adultOilFee = System.Convert.ToDecimal(parent.SelectSingleNode("AdultOilFee").InnerText); data.adultTax = System.Convert.ToDecimal(parent.SelectSingleNode("AdultTax").InnerText); data.standardPrice = System.Convert.ToDecimal(parent.SelectSingleNode("StandardPrice").InnerText); response.SetFlightResponseData(data); } } } return response; }
public void SetFlightResponse(FlightResponse fr) { li.Add(fr); }
//生成国内航班的FlightResponse返回值 private FlightResponseList GenerateResultsFromDmst(OTA_FlightSearchCallReturnEntity _returnEntity) { FlightResponseList frl = new FlightResponseList(); List<DomesticFlightRoute> routes = _returnEntity.FlightRoutes; CityCodeTranslator cct = new CityCodeTranslator(); AirlineCodeTranslator act = new AirlineCodeTranslator(); AirportCodeTranslator apct = new AirportCodeTranslator(); foreach (DomesticFlightRoute r in routes) { List<DomesticFlightData> flightList = r.FlightsList; FlightResponse fr = new FlightResponse(); foreach (DomesticFlightData d in flightList) { FlightResponseData frd = new FlightResponseData(); frd.adultOilFee = d.AdultOilFee; frd.adultTax = d.AdultTax; frd.airline = act.TranslateToName(d.AirlineCode); frd.craftType = d.CraftType; frd.aPort = apct.TranslateToName(d.APortCode); frd.arriveCity = cct.TranslateToName(d.ArriveCityCode); frd.departCity = cct.TranslateToName(d.DepartCityCode); frd.arriveTime = d.ArriveTime; frd.dPort = apct.TranslateToName(d.DPortCode); frd.flight = d.Flight; frd.priceType = d.PriceType; frd.standardPrice = d.Price; frd.subClass = d.SubClass; frd.takeOffTime = d.TakeOffTime; frd.provider = "携程旅行网"; fr.SetFlightResponseData(frd); } fr.GetFlightReponseData().Sort(); frl.SetFlightResponse(fr); } this.GenerateXmlFileFromDmst(frl); return frl; }