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); }
private void SetUpSeo(int type, int categoryId) { AnperoFrontend.WebService.Webconfig commonInfo = (AnperoFrontend.WebService.Webconfig)HttpRuntime.Cache["commonInfo"]; //Get Description and Keywords of Category production ViewBag.Description = string.Empty; ViewBag.Keywords = string.Empty; ViewBag.WebsiteUrl = string.Empty; ViewBag.ImageUrl = string.Empty; try { 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.GetProductLink(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.GetProductLink(item.Name, item.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; } } catch (Exception) { } }
private void SetUpSeo(int type, int categoryId) { AnperoFrontend.WebService.Webconfig commonInfo = (AnperoFrontend.WebService.Webconfig)HttpRuntime.Cache["commonInfo"]; if (commonInfo != null) { switch (type) { case 1: foreach (var item in commonInfo.ProductCategoryList) { if (item.Id == categoryId) { ViewBag.Keywords = item.Name; ViewBag.Title = item.Name; ViewBag.Description = item.Description; break; } } break; case 2: foreach (var item in commonInfo.ProductCategoryList) { foreach (var chidItem in item.ChildCategory) { if (chidItem.Id == categoryId) { ViewBag.isChildend = "1"; ViewBag.Keywords = chidItem.Name; ViewBag.ParentName = item.Name; ViewBag.ParentId = item.Id; ViewBag.Title = chidItem.Name; ViewBag.Description = chidItem.Description; 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.Title = "Tìm kiếm :" + commonInfo.Name; break; } } //Get Description and Keywords of Category production ViewBag.Description = string.Empty; ViewBag.Keywords = string.Empty; }
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); }