Exemplo n.º 1
0
        private void RunDownloadSync()
        {
            List <string> webUrl = WebsiteList();

            foreach (var item in webUrl)
            {
                WebsiteDataModel wdm = DownloadSite(item);
                ReportWebsiteInfo(wdm);
            }
        }
Exemplo n.º 2
0
        private WebsiteDataModel DownloadSite(string webUrl)
        {
            WebsiteDataModel wdm  = new WebsiteDataModel();
            WebClient        clnt = new WebClient();

            wdm.WebsiteUrl  = webUrl;
            wdm.WebsiteData = clnt.DownloadData(webUrl);

            return(wdm);
        }
Exemplo n.º 3
0
        private void RunDownloadSync()
        {
            List <string> websites = PrepData();

            foreach (string site in websites)
            {
                WebsiteDataModel results = DownloadWebsite(site);
                ReportWebsiteInfo(results);
            }
        }
Exemplo n.º 4
0
        private async Task <WebsiteDataModel> DownloadSiteAsync(string webUrl)
        {
            WebsiteDataModel wdm  = new WebsiteDataModel();
            WebClient        clnt = new WebClient();

            wdm.WebsiteUrl  = webUrl;
            wdm.WebsiteData = await clnt.DownloadDataTaskAsync(webUrl);

            return(wdm);
        }
Exemplo n.º 5
0
        private async Task <WebsiteDataModel> DownloadWebsiteAsync(string websiteURL)
        {
            var output = new WebsiteDataModel();
            var client = new WebClient();

            output.WebsiteUrl  = websiteURL;
            output.WebsiteData = await client.DownloadStringTaskAsync(websiteURL);

            return(output);
        }
Exemplo n.º 6
0
        private WebsiteDataModel DownloadWebsite(string websiteURL)
        {
            var output = new WebsiteDataModel();
            var client = new WebClient();

            output.WebsiteUrl  = websiteURL;
            output.WebsiteData = client.DownloadString(websiteURL);

            return(output);
        }
Exemplo n.º 7
0
        private async Task RunDownloadAsync()
        {
            List <string> webUrl = WebsiteList();

            foreach (var item in webUrl)
            {
                WebsiteDataModel wdm = await Task.Run(() => DownloadSite(item));

                ReportWebsiteInfo(wdm);
            }
        }
Exemplo n.º 8
0
        private async Task RunDownloadAsync()
        {
            List <string> websites = PrepData();

            foreach (string site in websites)
            {
                WebsiteDataModel results = await Task.Run(() => DownloadWebsite(site));

                ReportWebsiteInfo(results);
            }
        }
Exemplo n.º 9
0
        private async Task RunDownloadAsync(IProgress <ProgressReportModel> progress, CancellationToken ct)
        {
            List <string>       webUrl = WebsiteList();
            ProgressReportModel prm    = new ProgressReportModel();
            int i = 0;

            foreach (var item in webUrl)
            {
                ct.ThrowIfCancellationRequested();
                WebsiteDataModel wdm = await Task.Run(() => DownloadSite(item));

                i += 1;
                //ReportWebsiteInfo(wdm);
                prm.sitesDownloaded = wdm;
                prm.Percentage      = (i * 100) / webUrl.Count;

                progress.Report(prm);
            }
        }
Exemplo n.º 10
0
 private void ReportWebsiteInfo(WebsiteDataModel wdm)
 {
     txtResults.Text += "\r\n Downloaded " + wdm.WebsiteUrl + " , Size is: " + wdm.WebsiteData.Length.ToString();
 }
Exemplo n.º 11
0
 private void ReportWebsiteInfo(WebsiteDataModel data)
 {
     resultsWindow.Text += $"{ data.WebsiteUrl } downloaded: { data.WebsiteData.Length } characters long. { Environment.NewLine }";
 }