Beispiel #1
0
        //根据商区/酒店名搜索
        public HotelResponseList RestrictSearchHotel(string _hotelCity, string _rating, DateTime _start, DateTime _end, string _hotelName, int _zone)
        {
            HotelResponseList hotels = new HotelResponseList();
            HotelCityCodeTranslator hcct = new HotelCityCodeTranslator();
            int hotelCityCode = int.Parse(hcct.TranslateToCode(_hotelCity));
            HotelSearch hs = new HotelSearch(hotelCityCode, _rating, _start, _end);
            if (_hotelName == null || _hotelName == "") { }
            else
            {
                hs.SetHotelName(_hotelName);
            }
            if (_zone <= 0) { }
            else
            {
                hs.SetZone(_zone);
            }
            hs.SetReturnEntity(this.apiCallProxy);

            List<DomesticHotelDataForList> li = hs.returnEntity.HotelDataList;
            foreach (DomesticHotelDataForList dhdf in li)
            {
                HotelResponse hr = new HotelResponse();
                hr.address = dhdf.Address;
                hr.brief = dhdf.Brief;
                hr.graph = dhdf.HotelPic550URL;
                hr.hotelName = dhdf.HotelName;
                hr.price = dhdf.MinPrice.ToString();
                hr.zone = dhdf.Zone;
                hr.zoneName = dhdf.ZoneName;
                hr.provider = "携程旅行网";
                hotels.SetHotelResponse(hr);
            }
            this.GenerateXmlFileFromHotel(hotels);

            return hotels;
        }
Beispiel #2
0
        //生成酒店汇总数据文件
        private void GenerateXmlFileFromHotel(HotelResponseList hrl)
        {
            XmlDocument xmldoc = new XmlDocument();
            XmlDeclaration xmldec = xmldoc.CreateXmlDeclaration("1.0", "utf-8", null);
            XmlElement root = xmldoc.CreateElement("HotelResponses");
            foreach (HotelResponse hr in hrl.flightResponses)
            {
                XmlNode mainNode = xmldoc.CreateElement("HotelResponse");
                foreach (string s in this.HotelInfoNameList())
                {
                    XmlElement elei = xmldoc.CreateElement(s);
                    mainNode.AppendChild(elei);
                }

                mainNode.ChildNodes[0].InnerText = hr.hotelName;
                mainNode.ChildNodes[1].InnerText = hr.address;
                mainNode.ChildNodes[2].InnerText = hr.brief;
                mainNode.ChildNodes[3].InnerText = hr.graph;
                mainNode.ChildNodes[4].InnerText = hr.price;
                mainNode.ChildNodes[5].InnerText = hr.provider;
                mainNode.ChildNodes[6].InnerText = hr.zoneName;

                root.AppendChild(mainNode);
            }

            xmldoc.AppendChild(xmldec);
            xmldoc.AppendChild(root);
            xmldoc.Save(AppDomain.CurrentDomain.BaseDirectory + "/CtripData/HotelData.xml");
        }