public IActionResult GetHouseInfo(string cityName, string source = "", int houseCount = 100, int withAnyDays = 3, bool showDoubanInvalidData = true, string keyword = "") { try { var lstHouseInfo = new DBHouseInfoDAL().SearchHouseInfo(cityName, source, houseCount, withAnyDays, showDoubanInvalidData, keyword); var lstRoomInfo = lstHouseInfo.Select(house => { var markBGType = string.Empty; int housePrice = (int)house.HousePrice; if (housePrice > 0) { markBGType = LocationMarkBGType.SelectColor(housePrice / 1000); } return(new HouseInfo { Money = house.DisPlayPrice, HouseURL = house.HouseOnlineURL, HouseLocation = house.HouseLocation, HouseTime = house.PubTime.ToString(), HousePrice = housePrice, LocationMarkBG = markBGType, DisplaySource = ConstConfigurationName.ConvertToDisPlayName(house.Source) }); }); return(Json(new { IsSuccess = true, HouseInfos = lstRoomInfo })); }catch (Exception ex) { return(Json(new { IsSuccess = false, error = ex.ToString() })); } }
public IActionResult GetHouseInfo(string cityName, string source = "", int houseCount = 400, int withAnyDays = 3, string keyword = "") { var houses = new DBHouseInfoDAL().SearchHouseInfo(cityName, source, houseCount, withAnyDays, keyword); var lstRoomInfo = houses.Select(house => { var markBGType = string.Empty; int housePrice = (int)house.HousePrice; if (housePrice > 0) { markBGType = LocationMarkBGType.SelectColor(housePrice / 1000); } return(new HouseInfo { Money = house.DisPlayPrice, HouseURL = house.HouseOnlineURL, HouseLocation = house.HouseLocation, HouseTime = house.PubTime.ToString(CultureInfo.CurrentCulture), HousePrice = housePrice, LocationMarkBG = markBGType, DisplaySource = ConstConfigurationName.ConvertToDisPlayName(house.Source) }); }); return(Json(new { IsSuccess = true, HouseInfos = lstRoomInfo })); }
public static void AnalyzeDoubanHouseContentAll(bool isSleep = false) { System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); LogHelper.Info("AnalyzeDoubanHouseContent Start..."); Console.WriteLine("AnalyzeDoubanHouseContent Start..."); int index = 0; try { var dal = new DBHouseInfoDAL(); var lstHouse = dal.LoadUnAnalyzeList(); foreach (var houseInfo in lstHouse) { var housePrice = JiebaTools.GetHousePrice(houseInfo.HouseText); string houseTextContent = string.Empty; if (housePrice == 0) { AnalyzeFromWebPage(houseInfo, ref housePrice, ref houseTextContent); } else { houseInfo.Status = 1; houseInfo.DisPlayPrice = housePrice.ToString(CultureInfo.InvariantCulture); houseInfo.HousePrice = housePrice; } houseInfo.IsAnalyzed = true; dal.UpdateHouseInfo(houseInfo); index++; if (index % 100 == 0 && isSleep) { System.Threading.Thread.Sleep(1000 * 120); } Console.WriteLine("HouseInfo:" + Newtonsoft.Json.JsonConvert.SerializeObject(houseInfo)); } } catch (Exception ex) { LogHelper.Error("AnalyzeDoubanHouseContent Exception", ex); } sw.Stop(); var copyTime = sw.Elapsed.TotalSeconds.ToString(CultureInfo.InvariantCulture); LogHelper.Info("AnalyzeDoubanHouseContent Finish,Update Count:" + index + ";花费时间:" + copyTime); Console.WriteLine("AnalyzeDoubanHouseContent Finish,Update Count:" + index + ";花费时间:" + copyTime); }