public void RefreshSitemap(object sender, EventArgs args) { var sites = SitemapManagerConfiguration.GetSiteNames(); foreach (var site in sites) { var config = new SitemapManagerConfiguration(site); var sitemapManager = new SitemapManager(config); sitemapManager.SubmitSitemapToSearchenginesByHttp(); if (!config.GenerateRobotsFile) { continue; } sitemapManager.RegisterSitemapToRobotsFile(); } }
public void RefreshSitemap(object sender, EventArgs args) { try { var sites = SitemapManagerConfiguration.GetSiteNames(); foreach (var site in sites) { var config = new SitemapManagerConfiguration(site); var sitemapManager = new SitemapManager(config); sitemapManager.SubmitSitemapToSearchenginesByHttp(); //removed because now the robots is generated when it is invoked the url with robots.txt at the end //if (!config.GenerateRobotsFile) continue; //sitemapManager.RegisterSitemapToRobotsFile(); } } catch (Exception e) { Log.Error("Error Sitemap", e, this); } }
protected void RefreshButtonClick() { var sh = new SitemapHandler(); sh.RefreshSitemap(this, new EventArgs()); StringBuilder sb = new StringBuilder(); var siteNames = SitemapManagerConfiguration.GetSiteNames(); var message = string.Empty; if (siteNames == null || !siteNames.Any()) { Message.Text = "No sitemap configurations found under /sitecore/system/Modules/Sitemap XML. Please create one or more configuration nodes and try refreshing again."; RefreshPanel("MainPanel"); return; } foreach (var siteName in siteNames) { var config = new SitemapManagerConfiguration(siteName); if (string.IsNullOrWhiteSpace(config.FileName)) { continue; } if (sb.Length > 0) { sb.Append(", "); } sb.Append(config.FileName); } message = !string.IsNullOrWhiteSpace(sb.ToString()) ? string.Format(" - The sitemap file <b>\"{0}\"</b> has been refreshed<br /> - <b>\"{0}\"</b> has been registered to \"robots.txt\"", sb.ToString()) :"File name has not been specified for one or more sitemap configurations under /sitecore/system/Modules/Sitemap XML."; Message.Text = message; RefreshPanel("MainPanel"); }