private void    SeasonYearCMB_SelectedIndexChanged(object sender, EventArgs e)
 {
     CurrentActiveYear = SeasonYearCMB.SelectedIndex + 1993;
     foreach (var club in SelectedClubs)
     {
         var clubInfo = ClubShortInfo.First(a => a.ClubName == club.Value.ClubName);
         var season   = club.Value.Seasons.SingleOrDefault(s => s.FinishYear == CurrentActiveYear);
         if (season != null && (season.Games == null || season.Games.Count == 0))
         {
             season.Games = PagesParser.GetSeasonGamesForTeam(season, clubInfo.ClubName, clubInfo.Url);
         }
     }
     Refresh();
 }
        private void    TeamComboBox_SelectedIndexChanged(object sender, EventArgs args)
        {
            if (IsComboboxChangesIgnored)
            {
                return;
            }

            var comboBox = (ComboBox)sender;
            var index    = (int)comboBox.Tag;
            var text     = comboBox.SelectedItem.ToString();

            if (string.IsNullOrEmpty(text))
            {
                SelectedClubs.Remove(index);
                Refresh();
                return;
            }

            var clubName = text.Substring(6);
            var clubInfo = ClubShortInfo.First(a => a.ClubName == clubName);

            var fetchedHistory = FetchedClubs.FirstOrDefault(a => a.ClubName == clubName);

            if (fetchedHistory == null)
            {
                var clubHistory = PagesParser.GetAllSeasonsForTeam(ActiveCountryName, clubInfo.ClubName, clubInfo.Url);
                FetchedClubs.Add(clubHistory);
                SelectedClubs[index] = clubHistory;
            }
            else
            {
                SelectedClubs[index] = fetchedHistory;
            }

            if (IsSingleSeasonView)
            {
                var season = SelectedClubs[index].Seasons.SingleOrDefault(s => s.FinishYear == CurrentActiveYear);
                if (season != null && (season.Games == null || season.Games.Count == 0))
                {
                    season.Games = PagesParser.GetSeasonGamesForTeam(season, clubInfo.ClubName, clubInfo.Url);
                }
            }

            Refresh();
        }
        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);
            }
        }