コード例 #1
0
        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();
        }
コード例 #2
0
        public async Task <ActionResult> ListPost(ViewModels.ContentOptions options, IEnumerable <string> itemIds)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageSitemaps))
            {
                return(Forbid());
            }

            if (itemIds?.Count() > 0)
            {
                var sitemapsList = await _sitemapManager.LoadSitemapsAsync();

                var checkedContentItems = sitemapsList.Where(x => itemIds.Contains(x.SitemapId));
                switch (options.BulkAction)
                {
                case ContentsBulkAction.None:
                    break;

                case ContentsBulkAction.Remove:
                    foreach (var item in checkedContentItems)
                    {
                        await _sitemapManager.DeleteSitemapAsync(item.SitemapId);
                    }
                    await _notifier.SuccessAsync(H["Sitemaps successfully removed."]);

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            return(RedirectToAction(nameof(List)));
        }
コード例 #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();
        }
コード例 #4
0
        public async Task UpdateSitemapAsync(SitemapUpdateContext context)
        {
            var contentItem = context.UpdateObject as ContentItem;

            if (contentItem == null)
            {
                return;
            }

            var sitemaps = (await _sitemapManager.LoadSitemapsAsync())
                           .Where(s => s.GetType() == typeof(Sitemap));

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

            var contentTypeName = contentItem.ContentType;

            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 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();
        }