public void CreateMatchResult(MatchResultData data) { // TODO: Refactor string MySql queries var query = "INSERT INTO MatchResult (MID, UID, Kills, Deaths, Wins, Losses)" + "VALUES('" + data.MID + "', '" + data.UID + "'," + data.Kills + "," + data.Deaths + "," + data.Wins + "," + data.Losses + "', Date('" + data.DateOfMatch.Date.ToString("yyyy-MM-dd HH:mm:ss") + "'))"; using (_mySqlConnection = new MySqlConnection(_mySqlConnectionManager.ConnectionString())) { using (var command = new MySqlCommand(query, _mySqlConnection)) { try { _mySqlConnection.Open(); command.ExecuteNonQuery(); _mySqlConnection.Close(); } catch (SqlException e) { throw new Exception(e.ToString()); } } } }
private Event Map_match_result(StoreMatchResultCommandContextModel ctx_model, MatchResultNotificationCommand cmd) { var match_result_data = new MatchResultData() { Match_id = cmd.MatchId, Results = cmd.Results.Select(result => (events.data.SetResult)result).ToList() }; return(new MatchPlayed(nameof(MatchPlayed), new TournamentContext(ctx_model.Tournament_id, nameof(TournamentContext)), match_result_data)); }
void updateTournamentResults(MatchSummary summary) { MatchResultData result = new MatchResultData(); result.Team1.Alias = summary.Team1.Alias; result.Team1.Score = summary.Team1.Score; result.Team2.Alias = summary.Team2.Alias; result.Team2.Score = summary.Team2.Score; OnlineTournamentHandler.AddMatchResult(result); }
public void CreateMatchResult(Guid uid, int kills, int deaths, int wins, int losses) { var data = new MatchResultData() { MID = Guid.NewGuid(), UID = uid, Kills = kills, Deaths = deaths, Wins = wins, Losses = losses, DateOfMatch = DateTime.Now }; _dataServices.CreateMatchResult(data); }
public MatchResultData GetMatchResultByID(Guid mid) { var data = new MatchResultData(); // TODO: Refactor string MySql queries var query = "SELECT * FROM MatchResult WHERE MID = '" + mid + "' LIMIT 1"; using (_mySqlConnection = new MySqlConnection(_mySqlConnectionManager.ConnectionString())) { using (var command = new MySqlCommand(query, _mySqlConnection)) { try { _mySqlConnection.Open(); using (var reader = command.ExecuteReader()) { if (reader.Read()) { data = new MatchResultData() { DateOfMatch = DateTime.Parse(reader.GetString(reader.GetOrdinal("DateOfMatch"))), MID = new Guid(reader.GetString(reader.GetOrdinal("UID"))), UID = new Guid(reader.GetString(reader.GetOrdinal("UID"))), Kills = reader.GetInt32(reader.GetOrdinal("Kills")), Deaths = reader.GetInt32(reader.GetOrdinal("Deaths")), Wins = reader.GetInt32(reader.GetOrdinal("Wins")), Losses = reader.GetInt32(reader.GetOrdinal("Losses")) }; } } _mySqlConnection.Close(); } catch (SqlException e) { throw new Exception(e.ToString()); } } } return data; }
void onMatchResult(MatchResultData result) { updateRoundSection(); }
// TODO: Review Function Necessity, should not be able to modify results public void UpdateMatchResult(MatchResultData data) { // TODO: Refactor string MySql queries var query = "UPDATE MatchResult" + "SET UID='" + data.UID + "', " + "Kills=" + data.Kills + ", Deaths=" + data.Deaths + ", " + "Wins=" + data.Wins + ", Losses=" + data.Losses + "WHERE MID='" + data.MID + "'"; using (_mySqlConnection = new MySqlConnection(_mySqlConnectionManager.ConnectionString())) { using (var command = new MySqlCommand(query, _mySqlConnection)) { try { _mySqlConnection.Open(); command.ExecuteNonQuery(); _mySqlConnection.Close(); } catch (SqlException e) { throw new Exception(e.ToString()); } } } }
public async Task <string> GetMatch(Enumeration.GameMode gameMode, Guid id, string gamerTag) { if (_settings.CacheResults) { var result = await _db.FindAsync <MatchResultData>(id.ToString()); if (result != null) { return(result.Data); } } MatchEvents matchEvents = await _statsRepository.GetEventsForMatch(id); matchEvents.GameEvents = matchEvents.GameEvents.Where(e => e.EventName == Enumeration.EventType.Death).ToList(); MatchResult match = null; switch (gameMode) { case Enumeration.GameMode.Arena: var arenaMatch = await _statsRepository.GetArenaMatch(id); match = await GetMatchResult(arenaMatch, gamerTag, matchEvents); break; case Enumeration.GameMode.Campaign: var campaignMatch = await _statsRepository.GetCampaignMatch(id); match = GetMatchResult(campaignMatch, gamerTag, matchEvents); break; case Enumeration.GameMode.Custom: var customMatch = await _statsRepository.GetCustomMatch(id); match = await GetMatchResult(customMatch, gamerTag, matchEvents); break; case Enumeration.GameMode.Warzone: var warzoneMatch = await _statsRepository.GetWarzoneMatch(id); match = await GetMatchResult(warzoneMatch, gamerTag, matchEvents); break; default: return(null); } if (match != null) { match.GameMode = gameMode; match.Id = id; } var matchResult = new MatchResultData(id.ToString(), match); if (_settings.CacheResults) { _db.InsertAsync(matchResult); await _db.CommitChanges(); } return(matchResult.Data); }