Exemplo n.º 1
0
        static void Main(string[] args)
        {
            List <SeasonData> seasons = new List <SeasonData>();

            Console.WriteLine("Starting Legacy Extractions");

            seasons = GetAllSeasons();
            //seasons = GetOneShlSeason(22);

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

            DatabaseHelpers.AddLeagues();
            DatabaseHelpers.AddSeasonTypes();

            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();
        }
Exemplo n.º 2
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();
        }