public static async Task <string> GetEntryCanonicalNameAsync(int blogEntry)
        {
            BlogConfigData config = await BlogConfigDataProvider.GetConfigAsync();

            string canon = string.Format("{0}/?BlogEntry={1}", config.BlogEntryUrl, blogEntry);

            using (BlogEntryDataProvider entryDP = new BlogEntryDataProvider()) {
                BlogEntry data = await entryDP.GetItemAsync(blogEntry);

                if (data != null)
                {
                    canon = string.Format("{0}/Title/{1}/?BlogEntry={2}", config.BlogEntryUrl, Utility.UrlEncodeSegment(data.Title.ToString().Truncate(80)), blogEntry);
                }
                return(canon);
            }
        }
Пример #2
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();
                    }
                }
            }
        }
        private async Task <ImageSupport.GetImageInBytesInfo> RetrieveImageAsync(string name, string location)
        {
            ImageSupport.GetImageInBytesInfo fail = new ImageSupport.GetImageInBytesInfo();
            if (!string.IsNullOrWhiteSpace(location))
            {
                return(fail);
            }
            if (string.IsNullOrWhiteSpace(name))
            {
                return(fail);
            }
            BlogConfigData config = await BlogConfigDataProvider.GetConfigAsync();

            if (config.FeedImage_Data == null || config.FeedImage_Data.Length == 0)
            {
                return(fail);
            }
            return(new ImageSupport.GetImageInBytesInfo {
                Content = config.FeedImage_Data,
                Success = true,
            });
        }
        internal static async Task <string> GetCategoryCanonicalNameAsync(int blogCategory = 0)
        {
            using (BlogCategoryDataProvider categoryDP = new BlogCategoryDataProvider()) {
                BlogConfigData config = await BlogConfigDataProvider.GetConfigAsync();

                string canon = config.BlogUrl;
                if (blogCategory != 0)
                {
                    BlogCategory cat = await categoryDP.GetItemAsync(blogCategory);

                    if (cat != null)
                    {
                        canon = string.Format("{0}/Title/{1}/?BlogCategory={2}", config.BlogUrl, Utility.UrlEncodeSegment(cat.Category.ToString().Truncate(80)), blogCategory);
                    }
                }
                else
                {
                    canon = config.BlogUrl;
                }
                return(canon);
            }
        }
        // API
        // API
        // API

        public static async Task <BlogConfigData> GetConfigAsync()
        {
            using (BlogConfigDataProvider configDP = new BlogConfigDataProvider()) {
                return(await configDP.GetItemAsync());
            }
        }