public IReadOnlyCollection <SitemapNode> GetSitemapNodes(string baseUrl) { List <SitemapNode> nodes = new List <SitemapNode>(); if (HttpRuntime.Cache["commonInfo"] != null) { AnperoFrontend.WebService.Webconfig commontData = (AnperoFrontend.WebService.Webconfig)HttpRuntime.Cache["commonInfo"]; } else { WebService.AnperoService service = new WebService.AnperoService(); var rs = service.GetCommonConfig(CommonConfig.StoreID, CommonConfig.TokenKey); if (rs != null) { HttpRuntime.Cache.Insert("commonInfo", rs, null, DateTime.Now.AddMinutes(shortCacheTime), TimeSpan.Zero); } } nodes.Add( new SitemapNode() { Url = baseUrl, Priority = 1 }); //nodes.Add( // new SitemapNode() // { // Url = urlHelper.AbsoluteRouteUrl("HomeGetAbout"), // Priority = 0.9 // }); return(nodes); }
public override void OnActionExecuted(ActionExecutedContext filterContext) { int shortCacheTime = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["shortCacheTime"]); WebService.AnperoService service = new WebService.AnperoService(); SetupCommonData(filterContext); if (HttpRuntime.Cache["commonInfo"] != null) { filterContext.Controller.ViewData["commonInfo"] = HttpRuntime.Cache["commonInfo"]; } else { var rs = service.GetCommonConfig(CommonConfig.StoreID, CommonConfig.TokenKey); filterContext.Controller.ViewData["commonInfo"] = rs; if (rs != null) { HttpRuntime.Cache.Insert("commonInfo", rs, null, DateTime.Now.AddMinutes(shortCacheTime), TimeSpan.Zero); } } WebService.Ads[] Ads5 = null; if (!cacheService.TryGet("Ads5", out Ads5)) { Ads5 = service.GetAdsSlide(CommonConfig.StoreID, CommonConfig.TokenKey, PageContent.Ads5); cacheService.AddOrUpdate("Ads5", Ads5, new TimeSpan(0, 0, 10, 0, 0)); } filterContext.Controller.ViewData["ads5"] = Ads5; }
public override void OnActionExecuted(ActionExecutedContext filterContext) { int shortCacheTime = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["shortCacheTime"]); WebService.AnperoService service = new WebService.AnperoService(); if (HttpRuntime.Cache["commonInfo"] != null) { Webconfig rs = (Webconfig)HttpRuntime.Cache["commonInfo"]; filterContext.Controller.ViewData["commonInfo"] = rs; } else { Webconfig rs = service.GetCommonConfig(CommonConfig.StoreID, CommonConfig.TokenKey); filterContext.Controller.ViewData["commonInfo"] = rs; if (rs != null) { HttpRuntime.Cache.Insert("commonInfo", rs, null, DateTime.Now.AddMinutes(shortCacheTime), TimeSpan.Zero); } } WebService.Ads[] AdsSlide3 = null; if (HttpRuntime.Cache["AdsSlide3"] != null) { filterContext.Controller.ViewData["AdsSlide3"] = (WebService.Ads[])HttpRuntime.Cache["AdsSlide3"]; } else { AdsSlide3 = service.GetAdsSlide(CommonConfig.StoreID, CommonConfig.TokenKey, PageContent.Ads3); filterContext.Controller.ViewData["AdsSlide3"] = AdsSlide3; if (AdsSlide3 != null) { HttpRuntime.Cache.Insert("AdsSlide3", AdsSlide3, null, DateTime.Now.AddMinutes(shortCacheTime + 1), TimeSpan.Zero); } } }
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 override void OnActionExecuted(ActionExecutedContext filterContext) { int shortCacheTime = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["shortCacheTime"]); if (HttpRuntime.Cache["commonInfo"] != null) { filterContext.Controller.ViewData["commonInfo"] = HttpRuntime.Cache["commonInfo"]; } else { WebService.AnperoService service = new WebService.AnperoService(); var rs = service.GetCommonConfig(CommonConfig.StoreID, CommonConfig.TokenKey); filterContext.Controller.ViewData["commonInfo"] = rs; if (rs != null) { HttpRuntime.Cache.Insert("commonInfo", rs, null, DateTime.Now.AddMinutes(shortCacheTime), TimeSpan.Zero); } } }
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; }
private void SetUpSeo(int type, int categoryId) { AnperoFrontend.WebService.Webconfig commonInfo = null; if (HttpRuntime.Cache["commonInfo"] != null) { ViewData["commonInfo"] = HttpRuntime.Cache["commonInfo"]; commonInfo = (AnperoFrontend.WebService.Webconfig)HttpRuntime.Cache["commonInfo"]; } else { WebService.AnperoService service = new WebService.AnperoService(); var rs = service.GetCommonConfig(CommonConfig.StoreID, CommonConfig.TokenKey); ViewData["commonInfo"] = rs; commonInfo = rs; if (rs != null) { HttpRuntime.Cache.Insert("commonInfo", rs, null, DateTime.Now.AddMinutes(shortCacheTime), TimeSpan.Zero); } } //Get Description and Keywords of Category production ViewBag.Description = string.Empty; ViewBag.Keywords = string.Empty; ViewBag.WebsiteUrl = string.Empty; ViewBag.ImageUrl = string.Empty; if (commonInfo != null) { switch (type) { case 1: foreach (var item in commonInfo.ProductCategoryList) { if (item.Id == categoryId) { ViewBag.Keywords = item.Keywords; ViewBag.Description = item.Description; ViewBag.WebsiteUrl = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host + Anpero.StringHelpper.GetParentCategoryLink(item.Name, item.Id); ViewBag.ImageUrl = item.Images; break; } } break; case 2: foreach (var item in commonInfo.ProductCategoryList) { foreach (var chidItem in item.ChildCategory) { if (chidItem.Id == categoryId) { ViewBag.Keywords = item.Keywords; ViewBag.Description = item.Description; ViewBag.WebsiteUrl = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host + Anpero.StringHelpper.GetCategoryLink(chidItem.Name, chidItem.Id); ViewBag.ImageUrl = item.Images; break; } } } break; default: ViewBag.Keywords = "Tìm kiếm " + commonInfo.Name + "| " + commonInfo.Desc; ViewBag.Description = "Tìm kiếm trên " + commonInfo.Name + "| " + commonInfo.Desc; ViewBag.WebsiteUrl = Request.Url.AbsoluteUri; ViewBag.ImageUrl = commonInfo.Logo; break; } } }
public IReadOnlyCollection <SitemapNode> GetSitemapNodes(string baseUrl) { AnperoFrontend.WebService.Webconfig commontData = new AnperoFrontend.WebService.Webconfig(); List <SitemapNode> nodes = new List <SitemapNode>(); if (HttpRuntime.Cache["commonInfo"] != null) { commontData = (AnperoFrontend.WebService.Webconfig)HttpRuntime.Cache["commonInfo"]; } else { WebService.AnperoService service = new WebService.AnperoService(); commontData = service.GetCommonConfig(CommonConfig.StoreID, CommonConfig.TokenKey); if (commontData != null) { HttpRuntime.Cache.Insert("commonInfo", commontData, null, DateTime.Now.AddMinutes(shortCacheTime), TimeSpan.Zero); } } nodes.Add(new SitemapNode() { Url = baseUrl, Priority = 1 }); if (commontData.ProductCategoryList != null && commontData.ProductCategoryList.Length > 0) { foreach (var item in commontData.ProductCategoryList) { nodes.Add(new SitemapNode() { Url = baseUrl + Anpero.StringHelpper.GetParentCategoryLink(item.Name, item.Id), Priority = 1 }); if (item.ChildCategory != null && item.ChildCategory.Length > 0) { foreach (var childItem in item.ChildCategory) { nodes.Add(new SitemapNode() { Url = baseUrl + Anpero.StringHelpper.GetCategoryLink(childItem.Name, childItem.Id), Priority = 1 }); } } } } if (commontData.ProductGroupList != null && commontData.ProductGroupList.Length > 0) { foreach (var item in commontData.ProductGroupList) { nodes.Add(new SitemapNode() { Url = baseUrl + Anpero.StringHelpper.GetProductGroupLink(item.Name, item.Id), Priority = 1 }); } } if (commontData.ProductProperties != null && commontData.ProductProperties.Length > 0) { foreach (var item in commontData.ProductProperties) { nodes.Add(new SitemapNode() { Url = baseUrl + "/search?property=" + item.Id, Priority = 0.9 }); } } nodes.Add(new SitemapNode() { Url = baseUrl + "/Blog", Priority = 1 }); nodes.Add(new SitemapNode() { Url = baseUrl + "/home/contact", Priority = 1 }); nodes.Add(new SitemapNode() { Url = baseUrl + "/about", Priority = 1 }); return(nodes); }
private void SetUpSeo(int type, int categoryId) { AnperoFrontend.WebService.Webconfig commonInfo; ICacheService cache = new CacheService(); if (!cache.TryGet(CommonInfoCache, out commonInfo)) { var service = new WebService.AnperoService(); commonInfo = service.GetCommonConfig(CommonConfig.StoreID, CommonConfig.TokenKey); cache.AddOrUpdate(CommonInfoCache, commonInfo, DateTime.Now.AddMinutes(shortCacheTime)); } ViewData["commonInfo"] = commonInfo; //Get Description and Keywords of Category production ViewBag.Description = string.Empty; ViewBag.Keywords = string.Empty; ViewBag.WebsiteUrl = string.Empty; ViewBag.ImageUrl = string.Empty; string title = ViewBag.Title; if (commonInfo != null) { if (string.IsNullOrEmpty(title)) { ViewBag.Title = "Tìm kiếm trên " + commonInfo.Name; } switch (type) { case 1: foreach (var item in commonInfo.ProductCategoryList) { if (item.Id == categoryId) { ViewBag.Keywords = item.Keywords; ViewBag.Description = item.Description; ViewBag.WebsiteUrl = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host + Anpero.StringHelpper.GetParentCategoryLink(item.Name, item.Id); ViewBag.ImageUrl = item.Images; break; } } break; case 2: foreach (var item in commonInfo.ProductCategoryList) { foreach (var chidItem in item.ChildCategory) { if (chidItem.Id == categoryId) { ViewBag.Keywords = item.Keywords; ViewBag.Description = item.Description; ViewBag.WebsiteUrl = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host + Anpero.StringHelpper.GetCategoryLink(chidItem.Name, chidItem.Id); ViewBag.ImageUrl = item.Images; break; } } } break; default: ViewBag.Keywords = "Tìm kiếm " + commonInfo.Name + "| " + commonInfo.Desc; ViewBag.Description = "Tìm kiếm trên " + commonInfo.Name + "| " + commonInfo.Desc; ViewBag.WebsiteUrl = Request.Url.AbsoluteUri; ViewBag.ImageUrl = commonInfo.Logo; break; } } }