Read and set date added. TODO: Insert when reading song.
This commit is contained in:
1 parent
e25ba258d2
commit
51f7ce1cc0
3 files changed
+22
-8
No files matched your search
@@ -354,11 +354,12 @@ namespace Vocaluxe.Base
|
|||||||
if (reader != null)
|
if (reader != null)
|
||||||
reader.Close();
|
reader.Close();
|
||||||
|
|
||||||
command.CommandText = "INSERT INTO Songs (Title, Artist, NumPlayed) " +
|
command.CommandText = "INSERT INTO Songs (Title, Artist, NumPlayed, DateAdded) " +
|
||||||
"VALUES (@title, @artist, @numplayed)";
|
"VALUES (@title, @artist, @numplayed, @dateadded)";
|
||||||
command.Parameters.Add("@title", System.Data.DbType.String, 0).Value = Title;
|
command.Parameters.Add("@title", System.Data.DbType.String, 0).Value = Title;
|
||||||
command.Parameters.Add("@artist", System.Data.DbType.String, 0).Value = Artist;
|
command.Parameters.Add("@artist", System.Data.DbType.String, 0).Value = Artist;
|
||||||
command.Parameters.Add("@numplayed", System.Data.DbType.Int32, 0).Value = DefNumPlayed;
|
command.Parameters.Add("@numplayed", System.Data.DbType.Int32, 0).Value = DefNumPlayed;
|
||||||
|
command.Parameters.Add("@dateadded", System.Data.DbType.Int64, 0).Value = DateTime.Now.Ticks;
|
||||||
command.ExecuteNonQuery();
|
command.ExecuteNonQuery();
|
||||||
|
|
||||||
command.CommandText = "SELECT id FROM Songs WHERE [Title] = @title AND [Artist] = @artist";
|
command.CommandText = "SELECT id FROM Songs WHERE [Title] = @title AND [Artist] = @artist";
|
||||||
@@ -394,11 +395,12 @@ namespace Vocaluxe.Base
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool GetDataBaseSongInfos(int SongID, out string Artist, out string Title, out int NumPlayed, string FilePath)
|
private static bool GetDataBaseSongInfos(int SongID, out string Artist, out string Title, out int NumPlayed, out string DateAdded, string FilePath)
|
||||||
{
|
{
|
||||||
Artist = String.Empty;
|
Artist = String.Empty;
|
||||||
Title = String.Empty;
|
Title = String.Empty;
|
||||||
NumPlayed = 0;
|
NumPlayed = 0;
|
||||||
|
DateAdded = String.Empty;
|
||||||
|
|
||||||
SQLiteConnection connection = new SQLiteConnection();
|
SQLiteConnection connection = new SQLiteConnection();
|
||||||
connection.ConnectionString = "Data Source=" + FilePath;
|
connection.ConnectionString = "Data Source=" + FilePath;
|
||||||
@@ -414,7 +416,7 @@ namespace Vocaluxe.Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
command = new SQLiteCommand(connection);
|
command = new SQLiteCommand(connection);
|
||||||
command.CommandText = "SELECT Artist, Title, NumPlayed FROM Songs WHERE [id] = @id";
|
command.CommandText = "SELECT Artist, Title, NumPlayed, DateAdded FROM Songs WHERE [id] = @id";
|
||||||
command.Parameters.Add("@id", System.Data.DbType.String, 0).Value = SongID;
|
command.Parameters.Add("@id", System.Data.DbType.String, 0).Value = SongID;
|
||||||
|
|
||||||
SQLiteDataReader reader = null;
|
SQLiteDataReader reader = null;
|
||||||
@@ -433,6 +435,7 @@ namespace Vocaluxe.Base
|
|||||||
Artist = reader.GetString(0);
|
Artist = reader.GetString(0);
|
||||||
Title = reader.GetString(1);
|
Title = reader.GetString(1);
|
||||||
NumPlayed = reader.GetInt32(2);
|
NumPlayed = reader.GetInt32(2);
|
||||||
|
DateAdded = reader.GetInt64(3).ToString("dd/MM/yyyy");
|
||||||
reader.Close();
|
reader.Close();
|
||||||
reader.Dispose();
|
reader.Dispose();
|
||||||
|
|
||||||
@@ -613,12 +616,14 @@ namespace Vocaluxe.Base
|
|||||||
CreateHighscoreDBV1(FilePath);
|
CreateHighscoreDBV1(FilePath);
|
||||||
ConvertFrom110(FilePath);
|
ConvertFrom110(FilePath);
|
||||||
UpdateDatabase(1, connection);
|
UpdateDatabase(1, connection);
|
||||||
|
UpdateDatabase(2, connection);
|
||||||
}
|
}
|
||||||
else if (version == 0 && scoresTableExists) //Check for USDX 1.01 or CMD Mod DB
|
else if (version == 0 && scoresTableExists) //Check for USDX 1.01 or CMD Mod DB
|
||||||
{
|
{
|
||||||
CreateHighscoreDBV1(FilePath);
|
CreateHighscoreDBV1(FilePath);
|
||||||
ConvertFrom101(FilePath);
|
ConvertFrom101(FilePath);
|
||||||
UpdateDatabase(1, connection);
|
UpdateDatabase(1, connection);
|
||||||
|
UpdateDatabase(2, connection);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CreateHighscoreDB(FilePath);
|
CreateHighscoreDB(FilePath);
|
||||||
@@ -631,12 +636,14 @@ namespace Vocaluxe.Base
|
|||||||
CreateHighscoreDBV1(FilePath);
|
CreateHighscoreDBV1(FilePath);
|
||||||
ConvertFrom110(FilePath);
|
ConvertFrom110(FilePath);
|
||||||
UpdateDatabase(1, connection);
|
UpdateDatabase(1, connection);
|
||||||
|
UpdateDatabase(2, connection);
|
||||||
}
|
}
|
||||||
else if (version == 0 && scoresTableExists) //Check for USDX 1.01 or CMD Mod DB
|
else if (version == 0 && scoresTableExists) //Check for USDX 1.01 or CMD Mod DB
|
||||||
{
|
{
|
||||||
CreateHighscoreDBV1(FilePath);
|
CreateHighscoreDBV1(FilePath);
|
||||||
ConvertFrom101(FilePath);
|
ConvertFrom101(FilePath);
|
||||||
UpdateDatabase(1, connection);
|
UpdateDatabase(1, connection);
|
||||||
|
UpdateDatabase(2, connection);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CreateHighscoreDB(FilePath);
|
CreateHighscoreDB(FilePath);
|
||||||
@@ -983,6 +990,10 @@ namespace Vocaluxe.Base
|
|||||||
{
|
{
|
||||||
updated &= ConvertV1toV2(connection);
|
updated &= ConvertV1toV2(connection);
|
||||||
}
|
}
|
||||||
|
if (CurrentVersion < 3)
|
||||||
|
{
|
||||||
|
updated &= ConvertV2toV3(connection);
|
||||||
|
}
|
||||||
return updated;
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1017,7 +1028,7 @@ namespace Vocaluxe.Base
|
|||||||
command.Parameters.Add("@DateAdded",System.Data.DbType.Int64, 0).Value = DateTime.Now.Ticks;
|
command.Parameters.Add("@DateAdded",System.Data.DbType.Int64, 0).Value = DateTime.Now.Ticks;
|
||||||
command.ExecuteNonQuery();
|
command.ExecuteNonQuery();
|
||||||
command.CommandText = "UPDATE Version SET [Value] = @version";
|
command.CommandText = "UPDATE Version SET [Value] = @version";
|
||||||
command.Parameters.Add("@version", System.Data.DbType.Int32, 0).Value = 2;
|
command.Parameters.Add("@version", System.Data.DbType.Int32, 0).Value = 3;
|
||||||
command.ExecuteNonQuery();
|
command.ExecuteNonQuery();
|
||||||
command.Dispose();
|
command.Dispose();
|
||||||
|
|
||||||
@@ -1074,9 +1085,9 @@ namespace Vocaluxe.Base
|
|||||||
int shortsong = rSource.GetInt32(7);
|
int shortsong = rSource.GetInt32(7);
|
||||||
int diff = rSource.GetInt32(8);
|
int diff = rSource.GetInt32(8);
|
||||||
|
|
||||||
string artist, title;
|
string artist, title, dateadded;
|
||||||
int numplayed;
|
int numplayed;
|
||||||
if (GetDataBaseSongInfos(songid, out artist, out title, out numplayed, SourceDBPath))
|
if (GetDataBaseSongInfos(songid, out artist, out title, out numplayed, out dateadded, SourceDBPath))
|
||||||
{
|
{
|
||||||
AddScore(player, score, linenr, date, medley, duet, shortsong, diff, artist, title, numplayed, _HighscoreFilePath);
|
AddScore(player, score, linenr, date, medley, duet, shortsong, diff, artist, title, numplayed, _HighscoreFilePath);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
public const int iBuild = 72; // Increase on every published version! Never Reset!
|
public const int iBuild = 72; // Increase on every published version! Never Reset!
|
||||||
|
|
||||||
public const int iDatabaseHighscoreVersion = 2;
|
public const int iDatabaseHighscoreVersion = 3;
|
||||||
public const int iDatabaseCoverVersion = 1;
|
public const int iDatabaseCoverVersion = 1;
|
||||||
public const int iDatabaseCreditsRessourcesVersion = 1;
|
public const int iDatabaseCreditsRessourcesVersion = 1;
|
||||||
|
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ namespace Vocaluxe.Menu.SongMenu
|
|||||||
public List<string> Genre = new List<string>();
|
public List<string> Genre = new List<string>();
|
||||||
public string Year = "0000";
|
public string Year = "0000";
|
||||||
public List<string> Language = new List<string>();
|
public List<string> Language = new List<string>();
|
||||||
|
public string DateAdded;
|
||||||
|
|
||||||
// Notes
|
// Notes
|
||||||
public CNotes Notes = new CNotes();
|
public CNotes Notes = new CNotes();
|
||||||
@@ -277,6 +278,8 @@ namespace Vocaluxe.Menu.SongMenu
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.Notes = new CNotes(song.Notes);
|
this.Notes = new CNotes(song.Notes);
|
||||||
|
|
||||||
|
this.DateAdded = song.DateAdded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetMP3()
|
public string GetMP3()
|
||||||
|
|||||||
Reference in new issue
Block a user