public MainWindow() { ServicePointManager.DefaultConnectionLimit = 100; InitializeComponent(); string retrievedHTML = RetrieveData(Url); IEnumerable<Categories> categorieses = FetchCategoryNames(retrievedHTML); foreach (var categoriesContent in categorieses) { var webSite = new WebSite(); webSite.AddCategories(categoriesContent.CategoryName, categoriesContent.CategoryURL); } cmbCategories.ItemsSource = categorieses; }
private void FetchSubCategories() { const int pagesToCheckForSubCategories = 200; var categoriesContents = new List<CategoriesContent>(); string urlToFetch = cmbCategories.SelectedValue.ToString(); prgCategory.Maximum = pagesToCheckForSubCategories; prgCategory.Value = 1; string retrievedHTML = RetrieveData(urlToFetch); categoriesContents.AddRange(FetchSelectedCategoryContent(retrievedHTML)); for (int i = 2; i < pagesToCheckForSubCategories; i++)//Checks the no of pages where from different individual star celebrity names can be found. { string url = urlToFetch + "?order=n&page=" + i; retrievedHTML = RetrieveData(url); prgCategory.Value = i; categoriesContents.AddRange(FetchSelectedCategoryContent(retrievedHTML)); } var categoriesContentsToBind = new List<CategoriesContent>(); foreach (var categoriesContent in categoriesContents) { var content = categoriesContent; if (categoriesContentsToBind.Where(i => i.Name == content.Name).ToList().Count == 0) { var webSite = new WebSite(); webSite.AddSubCategoriesCategories(categoriesContent.Name, categoriesContent.URL); categoriesContentsToBind.Add(categoriesContent); } } cmbSubCategories.ItemsSource = categoriesContentsToBind.OrderBy(val => val.Name).ToList(); }
private void DownloadImage(string downloadImageUrl) { string filePath = GetFilePath(downloadImageUrl); try { WebSite webSite = new WebSite(); if (filePath.Contains("jpg")) { FunctionCallStatus functionCallStatus = webSite.AddDownloadLinks(cmbSubCategories.Text, downloadImageUrl); if (functionCallStatus != FunctionCallStatus.DataAlreadyExists) { _wc = new WebClient(); _wc.DownloadFile(new Uri(downloadImageUrl), filePath); } } } catch (Exception) { } }