public void Run() { LogHelper.Info("开始RefreshHouseSourceJob..."); var sw = new System.Diagnostics.Stopwatch(); sw.Start(); var cityDashboards = _configService.LoadCitySources(); foreach (var item in cityDashboards) { LogHelper.RunActionNotThrowEx(() => { //聚合房源的缓存,前600条数据 var search = new HouseCondition() { CityName = item.Key, HouseCount = 600, IntervalDay = 14, Refresh = true }; _houseService.Search(search); foreach (var dashboard in item.Value) { //每类房源的默认缓存,前600条数据 search.HouseCount = 600; search.Source = dashboard.Source; _houseService.Search(search); } }, "RefreshHouse"); } sw.Stop(); string copyTime = sw.Elapsed.TotalSeconds.ToString(CultureInfo.InvariantCulture); LogHelper.Info("RefreshHouseSourceJob结束,花费时间:" + copyTime); }
public IEnumerable <HouseInfo> Search(HouseCondition condition) { if (condition == null || condition.CityName == null) { throw new Exception("查询条件不能为null"); } return(houseDapper.SearchHouses(condition)); }
public void Run() { LogHelper.Info("开始RefreshHouseCacheJob..."); var sw = new System.Diagnostics.Stopwatch(); sw.Start(); var cityDashboards = _configService.LoadCitySources(); foreach (var item in cityDashboards) { //聚合房源的缓存,前600条数据 var search = new HouseCondition() { CityName = item.Key, HouseCount = 600, IntervalDay = 14, Refresh = true }; _houseService.Search(search); foreach (var dashboard in item.Value) { //每类房源的默认缓存,前600条数据 search.HouseCount = 600; search.Source = dashboard.Source; _houseService.Search(search); // 为小程序做的缓存,每次拉10条,一共20页 for (var page = 0; page <= 30; page++) { search.HouseCount = 20; search.Source = dashboard.Source; search.Page = page; _houseService.Search(search); } } //为移动端做的缓存,每次拉180条,一共10页 for (var page = 0; page <= 10; page++) { search.Source = ""; search.HouseCount = 180; search.Page = page; _houseService.Search(search); } //为小程序做的缓存,每次拉20条,一共30页 for (var page = 0; page <= 30; page++) { search.Source = ""; search.HouseCount = 20; search.Page = page; _houseService.Search(search); } } sw.Stop(); string copyTime = sw.Elapsed.TotalSeconds.ToString(CultureInfo.InvariantCulture); LogHelper.Info("RefreshHouseCacheJob结束,花费时间:" + copyTime); }
public IActionResult GetHouse() { var condition = new HouseCondition(); condition.City = !string.IsNullOrEmpty(HttpContext.Request.Query["city"]) ? HttpContext.Request.Query["city"].ToString() : "上海"; condition.Source = HttpContext.Request.Query["source"]; condition.Keyword = HttpContext.Request.Query["keyword"]; condition.Page = !string.IsNullOrEmpty(HttpContext.Request.Query["page"]) ? int.Parse(HttpContext.Request.Query["page"]) : 0; condition.Size = !string.IsNullOrEmpty(HttpContext.Request.Query["size"]) ? int.Parse(HttpContext.Request.Query["size"]) : 0; condition.RentType = !string.IsNullOrEmpty(HttpContext.Request.Query["rentType"]) ? int.Parse(HttpContext.Request.Query["rentType"]) : 0; condition.FromPrice = !string.IsNullOrEmpty(HttpContext.Request.Query["fromPrice"]) ? int.Parse(HttpContext.Request.Query["fromPrice"]) : 0; condition.ToPrice = !string.IsNullOrEmpty(HttpContext.Request.Query["toPrice"]) ? int.Parse(HttpContext.Request.Query["toPrice"]) : 0; condition.Refresh = !string.IsNullOrEmpty(HttpContext.Request.Query["refresh"]) ? bool.Parse(HttpContext.Request.Query["refresh"]) : false; return(Ok(new { success = true, data = _houseService.Search(condition) })); }
public IActionResult Search([FromBody] HouseCondition search) { return(Ok(new { success = true, data = _houseService.Search(search) })); }
public IActionResult RefreshSearch([FromBody] HouseCondition search) { _houseService.RefreshSearch(search); return(Ok(new { success = true })); }