public IEnumerable <DBHouse> NewSearch(NewHouseCondition condition) { if (string.IsNullOrEmpty(condition.Source)) { var houseList = new List <DBHouse>(); // 获取当前城市的房源配置 var cityConfigs = _configService.LoadSources(condition.City); if (cityConfigs.Count == 0) { return(houseList); } var limitCount = condition.Size / cityConfigs.Count; foreach (var config in cityConfigs) { condition.Source = config.Source; condition.Size = limitCount; houseList.AddRange(NewDBSearch(condition)); } return(houseList.OrderByDescending(h => h.PubTime)); } else { return(NewDBSearch(condition)); } }
public void RefreshHouseV2() { LogHelper.Info("开始RefreshHouseV2..."); var sw = new System.Diagnostics.Stopwatch(); sw.Start(); var cityDashboards = _configService.LoadCitySources(); foreach (var item in cityDashboards) { //聚合房源的缓存,前600条数据 var search = new NewHouseCondition() { City = item.Key, Size = 600, IntervalDay = 14, Refresh = true }; NewSearch(search); foreach (var dashboard in item.Value) { //每类房源的默认缓存,前600条数据 search.Size = 600; search.Source = dashboard.Source; NewSearch(search); // 为小程序做的缓存,每次拉10条,一共20页 for (var page = 0; page <= 30; page++) { search.Size = 20; search.Source = dashboard.Source; search.Page = page; this.NewSearch(search); } } //为移动端做的缓存,每次拉180条,一共10页 for (var page = 0; page <= 10; page++) { search.Source = ""; search.Size = 180; search.Page = page; this.NewSearch(search); } //为小程序做的缓存,每次拉20条,一共30页 for (var page = 0; page <= 30; page++) { search.Source = ""; search.Size = 20; search.Page = page; this.NewSearch(search); } } sw.Stop(); string copyTime = sw.Elapsed.TotalSeconds.ToString(CultureInfo.InvariantCulture); LogHelper.Info("RefreshHouseV2结束,花费时间:" + copyTime); }
public List <DBHouse> SearchHouses(NewHouseCondition condition) { var houses = new List <DBHouse>(); using (IDbConnection dbConnection = GetConnection()) { dbConnection.Open(); houses = dbConnection.Query <DBHouse>(condition.QueryText, condition).ToList(); return(houses); } }
public void RefreshHouseV3() { LogHelper.Info("RefreshHouseV3..."); var sw = new System.Diagnostics.Stopwatch(); sw.Start(); var cityDashboards = _configService.LoadCitySources(); foreach (var item in cityDashboards) { //无指定来源,前600条数据 var search = new NewHouseCondition() { City = item.Key, Size = 600, IntervalDay = 14, Refresh = true }; for (var page = 0; page <= 5; page++) { search.Page = page; NewSearch(search); } //无指定来源,每次拉180条,一共10页,一般用于移动端地图 for (var page = 0; page <= 10; page++) { search.Source = ""; search.Size = 180; search.Page = page; this.NewSearch(search); } //无指定来源,每次拉20条,一共30页,一般用于小程序或者移动端列表 for (var page = 0; page <= 30; page++) { search.Source = ""; search.Size = 20; search.Page = page; this.NewSearch(search); } } sw.Stop(); string copyTime = sw.Elapsed.TotalSeconds.ToString(CultureInfo.InvariantCulture); LogHelper.Info("RefreshHouseV2结束,花费时间:" + copyTime); }
private List <DBHouse> NewDBSearch(NewHouseCondition condition) { // LogHelper.Info($"Search start,key:{condition.RedisKey}"); if (condition == null || condition.City == null) { throw new Exception("查询条件不能为null"); } var houses = _redisTool.ReadCache <List <DBHouse> >(condition.RedisKey, RedisKey.NewHouses.DBName); if (houses == null || houses.Count == 0 || condition.Refresh) { houses = _newHouseDapper.SearchHouses(condition); if (houses != null && houses.Count > 0) { _redisTool.WriteObject(condition.RedisKey, houses, RedisKey.NewHouses.DBName); } } return(houses); }
public void RefreshHouseV2() { LogHelper.Info("开始RefreshHouseV2..."); var sw = new System.Diagnostics.Stopwatch(); sw.Start(); var cityDashboards = _configService.LoadCitySources(); foreach (var item in cityDashboards) { var search = new NewHouseCondition() { City = item.Key, Size = 600, IntervalDay = 14, Refresh = true }; foreach (var dashboard in item.Value) { //指定来源,每次拉600条,一般用于地图页 for (var page = 0; page <= 3; page++) { search.Size = 600; search.Page = page; search.Source = dashboard.Source; NewSearch(search); } // 指定来源,每次拉20条,前30页,一般用于小程序/移动端列表页 for (var page = 0; page <= 30; page++) { search.Size = 20; search.Source = dashboard.Source; search.Page = page; this.NewSearch(search); } } } sw.Stop(); string copyTime = sw.Elapsed.TotalSeconds.ToString(CultureInfo.InvariantCulture); LogHelper.Info("RefreshHouseV2结束,花费时间:" + copyTime); }