private bool GetSitemapData(SitemapData sitemapData) { int entryCount; string userAgent = Request.ServerVariables["USER_AGENT"]; var isGoogleBot = userAgent != null && userAgent.IndexOf("Googlebot", StringComparison.InvariantCultureIgnoreCase) > -1; string googleBotCacheKey = isGoogleBot ? "Google-" : string.Empty; if (SitemapSettings.Instance.EnableRealtimeSitemap) { string cacheKey = googleBotCacheKey + _sitemapRepository.GetSitemapUrl(sitemapData); var sitemapDataData = CacheManager.Get(cacheKey) as byte[]; if (sitemapDataData != null) { sitemapData.Data = sitemapDataData; return(true); } if (_sitemapXmlGeneratorFactory.GetSitemapXmlGenerator(sitemapData).Generate(sitemapData, false, out entryCount)) { if (SitemapSettings.Instance.EnableRealtimeCaching) { CacheEvictionPolicy cachePolicy; if (isGoogleBot) { cachePolicy = new CacheEvictionPolicy(null, new[] { DataFactoryCache.VersionKey }, null, Cache.NoSlidingExpiration, CacheTimeoutType.Sliding); } else { cachePolicy = null; } CacheManager.Insert(cacheKey, sitemapData.Data, cachePolicy); } return(true); } return(false); } return(_sitemapXmlGeneratorFactory.GetSitemapXmlGenerator(sitemapData).Generate(sitemapData, !SitemapSettings.Instance.EnableRealtimeSitemap, out entryCount)); }
private void GenerateSitemaps(SitemapData sitemapConfig, StringBuilder message) { int entryCount; bool success = _sitemapXmlGeneratorFactory.GetSitemapXmlGenerator(sitemapConfig).Generate(sitemapConfig, out entryCount); if (success) { message.Append(string.Format("<br/>\"{0}{1}\": {2} entries", sitemapConfig.SiteUrl, sitemapConfig.Host, entryCount)); } else { message.Append("<br/>Error creating sitemap for \"" + sitemapConfig.Host + "\""); } }
private void GenerateSitemaps(SitemapData sitemapConfig, StringBuilder message) { int entryCount; _currentGenerator = _sitemapXmlGeneratorFactory.GetSitemapXmlGenerator(sitemapConfig); bool success = _currentGenerator.Generate(sitemapConfig, true, out entryCount); if (success) { message.Append(string.Format("<br/>\"{0}{1}\": {2} entries", sitemapConfig.SiteUrl, _sitemapRepository.GetHostWithLanguage(sitemapConfig), entryCount)); } else { message.Append("<br/>Error creating sitemap for \"" + _sitemapRepository.GetHostWithLanguage(sitemapConfig) + "\""); } }