public void TestCanBeWrittenToDatabase() { var timeline = new ItemPurchaseTimeline(); timeline.AddToEndByItemId(3086, TimeSpan.Zero); timeline.AddToEndByItemId(3087, TimeSpan.FromSeconds(14)); timeline.AddToEndByItemId(3087, TimeSpan.FromSeconds(16)); var context = new GameContext(); var proGame = new ProPlayerGame(); proGame.GameId = 1; proGame.SummonerId = 5; proGame.ItemPurchaseTimeline = timeline; context.Games.Add(proGame); context.SaveChanges(); }
static void Main(string[] args) { try { var client = new RiotClient(Region.NA, new RiotClientSettings { ApiKey = ConfigurationManager.AppSettings["RiotAPIKey"] }); using (var context = new GameContext()) { foreach (var proUnderObservation in SummonerIds.Pros) { Console.WriteLine("Processing pro with summoner Id {0}", proUnderObservation); var matchList = client.GetMatchList(proUnderObservation, seasons: new Season[] { Season.SEASON2015 }, rankedQueues: new RankedQueue[] { RankedQueue.RANKED_SOLO_5x5 }); Console.WriteLine("We have info on {0} games for this pro", matchList.TotalGames); foreach (var game in matchList.Matches) { // some EUW games were causing problems (maybe region transfer?) if (game.PlatformId.Equals("NA1")) { System.Diagnostics.Debug.WriteLine("Processing game id {0}", game.MatchId); var oldItem = context.Games.SingleOrDefault((t) => t.SummonerId == proUnderObservation && t.GameId == game.MatchId); //var oldItem = context.Games.Find(proUnderObservation, game.MatchId); if (oldItem == null) // not in database already { var singleMatch = client.GetMatch(game.MatchId, true); var itemListFromSingleMatch = new ItemPurchaseTimeline(singleMatch, proUnderObservation); var championId = game.Champion; var proPlayerGame = new ProPlayerGame(proUnderObservation, game.MatchId, championId, itemListFromSingleMatch); context.Games.Add(proPlayerGame); context.SaveChanges(); } } } } } } catch(Exception e) { // may not always have a debugger Console.WriteLine(e); throw e; } }
public DBScanProPlayerGame(ProPlayerGame game) { Game = game; }