Exemplo n.º 1
0
        private static List <SeasonData> GetOneShlSeason(int seasonNumber)
        {
            List <SeasonData> seasons       = new List <SeasonData>();
            string            leagueAcronym = "SHL";
            bool isPlayoffs = false;

            string seasonType = isPlayoffs ? "Playoffs" : "Regular Season";

            Console.WriteLine($"### {leagueAcronym} - {seasonType}");

            string seasonValue = seasonNumber.ToString();

            if (seasonNumber < 10)
            {
                seasonValue = " " + seasonValue;
            }
            Console.Write(" - Season " + seasonValue);

            var sourceSeason = SeasonStatsExtractor.ExtractSeason(seasonNumber, isPlayoffs, leagueAcronym);

            if (sourceSeason != null)
            {
                seasons.Add(new SeasonData(sourceSeason));
                Console.Write(" [DONE]");
            }
            else
            {
                Console.Write(" [Not Found]");
            }
            Console.WriteLine();

            return(seasons);
        }
Exemplo n.º 2
0
        public static void GetOneShlSeason(int seasonNumber, string url, string leagueAcronym)
        {
            SeasonData season;

            bool isPlayoffs = url.Contains("-PLF-");

            var extractedSeason = SeasonStatsExtractor.ExtractSeason(url, seasonNumber, isPlayoffs, leagueAcronym);

            if (extractedSeason != null && extractedSeason.Teams.Count > 0)
            {
                season = new SeasonData(extractedSeason);
                Console.Write(" [DONE]");
                Console.WriteLine();
                Console.WriteLine("----");
                Console.WriteLine("Uploading Data to DB");
                Console.Write(" - Season " + season.SourceSeason.Number);
                season.SaveDataToDB();
                Console.Write(" [DONE]");
                Console.WriteLine();
            }
            else
            {
                Console.Write(" [Not Found]");
            }
            Console.WriteLine("----");
            Console.WriteLine("Extraction Complete");
            Console.WriteLine();
            Console.ReadKey();
        }
Exemplo n.º 3
0
        private static List <SeasonData> GetAllSeasons()
        {
            List <SeasonData> seasons = new List <SeasonData>();

            string[] leagueOptions     = { "SHL", "SMJHL" };
            bool[]   isPlayoffsOptions = { false, true };

            foreach (var isPlayoffs in isPlayoffsOptions)
            {
                foreach (var leagueAcronym in leagueOptions)
                {
                    string seasonType = isPlayoffs ? "Playoffs" : "Regular Season";
                    Console.WriteLine($"### {leagueAcronym} - {seasonType}");

                    for (int seasonNumber = 1; seasonNumber <= 28; seasonNumber++)
                    {
                        string seasonValue = seasonNumber.ToString();
                        if (seasonNumber < 10)
                        {
                            seasonValue = " " + seasonValue;
                        }
                        Console.Write(" - Season " + seasonValue);

                        var sourceSeason = SeasonStatsExtractor.ExtractSeason(seasonNumber, isPlayoffs, leagueAcronym);
                        if (sourceSeason != null)
                        {
                            seasons.Add(new SeasonData(sourceSeason));
                            Console.Write(" [DONE]");
                        }
                        else
                        {
                            Console.Write(" [Not Found]");
                        }
                        Console.WriteLine();
                    }
                }
            }

            return(seasons);
        }
Exemplo n.º 4
0
        public static void GetEverything()
        {
            List <SeasonData> seasons     = new List <SeasonData>();
            List <SeasonPage> seasonPages = new List <SeasonPage>
            {
                new SeasonPage()
                {
                    Url           = "http://www.shlstuff.wtgbear.com/RegSeason/S{0}/SHL-ProTeamScoring.html",
                    StartIndex    = 29,
                    LeagueAcronym = "SHL",
                    IsPlayoffs    = false,
                },
                new SeasonPage()
                {
                    Url           = "http://www.shlstuff.wtgbear.com/Playoffs/S{0}/SHL-PLF-ProTeamScoring.html",
                    StartIndex    = 30,
                    LeagueAcronym = "SHL",
                    IsPlayoffs    = true,
                },
                new SeasonPage()
                {
                    Url           = "http://www.smjhlstuff.wtgbear.com/S{0}Reg/SMJHL-ProTeamScoring.html",
                    StartIndex    = 23,
                    LeagueAcronym = "SMJHL",
                    IsPlayoffs    = false,
                },
                new SeasonPage()
                {
                    Url           = "http://www.smjhlstuff.wtgbear.com/S{0}PO/SMJHL-PLF-ProTeamScoring.html",
                    StartIndex    = 22,
                    LeagueAcronym = "SMJHL",
                    IsPlayoffs    = true,
                }
            };
            int endIndex = 40;

            Console.WriteLine("Starting Modern Extractions");
            foreach (var page in seasonPages)
            {
                Console.WriteLine($"### {page.LeagueAcronym} - {(page.IsPlayoffs ? "Playoffs" : "Regular Season")}");
                for (int seasonNumber = page.StartIndex; seasonNumber <= endIndex; seasonNumber++)
                {
                    Console.Write(" - Season " + (seasonNumber < 10 ? " " : "") + seasonNumber);

                    var season = SeasonStatsExtractor.ExtractSeason(page.Url, seasonNumber, page.IsPlayoffs, page.LeagueAcronym);
                    if (season != null && season.Teams.Count > 0)
                    {
                        seasons.Add(new SeasonData(season));
                        Console.Write(" [DONE]");
                    }
                    else
                    {
                        Console.Write(" [Not Found]");
                    }
                    Console.WriteLine();
                }
            }

            Console.WriteLine("----");
            Console.WriteLine("Uploading Data to DB");

            DatabaseHelpers.AddLeagues();
            DatabaseHelpers.AddRequestTypes();

            foreach (var season in seasons)
            {
                Console.Write(" - Season " + season.SourceSeason.Number);
                season.SaveDataToDB();
                Console.Write(" [DONE]");
                Console.WriteLine();
            }

            DatabaseHelpers.AddFranchises();
            DatabaseHelpers.RemoveExtraPlayers();

            Console.WriteLine("----");
            Console.WriteLine("Extraction Complete");
            Console.WriteLine();
        }