Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        public void SetupCommonData(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.AnperoService sv = new WebService.AnperoService();

            if (HttpRuntime.Cache["saleProduct"] != null)
            {
                saleProduct = (WebService.ProductItem[])HttpRuntime.Cache["saleProduct"];
            }
            else
            {
                saleProduct = sv.GetSaleProduct(StoreID, TokenKey);
                if (saleProduct != null)
                {
                    HttpRuntime.Cache.Insert("saleProduct", saleProduct, null, DateTime.Now.AddMinutes(shortCacheTime), TimeSpan.Zero);
                }
            }
            filterContext.Controller.ViewData["saleProduct"] = saleProduct;
            if (HttpRuntime.Cache["BestsaleProduct"] != null)
            {
                BestsaleProduct = (WebService.SearchResult)HttpRuntime.Cache["BestsaleProduct"];
            }
            else
            {
                BestsaleProduct = sv.SearchProductFullData(StoreID, TokenKey, "0", "0", "0", 0, 99999999, 1, 7, "", SearchOrder.TimeDesc, 1, true);
                if (BestsaleProduct != null)
                {
                    HttpRuntime.Cache.Insert("BestsaleProduct", BestsaleProduct, null, DateTime.Now.AddMinutes(shortCacheTime), TimeSpan.Zero);
                }
            }
            filterContext.Controller.ViewData["BestsaleProduct"] = BestsaleProduct;

            GetTopArticle(filterContext, shortCacheTime);
            //slide of list product page
        }