Exemple #1
0
 /// <summary>
 /// 生成
 /// </summary>
 /// <param name="entries"></param>
 /// <param name="step"></param>
 void Generate(HtmlStaticizeContext[] entries, StaticizeStepStatus step)
 {
     System.Threading.Tasks.Parallel.ForEach(entries, (entry) =>
     {
         using (var wc = new WebClient())
         {
             try
             {
                 wc.DownloadFile(entry.uri, entry.fileName);
                 step.AddGeneratedPageCount();
             }
             catch (Exception ex)
             {
                 entry.generationError = ex;
                 entry.Errors.Add(ex);
                 //step.Errors.Add(ex);
             }
         }
     });
     //// batch download html file
     //using (var wc = new WebClient())
     //{
     //    for (int j = 0; j < entries.Length; j++)
     //    {
     //        var entry = entries[j];
     //        // may be some url down failure
     //        // should log error
     //        try
     //        {
     //            wc.DownloadFile(entry.uri, entry.fileName);
     //        }
     //        catch (Exception ex)
     //        {
     //            entry.generationError = ex;
     //            entry.Errors.Add(ex);
     //        }
     //    }
     //}
 }