public static void WriteRuneTotals(SummonerDto summoner, RunePagesDtoManager runePagesManager, string region, HttpServerUtility server) { List <string> lines = new List <string>(); if (runePagesManager.CurrentPage != null) { lines.Add(runePagesManager.CurrentPage.name); lines.Add(runePagesManager.RunePageTotalsTable(runePagesManager.CurrentPage)); } else { lines.Add(""); lines.Add(""); } foreach (RunePageDto runePage in runePagesManager.runePagesDto.pages) { if (!runePage.current) { lines.Add(runePage.name); lines.Add(runePagesManager.RunePageTotalsTable(runePage)); } } File.WriteAllLines(server.MapPath(@"~/App_Data/Summoner_Data/" + region + '/' + summoner.id + @"/runetotals.dat"), lines); }
static void Cmd() { string cmd = Console.ReadLine(); if (cmd.StartsWith("getCurGame")) { string[] pieces = cmd.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); if (pieces.Length == 2) { string ID = pieces[1]; SummonerDto Chuvak = GetData.GetSummonerByName(ID); if (Chuvak == null) { Out("Cant find that dude", ConsoleColor.DarkYellow); } else { CurrentGameInfo Data = GetData.GetCurrentGameInfo(Chuvak.id.ToString()); if (Data == null) { Out("Cant find game", ConsoleColor.DarkYellow); } else { Out(Data.gameMode + " " + Data.gameType, ConsoleColor.DarkCyan); foreach (CurrentGameParticipant Chelik in Data.participants) { if (Chelik.summonerId == Chuvak.id) { try { Static.ChampionDto Champ = GetData.GetChampById(Chelik.championId.ToString()); Static.TempRune Rune = RitoPls.OfflineData.OfflineData.GetRune(Chelik.perks.perkIds[0]); Out(Champ.name + " with " + Rune.name, ConsoleColor.DarkGreen); } catch (Exception e) { Out(@"\\\\\ Exception \\\\\", ConsoleColor.DarkGray); Out(e.ToString()); Out(@"/////////////////////", ConsoleColor.DarkGray); break; } break; } } } } } else { Ebanuty(); } } else { Ebanuty(); } Cmd(); }
string buildOtherRunePagesFromFile(SummonerDto summoner) { string[] lines = SummonerDataManager.ReadRuneTotals(summoner, regionRadioList.SelectedValue, Server); StringBuilder sb = new StringBuilder(); for (int i = 2; i < lines.Length; i += 2) { if (lines[i + 1] != "") { sb.Append("<span class=\"PageName\">"); sb.Append(lines[i]); sb.Append("</span><br/><br/>"); sb.Append("<span class=\"RuneTotals\">"); sb.Append(lines[i + 1]); sb.Append("</span><br/><br/>"); } } if (sb.Length > 10) { sb.Remove(sb.Length - 10, 10); } if (sb.Length == 0) { sb.Append("<span class=\"PageName\">none</span><br/>"); } return(sb.ToString()); }
public static MatchDto GetMostRecentMatch(string summonerName) { SummonerDto needTheId = GetSummonerMetaByName(summonerName); MatchReferenceDto mostRecentMatch = GetRecentMatchesBySummonerId(needTheId.AccountId).Matches.OrderByDescending(x => x.TimeStamp).First(); return(GetMatchByMatchId(mostRecentMatch.GameId)); }
public static ChampionDto GetMostRecentlyPlayedChamp(string summonerName) { SummonerDto needTheId = GetSummonerMetaByName(summonerName); MatchReferenceDto mostRecentMatch = GetRecentMatchesBySummonerId(needTheId.Id).Matches.OrderByDescending(x => x.TimeStamp).First(); int mostRecentChampId = Convert.ToInt32(mostRecentMatch.Champion); return(GetChampionFromIDHttpClient(mostRecentChampId)); }
private async void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { string nameSummoner = NavigationContext.QueryString["name"]; SummonerDto summoner = new SummonerDto(); try { summoner = await summoner.SearchSummoner(nameSummoner); textBlockNomeInv.Text = summoner.Nome; } catch { MessageBox.Show("Não existe um invocador com esse nome."); NavigationService.GoBack(); return; } textBlockLevel.Text += summoner.SummonerLevel.ToString(); try { LeagueDto leagueSummoner = new LeagueDto(); leagueSummoner = await leagueSummoner.SearchLeague(summoner.Id); textBlockElo.Text = leagueSummoner.Tier + " " + leagueSummoner.Entries[0].Division; textBlockVit.Text = leagueSummoner.Entries[0].Wins > 1 ? leagueSummoner.Entries[0].Wins.ToString() + " vitórias" : leagueSummoner.Entries[0].Wins.ToString() + " vitória"; textBlockDer.Text = leagueSummoner.Entries[0].Losses > 1 ? leagueSummoner.Entries[0].Losses.ToString() + " derrotas" : leagueSummoner.Entries[0].Losses.ToString() + " derrota"; } catch { MessageBox.Show("Informações de derrotas e vitórias são apenas para jogadores ranqueados.", "Informação", MessageBoxButton.OK); textBlockElo.Text = "Unranked"; textBlockVit.Text = "0 vitória"; textBlockDer.Text = "0 derrota"; } imageInvocador.Source = await summoner.GetProfileIcon(); RecentGamesDto gamesRecent = await new RecentGamesDto().GetLatestGamesById(summoner.Id); List <int> lastChampionsPlayed = new List <int>(); foreach (GameDto game in gamesRecent.Games) { lastChampionsPlayed.Add(game.ChampionId); LastMatches controlMatch = new LastMatches(game); controlMatch.Margin = new Thickness(0, 0, 0, 10); controlMatch.Load(); listboxPartidas.Items.Add(controlMatch); } int idChampPref = lastChampionsPlayed[new Random().Next(lastChampionsPlayed.Count - 1)]; ImageBrush imgBrush = new ImageBrush(); BitmapImage source = (await ChampionDto.SearchChampionAllData(idChampPref)).GetChampionSplash(0); imgBrush.ImageSource = source; imgBrush.Stretch = Stretch.UniformToFill; LayoutRoot.Background = imgBrush; }
public static void ResetSummonerRevisionDate(SummonerDto summoner, string region, HttpServerUtility server) { string summonerFilePath = server.MapPath(@"~/App_Data/Summoner_Data/" + region + '/' + summoner.id); if (Directory.Exists(summonerFilePath)) { string[] lines = File.ReadAllLines(summonerFilePath + @"/info.txt"); lines[0] = "0"; File.WriteAllLines(summonerFilePath + @"/info.txt", lines); } }
public static MasteryPagesDto ReadSummonerMasteriesFile(SummonerDto summoner, string region, HttpServerUtility server) { string summonerMasteriesPath = server.MapPath(@"~/App_Data/Summoner_Data/" + region + '/' + summoner.id + @"/masteries.json"); FileStream fin = File.OpenRead(summonerMasteriesPath); JsonSerializer serializer = new JsonSerializer(); JsonTextReader jsonTextReader = new JsonTextReader(new StreamReader(fin)); MasteryPagesDto masterypages = (MasteryPagesDto)serializer.Deserialize(jsonTextReader, typeof(MasteryPagesDto)); fin.Close(); return(masterypages); }
public static bool HasSummonerChanged(SummonerDto summoner, string region, HttpServerUtility server) { string summonerFilePath = server.MapPath(@"~/App_Data/Summoner_Data/" + region + '/' + summoner.id); if (Directory.Exists(summonerFilePath)) { long revisionDate = long.Parse(File.ReadAllLines(summonerFilePath + @"/info.txt")[0]); return(revisionDate != summoner.revisionDate); } else { return(true); } }
public static CurrentGameInfo GetCurrentGameBySummonerName(string name, string platform) { CurrentGameInfo result; try { SummonerDto summoners = Summoner.GetSummonerByName(name, platform); result = Request.GetData(platform, String.Format("observer-mode/rest/consumer/getSpectatorGameInfo/{0}/{1}?", platform.ToUpperInvariant(), summoners.id), typeof(CurrentGameInfo)); } catch (Exception) { return(null); } return(result); }
public static void WriteSummonerMasteriesFile(SummonerDto summoner, MasteryPagesDto masteryPages, string region, HttpServerUtility server) { string summonerMasteriesPath = server.MapPath(@"~/App_Data/Summoner_Data/" + region + '/' + summoner.id + @"/masteries.json"); FileStream fout = File.OpenWrite(summonerMasteriesPath); JsonSerializer serializer = new JsonSerializer(); JsonTextWriter jsonTextWriter = new JsonTextWriter(new StreamWriter(fout)); serializer.Serialize(jsonTextWriter, masteryPages); jsonTextWriter.Flush(); jsonTextWriter.Close(); fout.Close(); }
public static void WriteSummonerInfoFile(SummonerDto summoner, string region, HttpServerUtility server) { string summonerFilePath = server.MapPath(@"~/App_Data/Summoner_Data/" + region + '/' + summoner.id); string str = summoner.revisionDate + "\n" + summoner.id + "\n" + summoner.name + "\n" + summoner.profileIconId + "\n" + summoner.summonerLevel; if (!Directory.Exists(summonerFilePath)) { Directory.CreateDirectory(summonerFilePath); } File.WriteAllText(summonerFilePath + @"/info.txt", str); }
static void Main(string[] args) { string APIKeyFile = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "APIKey.txt"); if (!File.Exists(APIKeyFile)) { Console.WriteLine("Please enter in your API Key"); string apiKey = Console.ReadLine(); LeagueAPIStaticFunctions.ApiClient.DefaultRequestHeaders.Add(LeagueURLConstants.HeaderConstants.APIKeyHeader, apiKey); File.WriteAllText(APIKeyFile, apiKey); } else { LeagueAPIStaticFunctions.ApiClient.DefaultRequestHeaders.Add(LeagueURLConstants.HeaderConstants.APIKeyHeader, File.ReadAllText(APIKeyFile)); } ChampionMetaDtoList freeToPlayMetaList = LeagueAPIStaticFunctions.GetCurrentFreeToPlayListHttpClient(); List <ChampionDto> freeToPlayList = new List <ChampionDto>(); foreach (ChampionMetaDto champMeta in freeToPlayMetaList.Champions) { freeToPlayList.Add(LeagueAPIStaticFunctions.GetChampionFromIDHttpClient(Convert.ToInt32(champMeta.Id))); } foreach (ChampionDto champ in freeToPlayList) { Console.WriteLine(string.Format("{0:000}: {1}", champ.Id, champ.Name)); } Console.WriteLine("Please enter the name of a summoner to get information for"); string summonerName = Console.ReadLine(); //This name should really be checked before doing this //Riot would probably yell at me. SummonerDto summoner = LeagueAPIStaticFunctions.GetSummonerMetaByName(summonerName); Console.WriteLine(string.Format("The ID for Summoner with name {0} is {1}", summonerName, summoner.Id)); ChampionDto MostRecentChamp = LeagueAPIStaticFunctions.GetMostRecentlyPlayedChamp(summonerName); Console.WriteLine(string.Format("The most recent champt that {0} played is {1}", summonerName, MostRecentChamp.Name)); Console.ReadLine(); }
string buildCurrentRunePageFromFile(SummonerDto summoner) { string[] lines = SummonerDataManager.ReadRuneTotals(summoner, regionRadioList.SelectedValue, Server); string str = ""; if (lines[1] == "") { str += "<span class=\"PageName\">none</span><br/>"; } else { str += "<span class=\"PageName\">" + lines[0] + "</span><br/><br/>"; str += "<span class=\"RuneTotals\">" + lines[1] + "</span>"; } return(str); }
// GET: api/RiotGames public SummonerDto Get() { HttpClient client = new HttpClient(); client.BaseAddress = new Uri("https://euw.api.pvp.net/api/lol/euw/v1.4/summoner/by-name/xFlawZy?api_key=RGAPI-fcc50458-8344-4759-9ebd-30716cb922e9"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = client.GetAsync("").Result; var summoner = new SummonerDto(); if (response.IsSuccessStatusCode) { summoner = response.Content.ReadAsAsync <SummonerDto>().Result; } return(summoner); }
public async new Task <ActionResult> Profile() { HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:60030/api/RiotGames"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await client.GetAsync(""); var summoner = new SummonerDto(); if (response.IsSuccessStatusCode) { summoner = await response.Content.ReadAsAsync <SummonerDto>(); } return(View(summoner)); }
public static SummonerDto GetSummonerByName(string name, string platform) { SummonerDto summoner = null; try { string encodedName = System.Web.HttpUtility.UrlPathEncode(name); Dictionary <String, SummonerDto> result = Request.GetData(platform, String.Format("api/lol/{0}/v1.4/summoner/by-name/{1}?", Request.RegionName[platform], encodedName), typeof(Dictionary <String, SummonerDto>)); summoner = result.Values.First(); BaronReplays.Database.PublicDatabaseManager.Instance.AddSummonerId(summoner.id, summoner.name, platform); Logger.Instance.WriteLog(String.Format("Summoner Id of {0} in {1} is {2}", name, platform, summoner.id)); } catch (Exception e) { Logger.Instance.WriteLog(String.Format("GetSummonerByName failed: {0}", e.Message)); } return(summoner); }
public static SummonerDto GetSummonerMetaByName(string name) { string sURL = String.Format(LeagueURLConstants.APIPaths.SummonerMetaPath, name); SummonerDto summoner = null; using (StreamReader response = new StreamReader(ApiClient.GetStreamAsync(sURL).Result)) using (JsonReader jsonResponse = new JsonTextReader(response)) { JsonSerializer serializer = new JsonSerializer(); summoner = serializer.Deserialize <SummonerDto>(jsonResponse); } if (summoner == null) { Console.WriteLine("Error occured while trying to retreive summoner information for {0}", name); } return(summoner); }
private async void buttonCadastro_Click(object sender, RoutedEventArgs e) { if (nomeInvocador.Text == string.Empty) { MessageBox.Show("Digite o nome do invocador antes de se cadastrar."); } else { summoner = new SummonerDto(); try { summoner = await summoner.SearchSummoner(nomeInvocador.Text); ls = new LeagueWS.LeagueServiceClient(); ls.encontrarUsuarioCompleted += Ls_encontrarUsuarioCompleted; ls.encontrarUsuarioAsync(nomeInvocador.Text); } catch (Exception) { MessageBox.Show("Erro ao procurar invocador."); } } }
void showPlayerInfo(SummonerDto summoner) { playerInfoLabel.Text = "<div id=\"playerInfoBorder\"><span style=\"margin-bottom: 0px; padding-bottom: 0px; font-size: x-large; font-weight: bold\">" + summoner.name + "</span><br/><span style=\"font-size: 12px; margin-top: 0px; padding-top: 0px\">Level " + summoner.summonerLevel + "</span></div>"; }
public void ThenIVeGottenInformationForSummonerId(int id) { SummonerDto summoner = ScenarioContext.Current["SUMMONER_DTO"] as SummonerDto; Assert.IsTrue(summoner.Id.Equals(id)); }
public static bool MasteriesFileExists(SummonerDto summoner, string region, HttpServerUtility server) { return(File.Exists(server.MapPath(@"~/App_Data/Summoner_Data/" + region + '/' + summoner.id + @"/masteries.json"))); }
public static bool RunesFileExists(SummonerDto summoner, string region, HttpServerUtility server) { return(File.Exists(server.MapPath(@"~/App_Data/Summoner_Data/" + region + '/' + summoner.id + @"/runetotals.dat"))); }
public async Task <Summoner> GetSummoner(string summonerName) { try { using (CancellationTokenSource cts = new CancellationTokenSource(_timeout)) { if (summonerName.Length > 16) { return(new Summoner(summonerName, SummonerNameAvailability.TooLong)); } // Fetch Summoner SummonerDto summonerDto = null; try { summonerDto = await ApiRequestAsync <SummonerDto>($"summoner/v4/summoners/by-name/{summonerName}?api_key={_apiKey}", cts.Token); } catch (ApiRequestException e) { if (e.StatusCode == HttpStatusCode.NotFound) { // 404 = summoner does not exist return(new Summoner(summonerName, SummonerNameAvailability.AvailableNotFound)); } throw; } if (summonerDto == null) { return(new Summoner(summonerName, SummonerNameAvailability.Unknown)); } // Fetch Summoner's match history MatchListDto matchListDto = null; try { matchListDto = await ApiRequestAsync <MatchListDto>($"match/v4/matchlists/by-account/{summonerDto.AccountId}?api_key={_apiKey}", cts.Token); } catch (ApiRequestException e) { if (e.StatusCode == HttpStatusCode.NotFound) { // 404 = no matches played return(new Summoner(summonerName, SummonerNameAvailability.UnknownNeverPlayed)); } throw; } if (matchListDto == null || !matchListDto.Matches.Any()) { return(new Summoner(summonerName, SummonerNameAvailability.UnknownNeverPlayed)); } return(new Summoner( summonerDto.Name, summonerDto.SummonerLevel, summonerDto.Id, summonerDto.AccountId, DateTimeOffset.FromUnixTimeMilliseconds(matchListDto.Matches.First().Timestamp).UtcDateTime)); } } catch (Exception e) when(e is ApiRequestException || e is OperationCanceledException) { return(new Summoner(summonerName, SummonerNameAvailability.Unknown)); } }
public static string[] ReadRuneTotals(SummonerDto summoner, string region, HttpServerUtility server) { return(File.ReadAllLines(server.MapPath(@"~/App_Data/Summoner_Data/" + region + '/' + summoner.id + @"/runetotals.dat"))); }
public async Task <IActionResult> Index(SummonerDto dto) { dto = await _service.UpdateSummonerAsync(dto.Name); return(View("Detail", dto)); }