Esempio n. 1
0
        /// <summary>
        /// Download website
        /// </summary>
        /// <param name="site"></param>
        /// <returns></returns>
        private WebsiteDataModel DownloadWebsite(string site)
        {
            WebsiteDataModel output = new WebsiteDataModel();
            WebClient        client = new WebClient();

            output.WebsiteUrl  = site;
            output.WebsiteData = client.DownloadString(site);
            return(output);
        }
Esempio n. 2
0
        /// <summary>
        /// Download website
        /// </summary>
        /// <param name="site"></param>
        /// <returns></returns>
        private async Task <WebsiteDataModel> DownloadWebsiteAsync(string site)
        {
            WebsiteDataModel output = new WebsiteDataModel();
            WebClient        client = new WebClient();

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

            return(output);
        }
Esempio n. 3
0
        /// <summary>
        /// Download websites synchronously
        /// </summary>
        private void RunDownloadSync()
        {
            List <string> websiteList = GetPrepDataList();

            foreach (var site in websiteList)
            {
                WebsiteDataModel results = DownloadWebsite(site);
                ReportWebsiteInfo(results);
            }
        }
Esempio n. 4
0
        private WebsiteDataModel DownloadWebsite(string websiteURL)
        {
            WebsiteDataModel output = new WebsiteDataModel();
            WebClient        client = new WebClient();

            output.WebsiteURL  = websiteURL;
            output.WebsiteData = client.DownloadString(websiteURL); //donwloading index page

            return(output);
        }
Esempio n. 5
0
        private void RunDownloadSync()
        {
            List <string> webistes = PrepData();

            foreach (string item in webistes)
            {
                WebsiteDataModel results = DownloadWebsite(item);
                ReportWebsiteInfo(results);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Download websites async but in sequence - not locking up UI but they run in order from first to last.
        /// </summary>
        /// <returns></returns>
        private async Task RunDownloadAsync()
        {
            List <string> websiteList = GetPrepDataList();

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

                ReportWebsiteInfo(results);
            }
        }
Esempio n. 7
0
        private async Task RunDownloadAsync()
        {
            List <string> webistes = PrepData();

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

                ReportWebsiteInfo(results);
            }
        }
Esempio n. 8
0
 /// <summary>
 /// Write our results to UI
 /// </summary>
 /// <param name="results"></param>
 private void ReportWebsiteInfo(WebsiteDataModel results)
 {
     resultsWindow.Text += $"{results.WebsiteUrl} downloaded {results.WebsiteData.Length} characters. \n";
 }
Esempio n. 9
0
 private void ReportWebsiteInfo(WebsiteDataModel data)
 {
     resultsWindow.Text += $"{data.WebsiteURL} downloaded: {data.WebsiteData.Length} characters long {Environment.NewLine}";
 }