Example #1
0
 public async Task UpdateSitemapAsync(SitemapUpdateContext context)
 {
     foreach (var sitemapSourceUpdateHandler in _sitemapSourceUpdateHandlers)
     {
         await sitemapSourceUpdateHandler.UpdateSitemapAsync(context);
     }
 }
        public async Task UpdateSitemapAsync(SitemapUpdateContext context)
        {
            var sitemaps = (await _sitemapManager.LoadSitemapsAsync()).Where(s => s.GetType() == typeof(Sitemap));

            if (!sitemaps.Any())
            {
                return;
            }

            foreach (var sitemap in sitemaps)
            {
                // Do not break out of this loop, as it must check each sitemap.
                foreach (var source in sitemap.SitemapSources
                         .Select(s => s as CustomPathSitemapSource))
                {
                    if (source == null)
                    {
                        continue;
                    }

                    sitemap.Identifier = IdGenerator.GenerateId();
                }
            }

            await _sitemapManager.UpdateSitemapAsync();
        }
Example #3
0
        public async Task UpdateSitemapAsync(SitemapUpdateContext context)
        {
            var contentItem = context.UpdateObject as ContentItem;

            var allSitemaps = await _sitemapManager.LoadSitemapsAsync();

            var sitemapIndex = allSitemaps
                               .FirstOrDefault(s => s.GetType() == typeof(SitemapIndex));

            if (contentItem == null || sitemapIndex == null)
            {
                return;
            }

            var sitemaps = allSitemaps.OfType <Sitemap>();

            if (!sitemaps.Any())
            {
                return;
            }

            var contentTypeName = contentItem.ContentType;

            foreach (var sitemap in sitemaps)
            {
                foreach (var source in sitemap.SitemapSources.Select(x => x as ContentTypesSitemapSource))
                {
                    if (source == null)
                    {
                        continue;
                    }

                    if (source.IndexAll)
                    {
                        sitemap.Identifier = IdGenerator.GenerateId();
                        break;
                    }
                    else if (source.LimitItems && String.Equals(source.LimitedContentType.ContentTypeName, contentTypeName))
                    {
                        sitemap.Identifier = IdGenerator.GenerateId();
                        break;
                    }
                    else if (source.ContentTypes.Any(ct => String.Equals(ct.ContentTypeName, contentTypeName)))
                    {
                        sitemap.Identifier = IdGenerator.GenerateId();
                        break;
                    }
                }
            }

            await _sitemapManager.UpdateSitemapAsync();
        }