예제 #1
0
 private string buildSongUpdateQueryString(SongInfo song)
 {
     var query = new StringBuilder(UPDATE_SONG);
     query.Append("`album` = ");
     query.Append("'" + addEscapeChar(song.Album) + "',");
     query.Append("`artist` = ");
     query.Append("'" + addEscapeChar(song.Artist) + "',");
     query.Append("`comment` = ");
     query.Append("'" + addEscapeChar(song.Comment) + "',");
     query.Append("`composer` = ");
     query.Append("'" + addEscapeChar(song.Composer) + "',");
     query.Append("`genre` = ");
     query.Append("'" + addEscapeChar(song.Genre) + "',");
     query.Append("`songName` = ");
     query.Append("'" + addEscapeChar(song.SongName) + "',");
     query.Append("`duration` = ");
     query.Append("'" + addEscapeChar(song.Duration.ToString()) + "',");
     query.Append("`bpm` = ");
     query.Append(song.BeatsPerMinute + ",");
     query.Append("`playCount` = ");
     query.Append(song.PlayCount + ",");
     query.Append("`trackNumber` = ");
     query.Append(song.TrackNumber + ",");
     query.Append("`year` = ");
     query.Append(song.Year);
     query.Append(" WHERE `filePath` = ");
     query.Append("'" + addEscapeChar(song.FilePath) + "';");
     return query.ToString();
 }
예제 #2
0
        public List<SongInfo> readSongInfoQuery(string query)
        {
            List<SongInfo> searchResults = new List<SongInfo>();

            if (this.OpenConnection())
            {
                var command = new MySqlCommand(query, connection);
                MySqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    SongInfo songItem = new SongInfo(reader["filePath"].ToString(), Convert.ToUInt32(reader["idSongInfo"]));

                    searchResults.Add(songItem);
                }
                reader.Close();
                this.CloseConnection();
            }
            else
            {
                throw new Exception("[Repository] Error opening connection to MySQL Database");
            }

            return searchResults;
        }
예제 #3
0
 private string buildSongInsertQueryString(SongInfo song)
 {
     var query = new StringBuilder(INSERT_SONG_INFO);
     query.Append("'" + addEscapeChar(song.Album) + "',");
     query.Append("'" + addEscapeChar(song.Artist) + "',");
     query.Append("'" + addEscapeChar(song.Comment) + "',");
     query.Append("'" + addEscapeChar(song.Composer) + "',");
     query.Append("'" + addEscapeChar(song.FilePath) + "',");
     query.Append("'" + addEscapeChar(song.Genre) + "',");
     query.Append("'" + addEscapeChar(song.SongName) + "',");
     query.Append("'" + addEscapeChar(song.Duration.ToString()) + "',");
     query.Append(song.BeatsPerMinute + ",");
     query.Append(song.PlayCount + ",");
     query.Append(song.TrackNumber + ",");
     query.Append(song.Year + ")");
     return query.ToString();
 }