示例#1
0
        public HotelStaticInfo GetHotelInfo(string hotelId)
        {
            var hotelDesInfoResEntity = HotelApiAccess.QueryObj <HotelDesInfoReqEntity, HotelDesInfoResEntity>(new HotelDesInfoReqEntity
            {
                SearchCandidate = new SearchCandidate {
                    HotelID = hotelId
                },
                Settings = new Settings
                {
                    PrimaryLangID = "zh-cn",
                    ExtendedNodes = new string[] { "HotelStaticInfo.GeoInfo",
                                                   "HotelStaticInfo.NearbyPOIs",
                                                   "HotelStaticInfo.TransportationInfos",
                                                   "HotelStaticInfo.Brand",
                                                   "HotelStaticInfo.Group",
                                                   "HotelStaticInfo.Ratings",
                                                   "HotelStaticInfo.Policies",
                                                   "HotelStaticInfo.NormalizedPolicies.ChildAndExtraBedPolicy",
                                                   "HotelStaticInfo.AcceptedCreditCards",
                                                   "HotelStaticInfo.ImportantNotices",
                                                   "HotelStaticInfo.Facilities",
                                                   "HotelStaticInfo.Pictures",
                                                   "HotelStaticInfo.Descriptions",
                                                   "HotelStaticInfo.Themes",
                                                   "HotelStaticInfo.ContactInfo",
                                                   "HotelStaticInfo.ArrivalTimeLimitInfo",
                                                   "HotelStaticInfo.DepartureTimeLimitInfo",
                                                   "HotelStaticInfo.HotelTags.IsBookable" }
                }
            });

            return(hotelDesInfoResEntity.HotelStaticInfo);
        }
示例#2
0
        public string[] GetHotelIdList(int cityCode)
        {
            StringBuilder hotelIdList    = new StringBuilder();
            var           hotelIdlistRes = HotelApiAccess.QueryObj <HotelIdListReqEntity, HotelIdListResEntity>(new HotelIdListReqEntity
            {
                City      = cityCode,
                PageIndex = 1,
                PageSize  = 4000
            });

            if (hotelIdlistRes.Total != 0)
            {
                hotelIdList = hotelIdList.Append(hotelIdlistRes.HotelIDs);
                var temp = hotelIdlistRes.Total / 4000;
                for (int i = 1; i <= temp; i++)
                {
                    hotelIdList = hotelIdList.Append(HotelApiAccess.QueryObj <HotelIdListReqEntity, HotelIdListResEntity>(new HotelIdListReqEntity
                    {
                        City      = 2,
                        PageIndex = (i + 1),
                        PageSize  = 4000
                    }).HotelIDs);
                }
            }
            return(hotelIdList.ToString().Split(','));
        }
示例#3
0
        public void AddHotels(string hotelId)
        {
            var hotelDesReq = new HotelDesInfoReqEntity
            {
                SearchCandidate = new EntityModel.Proxy.CTripHotel.SearchCandidate {
                    HotelID = hotelId
                },
                Settings = new Settings
                {
                    PrimaryLangID = "zh-cn",
                    ExtendedNodes = new string[] { "HotelStaticInfo.GeoInfo",
                                                   "HotelStaticInfo.NearbyPOIs",
                                                   "HotelStaticInfo.TransportationInfos",
                                                   "HotelStaticInfo.Brand",
                                                   "HotelStaticInfo.Group",
                                                   "HotelStaticInfo.Ratings",
                                                   "HotelStaticInfo.Policies",
                                                   "HotelStaticInfo.NormalizedPolicies.ChildAndExtraBedPolicy",
                                                   "HotelStaticInfo.AcceptedCreditCards",
                                                   "HotelStaticInfo.ImportantNotices",
                                                   "HotelStaticInfo.Facilities",
                                                   "HotelStaticInfo.Pictures",
                                                   "HotelStaticInfo.Descriptions",
                                                   "HotelStaticInfo.Themes",
                                                   "HotelStaticInfo.ContactInfo",
                                                   "HotelStaticInfo.ArrivalTimeLimitInfo",
                                                   "HotelStaticInfo.DepartureTimeLimitInfo",
                                                   "HotelStaticInfo.HotelTags.IsBookable" }
                }
            };

            var resultObj = HotelApiAccess.QueryObj <HotelDesInfoReqEntity, HotelDesInfoResEntity>(hotelDesReq);
            //_cTripHotelDesDal.AddHotelDesToSolr();
        }
示例#4
0
        public void UpLoadHotelListToSolr(int cityCode)
        {
            StringBuilder hotelIdList    = new StringBuilder();
            var           hotelIdlistRes = HotelApiAccess.QueryObj <HotelIdListReqEntity, HotelIdListResEntity>(new HotelIdListReqEntity
            {
                City      = cityCode,
                PageIndex = 1,
                PageSize  = 4000
            });

            if (hotelIdlistRes.Total != 0)
            {
                hotelIdList = hotelIdList.Append(hotelIdlistRes.HotelIDs);
                var temp = hotelIdlistRes.Total / 4000;
                for (int i = 1; i <= temp; i++)
                {
                    hotelIdList = hotelIdList.Append(HotelApiAccess.QueryObj <HotelIdListReqEntity, HotelIdListResEntity>(new HotelIdListReqEntity
                    {
                        City      = 2,
                        PageIndex = (i + 1),
                        PageSize  = 4000
                    }).HotelIDs);
                }
            }
            var    hotelIdArr = hotelIdList.ToString().Split(',');
            var    hotels     = new List <HotelSimpleInfoSolrModel>();
            Random rd         = new Random();

            for (int i = 0; i < hotelIdArr.Length; i++)
            {
                var hotelDesInfoResEntity = HotelApiAccess.QueryObj <HotelDesInfoReqEntity, HotelDesInfoResEntity>(new HotelDesInfoReqEntity
                {
                    SearchCandidate = new SearchCandidate {
                        HotelID = hotelIdArr[i]
                    },
                    Settings = new Settings
                    {
                        PrimaryLangID = "zh-cn",
                        ExtendedNodes = new string[] { "HotelStaticInfo.GeoInfo",
                                                       "HotelStaticInfo.NearbyPOIs",
                                                       "HotelStaticInfo.TransportationInfos",
                                                       "HotelStaticInfo.Brand",
                                                       "HotelStaticInfo.Group",
                                                       "HotelStaticInfo.Ratings",
                                                       "HotelStaticInfo.Policies",
                                                       "HotelStaticInfo.NormalizedPolicies.ChildAndExtraBedPolicy",
                                                       "HotelStaticInfo.AcceptedCreditCards",
                                                       "HotelStaticInfo.ImportantNotices",
                                                       "HotelStaticInfo.Facilities",
                                                       "HotelStaticInfo.Pictures",
                                                       "HotelStaticInfo.Descriptions",
                                                       "HotelStaticInfo.Themes",
                                                       "HotelStaticInfo.ContactInfo",
                                                       "HotelStaticInfo.ArrivalTimeLimitInfo",
                                                       "HotelStaticInfo.DepartureTimeLimitInfo",
                                                       "HotelStaticInfo.HotelTags.IsBookable" }
                    }
                });
                var hotelStaticInfo = hotelDesInfoResEntity.HotelStaticInfo;
                if (hotelStaticInfo != null)
                {
                    hotels.Add(new HotelSimpleInfoSolrModel
                    {
                        HotelId              = hotelStaticInfo.HotelId,
                        HotelName            = hotelStaticInfo.HotelName,
                        HotelNameEN          = hotelStaticInfo.HotelNameEN,
                        StarRating           = hotelStaticInfo.StarRating,
                        Price                = rd.Next(100, 1000),
                        CityCode             = hotelStaticInfo.GeoInfo.City?.Code,
                        CityName             = hotelStaticInfo.GeoInfo.City?.Name,
                        AreaCode             = hotelStaticInfo.GeoInfo.Area?.Code,
                        AreaName             = hotelStaticInfo.GeoInfo.Area?.Name,
                        PostalCode           = string.IsNullOrWhiteSpace(hotelStaticInfo.GeoInfo.PostalCode) ? null : hotelStaticInfo.GeoInfo.PostalCode,
                        Address              = hotelStaticInfo.GeoInfo?.Address,
                        AdjacentIntersection = hotelStaticInfo.GeoInfo?.AdjacentIntersection,
                        GetInfo              = JsonHelper.SerializeObject(hotelStaticInfo.GeoInfo),
                        Ratings              = JsonHelper.SerializeObject(hotelStaticInfo.Ratings),
                        Pictures             = JsonHelper.SerializeObject(hotelStaticInfo.Pictures),
                        ImportantNotices     = JsonHelper.SerializeObject(hotelStaticInfo.ImportantNotices),
                        TransportationInfos  = JsonHelper.SerializeObject(hotelStaticInfo.TransportationInfos)
                    });
                }
            }
            SolrApi.Adds <HotelSimpleInfoSolrModel>(hotels, "simplehotel");
        }
示例#5
0
        public void GetHotelsByCityCode(int cityCode)
        {
            StringBuilder hotelIdList    = new StringBuilder();
            var           hotelIdlistRes = HotelApiAccess.QueryObj <HotelIdListReqEntity, HotelIdListResEntity>(new HotelIdListReqEntity
            {
                City      = cityCode,
                PageIndex = 1,
                PageSize  = 4000
            });

            if (hotelIdlistRes.Total != 0)
            {
                hotelIdList = hotelIdList.Append(hotelIdlistRes.HotelIDs);
                var temp = hotelIdlistRes.Total / 4000;
                for (int i = 1; i <= temp; i++)
                {
                    hotelIdList = hotelIdList.Append(HotelApiAccess.QueryObj <HotelIdListReqEntity, HotelIdListResEntity>(new HotelIdListReqEntity
                    {
                        City      = 2,
                        PageIndex = (i + 1),
                        PageSize  = 4000
                    }).HotelIDs);
                }
            }
            var hotelIdArr = hotelIdList.ToString().Split(',');
            var hotels     = new List <KeyWordHotel>();

            for (int i = 0; i < 1000; i++)
            {
                var hotelDesInfoResEntity = HotelApiAccess.QueryObj <HotelDesInfoReqEntity, HotelDesInfoResEntity>(new HotelDesInfoReqEntity
                {
                    SearchCandidate = new SearchCandidate {
                        HotelID = hotelIdArr[i]
                    },
                    Settings = new Settings
                    {
                        PrimaryLangID = "zh-cn",
                        ExtendedNodes = new string[] { "HotelStaticInfo.GeoInfo",
                                                       "HotelStaticInfo.NearbyPOIs",
                                                       "HotelStaticInfo.TransportationInfos",
                                                       "HotelStaticInfo.Brand",
                                                       "HotelStaticInfo.Group",
                                                       "HotelStaticInfo.Ratings",
                                                       "HotelStaticInfo.Policies",
                                                       "HotelStaticInfo.NormalizedPolicies.ChildAndExtraBedPolicy",
                                                       "HotelStaticInfo.AcceptedCreditCards",
                                                       "HotelStaticInfo.ImportantNotices",
                                                       "HotelStaticInfo.Facilities",
                                                       "HotelStaticInfo.Pictures",
                                                       "HotelStaticInfo.Descriptions",
                                                       "HotelStaticInfo.Themes",
                                                       "HotelStaticInfo.ContactInfo",
                                                       "HotelStaticInfo.ArrivalTimeLimitInfo",
                                                       "HotelStaticInfo.DepartureTimeLimitInfo",
                                                       "HotelStaticInfo.HotelTags.IsBookable" }
                    }
                });
                var hotelStaticInfo = hotelDesInfoResEntity.HotelStaticInfo;
                if (hotelStaticInfo != null)
                {
                    hotels.Add(new KeyWordHotel
                    {
                        HotelId          = hotelStaticInfo.HotelId,
                        HotelName        = hotelStaticInfo.HotelName,
                        CityName         = hotelStaticInfo.GeoInfo.City?.Name,
                        CityCode         = hotelStaticInfo.GeoInfo.City?.Code,
                        AreaName         = hotelStaticInfo.GeoInfo.Area?.Name,
                        AreaCode         = hotelStaticInfo.GeoInfo.Area?.Code,
                        BusinessDistrict = string.Join(";", hotelStaticInfo.GeoInfo.BusinessDistrict.Select(a => a.Code + "," + a.Name).ToArray()),//!string.IsNullOrEmpty(businessDistrictNames) ? businessDistrictNames : null,
                        HotelBrandName   = hotelStaticInfo.Brand?.Name,
                        HotelBrandCode   = hotelStaticInfo.Brand?.Code
                    });
                }
            }
            SolrApi.Adds <KeyWordHotel>(hotels, "testsolr2");
        }
示例#6
0
 public LowPriceResEntity QueryObj(LowPriceReqEntity req)
 {
     return(HotelApiAccess.QueryObj <LowPriceReqEntity, LowPriceResEntity>(req));
 }