//设置国外往返机票搜索信息 public IntlFlightResponseList SearchIntlRoundTripFlight(String _departCity, String _arriveCity, DateTime _departDate, DateTime _backDate) { //搜索出发机票 FlightRoute goRoute = new FlightRoute(); CityCodeTranslator cct = new CityCodeTranslator(); goRoute.DepartCity = cct.TranslateToCode(_departCity); goRoute.ArriveCity = cct.TranslateToCode(_arriveCity); goRoute.DepartDate = _departDate;//出发日期 IntlRoundFlightSearch irfs = new IntlRoundFlightSearch(); irfs.AddRoutes(goRoute, _departDate, _backDate);//返程日期 irfs.SetReturnEntity(apiCallProxy); IntlFlightResponse ifr = this.GenerateResultsFromIntl(irfs.returnEntity); //搜索返程机票 irfs.AddRouting(ifr.GetFlightReponseData()[0].Routings); irfs.SetShoppingInfoID(ifr.GetFlightReponseData()[0].ShoppingInfoID); irfs.SetReturnEntity(apiCallProxy); IntlFlightResponse ifr2 = this.GenerateResultsFromIntl(irfs.returnEntity); IntlFlightResponseList ifrl = new IntlFlightResponseList(); ifrl.SetFlightResponse(ifr); ifrl.SetFlightResponse(ifr2); this.GenerateXmlFileFromIntl(ifrl); /* IntlFlightResponseList result = new IntlFlightResponseList(); IntlFlightResponse response = new IntlFlightResponse(); IntlFlightResponse response2 = new IntlFlightResponse(); response.SetFlightResponseData(ifr.GetFlightReponseData()[0]); response.SetFlightResponseData(ifr2.GetFlightReponseData()[0]); result.SetFlightResponse(response); result.SetFlightResponse(response2); */ return ifrl; }
//生成国外航班汇总数据文件 private void GenerateXmlFileFromIntl(IntlFlightResponseList _ifrl) { XmlDocument xmldoc = new XmlDocument(); XmlDeclaration xmldec = xmldoc.CreateXmlDeclaration("1.0", "utf-8", null); XmlElement root = xmldoc.CreateElement("FlightResponses"); foreach (IntlFlightResponse _ifr in _ifrl.GetFlightReponse()) { XmlNode routeNode = xmldoc.CreateElement("FlightRoute"); foreach (IntlFlightResponseData _ifrd in _ifr.GetFlightReponseData()) { XmlNode mainNode = xmldoc.CreateElement("FlightResponse"); XmlElement ele1 = xmldoc.CreateElement("Flight"); XmlNode node_ele2 = xmldoc.CreateElement("FlightInfo"); foreach (string s in this.IntlFlightInfoNameList()) { XmlElement ele2_elei = xmldoc.CreateElement(s); node_ele2.AppendChild(ele2_elei); }; XmlElement ele3 = xmldoc.CreateElement("StandardPrice"); XmlElement ele4 = xmldoc.CreateElement("Stops"); XmlElement ele5 = xmldoc.CreateElement("Provider"); ele1.InnerText = _ifrd.flight; node_ele2.ChildNodes.Item(0).InnerText = _ifrd.fuelCharge.ToString(); node_ele2.ChildNodes.Item(1).InnerText = _ifrd.tax.ToString(); node_ele2.ChildNodes.Item(2).InnerText = _ifrd.airline.ToString(); node_ele2.ChildNodes.Item(3).InnerText = _ifrd.craftType.ToString(); node_ele2.ChildNodes.Item(4).InnerText = _ifrd.aPort.ToString(); node_ele2.ChildNodes.Item(5).InnerText = _ifrd.dPort.ToString(); node_ele2.ChildNodes.Item(6).InnerText = _ifrd.arriveCity.ToString(); node_ele2.ChildNodes.Item(7).InnerText = _ifrd.departCity.ToString(); node_ele2.ChildNodes.Item(8).InnerText = _ifrd.arriveTime.ToString(); node_ele2.ChildNodes.Item(9).InnerText = _ifrd.takeOffTime.ToString(); ele3.InnerText = _ifrd.standardPrice.ToString(); ele4.InnerText = _ifrd.TotalRoutings.ToString(); ele5.InnerText = _ifrd.provider; mainNode.AppendChild(ele1); mainNode.AppendChild(node_ele2); mainNode.AppendChild(ele3); mainNode.AppendChild(ele4); routeNode.AppendChild(mainNode); } root.AppendChild(routeNode); } xmldoc.AppendChild(xmldec); xmldoc.AppendChild(root); xmldoc.Save(AppDomain.CurrentDomain.BaseDirectory + "/CtripData/In_FlightData.xml"); }
//设置国外单程机票搜索信息 public IntlFlightResponseList SearchIntlOneWayFlight(String _departCity, String _arriveCity, DateTime _departDate) { FlightRoute route = new FlightRoute(); CityCodeTranslator cct = new CityCodeTranslator(); route.DepartCity = cct.TranslateToCode(_departCity); route.ArriveCity = cct.TranslateToCode(_arriveCity); route.DepartDate = _departDate;//出发日期 IntlSingleFlightSearch isfs = new IntlSingleFlightSearch(route); isfs.SetReturnEntity(apiCallProxy); IntlFlightResponse ifr = this.GenerateResultsFromIntl(isfs.returnEntity); IntlFlightResponseList ifrl = new IntlFlightResponseList(); ifrl.SetFlightResponse(ifr); this.GenerateXmlFileFromIntl(ifrl); /* IntlFlightResponseList result = new IntlFlightResponseList(); IntlFlightResponse response = new IntlFlightResponse(); response.SetFlightResponseData(ifr.GetFlightReponseData()[0]); result.SetFlightResponse(response); */ return ifrl; }