Exemple #1
0
        //生成国内航班汇总数据文件
        private void GenerateXmlFileFromDmst(FlightResponseList _frl)
        {
            XmlDocument xmldoc = new XmlDocument();
            XmlDeclaration xmldec = xmldoc.CreateXmlDeclaration("1.0", "utf-8", null);
            XmlElement root = xmldoc.CreateElement("FlightResponses");
            foreach (FlightResponse _fr in _frl.GetFlightReponse())
            {
                XmlNode routeNode = xmldoc.CreateElement("FlightRoute");
                foreach (FlightResponseData _frd in _fr.GetFlightReponseData())
                {
                    XmlNode mainNode = xmldoc.CreateElement("FlightResponse");
                    XmlElement ele1 = xmldoc.CreateElement("Flight");
                    XmlNode node_ele2 = xmldoc.CreateElement("FlightInfo");
                    foreach (string s in this.dmstFlightInfoNameList())
                    {
                        XmlElement ele2_elei = xmldoc.CreateElement(s);
                        node_ele2.AppendChild(ele2_elei);
                    }
                    XmlElement ele3 = xmldoc.CreateElement("PriceType");
                    XmlElement ele4 = xmldoc.CreateElement("StandardPrice");
                    XmlElement ele5 = xmldoc.CreateElement("SubClass");
                    XmlElement ele6 = xmldoc.CreateElement("Provider");

                    ele1.InnerText = _frd.flight;
                    node_ele2.ChildNodes.Item(0).InnerText = _frd.adultOilFee.ToString();
                    node_ele2.ChildNodes.Item(1).InnerText = _frd.adultTax.ToString();
                    node_ele2.ChildNodes.Item(2).InnerText = _frd.airline.ToString();
                    node_ele2.ChildNodes.Item(3).InnerText = _frd.craftType.ToString();
                    node_ele2.ChildNodes.Item(4).InnerText = _frd.aPort.ToString();
                    node_ele2.ChildNodes.Item(5).InnerText = _frd.dPort.ToString();
                    node_ele2.ChildNodes.Item(6).InnerText = _frd.arriveCity.ToString();
                    node_ele2.ChildNodes.Item(7).InnerText = _frd.departCity.ToString();
                    node_ele2.ChildNodes.Item(8).InnerText = _frd.arriveTime.ToString();
                    node_ele2.ChildNodes.Item(9).InnerText = _frd.takeOffTime.ToString();

                    ele3.InnerText = _frd.priceType;
                    ele4.InnerText = _frd.standardPrice.ToString();
                    ele5.InnerText = _frd.subClass;
                    ele6.InnerText = _frd.provider;

                    mainNode.AppendChild(ele1);
                    mainNode.AppendChild(node_ele2);
                    mainNode.AppendChild(ele3);
                    mainNode.AppendChild(ele4);
                    mainNode.AppendChild(ele5);
                    mainNode.AppendChild(ele6);

                    routeNode.AppendChild(mainNode);
                }
                root.AppendChild(routeNode);
            }

            xmldoc.AppendChild(xmldec);
            xmldoc.AppendChild(root);
            xmldoc.Save(AppDomain.CurrentDomain.BaseDirectory + "/CtripData/D_FlightData.xml");
        }
Exemple #2
0
        //生成国内航班的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;
        }