diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index 3c2867a2..77d1fc32 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -72,6 +72,31 @@ namespace Vocaluxe.Base #region Highscores + public static bool GetDataBaseSongInfos(string artist, string title, out int numPlayed, out string dateAdded) + { + string sArtist = string.Empty; + string sTitle = string.Empty; + int songID = -1; + using (SQLiteConnection connection = new SQLiteConnection()) + { + connection.ConnectionString = "Data Source=" + _HighscoreFilePath; + + try + { + connection.Open(); + } + catch (Exception) + { + } + + using (SQLiteCommand command = new SQLiteCommand(connection)) + { + songID = _GetDataBaseSongID(artist, title, 0, command); + } + } + return _GetDataBaseSongInfos(songID, out sArtist, out sTitle, out numPlayed, out dateAdded, _HighscoreFilePath); + } + public static void IncreaseSongCounter(SPlayer player) { using (SQLiteConnection connection = new SQLiteConnection()) @@ -330,7 +355,7 @@ namespace Vocaluxe.Base if (reader != null) reader.Close(); - command.CommandText = "INSERT INTO Songs (Title, Artist, NumPlayedm DateAdded) " + + command.CommandText = "INSERT INTO Songs (Title, Artist, NumPlayed, DateAdded) " + "VALUES (@title, @artist, @numplayed, @dateadded)"; command.Parameters.Add("@title", DbType.String, 0).Value = title; command.Parameters.Add("@artist", DbType.String, 0).Value = artist; diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index 61a997ea..cd9fb657 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -782,6 +782,11 @@ namespace Vocaluxe.Base { return CDataBase.GetCover(fileName, ref texture, coverSize); } + + public bool GetDataBaseSongInfos(string artist, string title, out int numPlayed, out string dateAdded) + { + return CDataBase.GetDataBaseSongInfos(artist, title, out numPlayed, out dateAdded); + } } class CBcontrollers : IControllers diff --git a/VocaluxeLib/IBasic.cs b/VocaluxeLib/IBasic.cs index 2c85ba9d..703dc18d 100644 --- a/VocaluxeLib/IBasic.cs +++ b/VocaluxeLib/IBasic.cs @@ -262,6 +262,7 @@ namespace VocaluxeLib public interface IDataBase { bool GetCover(string fileName, ref CTexture texture, int coverSize); + bool GetDataBaseSongInfos(string artist, string title, out int numPlayed, out string dateAdded); } public interface IControllers diff --git a/VocaluxeLib/Songs/CSong.cs b/VocaluxeLib/Songs/CSong.cs index 9af33523..9b13585b 100644 --- a/VocaluxeLib/Songs/CSong.cs +++ b/VocaluxeLib/Songs/CSong.cs @@ -148,6 +148,7 @@ namespace VocaluxeLib.Songs public readonly List Language = new List(); public string DateAdded = ""; + public int NumPlayed = 0; // Notes public readonly CNotes Notes = new CNotes(); @@ -534,6 +535,8 @@ namespace VocaluxeLib.Songs sr.Dispose(); _CheckFiles(); + CBase.DataBase.GetDataBaseSongInfos(Artist, Title, out NumPlayed, out DateAdded); + //Before saving this tags to .txt: Check, if ArtistSorting and Artist are equal, then don't save this tag. if (ArtistSorting == "") ArtistSorting = Artist;