public static void RefreshDashboard() { var cityDashboards = CrawlerDataDapper.GetHouseDashboard(); if (cityDashboards == null || cityDashboards.Count() == 0) { return; } var config = DataContent.CrawlerConfigurations.FirstOrDefault(c => c.ConfigurationName == ConstConfigurationName.CityHouseInfo); if (config == null) { config = new BizCrawlerConfiguration { ConfigurationKey = 0, ConfigurationName = ConstConfigurationName.CityHouseInfo, ConfigurationValue = Newtonsoft.Json.JsonConvert.SerializeObject(cityDashboards), IsEnabled = true }; DataContent.Add(config); DataContent.SaveChanges(); } else { config.ConfigurationKey = 0; config.ConfigurationName = ConstConfigurationName.CityHouseInfo; config.ConfigurationValue = Newtonsoft.Json.JsonConvert.SerializeObject(cityDashboards); config.IsEnabled = true; DataContent.SaveChanges(); } }
public static List <HouseDashboard> LoadDashboard() { string houseDashboardJson = RedisService.ReadCache("HouseDashboard"); if (string.IsNullOrEmpty(houseDashboardJson)) { List <HouseDashboard> dashboards = CrawlerDataDapper.GetHouseDashboard(); RedisService.WriteCache("HouseDashboard", Newtonsoft.Json.JsonConvert.SerializeObject(dashboards)); return(dashboards); } else { return(Newtonsoft.Json.JsonConvert.DeserializeObject <List <HouseDashboard> >(houseDashboardJson)); } }