示例#1
0
        public static void UpdateEntry(GameDayEntry entry)
        {
            var tableServiceContext = Helpers.TableStorage.GetTableServiceContext(TableName);

            GameDayEntry entryToUpdate =
                        (from e in tableServiceContext.CreateQuery<GameDayEntry>(TableName)
                         where e.RowKey == entry.RowKey
                         select e).FirstOrDefault();

            entryToUpdate.StartDate = entry.StartDate;
            entryToUpdate.StartTime = entry.StartTime;
            entryToUpdate.Teams = entry.Teams;
            entryToUpdate.Posted = entry.Posted;

            tableServiceContext.UpdateObject(entryToUpdate);
            tableServiceContext.SaveChangesWithRetries();
        }
示例#2
0
        public void UploadGamesToTable()
        {
            // load csv file into azure
            int count = 0;
            var games = File.ReadAllLines("schedule.csv");
            foreach (var game in games)
            {
                var gameSplit = game.Split(',');
                var gameDayEntry = new GameDayEntry(count, gameSplit[0], gameSplit[1], gameSplit[3], gameSplit[5], (gameSplit.Length == 18) ? "true" : "false");
                Trace.WriteLine(gameDayEntry);
                count++;
                var tableServiceContext = Helpers.TableStorage.GetTableServiceContext("GameDayEntries");
                Helpers.TableStorage.AddEntity(gameDayEntry, "GameDayEntries");

            }
        }
示例#3
0
        /// <summary>
        /// Scrapes the dodgers schedule from ESPN.com, if it finds a match, set the pitchers
        /// </summary>
        /// <param name="game">Game entry that will be posted</param>
        /// <param name="dodgersPitcher">Dodgers pitcher string</param>
        /// <param name="otherPitcher">Other team pitcher string</param>
        private void GetStartingPitchers(GameDayEntry game, out string dodgersPitcher, out string otherPitcher)
        {
            dodgersPitcher = string.Empty;
            otherPitcher = string.Empty;

            // Get the schedule from ESPN
            var espnGameDayEntries = this.GetEspnGameEntries();

            var htmlDate = DateTime.Parse(game.StartDate).ToString("ddd, MMM d");
            EspnGameDay espnGame = (from g in espnGameDayEntries
                                    where g.Date.Equals(htmlDate, StringComparison.InvariantCultureIgnoreCase)
                                    select g).FirstOrDefault();
            if (espnGame != null)
            {
                dodgersPitcher = espnGame.DodgersPitcher;
                otherPitcher = espnGame.AwayPitcher;
            }
        }