示例#1
0
        public JsResultObject LocalHotelImage(string basePath, HotelImageModel image,bool isTop)
        {
            JsResultObject re = new JsResultObject();
            WebClient client = new WebClient();
            string folder = string.Format("{0}/{1}", basePath.TrimEnd('/'), image.hotelFk);
            FileUtil.CreateFolder(folder);
            string filePattern = "";
            string filePath="";
            if (isTop)
            {
                if (image.isThum())
                {
                    filePattern = "{0}/top.thum{1}";
                }
                else if (image.isNormal())
                {
                    filePattern = "{0}/top.normal{1}";
                }
                filePath = string.Format(filePattern, folder, FileUtil.GetPostfixStr(image.imgUrl));
            }
            else
            {
                if (image.isThum())
                {
                    filePattern = "{0}/{1}.thum{2}";
                }
                else if (image.isNormal())
                {
                    filePattern = "{0}/{1}.normal{2}";
                }
                else if (image.isAround())
                {
                    filePattern = "{0}/{1}.around{2}";
                }
                else
                {
                    re.code = JsResultObject.CODE_ERROR;
                    return re;
                }
                filePath = string.Format(filePattern, folder, image.title, FileUtil.GetPostfixStr(image.imgUrl));
            }
            try
            {
                client.DownloadFile(image.imgUrl, filePath);
                re.rowNum = 1;
                re.msg = "保存图片:" + filePath;

            }
            catch (Exception ex)
            {
                re.rowNum = 0;
                re.msg = ex.Message;

            }
            return re;
        }
示例#2
0
        public JsResultObject ImportHotelDetail(string hotelId,bool hasSubInfo)
        {
            JsResultObject re = new JsResultObject();

            ELongHotelDetailAdapter adapter = ELongStaticClient.GetHotelDetail(hotelId);
            HotelDetailModel hotel = new HotelDetailModel();
            hotel.from(adapter);
            System.Console.WriteLine(string.Format("{0}:{1}:{2}", hotel.country, hotel.city, hotel.name));
            re= BaseZdBiz.SaveOrUpdate(hotel,"");

            if (!hasSubInfo) {  return re; }

                IList<ELongHotelImageAdapter> images = ELongStaticClient.GetHotelImageList(hotelId);
                foreach (ELongHotelImageAdapter image in images)
                {
                    HotelImageModel temp = new HotelImageModel();
                    temp.setPk(temp.createPk());
                    temp.from(image);
                    //System.Console.WriteLine(string.Format("{0}:{1}:{2}", temp.hotelFk, temp.title, temp.imgUrl));
                   re.rowNum+= BaseZdBiz.SaveOrUpdate(temp,"").rowNum;

                }

                IList<ELongHotelRoomAdapter> rooms = ELongStaticClient.GetHotelRoomList(hotelId);

                foreach (ELongHotelRoomAdapter room in rooms)
                {
                    HotelRoomModel temp = new HotelRoomModel();
                    temp.setPk(temp.createPk());
                    temp.from(room);
                    //System.Console.WriteLine(string.Format("{0}:{1}:{2}", temp.hotelFk, temp.roomName, temp.area));
                    re.rowNum += BaseZdBiz.SaveOrUpdate(temp,"").rowNum;

                }

                ELongHotelFeatureInfoAdapter featureInfo = ELongStaticClient.GetHotelFeatureInfo(hotelId);
                HotelFeatrueInfoModel hotelFeatrueInfoModel = new HotelFeatrueInfoModel();
                hotelFeatrueInfoModel.from(featureInfo);
                re.rowNum += BaseZdBiz.SaveOrUpdate(hotelFeatrueInfoModel,"").rowNum;

                IList<ELongHotelLandMarkAdapter> landmarks = ELongStaticClient.GetHotelLandMarkList(hotelId);

                foreach (ELongHotelLandMarkAdapter landmark in landmarks)
                {
                    HotelLandMarkModel temp = new HotelLandMarkModel();
                    temp.setPk(temp.createPk());
                    temp.from(landmark);
                    temp.id = temp.createPk().ToString();
                    //System.Console.WriteLine(string.Format("{0}:{1}:{2}", temp.hotelFk, temp.roomName, temp.area));
                    re.rowNum += BaseZdBiz.SaveOrUpdate(temp, "").rowNum;

                }

                IList<ElongHotelSurroundingAttractionAdapter> attractions = ELongStaticClient.GetHotelSurroundingAttractionList(hotelId);

                foreach (ElongHotelSurroundingAttractionAdapter attraction in attractions)
                {
                    HotelSurroundingAttractionModel temp = new HotelSurroundingAttractionModel();
                    temp.setPk(temp.createPk());
                    temp.from(attraction);
                    //System.Console.WriteLine(string.Format("{0}:{1}:{2}", temp.hotelFk, temp.roomName, temp.area));
                    re.rowNum += BaseZdBiz.SaveOrUpdate(temp, "").rowNum;

                }

                IList<ELongHotelSurroundingCommerceAdapter> commerces = ELongStaticClient.GetHotelSurroundingCommerceList(hotelId);

                foreach (ELongHotelSurroundingCommerceAdapter commerce in commerces)
                {
                    HotelSurroundingCommerceModel temp = new HotelSurroundingCommerceModel();
                    temp.setPk(temp.createPk());
                    temp.from(commerce);
                    //System.Console.WriteLine(string.Format("{0}:{1}:{2}", temp.hotelFk, temp.roomName, temp.area));
                    re.rowNum+= BaseZdBiz.SaveOrUpdate(temp,"").rowNum;

                }

                IList<ElongHotelSurroundingRestaurantAdapter> restaurants = ELongStaticClient.GetHotelSurroundingRestaurantList(hotelId);

                foreach (ElongHotelSurroundingRestaurantAdapter restaurant in restaurants)
                {
                    HotelSurroundingRestaurantModel temp = new HotelSurroundingRestaurantModel();
                    temp.setPk(temp.createPk());
                    temp.from(restaurant);
                    //System.Console.WriteLine(string.Format("{0}:{1}:{2}", temp.hotelFk, temp.roomName, temp.area));
                    re.rowNum+= BaseZdBiz.SaveOrUpdate(temp,"").rowNum;

                }

                IList<ElongHotelSurroundingShopAdapter> shops = ELongStaticClient.GetHotelSurroundingShopList(hotelId);

                foreach (ElongHotelSurroundingShopAdapter shop in shops)
                {
                    HotelSurroundingShopModel temp = new HotelSurroundingShopModel();
                    temp.setPk(temp.createPk());
                    temp.from(shop);
                    //System.Console.WriteLine(string.Format("{0}:{1}:{2}", temp.hotelFk, temp.roomName, temp.area));
                    re.rowNum += BaseZdBiz.SaveOrUpdate(temp, "").rowNum;

                }

                IList<ElongHotelTrafficInfoAdapter> traffics = ELongStaticClient.GetHotelTrafficInfoList(hotelId);

                foreach (ElongHotelTrafficInfoAdapter traffic in traffics)
                {
                    HotelTrafficInfoModel temp = new HotelTrafficInfoModel();

                    temp.from(traffic);
                    temp.id = temp.createPk().ToString();
                    //System.Console.WriteLine(string.Format("{0}:{1}:{2}", temp.hotelFk, temp.roomName, temp.area));
                    re.rowNum+= BaseZdBiz.SaveOrUpdate(temp,"").rowNum;

                }

            return re;
        }