Example #1
0
 private void DownloadNodeCss_(CssTreeNode root, CssTreeNode targetCssTreeNode, string url, string[] testIds)
 {
     root.IncrementActiveDownloads();
     DownloadCssAsync_(url, root.logger_,
                       (object sender, DownloadStringCompletedEventArgs args) =>
     {
         try
         {
             WebClientUserData data = (WebClientUserData)args.UserState;
             if (args.Error == null)
             {
                 string css          = args.Result;
                 WebClient webClient = (WebClient)sender;
                 logger_.Verbose("download completed for {0}", data.href);
                 logger_.Verbose("download took {0} ms", data.stopwatch.Elapsed.TotalMilliseconds);
                 webClient.Dispose();
                 ParseCss_(targetCssTreeNode, css);
                 targetCssTreeNode.DownloadNodeCss_(root, testIds);
             }
             else
             {
                 logger_.Log(TraceLevel.Error, testIds, Stage.Check, StageType.DownloadResource,
                             new { args.Error, data.href });
                 if (retriesCount_ > 0)
                 {
                     retriesCount_--;
                     logger_.Log(TraceLevel.Info, testIds, Stage.Check, StageType.Retry);
                     Thread.Sleep(100);
                     DownloadNodeCss_(root, this, Href, testIds);
                 }
             }
             root.DecrementActiveDownloads();
         }
         catch (Exception e)
         {
             CommonUtils.LogExceptionStackTrace(logger_, Stage.Check, e, testIds);
         }
     });
 }
Example #2
0
 private void DownloadNodeCss_(CssTreeNode root, CssTreeNode targetCssTreeNode, string url)
 {
     root.IncrementActiveDownloads();
     DownloadCssAsync_(url, root.logger_,
                       (object sender, DownloadStringCompletedEventArgs args) =>
     {
         try
         {
             WebClientUserData data = (WebClientUserData)args.UserState;
             if (args.Error == null)
             {
                 string css          = args.Result;
                 WebClient webClient = (WebClient)sender;
                 logger_.Verbose("download completed for {0}", data.href);
                 logger_.Verbose("download took {0} ms", data.stopwatch.Elapsed.TotalMilliseconds);
                 webClient.Dispose();
                 ParseCss_(targetCssTreeNode, css);
                 targetCssTreeNode.DownloadNodeCss_(root);
             }
             else
             {
                 logger_.Log("error downloading css {1}: {0}", args.Error, data.href);
                 if (retriesCount_ > 0)
                 {
                     retriesCount_--;
                     logger_.Log("Retrying...");
                     Thread.Sleep(100);
                     DownloadNodeCss_(root, this, Href);
                 }
             }
             root.DecrementActiveDownloads();
         }
         catch (Exception e)
         {
             logger_.Log("Error: " + e);
         }
     });
 }