public void GetTopArticle() { WebService.SearchArticleResults featureArticle = new WebService.SearchArticleResults(); WebService.SearchArticleResults topArticle = new WebService.SearchArticleResults(); WebService.AnperoService service = new WebService.AnperoService(); if (!cache.TryGet("FeatureArticle", out featureArticle)) { featureArticle = service.SearchArticle(StoreID, TokenKey, 0, 1, 4, 2); if (featureArticle != null) { cache.AddOrUpdate("FeatureArticle", featureArticle, new TimeSpan(0, 10, 0)); } } if (!cache.TryGet("topArticle", out topArticle)) { topArticle = service.SearchArticle(StoreID, TokenKey, 0, 1, 8, 3); if (topArticle != null) { cache.AddOrUpdate("topArticle", topArticle, new TimeSpan(0, 5, 0)); } } ViewData["FeatureArticle"] = featureArticle; ViewData["topArticle"] = topArticle; }
public void GetTopArticle() { WebService.SearchArticleResults rs = new WebService.SearchArticleResults(); WebService.SearchArticleResults TopNewArticle = new WebService.SearchArticleResults(); WebService.SearchArticleResults customArticle = new WebService.SearchArticleResults(); WebService.AnperoService service = new WebService.AnperoService(); if (HttpRuntime.Cache["TopArticle"] != null) { rs = (WebService.SearchArticleResults)HttpRuntime.Cache["TopArticle"]; } else { rs = service.SearchArticle(StoreID, TokenKey, 0, 1, 5, 2); if (rs != null) { HttpRuntime.Cache.Insert("TopArticle", rs, null, DateTime.Now.AddMinutes(shortCacheTime + 6), TimeSpan.Zero); } } if (HttpRuntime.Cache["TopNewArticle"] != null) { TopNewArticle = (WebService.SearchArticleResults)HttpRuntime.Cache["TopNewArticle"]; } else { TopNewArticle = service.SearchArticle(StoreID, TokenKey, 0, 0, 20, 0); if (TopNewArticle != null) { HttpRuntime.Cache.Insert("TopNewArticle", TopNewArticle, null, DateTime.Now.AddMinutes(shortCacheTime + 10), TimeSpan.Zero); } } if (HttpRuntime.Cache["customArticle"] != null) { customArticle = (WebService.SearchArticleResults)HttpRuntime.Cache["customArticle"]; } else { customArticle = service.SearchArticle(StoreID, TokenKey, Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["CustomArticleId"]), 0, 10, 0); if (customArticle != null) { HttpRuntime.Cache.Insert("customArticle", customArticle, null, DateTime.Now.AddMinutes(shortCacheTime + 10), TimeSpan.Zero); } } ViewData["FeatureArticle"] = rs; ViewData["TopNewArticle"] = TopNewArticle; ViewData["customArticle"] = customArticle; }
public override void OnActionExecuted(ActionExecutedContext filterContext) { int shortCacheTime = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["shortCacheTime"]); int StoreID = CommonConfig.StoreID; string TokenKey = CommonConfig.TokenKey; WebService.ProductItem[] saleProduct; WebService.SearchResult bestSaleProduct; WebService.SearchArticleResults topArticle; WebService.Webconfig webConfig; WebService.AnperoService sv = new WebService.AnperoService(); ICacheService cache = new CacheService(); if (!cache.TryGet(BaseController.SaleProductCache, out saleProduct)) { saleProduct = sv.GetSaleProduct(StoreID, TokenKey); cache.AddOrUpdate(BaseController.SaleProductCache, saleProduct, DateTime.Now.AddMinutes(shortCacheTime)); } if (!cache.TryGet(BaseController.BestSaleProductCache, out bestSaleProduct)) { bestSaleProduct = sv.SearchProductFullData(StoreID, TokenKey, "0", "0", "0", 0, 99999999, 1, 7, "", SearchOrder.TimeDesc, 1, true); cache.AddOrUpdate(BaseController.BestSaleProductCache, bestSaleProduct, DateTime.Now.AddMinutes(shortCacheTime)); } if (!cache.TryGet(BaseController.TopArticleCache, out topArticle)) { topArticle = sv.SearchArticle(StoreID, TokenKey, 0, 1, 4, 2); cache.AddOrUpdate(BaseController.TopArticleCache, topArticle, DateTime.Now.AddMinutes(shortCacheTime)); } if (!cache.TryGet(BaseController.CommonInfoCache, out webConfig)) { webConfig = sv.GetCommonConfig(CommonConfig.StoreID, CommonConfig.TokenKey); cache.AddOrUpdate(BaseController.CommonInfoCache, webConfig, DateTime.Now.AddMinutes(shortCacheTime)); } filterContext.Controller.ViewData["saleProduct"] = saleProduct; filterContext.Controller.ViewData["BestsaleProduct"] = bestSaleProduct; filterContext.Controller.ViewData["FeatureArticle"] = topArticle; filterContext.Controller.ViewData["commonInfo"] = webConfig; }
public void GetTopArticle() { WebService.SearchArticleResults rs = new WebService.SearchArticleResults(); WebService.AnperoService service = new WebService.AnperoService(); if (HttpRuntime.Cache["TopArticle"] != null) { rs = (WebService.SearchArticleResults)HttpRuntime.Cache["TopArticle"]; } else { rs = service.SearchArticle(StoreID, TokenKey, 0, 1, 4, 2); if (rs != null) { HttpRuntime.Cache.Insert("TopArticle", rs, null, DateTime.Now.AddMinutes(shortCacheTime), TimeSpan.Zero); } } ViewData["FeatureArticle"] = rs; }
public void GetTopArticle(ActionExecutedContext filterContext, int shortCacheTime) { int StoreID = CommonConfig.StoreID; string TokenKey = CommonConfig.TokenKey; WebService.SearchArticleResults rs = new WebService.SearchArticleResults(); WebService.AnperoService service = new WebService.AnperoService(); if (!cacheService.TryGet("TopArticle", out rs)) { rs = service.SearchArticle(StoreID, TokenKey, 0, 1, 4, 1); if (rs != null) { cacheService.AddOrUpdate("TopArticle", rs, new TimeSpan(0, 7, 0)); } } filterContext.Controller.ViewData["TopArticle"] = rs; }
public void GetTopArticle(ActionExecutedContext filterContext, int shortCacheTime) { int StoreID = CommonConfig.StoreID; string TokenKey = CommonConfig.TokenKey; WebService.SearchArticleResults rs = new WebService.SearchArticleResults(); WebService.AnperoService service = new WebService.AnperoService(); if (HttpRuntime.Cache["TopArticle"] != null) { rs = (WebService.SearchArticleResults)HttpRuntime.Cache["TopArticle"]; } else { rs = service.SearchArticle(StoreID, TokenKey, 0, 1, 4, 2); if (rs != null) { HttpRuntime.Cache.Insert("TopArticle", rs, null, DateTime.Now.AddMinutes(shortCacheTime), TimeSpan.Zero); } } filterContext.Controller.ViewData["FeatureArticle"] = rs; }
public override void OnActionExecuted(ActionExecutedContext filterContext) { WebService.AnperoService service = new WebService.AnperoService(); Anpero.ICacheService cacheService = new Anpero.CacheService(); Webconfig config = new Webconfig(); WebService.Ads[] Slide = null; WebService.Ads[] AdsSlide = null; WebService.SearchArticleResults FeatureArticle = new WebService.SearchArticleResults(); int shortCacheTime = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["shortCacheTime"]); if (!cacheService.TryGet("commonInfo", out config)) { config = service.GetCommonConfig(CommonConfig.StoreID, CommonConfig.TokenKey); cacheService.AddOrUpdate("commonInfo", config, new TimeSpan(0, 6, 0)); } if (!cacheService.TryGet("Slide", out Slide)) { Slide = service.GetRandomAdsSlide(CommonConfig.StoreID, CommonConfig.TokenKey, PageContent.Slide, 1); cacheService.AddOrUpdate("Slide", Slide, new TimeSpan(0, 6, 0)); } if (!cacheService.TryGet("AdsSlide", out AdsSlide)) { AdsSlide = service.GetAdsSlide(CommonConfig.StoreID, CommonConfig.TokenKey, PageContent.Ads1); cacheService.AddOrUpdate("AdsSlide", AdsSlide, new TimeSpan(0, 6, 0)); } if (!cacheService.TryGet("FeatureArticle", out FeatureArticle)) { FeatureArticle = service.SearchArticle(CommonConfig.StoreID, CommonConfig.TokenKey, 0, 1, 5, 1); cacheService.AddOrUpdate("FeatureArticle", FeatureArticle, new TimeSpan(0, 6, 0)); } filterContext.Controller.ViewData["slide"] = Slide; filterContext.Controller.ViewData["FeatureArticle"] = FeatureArticle; filterContext.Controller.ViewData["AdsSlide"] = AdsSlide; filterContext.Controller.ViewData["commonInfo"] = config; }