private void loadLeaderboards(object state) { foreach (string shard in shards) { try { foreach (Event ev in wle.Events) { string personas = mypers[shard]; { var list = (bForce || bEventsChanged ? stattypes.Keys.ToList<int>() : new List<int>() { 2 }); foreach (int lt in list) { var list2 = (bForce || bEventsChanged ? stattypes[lt] : new List<int>() { 0, 1 }); foreach (int rf in list2) { for (int et = 1; et < 3; et++) { string uri = uribase + string.Format("/ws/game/nfsw/leaderboards?et="+ et +"&eid={0}<=" + lt + "&rf=" + rf + "&dn={1}&shard={2}&output=json&now=", ev.eventId, personas, shard) + DateTime.Now.Ticks.ToString(); try { HttpWebRequest hwrq = WebRequest.Create(uri) as HttpWebRequest; hwrq.Method = "POST"; HttpWebResponse hwrs = hwrq.GetResponse() as HttpWebResponse; Stream s = hwrs.GetResponseStream(); StreamReader sr = new StreamReader(s); string json = sr.ReadToEnd(); dynamic wlbobj = JObject.Parse(json); if (wlbobj != null && wlbobj.worldLeaderboards != null) { foreach (dynamic obj in wlbobj.worldLeaderboards) { if (obj != null) { worldLeaderboards wlb = new worldLeaderboards() { car = new worldCars() { carName = obj.carName, make = obj.make }, createdDate = new worldLastLogin() { date = obj.createdDate.date, day = obj.createdDate.day, hours = obj.createdDate.hours, minutes = obj.createdDate.minutes, month = obj.createdDate.month, seconds = obj.createdDate.seconds, time = obj.createdDate.time, timezoneOffset = obj.createdDate.timezoneOffset, year = obj.createdDate.year }, eventDurationMilliseconds = obj.eventDurationMilliseconds, eventType = obj.eventType, persona = new Driver() { DriverProfile = new worldDriverProfile() { name = obj.persona.personaName, level = obj.persona.level, personaId = obj.persona.personaId } }, Event = new Event() { eventId = obj.eventId } }; if (!wllist.Any(x => x.createdDate.time == wlb.createdDate.time)) wllist.Add(wlb); } } } } catch { } } } } } } } catch(Exception ex) {} } fixLeaderboards(null); this.Invoke((MethodInvoker)delegate { cntdone++; }); }
private void loadLeaderboards(object state) { foreach (string shard in shards) { try { foreach (Event ev in wle.Events) { string personas = mypers[shard]; { var list = (bForce || bEventsChanged ? stattypes.Keys.ToList <int>() : new List <int>() { 2 }); foreach (int lt in list) { var list2 = (bForce || bEventsChanged ? stattypes[lt] : new List <int>() { 0, 1 }); foreach (int rf in list2) { for (int et = 1; et < 3; et++) { string uri = uribase + string.Format("/ws/game/nfsw/leaderboards?et=" + et + "&eid={0}<=" + lt + "&rf=" + rf + "&dn={1}&shard={2}&output=json&now=", ev.eventId, personas, shard) + DateTime.Now.Ticks.ToString(); try { HttpWebRequest hwrq = WebRequest.Create(uri) as HttpWebRequest; hwrq.Method = "POST"; HttpWebResponse hwrs = hwrq.GetResponse() as HttpWebResponse; Stream s = hwrs.GetResponseStream(); StreamReader sr = new StreamReader(s); string json = sr.ReadToEnd(); dynamic wlbobj = JObject.Parse(json); if (wlbobj != null && wlbobj.worldLeaderboards != null) { foreach (dynamic obj in wlbobj.worldLeaderboards) { if (obj != null) { worldLeaderboards wlb = new worldLeaderboards() { car = new worldCars() { carName = obj.carName, make = obj.make }, createdDate = new worldLastLogin() { date = obj.createdDate.date, day = obj.createdDate.day, hours = obj.createdDate.hours, minutes = obj.createdDate.minutes, month = obj.createdDate.month, seconds = obj.createdDate.seconds, time = obj.createdDate.time, timezoneOffset = obj.createdDate.timezoneOffset, year = obj.createdDate.year }, eventDurationMilliseconds = obj.eventDurationMilliseconds, eventType = obj.eventType, persona = new Driver() { DriverProfile = new worldDriverProfile() { name = obj.persona.personaName, level = obj.persona.level, personaId = obj.persona.personaId } }, Event = new Event() { eventId = obj.eventId } }; if (!wllist.Any(x => x.createdDate.time == wlb.createdDate.time)) { wllist.Add(wlb); } } } } } catch { } } } } } } } catch (Exception ex) {} } fixLeaderboards(null); this.Invoke((MethodInvoker) delegate { cntdone++; }); }