Пример #1
0
        // ISEARCHDYNAMICURLS
        // ISEARCHDYNAMICURLS
        // ISEARCHDYNAMICURLS

        public async Task KeywordsForDynamicUrlsAsync(ISearchWords searchWords)
        {
            using (this) {
                BlogConfigData config = await BlogConfigDataProvider.GetConfigAsync();

                List <DataProviderFilterInfo> filters = DataProviderFilterInfo.Join(null, new DataProviderFilterInfo {
                    Field = nameof(BlogEntry.Published), Operator = "==", Value = true
                });
                DataProviderGetRecords <BlogEntry> entries = await GetItemsAsync(0, 0, null, filters);

                foreach (BlogEntry entry in entries.Data)
                {
                    string url = await BlogConfigData.GetEntryCanonicalNameAsync(entry.Identity);

                    PageDefinition page = await PageDefinition.LoadFromUrlAsync(url);

                    if (page == null)
                    {
                        return;               // there is no such root page
                    }
                    if (!searchWords.WantPage(page))
                    {
                        return;
                    }

                    if (await searchWords.SetUrlAsync(url, page.PageSecurity, entry.Title, entry.DisplayableSummaryText, entry.DateCreated, entry.DateUpdated, page.IsAuthorized_View_Anonymous(), page.IsAuthorized_View_AnyUser()))
                    {
                        searchWords.AddObjectContents(entry);
                        using (BlogCommentDataProvider commentDP = new BlogCommentDataProvider(entry.Identity)) {
                            DataProviderGetRecords <BlogComment> comments = await commentDP.GetItemsAsync(0, 0, null, null);

                            foreach (BlogComment comment in comments.Data)
                            {
                                searchWords.AddObjectContents(comment);
                            }
                        }
                        await searchWords.SaveAsync();
                    }
                }
            }
        }
Пример #2
0
        // ISITEMAPDYNAMICURLS
        // ISITEMAPDYNAMICURLS
        // ISITEMAPDYNAMICURLS

        public async Task FindDynamicUrlsAsync(AddDynamicUrlAsync addDynamicUrlAsync, Func <PageDefinition, bool> validForSiteMap)
        {
            using (this) {
                List <DataProviderFilterInfo> filters = DataProviderFilterInfo.Join(null, new DataProviderFilterInfo {
                    Field = nameof(BlogEntry.Published), Operator = "==", Value = true
                });
                DataProviderGetRecords <BlogEntry> entries = await GetItemsAsync(0, 0, null, filters);

                foreach (BlogEntry entry in entries.Data)
                {
                    string url = await BlogConfigData.GetEntryCanonicalNameAsync(entry.Identity);

                    PageDefinition page = await PageDefinition.LoadFromUrlAsync(url);

                    if (page == null)
                    {
                        return;               // there is no such root page
                    }
                    await addDynamicUrlAsync(page, url, entry.DateUpdated, page.SiteMapPriority, page.ChangeFrequency, entry);
                }
            }
        }