public bool GetPlayerArenaInfo(SQLPlayerData _PlayerData, out SQLArenaInfo _ResultArenaInfo) { _ResultArenaInfo = new SQLArenaInfo(0, 0, 0); if (_PlayerData.PlayerArenaID == 0) { return(false); } var conn = OpenConnection(); try { const int TEAM2V2_COLUMN = 0; const int TEAM3V3_COLUMN = 1; const int TEAM5V5_COLUMN = 2; using (var cmd = new NpgsqlCommand("SELECT team_2v2, team_3v3, team_5v5 FROM PlayerArenaInfoTable WHERE id=:ID", conn)) { { var idParam = new NpgsqlParameter("ID", NpgsqlDbType.Integer); idParam.Value = (int)_PlayerData.PlayerArenaID; cmd.Parameters.Add(idParam); } using (var reader = cmd.ExecuteReader()) { if (reader.Read() == true) { _ResultArenaInfo.Team2v2 = reader.GetInt32(TEAM2V2_COLUMN); _ResultArenaInfo.Team3v3 = reader.GetInt32(TEAM3V3_COLUMN); _ResultArenaInfo.Team5v5 = reader.GetInt32(TEAM5V5_COLUMN); return(true); } } } } finally { CloseConnection(); } return(false); }
public bool GetPlayerArenaData(SQLArenaInfo _ArenaInfo, out PlayerData.ArenaData _ResultArenaData) { _ResultArenaData = null; if (_ArenaInfo.IsNull() == true) { return(false); } int[] teamIDs = new int[3]; int teamIDsCounter = 0; if (_ArenaInfo.Team2v2 != 0) { teamIDs[teamIDsCounter++] = _ArenaInfo.Team2v2; } if (_ArenaInfo.Team3v3 != 0) { teamIDs[teamIDsCounter++] = _ArenaInfo.Team3v3; } if (_ArenaInfo.Team5v5 != 0) { teamIDs[teamIDsCounter++] = _ArenaInfo.Team5v5; } if (teamIDs.Length > teamIDsCounter) { int[] oldTeamIDs = teamIDs; teamIDs = new int[teamIDsCounter]; for (int i = 0; i < teamIDsCounter; ++i) { teamIDs[i] = oldTeamIDs[i]; } } var conn = OpenConnection(); try { const int ID_COLUMN = 0; const int TEAMNAME_COLUMN = 1; const int TEAMRATING_COLUMN = 2; const int GAMESPLAYED_COLUMN = 3; const int GAMESWON_COLUMN = 4; const int PLAYERGAMESPLAYED_COLUMN = 5; const int PLAYERRATING_COLUMN = 6; using (var cmd = new NpgsqlCommand("SELECT id, teamname, teamrating, gamesplayed, gameswon, playergamesplayed, playerrating FROM PlayerArenaDataTable WHERE id = ANY(:IDs)", conn)) { { var idsParam = new NpgsqlParameter("IDs", NpgsqlDbType.Array | NpgsqlDbType.Integer); idsParam.Value = teamIDs; cmd.Parameters.Add(idsParam); } using (var reader = cmd.ExecuteReader()) { if (reader.HasRows == true) { _ResultArenaData = new PlayerData.ArenaData(); while (reader.Read() == true) { var arenaTeamData = new PlayerData.ArenaPlayerData(); int id = reader.GetInt32(ID_COLUMN); arenaTeamData.TeamName = reader.GetString(TEAMNAME_COLUMN); arenaTeamData.TeamRating = reader.GetInt32(TEAMRATING_COLUMN); arenaTeamData.GamesPlayed = reader.GetInt32(GAMESPLAYED_COLUMN); arenaTeamData.GamesWon = reader.GetInt32(GAMESWON_COLUMN); arenaTeamData.PlayerPlayed = reader.GetInt32(PLAYERGAMESPLAYED_COLUMN); arenaTeamData.PlayerRating = reader.GetInt32(PLAYERRATING_COLUMN); if (id == _ArenaInfo.Team2v2) { _ResultArenaData.Team2v2 = arenaTeamData; } if (id == _ArenaInfo.Team3v3) { _ResultArenaData.Team3v3 = arenaTeamData; } if (id == _ArenaInfo.Team5v5) { _ResultArenaData.Team5v5 = arenaTeamData; } } return(true); } } } } finally { CloseConnection(); } return(false); }