public void CreateRecord(BMSManager bmsManager, string playerName = DefaultPlayerName) { const string queryCommandText = "SELECT `play_count`, `combos`, `score` FROM `records` WHERE `hash` = ? AND `player_name` = ? AND `channel_config` = ?;"; const string updateCommandText = "UPDATE `records` SET `combos` = ?, `score` = ?, `play_count` = ?, `time` = (strftime('%s', 'now')) WHERE " + "`hash` = ? AND `player_name` = ? AND `channel_config` = ?;"; const string insertCommandText = "INSERT INTO `records`(`hash`, `player_name`, `channel_config`, `combos`, `score`, `play_count`)" + "VALUES (?, ?, ?, ?, ?, ?);"; string bmsHash = bmsManager.GetHash(SongInfoLoader.CurrentEncoding, hashAlgorithm); // string timeHash = DateTime.UtcNow.Ticks.ToBaseString(32); int channelConfig = GetAdoptedChannelHash(bmsManager.GetAllAdoptedChannels()); int playCount = 0; int maxCombos = bmsManager.MaxCombos; int maxScore = bmsManager.Score; OpenDatabase(); foreach (var record in database.QuerySql(queryCommandText, bmsHash, playerName, channelConfig)) { playCount += record.GetValueAsInt32(0); maxCombos = Math.Max(maxCombos, record.GetValueAsInt32(1)); maxScore = Math.Max(maxScore, record.GetValueAsInt32(2)); } if (playCount > 0) { database.RunSql(updateCommandText, maxCombos, maxScore, playCount + 1, bmsHash, playerName, channelConfig ); } else { database.RunSql(insertCommandText, bmsHash, playerName, channelConfig, maxCombos, maxScore, playCount + 1 ); } }