public void Deserialize(BinaryAPIReader reader) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } HostOsuId = reader.ReadLong(); Name = reader.ReadString(); Acronym = reader.ReadString(); Thread = reader.ReadString(); CountryCode = reader.ReadString(); Start = reader.ReadDate(); End = reader.ReadDate(); RankMin = reader.ReadLong(); RankMax = reader.ReadLong(); int teams = reader.ReadInt(); for (int i = 0; i < teams; i++) { GlobalStatsTeam team = new GlobalStatsTeam(); team.Deserialize(reader); Teams.Add(team); } }
public IHttpContext Submit(IHttpContext c) { try { if (!CheckApiKey(c)) { return(c); } else if (GetApiKeyAccess(c) <= AccessLevel.Host) { Respond(HttpStatusCode.Forbidden, "Not Enough permissions", c); return(c); } List <long> userIds = new List <long>(); BinaryAPIReader reader = new BinaryAPIReader(((HttpRequest)c.Request).Advanced.InputStream); GlobalStatsTournament tourneystats = new GlobalStatsTournament(); tourneystats.Deserialize(reader); using DBContext dbc = new DBContext(); GSTournament tourney = dbc.GSTournament.Add(new GSTournament(tourneystats.HostOsuId, tourneystats.Name, tourneystats.Acronym, tourneystats.Thread, tourneystats.CountryCode, tourneystats.Start, tourneystats.End, tourneystats.RankMin, tourneystats.RankMax)).Entity; dbc.SaveChanges(); foreach (var teamstats in tourneystats.Teams) { GSTeam team = dbc.GSTeam.Add(new GSTeam(tourney.Id, teamstats.Placement, teamstats.Name)).Entity; dbc.SaveChanges(); foreach (long userId in teamstats.OsuUserIds) { GSTeamMember member = new GSTeamMember(team.Id, userId); dbc.GSTeamMember.Add(member); userIds.Add(userId); } } dbc.SaveChanges(); Task.Run(() => SkyBot.GlobalStatistics.GSStatisticHandler.UpdatePlayerProfiles(tourney.Id)).ConfigureAwait(false); Respond(HttpStatusCode.Ok, "Submitted and updated", c); return(c); } catch (Exception ex) { Logger.Log(ex, LogLevel.Error); Respond(HttpStatusCode.InternalServerError, ex.ToString(), c); return(c); } }
public void Deserialize(BinaryAPIReader reader) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } Username = reader.ReadString(); OsuId = reader.ReadLong(); BWSRank = reader.ReadDouble(); TournamentWins = reader.ReadInt(); LastPlacement = reader.ReadString(); TournamentsPlayed = reader.ReadInt(); BadgeCount = reader.ReadInt(); LastUpdated = reader.ReadDate(); }
public void Deserialize(BinaryAPIReader reader) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } Placement = reader.ReadInt(); Name = reader.ReadString(); int users = reader.ReadInt(); for (int i = 0; i < users; i++) { OsuUserIds.Add(reader.ReadLong()); } }