示例#1
0
        static void Main(string[] args)
        {
            //Check for existing data (Useful for recoving from a crash, skips to only players without data)
            var playerList = BulkInsert.ReadPlayers(ConnectionString);

            if (playerList.Count == 0 || !RecoveryMode)
            {
                //Get team list
                var teamScraper = new TeamListScraper();
                var teamList    = teamScraper.TeamList;
                BulkInsert.LoadTeams(teamList, ConnectionString);

                //Get list of players for every team
                var playerScraper = new PlayerListScraper(teamList, YearList);
                playerList = playerScraper.PlayerList.OrderBy(x => x.YearCode).ThenBy(x => x.PlayerID).ToList();
                BulkInsert.LoadPlayers(playerList, ConnectionString);
            }
            //Begin pulling game data
            var gameScrpaer = new GameListScraper(playerList);
            var games       = gameScrpaer.GameList;

            BulkInsert.LoadGames(games, ConnectionString);

            Console.WriteLine("Data pull complete, press any key to continue...");
            Console.ReadLine();
        }
示例#2
0
        protected override void ProcessResult(string url)
        {
            if (scrapResult == null)
            {
                LogResult(url, 0);
                return;
            }
            var result = JsonConvert.DeserializeObject <List <GameModel> >(scrapResult);

            if (result == null)
            {
                LogResult(url, 0);
                return;
            }
            foreach (var game in result)
            {
                game.TeamID   = _player.TeamID;
                game.PlayerID = _player.PlayerID;
                game.YearCode = _player.YearCode;
            }
            GameList.AddRange(result);
            LogResult(url, result.Count);

            //Save as we go in chunks, just in case it all crashes
            if (GameList.Count > 100)
            {
                BulkInsert.LoadGames(GameList, Program.ConnectionString);
                GameList.Clear();
            }
        }