private void LoadOfflineMatches() { ClassCount classCount = new ClassCount(); classCount.Show(); DirectoryInfo info = new DirectoryInfo(@_folder + "/matches/" + SteamID); foreach (var matchFile in info.GetFiles("*.json")) { string json = File.ReadAllText(matchFile.FullName); JObject match = JObject.Parse(json); if (IsCombinedLog(match)) { continue; } _matches.Add(match); CurrentClassView.AverageMatch(match); CountClass(match); AmountOfMatches += 1; AmountLoaded += 1; } }
private async void RetrieveInformation() { string jsoninformation = await GetMatchesInformation(); if (jsoninformation != null) { JObject json = JObject.Parse(jsoninformation); int OldAmountOfMatches = AmountOfMatches; AmountOfMatches = (int)json["results"]; //No loading needed incase everything is offline. if (OldAmountOfMatches == AmountOfMatches) { return; } MessageBoxResult dialogResult = MessageBox.Show("This can take some time. A pause of 4 seconds every 25 logs is required so the request does not time out. This means you'll have to wait about " + (((AmountOfMatches - OldAmountOfMatches) / 25) * 4) / 60 + " minutes.\n\nContinue?", "Warning", MessageBoxButton.YesNo); if (dialogResult == MessageBoxResult.Yes) { CanRetrieve = false; for (int i = AmountLoaded; i < json["logs"].Reverse().Count(); ++i) { int id = (int)json["logs"][i]["id"]; JObject match = JObject.Parse(await GetMatchInformation(id)); if (IsCombinedLog(match)) { continue; } AmountLoaded += 1; CurrentClassView.AverageMatch(match); CountClass(match); //Requests will crash if no pauses. if (AmountLoaded % 25 == 0) { System.Threading.Thread.Sleep(4000); } _matches.Add(match); SaveMatch(id, match); } } } }