private void ShowHistory() { // Check cache string cacheFile = $"{Pid}_history"; if (!base.CacheFileExpired(cacheFile, 30)) { base.SendCachedResponse(cacheFile); return; } // Create our Model PlayerHistoryModel Model = new PlayerHistoryModel(Client); Model.Player = Rows[0]; Model.SearchBarValue = Pid.ToString(); // load data Rows = Database.Query("SELECT * FROM player_history WHERE id=@P0 ORDER BY timestamp DESC LIMIT 50", Pid); Model.History = new List <PlayerHistory>(Rows.Count); // Create our History objects foreach (Dictionary <string, object> row in Rows) { int timeStamp = Int32.Parse(row["timestamp"].ToString()); // Try and get our Map id from the Round Histroy table since the MapId // isnt stored in the player histroy table string mapName = "Unknown Map"; int iMapId = 0; object mapId = Database.ExecuteScalar("SELECT mapid FROM round_history WHERE timestamp=@P0", timeStamp); if (mapId != null && Int32.TryParse(mapId.ToString(), out iMapId) && Bf2StatsData.Maps.ContainsKey(iMapId)) { mapName = Bf2StatsData.Maps[iMapId]; } // Set history data Model.History.Add(new PlayerHistory() { Date = DateTime.Now.FromUnixTimestamp(timeStamp), Score = Int32.Parse(row["score"].ToString()), CmdScore = Int32.Parse(row["cmdscore"].ToString()), SkillScore = Int32.Parse(row["skillscore"].ToString()), TeamScore = Int32.Parse(row["teamscore"].ToString()), TimePlayed = Int32.Parse(row["time"].ToString()), Kills = Int32.Parse(row["kills"].ToString()), Deaths = Int32.Parse(row["deaths"].ToString()), Rank = Int32.Parse(row["rank"].ToString()), MapName = mapName }); } // Send the response base.SendTemplateResponse("player_history", typeof(PlayerHistoryModel), Model, cacheFile); }
private void ShowHistory() { // Check cache string cacheFile = $"{Pid}_history"; if (!base.CacheFileExpired(cacheFile, 30)) { base.SendCachedResponse(cacheFile); return; } // Create our Model PlayerHistoryModel Model = new PlayerHistoryModel(Client); Model.Player = Rows[0]; Model.SearchBarValue = Pid.ToString(); // load data Rows = Database.Query("SELECT * FROM player_history WHERE id=@P0 ORDER BY timestamp DESC LIMIT 50", Pid); Model.History = new List<PlayerHistory>(Rows.Count); // Create our History objects foreach (Dictionary<string, object> row in Rows) { int timeStamp = Int32.Parse(row["timestamp"].ToString()); // Try and get our Map id from the Round Histroy table since the MapId // isnt stored in the player histroy table string mapName = "Unknown Map"; int iMapId = 0; object mapId = Database.ExecuteScalar("SELECT mapid FROM round_history WHERE timestamp=@P0", timeStamp); if (mapId != null && Int32.TryParse(mapId.ToString(), out iMapId) && Bf2StatsData.Maps.ContainsKey(iMapId)) { mapName = Bf2StatsData.Maps[iMapId]; } // Set history data Model.History.Add(new PlayerHistory() { Date = DateTime.Now.FromUnixTimestamp(timeStamp), Score = Int32.Parse(row["score"].ToString()), CmdScore = Int32.Parse(row["cmdscore"].ToString()), SkillScore = Int32.Parse(row["skillscore"].ToString()), TeamScore = Int32.Parse(row["teamscore"].ToString()), TimePlayed = Int32.Parse(row["time"].ToString()), Kills = Int32.Parse(row["kills"].ToString()), Deaths = Int32.Parse(row["deaths"].ToString()), Rank = Int32.Parse(row["rank"].ToString()), MapName = mapName }); } // Send the response base.SendTemplateResponse("player_history", typeof(PlayerHistoryModel), Model, cacheFile); }