private readonly Encoding encode = Encoding.GetEncoding("UTF-8"); //gb18030 public async Task Export(string fileName, List<Article> urls, IBlogProcess process , IProgress<DownloadStringTaskAsyncExProgress> progress) { await Init(fileName,progress); articlesList.Clear(); articlesList.AddRange(urls); if (articlesList.Any()) { await Build1(process, progress); } if (progress != null) { progress.Report(new DownloadStringTaskAsyncExProgress { ProgressPercentage = 0.5f, Text = "正在编译。。。" }); } BuildTable(); Compile(); if (progress != null) { progress.Report(new DownloadStringTaskAsyncExProgress { ProgressPercentage = 1f, Text = "成功导出" }); } }
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); } } }
private readonly Encoding encode = Encoding.GetEncoding("UTF-8"); //gb18030 public async Task Export(string fileName, List <Article> urls, IBlogProcess process , IProgress <DownloadStringTaskAsyncExProgress> progress) { await Init(fileName, progress); articlesList.Clear(); articlesList.AddRange(urls); if (articlesList.Any()) { await Build1(process, progress); } if (progress != null) { progress.Report(new DownloadStringTaskAsyncExProgress { ProgressPercentage = 0.5f, Text = "正在编译。。。" }); } BuildTable(); Compile(); if (progress != null) { progress.Report(new DownloadStringTaskAsyncExProgress { ProgressPercentage = 1f, Text = "成功导出" }); } }
public HFMaracayController(IGaleriaProcess galeriaProcess, IBlogProcess blogProcess, IEventosProcess eventosProcess, IAreasProcess areasProcess, INivelProcess nivelProcess, IUsuariosProcess usuariosProcess, ITipoLocalidadesProcess tipoLocalidadesProcess, ILocalidadesProcess localidadesProcess) { _nivelProcess = nivelProcess; _areasProcess = areasProcess; _usuariosProcess = usuariosProcess; _tipoLocalidadesProcess = tipoLocalidadesProcess; _localidadesProcess = localidadesProcess; _eventosProcess = eventosProcess; _blogProcess = blogProcess; _galeriaProcess = galeriaProcess; }
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")); }
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); } } }
//baseDir public Task Export(string fileName, List<Article> articles, IBlogProcess processer, IProgress<DownloadStringTaskAsyncExProgress> progress = null) { throw new NotImplementedException(); }
//baseDir public Task Export(string fileName, List <Article> articles, IBlogProcess processer, IProgress <DownloadStringTaskAsyncExProgress> progress = null) { throw new NotImplementedException(); }