Beispiel #1
0
        private async Task Build1(IBlogProcess process, IProgress <DownloadStringTaskAsyncExProgress> progress)
        {
            var cnt = articlesList.Count;

            for (var i = cnt - 1; i >= 0; i--)
            {
                var entity = articlesList[i];

                if (progress != null)
                {
                    progress.Report(new DownloadStringTaskAsyncExProgress
                    {
                        Text = "获取文章 " + (cnt - i) + "/" + cnt + " " + entity.Title
                    });
                }

                var fileName = "article_" + (cnt - i) + ".html";

                if (await process.ExtractArticleContent(entity, progress))
                {
                    var content = strItem.Replace("{0}", entity.Title).Replace("\n{1}", entity.Content);
                    CreateFile(baseDir + fileName, content);
                }
            }
        }
 public async Task Export(string fileName, List<Article> articles, IBlogProcess processer
     , IProgress<DownloadStringTaskAsyncExProgress> progress = null)
 {
     Init(fileName);
     StringBuilder sb = new StringBuilder();
     sb.Append("<ol>");
     foreach (var article in articles)
     {
         if (await processer.ExtractArticleContent(article, progress).ConfigureAwait(false))
         {
             await Task.Yield();
             await SaveArticleToFile(article, article.Content, progress).ConfigureAwait(false);
         }
         var articleFileName = article.Title.ToValidFileName() + ".htm";
         sb.AppendFormat("<li><a href='{0}'>{1}</a></li>"
           , articleFileName, article.Title);
     }
     sb.Append("</ol>");
     string content2 = htmlString.Replace("{0}", fileName).Replace("\n{1}", sb.ToString());
     await SaveToFileAsync(content2, Path.Combine(BaseFolder, "_index.htm"));
 }
Beispiel #3
0
        public async Task Export(string fileName, List <Article> articles, IBlogProcess processer
                                 , IProgress <DownloadStringTaskAsyncExProgress> progress = null)
        {
            Init(fileName);
            StringBuilder sb = new StringBuilder();

            sb.Append("<ol>");
            foreach (var article in articles)
            {
                if (await processer.ExtractArticleContent(article, progress).ConfigureAwait(false))
                {
                    await Task.Yield();
                    await SaveArticleToFile(article, article.Content, progress).ConfigureAwait(false);
                }
                var articleFileName = article.Title.ToValidFileName() + ".htm";
                sb.AppendFormat("<li><a href='{0}'>{1}</a></li>"
                                , articleFileName, article.Title);
            }
            sb.Append("</ol>");
            string content2 = htmlString.Replace("{0}", fileName).Replace("\n{1}", sb.ToString());

            await SaveToFileAsync(content2, Path.Combine(BaseFolder, "_index.htm"));
        }
        private async Task Build1(IBlogProcess process, IProgress<DownloadStringTaskAsyncExProgress> progress)
        {
            var cnt = articlesList.Count;
            for (var i = cnt - 1; i >= 0; i--)
            {
                var entity = articlesList[i];

                if (progress != null)
                {
                    progress.Report(new DownloadStringTaskAsyncExProgress
                    {
                        Text = "获取文章 " + (cnt - i) + "/" + cnt + " " + entity.Title
                    });
                }

                var fileName = "article_" + (cnt - i) + ".html";

                if (await process.ExtractArticleContent(entity, progress))
                {
                    var content = strItem.Replace("{0}", entity.Title).Replace("\n{1}", entity.Content);
                    CreateFile(baseDir + fileName, content);
                }
            }
        }