Exemple #1
0
        private void tileRefresh_Click(object sender, EventArgs e)
        {
            tileRefresh.Enabled = false;
            //Get Match History
            List <GameData> gameDataList = new List <GameData>();
            int             matchIndex   = 0;

            //TODO: Not hit the endpoint so hard and spawn it in a new Thread or background worker
            while (true)
            {
                bool         breakout     = false;
                ACSMatchList MatchHistory = _leagueClient.GetMatchHistory(matchIndex * 20, (matchIndex + 1) * 20);
                foreach (GameData gameData in MatchHistory.games.games)
                {
                    if ((DateTime.Now - FromUnixTime(Convert.ToInt64(gameData.gameCreation))).Days > 30)
                    {
                        breakout = true;
                        break;
                    }

                    gameDataList.Add(gameData);
                }

                if (breakout)
                {
                    break;
                }

                matchIndex++;
            }
            //Clear the Current Panel
            panelMatchHistory.Controls.Clear();

            //Generate The UI
            //MatchHistory List is in reverse, oldest to newest
            //So Panel is set to show in reverse
            foreach (GameData gameData in gameDataList.OrderBy(g => g.gameCreation))
            {
                Application.DoEvents();
                MatchInfo matchInfoControl = new MatchInfo(_leagueClient, gameData.participants[0].championId, gameData.participants[0].spell1Id, gameData.participants[0].spell2Id,
                                                           gameData.participants[0].stats.item0, gameData.participants[0].stats.item1, gameData.participants[0].stats.item2, gameData.participants[0].stats.item3, gameData.participants[0].stats.item4, gameData.participants[0].stats.item5, gameData.participants[0].stats.item6,
                                                           gameData.participants[0].stats.kills, gameData.participants[0].stats.deaths, gameData.participants[0].stats.assists, _leagueClient.GetShareableMatchHistoryURL(gameData.gameId), gameData.gameId, GetDownloadUrl, FromUnixTime(Convert.ToInt64(gameData.gameCreation)), gameData.gameDuration);

                //Add it to the panel
                panelMatchHistory.Controls.Add(matchInfoControl);
            }

            tileRefresh.Enabled = true;
        }
Exemple #2
0
        public static ACSMatchList GetMatchList(int startIndex, int endIndex)
        {
            String history     = "";
            String bearerToken = APIRequest.Instance.IDToken;

            Login.Session session;

            if (!Login.GetSession(out session))
            {
                return(null);
            }

            MatchHistory.GetMatchHistoryUrl(out history);

            String acsUrl;

            PlatformConfig.GetConfigSetting("LCUACS", "Endpoint", out acsUrl);
            String region;

            PlatformConfig.GetConfigSetting("LoginDataPacket", "platformId", out region);

            String url = String.Format("{0}/v1/stats/player_history/{1}/{2}?begIndex={3}&endIndex={4}",
                                       acsUrl, region, session.accountId, startIndex, endIndex);

            using (WebClient webClient = new WebClient())
            {
                webClient.Proxy = null; //Because otherwise downloads are slow
                webClient.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)");
                webClient.Headers.Add("Bearer", bearerToken);
                webClient.CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache);
                using (MemoryStream stream = new MemoryStream(webClient.DownloadData(url)))
                {
                    using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
                    {
                        history = reader.ReadToEnd();
                    }
                }
            }
            ACSMatchList matchHistoryList = JsonHandler.LoadJson <ACSMatchList>(history);

            return(matchHistoryList);
        }