//public void StartCrawl(Region region, int numberOfSummoners = 50) //{ // InitiateSeedList(); // using(context){ // while (Summoners.Count() < numberOfSummoners) // { // foreach (long summonerid in seedList) // { // Console.WriteLine("Get Match history"); // ChooseApiKey(); // var matchHistory = Task.Run(async () => { return await api.Match.GetMatchListAsync(region, summonerid, queues: new List<int> { 420 }, beginTime: DateTime.Now.AddDays(-5)); }).Result; // Console.WriteLine("Match history retrieved"); // foreach (MatchReference mr in matchHistory.Matches) // { // ChooseApiKey(); // Match match = Task.Run(async () => { return await api.Match.GetMatchAsync(region, mr.GameId); }).Result; // MyMatch matchToComplete = new MyMatch(match); // context.Matches.Add(matchToComplete); // context.SaveChanges(); // Console.WriteLine("Match started"); // if (!matchCompletedList.Contains(matchToComplete.MatchId)) // { // CompleteMatch(region, matchToComplete); // } // } // } // StartCrawl(region); // } // } //} public void StartCrawlQueue(Region region, int numberOfMatches = 50) { InitiateSeedList(); try { using (context) { while (Matches.Count() < numberOfMatches) { while (seedQueue.Count != 0) { Console.WriteLine("Get Match history"); MySummoner summoner = seedQueue.Dequeue(); if (!summonersCompletedList.Contains(summoner.SummonerId)) { ChooseApiKey(); System.Threading.Thread.Sleep(500); var matchHistory = Task.Run(async() => { return(await api.Match.GetMatchListAsync(region, summoner.AccountId, queues: new List <int> { 420 }, beginTime: DateTime.Now.AddDays(-5))); }).Result; Console.WriteLine("Match history retrieved"); foreach (MatchReference mr in matchHistory.Matches) { ChooseApiKey(); System.Threading.Thread.Sleep(500); Match match = Task.Run(async() => { return(await api.Match.GetMatchAsync(region, mr.GameId)); }).Result; MyMatch matchToComplete = new MyMatch(match); Matches.AddMatch(matchToComplete); Console.WriteLine("Match started"); if (!matchCompletedList.Contains(matchToComplete.MatchId)) { CompleteMatch(region, matchToComplete); } } Summoners.CompleteSummoner(summoner); Console.WriteLine("Match History complete"); } } } } } catch (Exception e) { Console.WriteLine("Application restarted with error: " + e.Message + "\n" + e.StackTrace); StartCrawlQueue(region, numberOfMatches); } }