Esempio n. 1
0
        public void SetupCommonProduct()
        {
            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);
                }
            }
            ViewData["saleProduct"] = saleProduct;


            if (HttpRuntime.Cache["BestsaleProduct"] != null)
            {
                BestsaleProduct = (WebService.SearchResult)HttpRuntime.Cache["BestsaleProduct"];
            }
            else
            {
                BestsaleProduct = sv.SearchProduct(StoreID, TokenKey, "", "", "", 0, 99999999, 1, 5, "", SearchOrder.TimeDesc, 1, string.Empty);
                if (BestsaleProduct != null)
                {
                    HttpRuntime.Cache.Insert("BestsaleProduct", BestsaleProduct, null, DateTime.Now.AddMinutes(shortCacheTime), TimeSpan.Zero);
                }
            }
            ViewData["BestsaleProduct"] = BestsaleProduct;
        }
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 (!cacheService.TryGet("BestsaleProduct", out BestsaleProduct))
            {
                //BestsaleProduct = sv.SearchProductFullData(StoreID, TokenKey, "0", "0", "0", 0, 99999999, 1, 7, "", SearchOrder.TimeDesc,2, true);
                BestsaleProduct = sv.SearchProduct(StoreID, TokenKey, "", "", "", 0, int.MaxValue, 1, 99, "", SearchOrder.TimeDesc, 2, "");
                if (BestsaleProduct != null)
                {
                    cacheService.AddOrUpdate("BestsaleProduct", BestsaleProduct, new TimeSpan(0, 10, 0));
                }
            }
            if (!cacheService.TryGet("SaleProduct", out saleProduct))
            {
                saleProduct = sv.GetSaleProduct(StoreID, TokenKey).Take(6).ToArray();

                if (saleProduct != null)
                {
                    cacheService.AddOrUpdate("SaleProduct", saleProduct, new TimeSpan(0, 99, 0));
                }
            }
            filterContext.Controller.ViewData["saleProduct"]     = saleProduct;
            filterContext.Controller.ViewData["BestsaleProduct"] = BestsaleProduct;
            GetTopArticle(filterContext, shortCacheTime);
            //slide of list product page
        }
Esempio n. 3
0
        public PartialViewResult GetByCategory(int id, string type = "feature")
        {
            AnperoService sv            = new WebService.AnperoService();
            SearchResult  relateProduct = new SearchResult();

            switch (type)
            {
            case "sale":
                var rs = sv.GetSaleProduct(StoreID, TokenKey);
                if (id > 0)
                {
                    rs = rs.Where(x => x.CatID == id || x.ParentId == id).ToArray();
                }
                relateProduct.Item = rs.Take(6).ToArray();
                break;

            default:
                relateProduct = sv.SearchProduct(StoreID, TokenKey, id.ToString(), "0", "0", 0, int.MaxValue, 1, 6, "", SearchOrder.TimeDesc, 2, "");

                relateProduct.Item = relateProduct.Item.Skip(1).ToArray();
                break;
            }

            if (type == "sale")
            {
                return(PartialView("GetByCategory2", relateProduct));
            }
            return(PartialView(relateProduct));
        }
Esempio n. 4
0
        public void SetupCommonProduct()
        {
            WebService.ProductItem[] saleProduct;
            WebService.SearchResult  BestsaleProduct;
            WebService.AnperoService sv    = new WebService.AnperoService();
            WebService.Ads[]         Slide = null;
            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);
                }
            }
            ViewData["saleProduct"] = saleProduct;


            if (HttpRuntime.Cache["BestsaleProduct"] != null)
            {
                BestsaleProduct = (WebService.SearchResult)HttpRuntime.Cache["BestsaleProduct"];
            }
            else
            {
                BestsaleProduct = sv.SearchProduct(StoreID, TokenKey, "", "", "", 0, 99999999, 1, 7, "", SearchOrder.TimeDesc, 1);
                if (BestsaleProduct != null)
                {
                    HttpRuntime.Cache.Insert("BestsaleProduct", BestsaleProduct, null, DateTime.Now.AddMinutes(shortCacheTime), TimeSpan.Zero);
                }
            }
            ViewData["BestsaleProduct"] = BestsaleProduct;
            //slide of list product page
            if (HttpRuntime.Cache["slide3"] != null)
            {
                ViewData["slide3"] = (WebService.Ads[])HttpRuntime.Cache["slide3"];
            }
            else
            {
                Slide = sv.GetAdsSlide(StoreID, TokenKey, PageContent.Ads3);
                ViewData["slide3"] = Slide;
                if (Slide != null)
                {
                    HttpRuntime.Cache.Insert("slide3", Slide, null, DateTime.Now.AddMinutes(shortCacheTime + 6), TimeSpan.Zero);
                }
            }
        }
Esempio n. 5
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. 6
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
        }