song class 修改
This commit is contained in:
parent
db9ab8231f
commit
b5f46e2f27
@ -25,30 +25,45 @@ namespace DBObj
|
|||||||
public string ArtistBPinyin { get; set; }
|
public string ArtistBPinyin { get; set; }
|
||||||
public int HumanVoice { get; set; }
|
public int HumanVoice { get; set; }
|
||||||
|
|
||||||
|
/*
|
||||||
public SongData(string songNumber, string category, string song, double plays, string artistA, string artistB, string artistACategory, string artistBCategory, DateTime addedTime, string songFilePathHost1, string songFilePathHost2, string phoneticNotation, string pinyinNotation, string artistAPhonetic, string artistBPhonetic, string artistASimplified, string artistBSimplified, string songSimplified, string songGenre, string artistAPinyin, string artistBPinyin, int humanVoice)
|
public SongData(string songNumber, string category, string song, double plays, string artistA, string artistB, string artistACategory, string artistBCategory, DateTime addedTime, string songFilePathHost1, string songFilePathHost2, string phoneticNotation, string pinyinNotation, string artistAPhonetic, string artistBPhonetic, string artistASimplified, string artistBSimplified, string songSimplified, string songGenre, string artistAPinyin, string artistBPinyin, int humanVoice)
|
||||||
{
|
{
|
||||||
SongNumber = songNumber;
|
SongNumber = songNumber;
|
||||||
Category = category;
|
// Category = category;
|
||||||
Song = song;
|
Song = song;
|
||||||
Plays = plays;
|
// Plays = plays;
|
||||||
ArtistA = artistA;
|
ArtistA = artistA;
|
||||||
ArtistB = artistB;
|
ArtistB = artistB;
|
||||||
ArtistACategory = artistACategory;
|
//ArtistACategory = artistACategory;
|
||||||
ArtistBCategory = artistBCategory;
|
//ArtistBCategory = artistBCategory;
|
||||||
AddedTime = addedTime;
|
//AddedTime = addedTime;
|
||||||
|
SongFilePathHost1 = songFilePathHost1;
|
||||||
|
SongFilePathHost2 = songFilePathHost2;
|
||||||
|
//PhoneticNotation = phoneticNotation;
|
||||||
|
//PinyinNotation = pinyinNotation;
|
||||||
|
//ArtistAPhonetic = artistAPhonetic;
|
||||||
|
//ArtistBPhonetic = artistBPhonetic;
|
||||||
|
ArtistASimplified = artistASimplified;
|
||||||
|
ArtistBSimplified = artistBSimplified;
|
||||||
|
SongSimplified = songSimplified;
|
||||||
|
//SongGenre = songGenre;
|
||||||
|
//ArtistAPinyin = artistAPinyin;
|
||||||
|
//ArtistBPinyin = artistBPinyin;
|
||||||
|
HumanVoice = humanVoice;
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
public SongData(string songNumber, string song, string artistA, string artistB, string songFilePathHost1, string songFilePathHost2, string artistASimplified, string artistBSimplified, string songSimplified, int humanVoice)
|
||||||
|
{
|
||||||
|
SongNumber = songNumber;
|
||||||
|
Song = song;
|
||||||
|
ArtistA = artistA;
|
||||||
|
ArtistB = artistB;
|
||||||
SongFilePathHost1 = songFilePathHost1;
|
SongFilePathHost1 = songFilePathHost1;
|
||||||
SongFilePathHost2 = songFilePathHost2;
|
SongFilePathHost2 = songFilePathHost2;
|
||||||
PhoneticNotation = phoneticNotation;
|
|
||||||
PinyinNotation = pinyinNotation;
|
|
||||||
ArtistAPhonetic = artistAPhonetic;
|
|
||||||
ArtistBPhonetic = artistBPhonetic;
|
|
||||||
ArtistASimplified = artistASimplified;
|
ArtistASimplified = artistASimplified;
|
||||||
ArtistBSimplified = artistBSimplified;
|
ArtistBSimplified = artistBSimplified;
|
||||||
SongSimplified = songSimplified;
|
SongSimplified = songSimplified;
|
||||||
SongGenre = songGenre;
|
|
||||||
ArtistAPinyin = artistAPinyin;
|
|
||||||
ArtistBPinyin = artistBPinyin;
|
|
||||||
HumanVoice = humanVoice;
|
HumanVoice = humanVoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,55 +110,6 @@ namespace DBObj
|
|||||||
return AllSongs.Where(song => song.ArtistA == artistName || song.ArtistB == artistName).ToList();
|
return AllSongs.Where(song => song.ArtistA == artistName || song.ArtistB == artistName).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool CheckIfPhoneNumberExists(string phoneNumber)
|
|
||||||
{
|
|
||||||
string databaseFileName = "KSongDatabase.db";
|
|
||||||
string databasePath = Path.Combine(Application.StartupPath, "db", databaseFileName);
|
|
||||||
string connectionString = String.Format("Data Source={0};Version=3;", databasePath);
|
|
||||||
|
|
||||||
using (var connection = new SQLiteConnection(connectionString))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
connection.Open();
|
|
||||||
string sql = "SELECT COUNT(1) FROM FavoriteSongs WHERE PhoneNumber = @PhoneNumber";
|
|
||||||
using (var command = new SQLiteCommand(sql, connection))
|
|
||||||
{
|
|
||||||
command.Parameters.AddWithValue("@PhoneNumber", phoneNumber);
|
|
||||||
int count = Convert.ToInt32(command.ExecuteScalar());
|
|
||||||
return count > 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Failed to check phone number in SQLite database: " + ex.Message);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
connection.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void UserLogin(string phoneNumber)
|
|
||||||
{
|
|
||||||
IsUserLoggedIn = true;
|
|
||||||
UserPhoneNumber = phoneNumber;
|
|
||||||
LoadFavoriteSongs();
|
|
||||||
Console.WriteLine(String.Format("UserLoggedIn: {0}, PhoneNumber: {1}", IsUserLoggedIn, UserPhoneNumber));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void UserLogout()
|
|
||||||
{
|
|
||||||
IsUserLoggedIn = false;
|
|
||||||
UserPhoneNumber = null;
|
|
||||||
FavoriteSongs.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void InitializeDatabase()
|
public void InitializeDatabase()
|
||||||
{
|
{
|
||||||
string databaseFileName = "KSongDatabase.db";
|
string databaseFileName = "KSongDatabase.db";
|
||||||
@ -229,6 +180,7 @@ namespace DBObj
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private void LoadSongs()
|
private void LoadSongs()
|
||||||
{
|
{
|
||||||
string databaseFileName = "KSongDatabase.db";
|
string databaseFileName = "KSongDatabase.db";
|
||||||
@ -298,7 +250,7 @@ namespace DBObj
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadFavoriteSongs()
|
public void LoadFavoriteSongs()
|
||||||
{
|
{
|
||||||
if (!IsUserLoggedIn || string.IsNullOrEmpty(UserPhoneNumber))
|
if (!IsUserLoggedIn || string.IsNullOrEmpty(UserPhoneNumber))
|
||||||
@ -400,7 +352,7 @@ namespace DBObj
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public void AddToFavorite(string songNumber)
|
public void AddToFavorite(string songNumber)
|
||||||
{
|
{
|
||||||
if (!IsUserLoggedIn || string.IsNullOrEmpty(UserPhoneNumber))
|
if (!IsUserLoggedIn || string.IsNullOrEmpty(UserPhoneNumber))
|
||||||
@ -555,6 +507,7 @@ namespace DBObj
|
|||||||
else
|
else
|
||||||
return new List<SongData>();
|
return new List<SongData>();
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
public List<SongData> GetFavoriteSongsByPhoneNumber()
|
public List<SongData> GetFavoriteSongsByPhoneNumber()
|
||||||
{
|
{
|
||||||
List<SongData> favoriteSongs = new List<SongData>();
|
List<SongData> favoriteSongs = new List<SongData>();
|
||||||
@ -654,5 +607,6 @@ namespace DBObj
|
|||||||
|
|
||||||
return favoriteSongs;
|
return favoriteSongs;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1060,7 +1060,7 @@ namespace DualScreenDemo
|
|||||||
// 启动服务器的公共方法
|
// 启动服务器的公共方法
|
||||||
private static async Task HandleFavoriteRequest(HttpListenerContext context)
|
private static async Task HandleFavoriteRequest(HttpListenerContext context)
|
||||||
{
|
{
|
||||||
try
|
/* try
|
||||||
{
|
{
|
||||||
if (PrimaryForm.isPhoneNumberValid && !string.IsNullOrEmpty(PrimaryForm.phonenumber))
|
if (PrimaryForm.isPhoneNumberValid && !string.IsNullOrEmpty(PrimaryForm.phonenumber))
|
||||||
{
|
{
|
||||||
@ -1144,10 +1144,11 @@ namespace DualScreenDemo
|
|||||||
context.Response.ContentType = "application/json";
|
context.Response.ContentType = "application/json";
|
||||||
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
|
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
|
||||||
await SendResponseAsyncs(context, jsonResponse);
|
await SendResponseAsyncs(context, jsonResponse);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// 异步响应发送方法
|
// 异步响应发送方法
|
||||||
|
/*
|
||||||
private static async Task SendResponseAsyncs(HttpListenerContext context, string responseContent)
|
private static async Task SendResponseAsyncs(HttpListenerContext context, string responseContent)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -1162,7 +1163,7 @@ namespace DualScreenDemo
|
|||||||
Console.WriteLine("Error sending response: " + ex.Message);
|
Console.WriteLine("Error sending response: " + ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
private static async Task HandleGetRequest(HttpListenerContext context, string baseDirectory, string requestedFile)
|
private static async Task HandleGetRequest(HttpListenerContext context, string baseDirectory, string requestedFile)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -33,51 +33,22 @@ namespace DualScreenDemo{
|
|||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
string songNumber = reader["歌曲編號"].ToString();
|
string songNumber = reader["歌曲編號"].ToString();
|
||||||
string category = reader["語別"].ToString();
|
|
||||||
string song = reader["歌曲名稱"].ToString();
|
string song = reader["歌曲名稱"].ToString();
|
||||||
int plays = Convert.ToInt32(reader["點播次數"]);
|
|
||||||
string artistA = reader["歌星 A"].ToString();
|
string artistA = reader["歌星 A"].ToString();
|
||||||
string artistB = reader["歌星 B"].ToString();
|
string artistB = reader["歌星 B"].ToString();
|
||||||
string artistACategory = reader["歌星A分類"].ToString();
|
|
||||||
string artistBCategory = reader["歌星B分類"].ToString();
|
|
||||||
string dateValue = reader["新增日期"]?.ToString() ?? "";
|
|
||||||
DateTime addedTime;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
addedTime = DateTime.Parse(dateValue, CultureInfo.InvariantCulture).Date;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
addedTime = DateTime.Today;
|
|
||||||
}
|
|
||||||
|
|
||||||
string basePathHost1 = reader["路徑 1"].ToString();
|
|
||||||
string basePathHost2 = reader["路徑 2"].ToString();
|
|
||||||
string fileName = reader["歌曲檔名"].ToString();
|
string fileName = reader["歌曲檔名"].ToString();
|
||||||
string songFilePathHost1 = Path.Combine(basePathHost1, fileName);
|
string songFilePathHost1 = Path.Combine("\\SVR01\\DISK01\\", fileName); // \SVR01\DISK01\
|
||||||
string songFilePathHost2 = Path.Combine(basePathHost2, fileName);
|
string songFilePathHost2 = Path.Combine("\\SVR01\\DISK01\\", fileName); // \SVR02\DISK01\
|
||||||
string phoneticNotation = reader["歌曲注音"].ToString();
|
string artistASimplified = reader["歌星A簡體"].ToString();
|
||||||
string pinyinNotation = reader["歌曲拼音"].ToString();
|
|
||||||
string artistAPhonetic = reader["歌星A注音"].ToString();
|
|
||||||
string artistBPhonetic = reader["歌星B注音"].ToString();
|
|
||||||
string artistASimplified = reader["歌星A簡體"].ToString();
|
|
||||||
string artistBSimplified = reader["歌星B簡體"].ToString();
|
string artistBSimplified = reader["歌星B簡體"].ToString();
|
||||||
string songSimplified = reader["歌名簡體"].ToString();
|
string songSimplified = reader["歌名簡體"].ToString();
|
||||||
string songGenre = reader["分類"].ToString();
|
|
||||||
string artistAPinyin = reader["歌星A拼音"].ToString();
|
|
||||||
string artistBPinyin = reader["歌星B拼音"].ToString();
|
|
||||||
int humanVoice = Convert.ToInt32(reader["人聲"]);
|
int humanVoice = Convert.ToInt32(reader["人聲"]);
|
||||||
|
|
||||||
searchResults.Add(new SongData(
|
searchResults.Add(new SongData(
|
||||||
songNumber, category, song, plays, artistA, artistB,
|
songNumber, song, artistA, artistB,
|
||||||
artistACategory, artistBCategory, addedTime,
|
|
||||||
songFilePathHost1, songFilePathHost2,
|
songFilePathHost1, songFilePathHost2,
|
||||||
phoneticNotation, pinyinNotation,
|
|
||||||
artistAPhonetic, artistBPhonetic,
|
|
||||||
artistASimplified, artistBSimplified,
|
artistASimplified, artistBSimplified,
|
||||||
songSimplified, songGenre,
|
songSimplified, humanVoice
|
||||||
artistAPinyin, artistBPinyin,
|
|
||||||
humanVoice
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1589,26 +1589,26 @@ namespace DualScreenDemo
|
|||||||
|
|
||||||
SongData song = new SongData(
|
SongData song = new SongData(
|
||||||
songNumber, // songNumber
|
songNumber, // songNumber
|
||||||
"", // songNumberB
|
//"", // songNumberB
|
||||||
songName, // song
|
songName, // song
|
||||||
0, // songLength
|
//0, // songLength
|
||||||
"", // artistA
|
"", // artistA
|
||||||
"", // artistB
|
"", // artistB
|
||||||
"", // language
|
//"", // language
|
||||||
"", // category
|
//"", // category
|
||||||
DateTime.Now, // dateAdded
|
//DateTime.Now, // dateAdded
|
||||||
songPath, // songFilePathHost1
|
songPath, // songFilePathHost1
|
||||||
"", // songFilePathHost2
|
"", // songFilePathHost2
|
||||||
"", // songFilePathHost3
|
"", // songFilePathHost3
|
||||||
"", // songFilePathHost4
|
"", // songFilePathHost4
|
||||||
"", // songFilePathHost5
|
"", // songFilePathHost5
|
||||||
"", // songFilePathHost6
|
//"", // songFilePathHost6
|
||||||
"", // songFilePathHost7
|
//"", // songFilePathHost7
|
||||||
"", // songFilePathHost8
|
//"", // songFilePathHost8
|
||||||
"", // songFilePathHost9
|
//"", // songFilePathHost9
|
||||||
"", // songFilePathHost10
|
//"", // songFilePathHost10
|
||||||
"", // humanVoice
|
//"", // humanVoice
|
||||||
"", // songType
|
//"", // songType
|
||||||
1 // priority
|
1 // priority
|
||||||
);
|
);
|
||||||
publicSongList.Add(song);
|
publicSongList.Add(song);
|
||||||
@ -1617,26 +1617,26 @@ namespace DualScreenDemo
|
|||||||
{
|
{
|
||||||
SongData song = new SongData(
|
SongData song = new SongData(
|
||||||
"", // songNumber
|
"", // songNumber
|
||||||
"", // songNumberB
|
//"", // songNumberB
|
||||||
"", // song
|
"", // song
|
||||||
0, // songLength
|
//0, // songLength
|
||||||
"", // artistA
|
"", // artistA
|
||||||
"", // artistB
|
"", // artistB
|
||||||
"", // language
|
//"", // language
|
||||||
"", // category
|
//"", // category
|
||||||
DateTime.Now, // dateAdded
|
//DateTime.Now, // dateAdded
|
||||||
songPath, // songFilePathHost1
|
songPath, // songFilePathHost1
|
||||||
"", // songFilePathHost2
|
"", // songFilePathHost2
|
||||||
"", // songFilePathHost3
|
"", // songFilePathHost3
|
||||||
"", // songFilePathHost4
|
"", // songFilePathHost4
|
||||||
"", // songFilePathHost5
|
"", // songFilePathHost5
|
||||||
"", // songFilePathHost6
|
//"", // songFilePathHost6
|
||||||
"", // songFilePathHost7
|
//"", // songFilePathHost7
|
||||||
"", // songFilePathHost8
|
//"", // songFilePathHost8
|
||||||
"", // songFilePathHost9
|
//"", // songFilePathHost9
|
||||||
"", // songFilePathHost10
|
//"", // songFilePathHost10
|
||||||
"", // humanVoice
|
//"", // humanVoice
|
||||||
"", // songType
|
//"", // songType
|
||||||
1 // priority
|
1 // priority
|
||||||
);
|
);
|
||||||
publicSongList.Add(song);
|
publicSongList.Add(song);
|
||||||
|
@ -146,9 +146,9 @@ namespace DualScreenDemo
|
|||||||
if (File.Exists(closePath))
|
if (File.Exists(closePath))
|
||||||
{
|
{
|
||||||
SongData closeSong = new SongData(
|
SongData closeSong = new SongData(
|
||||||
"", "", "結束播放", 0, "", "", "", "",
|
"0", "結束播放", "", "",
|
||||||
DateTime.Now, closePath, "", "", "", "",
|
closePath, "", "", "", "",
|
||||||
"", "", "", "", "", "", "", 1
|
1
|
||||||
);
|
);
|
||||||
VideoPlayerForm.publicPlaylist = new List<SongData>();
|
VideoPlayerForm.publicPlaylist = new List<SongData>();
|
||||||
VideoPlayerForm.playingSongList = new List<SongData>();
|
VideoPlayerForm.playingSongList = new List<SongData>();
|
||||||
|
@ -570,9 +570,8 @@ namespace DualScreenDemo
|
|||||||
if (File.Exists(welcomePath))
|
if (File.Exists(welcomePath))
|
||||||
{
|
{
|
||||||
publicPlaylist.Add(new SongData(
|
publicPlaylist.Add(new SongData(
|
||||||
"0", "", "歡迎光臨", 0, "", "", "", "",
|
"0", "歡迎光臨", "", "", welcomePath,
|
||||||
DateTime.Now, welcomePath, "", "", "", "",
|
"", "", "", "", 1
|
||||||
"", "", "", "", "", "", "", 1
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -583,9 +582,8 @@ namespace DualScreenDemo
|
|||||||
if (File.Exists(bgmPath))
|
if (File.Exists(bgmPath))
|
||||||
{
|
{
|
||||||
publicPlaylist.Add(new SongData(
|
publicPlaylist.Add(new SongData(
|
||||||
i.ToString(), "", $"背景音樂{i:D2}", 0, "", "", "", "",
|
i.ToString(), $"背景音樂{i:D2}",
|
||||||
DateTime.Now, bgmPath, "", "", "", "",
|
"", "", bgmPath, "", "", "", "", 1
|
||||||
"", "", "", "", "", "", "", 1
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -599,9 +597,9 @@ namespace DualScreenDemo
|
|||||||
{
|
{
|
||||||
string fileName = Path.GetFileNameWithoutExtension(songPath);
|
string fileName = Path.GetFileNameWithoutExtension(songPath);
|
||||||
publicPlaylist.Add(new SongData(
|
publicPlaylist.Add(new SongData(
|
||||||
"0", "", fileName, 0, "", "", "", "",
|
"0", fileName, "", "",
|
||||||
DateTime.Now, songPath, "", "", "", "",
|
songPath, "", "", "", "",
|
||||||
"", "", "", "", "", "", "", 1
|
1
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -879,9 +877,7 @@ namespace DualScreenDemo
|
|||||||
if (File.Exists(welcomePath))
|
if (File.Exists(welcomePath))
|
||||||
{
|
{
|
||||||
publicPlaylist.Add(new SongData(
|
publicPlaylist.Add(new SongData(
|
||||||
"0", "", "歡迎光臨", 0, "", "", "", "",
|
"0", "歡迎光臨", "", "", welcomePath, "", "", "", "", 1
|
||||||
DateTime.Now, welcomePath, "", "", "", "",
|
|
||||||
"", "", "", "", "", "", "", 1
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -892,9 +888,8 @@ namespace DualScreenDemo
|
|||||||
if (File.Exists(bgmPath))
|
if (File.Exists(bgmPath))
|
||||||
{
|
{
|
||||||
publicPlaylist.Add(new SongData(
|
publicPlaylist.Add(new SongData(
|
||||||
i.ToString(), "", $"背景音樂{i:D2}", 0, "", "", "", "",
|
i.ToString(), $"背景音樂{i:D2}", "", "", bgmPath,
|
||||||
DateTime.Now, bgmPath, "", "", "", "",
|
"", "", "", "", 1
|
||||||
"", "", "", "", "", "", "", 1
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user