private void FetchAndWriteAllData() { foreach (var countryName in from object item in CountryCMB.Items select((string)item).Trim()) { var allClubs = PagesParser.GetAllTeams(countryName); if (allClubs == null) { return; } var clubHistories = DataReader.ReadFullData(countryName);; // var clubHistories = new List<ClubHistory>(); // foreach (var club in allClubs.Where(c => c.CurrentDivision < 5)) // { // clubHistories.Add(PagesParser.GetAllSeasonsForTeam(club.ClubName, club.Url)); // Thread.Sleep(5000); // } foreach (var club in clubHistories) { var fileName = Config.ClubsDataDirectory + @"\" + countryName + @"\" + club.ClubName + ".data"; if (File.Exists(fileName)) { continue; } foreach (var season in club.Seasons.Where(s => s.FinishYear > 1990)) { var clubUrl = allClubs.Single(c => c.ClubName == club.ClubName).Url; season.Games = PagesParser.GetSeasonGamesForTeam(season, club.ClubName, clubUrl); Thread.Sleep(10000); } DataWriter.WriteClubHistory(countryName, club); } // DataWriter.WriteFullData(countryName, clubHistories); } }
private void CountryCMB_SelectedIndexChanged(object sender, EventArgs e) { if (IS_LOCAL_DATA_USED) { FetchedClubs = DataReader.ReadFullData(ActiveCountryName); } ClubShortInfo = IS_LOCAL_DATA_USED ? FetchedClubs.Select(a => new ClubInfo { ClubName = a.ClubName }).ToList() : PagesParser.GetAllTeams(ActiveCountryName); if (ClubShortInfo == null) { MessageBox.Show("The site-source WWW.STATTO.COM is not available.", "Error"); Close(); return; } if (TeamSelectors == null) { return; } foreach (var teamSelector in TeamSelectors) { teamSelector.Items.Clear(); teamSelector.Items.AddRange(ClubShortInfo.Select(a => (object)(a.CurrentDivision + " - " + a.ClubName)).ToArray()); teamSelector.Items.Insert(0, ""); } Config.SeasonGamesCount = Config.GetGamesPerSeason(ActiveCountryName, CurrentActiveYear, 1); Config.PositionCount = Config.LeaguesInfo[ActiveCountryName].PositionsCount; IsSingleSeasonView = true; ChangeViewBtn_Click(null, null); }