public AllRunes GetRunes() { string json = ""; DALSoloQ dsq = new DALSoloQ(); json = dsq.GetRunesJson(ConfigurationManager.AppSettings["PatchVersion"]); if (string.IsNullOrEmpty(json)) { using (WebClient wc = new WebClient()) { wc.Encoding = Encoding.UTF8; var url = ConfigurationManager.AppSettings["UrlRunes"].Replace("[patchversion]", ConfigurationManager.AppSettings["PatchVersion"]); json = wc.DownloadString(url); Thread.Sleep(100); //dsq.SaveRunesJson(json, patchVersion); } } var obj = JArray.Parse(json); json = obj.ToString(); var runes = JsonConvert.DeserializeObject <SlotsJson[]>(json); var arunes = BuildAllRunes(runes); return(arunes); }
//timelanes = liste de frames ?? => apparament oui public List <Frame> GetTimeLinesMatchInfos(string gameId = "4521496705") { //4521496705 => gameId exemple string json = ""; DALSoloQ dsq = new DALSoloQ(); json = dsq.GetTimelinesMatchInfos(gameId); if (string.IsNullOrEmpty(json)) { int retry = 0; while (retry < 4) { try { using (WebClient wc = new WebClient()) { wc.Encoding = Encoding.UTF8; var url = ConfigurationManager.AppSettings["UrlTimelineMatch"] + gameId + "?&api_key=" + ConfigurationManager.AppSettings["ApiRiotKey"]; json = wc.DownloadString(url); Thread.Sleep(100); dsq.SaveTimelinesMatchInfos(json, gameId); break; } } catch (Exception ex) { string e = ex.Message; if (e.ToLower().Contains("too many")) { Thread.Sleep(2000); retry++; } if (e.ToLower().Contains("504")) { Thread.Sleep(2000); retry++; } if (retry == 3) { throw; } } } } var obj = JObject.Parse(json); json = obj.SelectToken("frames").ToString(); var timelinesJson = JsonConvert.DeserializeObject <List <FrameJson> >(json); var timeline = BuildListFrame(timelinesJson);//=> dans le json : c'est pas une liste de participantframe: cette méthode me permet de reconstruire l'objet return(timeline); }
public MatchInfos GetMatchInfo(string gameId) { //4521496705 => gameId exemple string json = ""; DALSoloQ dsq = new DALSoloQ(); json = dsq.GetMatchInfos(gameId); if (string.IsNullOrEmpty(json)) { int retry = 0; while (retry < 4) { try { using (WebClient wc = new WebClient()) { wc.Encoding = Encoding.UTF8; var url = ConfigurationManager.AppSettings["UrlMatch"] + gameId + "?&api_key=" + ConfigurationManager.AppSettings["ApiRiotKey"]; json = wc.DownloadString(url); Thread.Sleep(100); dsq.SaveMatchInfos(json, gameId); break; } } catch (Exception ex) { string e = ex.Message; if (e.ToLower().Contains("too many")) { Thread.Sleep(2000); retry++; } if (e.ToLower().Contains("504")) { Thread.Sleep(2000); retry++; } if (retry == 3) { throw; } } } } var obj = JObject.Parse(json); json = obj.ToString(); var match = JsonConvert.DeserializeObject <MatchInfos>(json); return(match); }