static void Main(string[] args) { mainMenu menuObject = new mainMenu(); bool menuLoop = true; bool errorConnection = false; bool fileCreate = false; int menuItem = 0; string fileSettings = "Settings.ini"; // Json objects from servers ChampionListDto liveChampionList = new ChampionListDto(); GameObject pastGames = new GameObject(); league_v2_3 summonerLeagueLadder = new league_v2_3(); API_Call Operator = new API_Call(); summonerProfile summonerStats = new summonerProfile(); stats_v1_2_Ranked testStats = new stats_v1_2_Ranked(); ChampionListDTO listOfChampions = new ChampionListDTO(); // Operator makes call and grabs data from Riot. Operator.MakeCall(ref liveChampionList); Console.WriteLine("Calling pastGames"); Operator.MakeCall(ref pastGames); Console.WriteLine("Calling summonerLeagueLadder"); Operator.MakeCall(ref summonerLeagueLadder); Operator.MakeCall(ref testStats); Operator.MakeCall(ref listOfChampions); // Determines if user has run the program before. fileCreate = menuObject.checkFile(fileSettings); // Creates a file for user; mostly ini if (fileCreate) { } if (!errorConnection) { while (menuLoop) { menuObject.displayMenu(ref menuItem); switch (menuItem) { case 1: // Display Active Roster menuObject.displayActiveRoster(liveChampionList, listOfChampions); break; case 2: //Display Free to Play Roster // menuObject.displayFreeToPlay(liveChampionList); break; case 3: // Change Current Region // menuObject.displayBotChampions(liveChampionList); break; case 4: // Displays last 10 games from user. // menuObject.displayGamesPlayed(pastGames, liveChampionList); break; case 5: // Display players in current league of player menuObject.displayLeaderBoard(ref summonerLeagueLadder); break; case 6: // Display Summary Stats menuObject.displaySummaryStats(summonerStats); break; default: menuLoop = false; break; } // Exit program by user. if (menuItem == 0) { menuLoop = false; } } } else { Console.WriteLine("Closing program."); } Console.WriteLine("Hit any-key"); Console.Read(); }
public void displaySummaryStats(summonerProfile summonerStats) { }
/****************************************************************************************** * Method Name: void MakeCall() * Arguements: league_v2_3 summonerLeaderBoard. * Purpose: Calls Riot Servers to grab list of the current leader board the summoner is currently * in. * PreConditions: Assumes that API Key and Region have been set to desired location. * PostConditions: Fills current object with JSON parsed data. ******************************************************************************************/ public void MakeCall(ref summonerProfile summonersProfile) { WebRequest request_champ_stream; string responseFromServer; string API_URL = requestUrl_PlayerStatsSummary_v1_2 + api_Key; string temp = API_URL; API_URL = temp.Replace("{region}", user_region); temp = API_URL; API_URL = temp.Replace("{summonerId}", user_summonerid); // Displays where at Console.WriteLine("leaderBoard Object Call"); try { // Open stream and generate URI request WebRequest.Create(API_URL); request_champ_stream = WebRequest.Create(API_URL); request_champ_stream.Credentials = CredentialCache.DefaultCredentials; // Setting 'Timeout' property in Milliseconds request_champ_stream.Timeout = 30000; // This request will throw a WebException if it reaches the timeout limit before it is able to fetch the resource. WebResponse response = request_champ_stream.GetResponse(); Console.WriteLine(((HttpWebResponse)response).StatusDescription); // Get the stream contaning content returned by the server. Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); // Reading content from server and converting it to string type. responseFromServer = reader.ReadToEnd(); // Parse Data from server into object summonersProfile = JsonConvert.DeserializeObject <summonerProfile>(responseFromServer); // Closing Stream reader.Close(); response.Close(); errorResponse = false; } // Determines if the call failed. catch (WebException e) { Console.WriteLine("This program can't comminicate with the Web Server." + "\n\nException Message :" + e.Message); if (e.Status == WebExceptionStatus.ProtocolError) { errorHTTPStatusCode = "Status Code : {0}" + (((HttpWebResponse)e.Response).StatusCode).ToString(); Console.WriteLine("Status Code : {0}", ((HttpWebResponse)e.Response).StatusCode); errorReason = "Status Description : {0}" + (((HttpWebResponse)e.Response).StatusDescription).ToString(); Console.WriteLine("Status Description : {0}", ((HttpWebResponse)e.Response).StatusDescription); } } catch (Exception e) { Console.WriteLine(e.Message); } }