歌曲SQL改版(class 修改)
This commit is contained in:
parent
fec592d94a
commit
67c05a122b
@ -30,66 +30,6 @@ namespace DBObj
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
private void LoadArtists()
|
|
||||||
{
|
|
||||||
string databaseFileName = "KSongDatabase.db";
|
|
||||||
string databasePath = Path.Combine(Application.StartupPath,"db" ,databaseFileName);
|
|
||||||
|
|
||||||
Console.WriteLine(databasePath);
|
|
||||||
string connectionString = String.Format("Data Source={0};Version=3;", databasePath);
|
|
||||||
|
|
||||||
using (var connection = new SQLiteConnection(connectionString))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
connection.Open();
|
|
||||||
|
|
||||||
string sql = "SELECT 歌手姓名, 歌手注音, 歌手分類, 歌手筆畫 FROM ArtistLibrary";
|
|
||||||
using (var command = new SQLiteCommand(sql, connection))
|
|
||||||
{
|
|
||||||
using (SQLiteDataReader reader = command.ExecuteReader())
|
|
||||||
{
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
string artist = reader["歌手姓名"].ToString();
|
|
||||||
string phonetic = reader["歌手注音"].ToString();
|
|
||||||
string category = reader["歌手分類"].ToString();
|
|
||||||
string strokesStr = reader["歌手筆畫"].ToString();
|
|
||||||
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(strokesStr))
|
|
||||||
{
|
|
||||||
// Console.WriteLine("歌手筆畫的值為空或無效");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (double.TryParse(strokesStr, out double strokesDouble))
|
|
||||||
{
|
|
||||||
int strokes = (int)Math.Round(strokesDouble);
|
|
||||||
AllArtists.Add(new Artist(artist, phonetic, category, strokes));
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Console.WriteLine($"Failed to parse '歌手筆畫' value: {strokesStr}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
connection.Close();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Failed to load artists from SQLite database: " + ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
public List<Artist> GetArtistsByCategoryAndStrokeCountRange(string category, int minStrokes, int maxStrokes)
|
public List<Artist> GetArtistsByCategoryAndStrokeCountRange(string category, int minStrokes, int maxStrokes)
|
||||||
{
|
{
|
||||||
if (category == "全部")
|
if (category == "全部")
|
||||||
|
@ -3,26 +3,14 @@ namespace DBObj
|
|||||||
public class SongData
|
public class SongData
|
||||||
{
|
{
|
||||||
public string SongNumber { get; set; }
|
public string SongNumber { get; set; }
|
||||||
public string Category { get; set; }
|
|
||||||
public string Song { get; set; }
|
public string Song { get; set; }
|
||||||
public double Plays { get; set; }
|
|
||||||
public string ArtistA { get; set; }
|
public string ArtistA { get; set; }
|
||||||
public string ArtistB { get; set; }
|
public string ArtistB { get; set; }
|
||||||
public string ArtistACategory { get; set; }
|
|
||||||
public string ArtistBCategory { get; set; }
|
|
||||||
public DateTime AddedTime { get; set; }
|
|
||||||
public string SongFilePathHost1 { get; set; }
|
public string SongFilePathHost1 { get; set; }
|
||||||
public string SongFilePathHost2 { get; set; }
|
public string SongFilePathHost2 { get; set; }
|
||||||
public string PhoneticNotation { get; set; }
|
|
||||||
public string PinyinNotation { get; set; }
|
|
||||||
public string ArtistAPhonetic { get; set; }
|
|
||||||
public string ArtistBPhonetic { get; set; }
|
|
||||||
public string ArtistASimplified { get; set; }
|
public string ArtistASimplified { get; set; }
|
||||||
public string ArtistBSimplified { get; set; }
|
public string ArtistBSimplified { get; set; }
|
||||||
public string SongSimplified { get; set; }
|
public string SongSimplified { get; set; }
|
||||||
public string SongGenre { get; set; }
|
|
||||||
public string ArtistAPinyin { get; set; }
|
|
||||||
public string ArtistBPinyin { get; set; }
|
|
||||||
public int HumanVoice { get; set; }
|
public int HumanVoice { get; set; }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -12,7 +12,7 @@ namespace DBObj
|
|||||||
public static Dictionary<string, List<SongData>> NewSongLists { get; private set; }
|
public static Dictionary<string, List<SongData>> NewSongLists { get; private set; }
|
||||||
public static Dictionary<string, List<SongData>> HotSongLists { get; private set; }
|
public static Dictionary<string, List<SongData>> HotSongLists { get; private set; }
|
||||||
public List<SongData> FavoriteSongs { get; private set; }
|
public List<SongData> FavoriteSongs { get; private set; }
|
||||||
public const int SongsPerPage = 9;
|
//public const int SongsPerPage = 9;
|
||||||
|
|
||||||
public bool IsUserLoggedIn { get; set; }
|
public bool IsUserLoggedIn { get; set; }
|
||||||
public string UserPhoneNumber { get; set; }
|
public string UserPhoneNumber { get; set; }
|
||||||
@ -25,74 +25,74 @@ namespace DBObj
|
|||||||
FavoriteSongs = new List<SongData>();
|
FavoriteSongs = new List<SongData>();
|
||||||
|
|
||||||
// 尝试更新数据库,但无论结果如何都继续运行
|
// 尝试更新数据库,但无论结果如何都继续运行
|
||||||
TryUpdateDatabase();
|
//TryUpdateDatabase();
|
||||||
|
|
||||||
// 继续使用可用的数据库(可能是更新后的或原本的本地数据库)
|
// 继续使用可用的数据库(可能是更新后的或原本的本地数据库)
|
||||||
InitializeDatabase();
|
//InitializeDatabase();
|
||||||
//LoadSongs();
|
//LoadSongs();
|
||||||
InitializeNewSongLists();
|
//InitializeNewSongLists();
|
||||||
InitializeHotSongLists();
|
//InitializeHotSongLists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private bool TryUpdateDatabase()
|
private bool TryUpdateDatabase()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
// 1. 检查是否能连接到 SVR01
|
try
|
||||||
if (!Directory.Exists(@"\\SVR01\SuperstarB"))
|
|
||||||
{
|
{
|
||||||
Console.WriteLine("未連接到SVR使用本地DB");
|
// 1. 检查是否能连接到 SVR01
|
||||||
return true; // 继续使用本地数据库
|
if (!Directory.Exists(@"\\SVR01\SuperstarB"))
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 比较本地和服务器文件
|
|
||||||
string localDbPath = Path.Combine(Application.StartupPath,"db" ,"KSongDatabase.db");
|
|
||||||
string serverDbPath = @"\\SVR01\SuperstarB\KSongDatabase.db";
|
|
||||||
|
|
||||||
if (!File.Exists(localDbPath))
|
|
||||||
{
|
|
||||||
Console.WriteLine("本地無db");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FileInfo localFile = new FileInfo(localDbPath);
|
|
||||||
FileInfo serverFile = new FileInfo(serverDbPath);
|
|
||||||
|
|
||||||
if (serverFile.LastWriteTime <= localFile.LastWriteTime)
|
|
||||||
{
|
{
|
||||||
Console.WriteLine("歌單已是最新");
|
Console.WriteLine("未連接到SVR使用本地DB");
|
||||||
return true;
|
return true; // 继续使用本地数据库
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2. 比较本地和服务器文件
|
||||||
|
string localDbPath = Path.Combine(Application.StartupPath,"db" ,"KSongDatabase.db");
|
||||||
|
string serverDbPath = @"\\SVR01\SuperstarB\KSongDatabase.db";
|
||||||
|
|
||||||
|
if (!File.Exists(localDbPath))
|
||||||
|
{
|
||||||
|
Console.WriteLine("本地無db");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FileInfo localFile = new FileInfo(localDbPath);
|
||||||
|
FileInfo serverFile = new FileInfo(serverDbPath);
|
||||||
|
|
||||||
|
if (serverFile.LastWriteTime <= localFile.LastWriteTime)
|
||||||
|
{
|
||||||
|
Console.WriteLine("歌單已是最新");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 需要更新时,复制新文件
|
||||||
|
Process copyProcess = new Process();
|
||||||
|
copyProcess.StartInfo.FileName = "cmd.exe";
|
||||||
|
copyProcess.StartInfo.Arguments = "/C copy /Y \\\\SVR01\\SuperstarB\\KSongDatabase.db \\db\\KSongDatabase.db";
|
||||||
|
copyProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
||||||
|
copyProcess.StartInfo.CreateNoWindow = true;
|
||||||
|
copyProcess.Start();
|
||||||
|
copyProcess.WaitForExit();
|
||||||
|
|
||||||
|
if (copyProcess.ExitCode == 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine("歌單更新成功");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("歌單複製失敗,使用本地歌單");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
// 3. 需要更新时,复制新文件
|
|
||||||
Process copyProcess = new Process();
|
|
||||||
copyProcess.StartInfo.FileName = "cmd.exe";
|
|
||||||
copyProcess.StartInfo.Arguments = "/C copy /Y \\\\SVR01\\SuperstarB\\KSongDatabase.db \\db\\KSongDatabase.db";
|
|
||||||
copyProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
|
||||||
copyProcess.StartInfo.CreateNoWindow = true;
|
|
||||||
copyProcess.Start();
|
|
||||||
copyProcess.WaitForExit();
|
|
||||||
|
|
||||||
if (copyProcess.ExitCode == 0)
|
|
||||||
{
|
{
|
||||||
Console.WriteLine("歌單更新成功");
|
Console.WriteLine($"更新歌單失敗:{ex.Message}");
|
||||||
|
return true; // 出错时继续使用本地数据库
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("歌單複製失敗,使用本地歌單");
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
*/
|
||||||
{
|
|
||||||
Console.WriteLine($"更新歌單失敗:{ex.Message}");
|
|
||||||
return true; // 出错时继续使用本地数据库
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SongListManager Instance
|
public static SongListManager Instance
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -179,180 +179,7 @@ namespace DBObj
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
private void LoadSongs()
|
|
||||||
{
|
|
||||||
string databaseFileName = "KSongDatabase.db";
|
|
||||||
string databasePath = Path.Combine(Application.StartupPath, "db", databaseFileName);
|
|
||||||
|
|
||||||
Console.WriteLine(databasePath);
|
|
||||||
string connectionString = String.Format("Data Source={0};Version=3;", databasePath);
|
|
||||||
|
|
||||||
using (var connection = new SQLiteConnection(connectionString))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
connection.Open();
|
|
||||||
|
|
||||||
string sql = "SELECT 歌曲編號, 語別, 歌曲名稱, 點播次數, [歌星 A], [歌星 B], 新增日期, [路徑 1], [路徑 2], 歌曲檔名, 歌曲注音, 歌曲拼音, 歌星A分類, 歌星B分類, 歌星A注音, 歌星B注音, 歌星A簡體, 歌星B簡體, 歌名簡體, 分類, 歌星A拼音, 歌星B拼音, 人聲 FROM SongLibrary";
|
|
||||||
using (var command = new SQLiteCommand(sql, connection))
|
|
||||||
{
|
|
||||||
using (SQLiteDataReader reader = command.ExecuteReader())
|
|
||||||
{
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
string songNumber = reader["歌曲編號"].ToString();
|
|
||||||
string category = reader["語別"].ToString();
|
|
||||||
string song = reader["歌曲名稱"].ToString();
|
|
||||||
int plays = Convert.ToInt32(reader["點播次數"]);
|
|
||||||
string artistA = reader["歌星 A"].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 (System.FormatException)
|
|
||||||
{
|
|
||||||
addedTime = DateTime.Today;
|
|
||||||
}
|
|
||||||
string basePathHost1 = reader["路徑 1"].ToString();
|
|
||||||
string basePathHost2 = reader["路徑 2"].ToString();
|
|
||||||
string fileName = reader["歌曲檔名"].ToString();
|
|
||||||
string songFilePathHost1 = Path.Combine(basePathHost1, fileName);
|
|
||||||
string songFilePathHost2 = Path.Combine(basePathHost2, fileName);
|
|
||||||
string phoneticNotation = reader["歌曲注音"].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 songSimplified = reader["歌名簡體"].ToString();
|
|
||||||
string songGenre = reader["分類"].ToString();
|
|
||||||
string artistAPinyin = reader["歌星A拼音"].ToString();
|
|
||||||
string artistBPinyin = reader["歌星B拼音"].ToString();
|
|
||||||
int humanVoice = Convert.ToInt32(reader["人聲"]);
|
|
||||||
|
|
||||||
AllSongs.Add(new SongData(songNumber, category, song, plays, artistA, artistB, artistACategory, artistBCategory, addedTime, songFilePathHost1, songFilePathHost2, phoneticNotation, pinyinNotation, artistAPhonetic, artistBPhonetic, artistASimplified, artistBSimplified, songSimplified, songGenre, artistAPinyin, artistBPinyin, humanVoice));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
connection.Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Failed to load songs from SQLite database: " + ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadFavoriteSongs()
|
|
||||||
{
|
|
||||||
if (!IsUserLoggedIn || string.IsNullOrEmpty(UserPhoneNumber))
|
|
||||||
return;
|
|
||||||
|
|
||||||
string databaseFileName = "KSongDatabase.db";
|
|
||||||
string databasePath = Path.Combine(Application.StartupPath, "db", databaseFileName);
|
|
||||||
string connectionString = String.Format("Data Source={0};Version=3;", databasePath);
|
|
||||||
|
|
||||||
|
|
||||||
FavoriteSongs.Clear();
|
|
||||||
FavoriteSongs.Add(new SongData("", "", UserPhoneNumber + " 的歌單", 0, "", "", "", "", DateTime.MinValue, "", "", "", "", "", "", "", "", "", "", "", "", 1));
|
|
||||||
|
|
||||||
using (var connection = new SQLiteConnection(connectionString))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
connection.Open();
|
|
||||||
|
|
||||||
string sql = @"
|
|
||||||
SELECT
|
|
||||||
sl.歌曲編號, sl.語別, sl.歌曲名稱, sl.點播次數,
|
|
||||||
sl.[歌星 A], sl.[歌星 B], sl.新增日期, sl.[路徑 1],
|
|
||||||
sl.[路徑 2], sl.歌曲檔名, sl.歌曲注音, sl.歌曲拼音,
|
|
||||||
sl.歌星A分類, sl.歌星B分類, sl.歌星A注音, sl.歌星B注音,
|
|
||||||
sl.歌星A簡體, sl.歌星B簡體, sl.歌名簡體, sl.分類,
|
|
||||||
sl.歌星A拼音, sl.歌星B拼音, sl.人聲
|
|
||||||
FROM
|
|
||||||
FavoriteSongs fs
|
|
||||||
JOIN
|
|
||||||
SongLibrary sl
|
|
||||||
ON
|
|
||||||
fs.SongNumber = sl.歌曲編號
|
|
||||||
WHERE
|
|
||||||
fs.PhoneNumber = @PhoneNumber";
|
|
||||||
|
|
||||||
using (var command = new SQLiteCommand(sql, connection))
|
|
||||||
{
|
|
||||||
command.Parameters.AddWithValue("@PhoneNumber", UserPhoneNumber);
|
|
||||||
|
|
||||||
using (SQLiteDataReader reader = command.ExecuteReader())
|
|
||||||
{
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
string songNumber = reader["歌曲編號"].ToString();
|
|
||||||
string category = reader["語別"].ToString();
|
|
||||||
string song = reader["歌曲名稱"].ToString();
|
|
||||||
int plays = Convert.ToInt32(reader["點播次數"]);
|
|
||||||
string artistA = reader["歌星 A"].ToString();
|
|
||||||
string artistB = reader["歌星 B"].ToString();
|
|
||||||
string artistACategory = reader["歌星A分類"].ToString();
|
|
||||||
string artistBCategory = reader["歌星B分類"].ToString();
|
|
||||||
DateTime addedTime;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
addedTime = DateTime.ParseExact(reader["新增日期"].ToString(), "yyyy-MM-dd", CultureInfo.InvariantCulture);
|
|
||||||
}
|
|
||||||
catch (System.FormatException)
|
|
||||||
{
|
|
||||||
addedTime = DateTime.Today;
|
|
||||||
}
|
|
||||||
|
|
||||||
string basePathHost1 = reader["路徑 1"].ToString();
|
|
||||||
string basePathHost2 = reader["路徑 2"].ToString();
|
|
||||||
string fileName = reader["歌曲檔名"].ToString();
|
|
||||||
string songFilePathHost1 = Path.Combine(basePathHost1, fileName);
|
|
||||||
string songFilePathHost2 = Path.Combine(basePathHost2, fileName);
|
|
||||||
string phoneticNotation = reader["歌曲注音"].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 songSimplified = reader["歌名簡體"].ToString();
|
|
||||||
string songGenre = reader["分類"].ToString();
|
|
||||||
string artistAPinyin = reader["歌星A拼音"].ToString();
|
|
||||||
string artistBPinyin = reader["歌星B拼音"].ToString();
|
|
||||||
int humanVoice = Convert.ToInt32(reader["人聲"]);
|
|
||||||
|
|
||||||
FavoriteSongs.Add(new SongData(
|
|
||||||
songNumber, category, song, plays, artistA, artistB,
|
|
||||||
artistACategory, artistBCategory, addedTime, songFilePathHost1,
|
|
||||||
songFilePathHost2, phoneticNotation, pinyinNotation,
|
|
||||||
artistAPhonetic, artistBPhonetic, artistASimplified,
|
|
||||||
artistBSimplified, songSimplified, songGenre,
|
|
||||||
artistAPinyin, artistBPinyin, humanVoice));
|
|
||||||
}
|
|
||||||
PrimaryForm.Instance.multiPagePanel.currentPageIndex = 0;
|
|
||||||
PrimaryForm.Instance.multiPagePanel.LoadSongs(FavoriteSongs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
connection.Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Failed to load favorite songs from SQLite database: " + ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
public void AddToFavorite(string songNumber)
|
public void AddToFavorite(string songNumber)
|
||||||
{
|
{
|
||||||
if (!IsUserLoggedIn || string.IsNullOrEmpty(UserPhoneNumber))
|
if (!IsUserLoggedIn || string.IsNullOrEmpty(UserPhoneNumber))
|
||||||
@ -448,165 +275,5 @@ namespace DBObj
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeNewSongLists()
|
|
||||||
{
|
|
||||||
int songLimit = PrimaryForm.ReadNewSongLimit();
|
|
||||||
|
|
||||||
|
|
||||||
string[] categories = new string[] { "國語", "台語", "粵語", "英文", "日語", "韓語" };
|
|
||||||
|
|
||||||
foreach (var category in categories)
|
|
||||||
{
|
|
||||||
|
|
||||||
var songsInCategory = AllSongs
|
|
||||||
.Where(s => s.Category == category)
|
|
||||||
.OrderByDescending(s => s.AddedTime)
|
|
||||||
.Take(songLimit)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
|
|
||||||
NewSongLists.Add(category, songsInCategory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InitializeHotSongLists()
|
|
||||||
{
|
|
||||||
int songLimit = PrimaryForm.ReadHotSongLimit();
|
|
||||||
|
|
||||||
|
|
||||||
string[] categories = new string[] { "國語", "台語", "英文", "日語", "韓語" };
|
|
||||||
|
|
||||||
foreach (var category in categories)
|
|
||||||
{
|
|
||||||
|
|
||||||
var songsInCategory = AllSongs
|
|
||||||
.Where(s => s.Category == category)
|
|
||||||
.OrderByDescending(s => s.Plays)
|
|
||||||
.Take(songLimit)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
|
|
||||||
HotSongLists.Add(category, songsInCategory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SongData> GetNewSongsByCategory(string category)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (NewSongLists.ContainsKey(category))
|
|
||||||
return NewSongLists[category];
|
|
||||||
else
|
|
||||||
return new List<SongData>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SongData> GetHotSongsByCategory(string category)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (HotSongLists.ContainsKey(category))
|
|
||||||
return HotSongLists[category];
|
|
||||||
else
|
|
||||||
return new List<SongData>();
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
public List<SongData> GetFavoriteSongsByPhoneNumber()
|
|
||||||
{
|
|
||||||
List<SongData> favoriteSongs = new List<SongData>();
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(UserPhoneNumber))
|
|
||||||
return favoriteSongs;
|
|
||||||
|
|
||||||
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
|
|
||||||
sl.歌曲編號, sl.語別, sl.歌曲名稱, sl.點播次數,
|
|
||||||
sl.[歌星 A], sl.[歌星 B], sl.新增日期, sl.[路徑 1],
|
|
||||||
sl.[路徑 2], sl.歌曲檔名, sl.歌曲注音, sl.歌曲拼音,
|
|
||||||
sl.歌星A分類, sl.歌星B分類, sl.歌星A注音, sl.歌星B注音,
|
|
||||||
sl.歌星A簡體, sl.歌星B簡體, sl.歌名簡體, sl.分類,
|
|
||||||
sl.歌星A拼音, sl.歌星B拼音, sl.人聲
|
|
||||||
FROM
|
|
||||||
FavoriteSongs fs
|
|
||||||
JOIN
|
|
||||||
SongLibrary sl
|
|
||||||
ON
|
|
||||||
fs.SongNumber = sl.歌曲編號
|
|
||||||
WHERE
|
|
||||||
fs.PhoneNumber = @PhoneNumber";
|
|
||||||
|
|
||||||
using (var command = new SQLiteCommand(sql, connection))
|
|
||||||
{
|
|
||||||
command.Parameters.AddWithValue("@PhoneNumber", UserPhoneNumber);
|
|
||||||
|
|
||||||
using (SQLiteDataReader reader = command.ExecuteReader())
|
|
||||||
{
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
string songNumber = reader["歌曲編號"].ToString();
|
|
||||||
string category = reader["語別"].ToString();
|
|
||||||
string song = reader["歌曲名稱"].ToString();
|
|
||||||
int plays = Convert.ToInt32(reader["點播次數"]);
|
|
||||||
string artistA = reader["歌星 A"].ToString();
|
|
||||||
string artistB = reader["歌星 B"].ToString();
|
|
||||||
string artistACategory = reader["歌星A分類"].ToString();
|
|
||||||
string artistBCategory = reader["歌星B分類"].ToString();
|
|
||||||
DateTime addedTime;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
addedTime = DateTime.ParseExact(reader["新增日期"].ToString(), "yyyy-MM-dd", CultureInfo.InvariantCulture);
|
|
||||||
}
|
|
||||||
catch (System.FormatException)
|
|
||||||
{
|
|
||||||
addedTime = DateTime.Now;
|
|
||||||
}
|
|
||||||
|
|
||||||
string basePathHost1 = reader["路徑 1"].ToString();
|
|
||||||
string basePathHost2 = reader["路徑 2"].ToString();
|
|
||||||
string fileName = reader["歌曲檔名"].ToString();
|
|
||||||
string songFilePathHost1 = Path.Combine(basePathHost1, fileName);
|
|
||||||
string songFilePathHost2 = Path.Combine(basePathHost2, fileName);
|
|
||||||
string phoneticNotation = reader["歌曲注音"].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 songSimplified = reader["歌名簡體"].ToString();
|
|
||||||
string songGenre = reader["分類"].ToString();
|
|
||||||
string artistAPinyin = reader["歌星A拼音"].ToString();
|
|
||||||
string artistBPinyin = reader["歌星B拼音"].ToString();
|
|
||||||
int humanVoice = Convert.ToInt32(reader["人聲"]);
|
|
||||||
|
|
||||||
favoriteSongs.Add(new SongData(
|
|
||||||
songNumber, category, song, plays, artistA, artistB,
|
|
||||||
artistACategory, artistBCategory, addedTime, songFilePathHost1,
|
|
||||||
songFilePathHost2, phoneticNotation, pinyinNotation,
|
|
||||||
artistAPhonetic, artistBPhonetic, artistASimplified,
|
|
||||||
artistBSimplified, songSimplified, songGenre,
|
|
||||||
artistAPinyin, artistBPinyin, humanVoice));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
connection.Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Failed to load favorite songs from SQLite database: " + ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return favoriteSongs;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -252,7 +252,7 @@ namespace DualScreenDemo
|
|||||||
}
|
}
|
||||||
|
|
||||||
private string SetQueryforSQL(string contains){
|
private string SetQueryforSQL(string contains){
|
||||||
string query = $"SELECT * FROM SongLibrary WHERE `分類` LIKE '%{contains}%' ORDER BY `點播次數` DESC";
|
string query = $"SELECT * FROM song_library_cache WHERE situation LIKE '%{contains}%' ORDER BY `song_id` DESC";
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ namespace DualScreenDemo
|
|||||||
/*guoYuSongs = allSongs.Where(song => song.Category == "國語" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
/*guoYuSongs = allSongs.Where(song => song.Category == "國語" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
||||||
.OrderByDescending(song => song.Plays)
|
.OrderByDescending(song => song.Plays)
|
||||||
.ToList();*/
|
.ToList();*/
|
||||||
String query = "SELECT * FROM SongLibrary WHERE `語別` = '國語' AND (`歌星A分類` = '團' OR `歌星B分類` = '團') ORDER BY `點播次數` DESC";
|
string query = "SELECT * FROM song_library_cache WHERE language_name = '國語' AND (`artistA_category` = '團' OR `artistB_category` = '團') ORDER BY song_id DESC";
|
||||||
var guoYuSongs = SearchSongs_Mysql(query);
|
var guoYuSongs = SearchSongs_Mysql(query);
|
||||||
currentPage = 0;
|
currentPage = 0;
|
||||||
currentSongList = guoYuSongs;
|
currentSongList = guoYuSongs;
|
||||||
|
@ -14,7 +14,7 @@ namespace DualScreenDemo
|
|||||||
/*hanYuSongs = allSongs.Where(song => song.Category == "韓語" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
/*hanYuSongs = allSongs.Where(song => song.Category == "韓語" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
||||||
.OrderByDescending(song => song.Plays)
|
.OrderByDescending(song => song.Plays)
|
||||||
.ToList();*/
|
.ToList();*/
|
||||||
String query = "SELECT * FROM SongLibrary WHERE `語別` = '韓語' AND (`歌星A分類` = '團' OR `歌星B分類` = '團') ORDER BY `點播次數` DESC";
|
string query = "SELECT * FROM song_library_cache WHERE language_name = '韓語' AND (`artistA_category` = '團' OR `artistB_category` = '團') ORDER BY song_id DESC";
|
||||||
var hanYuSongs = SearchSongs_Mysql(query);
|
var hanYuSongs = SearchSongs_Mysql(query);
|
||||||
currentPage = 0;
|
currentPage = 0;
|
||||||
currentSongList = hanYuSongs;
|
currentSongList = hanYuSongs;
|
||||||
|
@ -14,7 +14,8 @@ namespace DualScreenDemo
|
|||||||
/*riYuSongs = allSongs.Where(song => song.Category == "日語" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
/*riYuSongs = allSongs.Where(song => song.Category == "日語" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
||||||
.OrderByDescending(song => song.Plays)
|
.OrderByDescending(song => song.Plays)
|
||||||
.ToList();*/
|
.ToList();*/
|
||||||
String query = "SELECT * FROM SongLibrary WHERE `語別` = '日語' AND (`歌星A分類` = '團' OR `歌星B分類` = '團') ORDER BY `點播次數` DESC";
|
|
||||||
|
string query = "SELECT * FROM song_library_cache WHERE language_name = '日語' AND (`artistA_category` = '團' OR `artistB_category` = '團') ORDER BY song_id DESC";
|
||||||
var riYuSongs = SearchSongs_Mysql(query);
|
var riYuSongs = SearchSongs_Mysql(query);
|
||||||
currentPage = 0;
|
currentPage = 0;
|
||||||
currentSongList = riYuSongs;
|
currentSongList = riYuSongs;
|
||||||
|
@ -14,7 +14,7 @@ namespace DualScreenDemo
|
|||||||
/*taiYuSongs = allSongs.Where(song => song.Category == "台語" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
/*taiYuSongs = allSongs.Where(song => song.Category == "台語" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
||||||
.OrderByDescending(song => song.Plays)
|
.OrderByDescending(song => song.Plays)
|
||||||
.ToList();*/
|
.ToList();*/
|
||||||
String query = "SELECT * FROM SongLibrary WHERE `語別` = '台語' AND (`歌星A分類` = '團' OR `歌星B分類` = '團') ORDER BY `點播次數` DESC";
|
string query = "SELECT * FROM song_library_cache WHERE language_name = '台語' AND (`artistA_category` = '團' OR `artistB_category` = '團') ORDER BY song_id DESC";
|
||||||
var taiYuSongs = SearchSongs_Mysql(query);
|
var taiYuSongs = SearchSongs_Mysql(query);
|
||||||
currentPage = 0;
|
currentPage = 0;
|
||||||
currentSongList = taiYuSongs;
|
currentSongList = taiYuSongs;
|
||||||
|
@ -14,7 +14,7 @@ namespace DualScreenDemo
|
|||||||
/*yingWenSongs = allSongs.Where(song => song.Category == "英文" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
/*yingWenSongs = allSongs.Where(song => song.Category == "英文" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
||||||
.OrderByDescending(song => song.Plays)
|
.OrderByDescending(song => song.Plays)
|
||||||
.ToList();*/
|
.ToList();*/
|
||||||
String query = "SELECT * FROM SongLibrary WHERE `語別` = '英文' AND (`歌星A分類` = '團' OR `歌星B分類` = '團') ORDER BY `點播次數` DESC";
|
string query = "SELECT * FROM song_library_cache WHERE language_name = '英文' AND (`artistA_category` = '團' OR `artistB_category` = '團') ORDER BY song_id DESC";
|
||||||
var yingWenSongs = SearchSongs_Mysql(query);
|
var yingWenSongs = SearchSongs_Mysql(query);
|
||||||
currentPage = 0;
|
currentPage = 0;
|
||||||
currentSongList = yingWenSongs;
|
currentSongList = yingWenSongs;
|
||||||
|
@ -14,7 +14,8 @@ namespace DualScreenDemo
|
|||||||
/*yueYuSongs = allSongs.Where(song => song.Category == "粵語" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
/*yueYuSongs = allSongs.Where(song => song.Category == "粵語" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
||||||
.OrderByDescending(song => song.Plays)
|
.OrderByDescending(song => song.Plays)
|
||||||
.ToList();*/
|
.ToList();*/
|
||||||
String query = "SELECT * FROM SongLibrary WHERE `語別` = '粵語' AND (`歌星A分類` = '團' OR `歌星B分類` = '團') ORDER BY `點播次數` DESC";
|
|
||||||
|
string query = "SELECT * FROM song_library_cache WHERE language_name = '粵語' AND (`artistA_category` = '團' OR `artistB_category` = '團') ORDER BY song_id DESC";
|
||||||
var yueYuSongs = SearchSongs_Mysql(query);
|
var yueYuSongs = SearchSongs_Mysql(query);
|
||||||
currentPage = 0;
|
currentPage = 0;
|
||||||
currentSongList = yueYuSongs;
|
currentSongList = yueYuSongs;
|
||||||
|
@ -131,7 +131,7 @@ namespace DualScreenDemo
|
|||||||
/*guoYuSongs = allSongs.Where(song => song.Category == "國語" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
/*guoYuSongs = allSongs.Where(song => song.Category == "國語" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
||||||
.OrderByDescending(song => song.Plays)
|
.OrderByDescending(song => song.Plays)
|
||||||
.ToList();*/
|
.ToList();*/
|
||||||
String query = "SELECT * FROM SongLibrary WHERE `語別` = '國語' AND (`歌星A分類` = '團' OR `歌星B分類` = '團') ORDER BY `點播次數` DESC";
|
string query = "SELECT * FROM song_library_cache WHERE language_name = '國語' AND (`artistA_category` = '團' OR `artistB_category` = '團') ORDER BY song_id DESC";
|
||||||
var guoYuSongs = SearchSongs_Mysql(query);
|
var guoYuSongs = SearchSongs_Mysql(query);
|
||||||
currentPage = 0;
|
currentPage = 0;
|
||||||
currentSongList = guoYuSongs;
|
currentSongList = guoYuSongs;
|
||||||
|
@ -62,7 +62,7 @@ namespace DualScreenDemo
|
|||||||
isOnOrderedSongsPage = false;
|
isOnOrderedSongsPage = false;
|
||||||
|
|
||||||
int songLimit = ReadHotSongLimit();
|
int songLimit = ReadHotSongLimit();
|
||||||
string query = $"SELECT * FROM SongLibrary WHERE `語別` = '國語' ORDER BY `點播次數` DESC LIMIT {songLimit}";
|
string query = $"SELECT * FROM song_library_cache WHERE language_name = '國語' ORDER BY `song_id` DESC LIMIT {songLimit}";
|
||||||
var guoYuSongs = SearchSongs_Mysql(query);
|
var guoYuSongs = SearchSongs_Mysql(query);
|
||||||
UpdateSongList(guoYuSongs);
|
UpdateSongList(guoYuSongs);
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ namespace DualScreenDemo
|
|||||||
UpdateHotSongButtons(activeButton, activeBackground);
|
UpdateHotSongButtons(activeButton, activeBackground);
|
||||||
|
|
||||||
int songLimit = ReadHotSongLimit();
|
int songLimit = ReadHotSongLimit();
|
||||||
string query = $"SELECT * FROM SongLibrary WHERE `語別` = '{category}' ORDER BY `點播次數` DESC LIMIT {songLimit}";
|
string query = $"SELECT * FROM song_library_cache WHERE language_name = '{category}' ORDER BY `song_id` DESC LIMIT {songLimit}";
|
||||||
var selectedSongs = SearchSongs_Mysql(query);
|
var selectedSongs = SearchSongs_Mysql(query);
|
||||||
|
|
||||||
UpdateSongList(selectedSongs);
|
UpdateSongList(selectedSongs);
|
||||||
|
@ -8,8 +8,7 @@ namespace DualScreenDemo
|
|||||||
UpdateHotSongButtons(guoYuNewSongButtonHotSong, guoYuNewSongHotSongActiveBackground);
|
UpdateHotSongButtons(guoYuNewSongButtonHotSong, guoYuNewSongHotSongActiveBackground);
|
||||||
|
|
||||||
int songLimit = ReadHotSongLimit();
|
int songLimit = ReadHotSongLimit();
|
||||||
|
string query = $"SELECT * FROM song_library_cache WHERE language_name = '國語' ORDER BY `add_date` DESC LIMIT {songLimit}";
|
||||||
string query = $"SELECT * FROM SongLibrary WHERE `語別` = '國語' ORDER BY `新增日期` DESC ,`點播次數` DESC LIMIT {songLimit}";
|
|
||||||
var selectedSongs = PrimaryForm.Instance.SearchSongs_Mysql(query);
|
var selectedSongs = PrimaryForm.Instance.SearchSongs_Mysql(query);
|
||||||
|
|
||||||
currentPage = 0;
|
currentPage = 0;
|
||||||
|
@ -9,7 +9,7 @@ namespace DualScreenDemo
|
|||||||
|
|
||||||
int songLimit = ReadHotSongLimit();
|
int songLimit = ReadHotSongLimit();
|
||||||
|
|
||||||
string query = $"SELECT * FROM SongLibrary WHERE `語別` = '台語' ORDER BY `新增日期` DESC ,`點播次數` DESC LIMIT {songLimit}";
|
string query = $"SELECT * FROM song_library_cache WHERE language_name = '台語' ORDER BY `add_date` DESC LIMIT {songLimit}";
|
||||||
var selectedSongs = SearchSongs_Mysql(query);
|
var selectedSongs = SearchSongs_Mysql(query);
|
||||||
|
|
||||||
currentPage = 0;
|
currentPage = 0;
|
||||||
|
@ -73,7 +73,8 @@ namespace DualScreenDemo
|
|||||||
hanYuButton.BackgroundImage = hanYuNormalBackground;
|
hanYuButton.BackgroundImage = hanYuNormalBackground;
|
||||||
keYuButton.BackgroundImage = keYuNormalBackground;
|
keYuButton.BackgroundImage = keYuNormalBackground;
|
||||||
|
|
||||||
string query = $"SELECT * FROM SongLibrary WHERE `語別` = '國語' ORDER BY `點播次數` DESC LIMIT 100;";
|
|
||||||
|
string query = $"SELECT * FROM song_library_cache WHERE language_name = '國語' ORDER BY song_id DESC LIMIT 100";
|
||||||
var guoYuSongs = SearchSongs_Mysql(query);
|
var guoYuSongs = SearchSongs_Mysql(query);
|
||||||
currentPage = 0;
|
currentPage = 0;
|
||||||
currentSongList = guoYuSongs;
|
currentSongList = guoYuSongs;
|
||||||
@ -121,7 +122,7 @@ namespace DualScreenDemo
|
|||||||
|
|
||||||
|
|
||||||
activeButton.BackgroundImage = activeBackground;
|
activeButton.BackgroundImage = activeBackground;
|
||||||
string query = $"SELECT * FROM SongLibrary WHERE `語別` = '{category}' ORDER BY `點播次數` DESC LIMIT 100;";
|
string query = $"SELECT * FROM song_library_cache WHERE language_name = '{category}' ORDER BY song_id DESC LIMIT 100";
|
||||||
var selectedSongs = SearchSongs_Mysql(query);
|
var selectedSongs = SearchSongs_Mysql(query);
|
||||||
/*var selectedSongs = allSongs.Where(song => song.Category == category)
|
/*var selectedSongs = allSongs.Where(song => song.Category == category)
|
||||||
.OrderByDescending(song => song.Plays)
|
.OrderByDescending(song => song.Plays)
|
||||||
|
@ -251,7 +251,8 @@ namespace DualScreenDemo
|
|||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
private string setQueryforNewSong(string category){
|
private string setQueryforNewSong(string category){
|
||||||
string query = $"SELECT * FROM SongLibrary WHERE `語別` = '{category}' ORDER BY `新增日期` DESC LIMIT {ReadNewSongLimit()}";
|
string query = $"SELECT * FROM song_library_cache WHERE language_name = '{category}' ORDER BY add_date DESC LIMIT {ReadNewSongLimit()}";
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ namespace DualScreenDemo
|
|||||||
{
|
{
|
||||||
string searchText = artistLabel.Text; // 取得輸入內容
|
string searchText = artistLabel.Text; // 取得輸入內容
|
||||||
// 歌星 轉 歌曲
|
// 歌星 轉 歌曲
|
||||||
string query = $"SELECT * FROM SongLibrary WHERE `歌星 A` = '{searchText}' OR `歌星 B` = '{searchText}'";
|
string query = $"SELECT * FROM song_library_cache WHERE artistA ='{searchText}' OR artistB='{searchText}' ";
|
||||||
var searchResults = PrimaryForm.Instance.SearchSongs_Mysql(query);
|
var searchResults = PrimaryForm.Instance.SearchSongs_Mysql(query);
|
||||||
// 重置分頁
|
// 重置分頁
|
||||||
PrimaryForm.Instance.currentPage = 0;
|
PrimaryForm.Instance.currentPage = 0;
|
||||||
@ -426,6 +426,7 @@ namespace DualScreenDemo
|
|||||||
(!string.IsNullOrEmpty(song.SongSimplified) ? song.SongSimplified : song.Song) :
|
(!string.IsNullOrEmpty(song.SongSimplified) ? song.SongSimplified : song.Song) :
|
||||||
song.Song;
|
song.Song;
|
||||||
|
|
||||||
|
// 歌手名稱設置點
|
||||||
string artistText = IsSimplified ?
|
string artistText = IsSimplified ?
|
||||||
(!string.IsNullOrEmpty(song.ArtistASimplified) ? song.ArtistASimplified : song.ArtistA) :
|
(!string.IsNullOrEmpty(song.ArtistASimplified) ? song.ArtistASimplified : song.ArtistA) :
|
||||||
song.ArtistA;
|
song.ArtistA;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using MySqlConnector;
|
using MySqlConnector;
|
||||||
using DBObj;
|
using DBObj;
|
||||||
using System.Globalization;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
@ -9,12 +8,12 @@ namespace DualScreenDemo{
|
|||||||
{
|
{
|
||||||
public bool isLoggedIn = false;
|
public bool isLoggedIn = false;
|
||||||
public string userPhone = string.Empty;
|
public string userPhone = string.Empty;
|
||||||
public List<SongData> SearchSongs_Mysql(string query)
|
public List<SongData> SearchSongs_Mysql(string query)
|
||||||
{
|
{
|
||||||
List<SongData> searchResults = new List<SongData>();
|
List<SongData> searchResults = new List<SongData>();
|
||||||
Console.WriteLine(query);
|
Console.WriteLine(query);
|
||||||
string connectionString = "Server=192.168.11.4;Port=3306;Database=Karaoke-Kingpin;User=Karaoke-Kingpin;Password=ESM7yTPMnavFmbBH;";
|
string connectionString = "Server=192.168.11.4;Port=3306;Database=Karaoke-Kingpin;User=Karaoke-Kingpin;Password=ESM7yTPMnavFmbBH;";
|
||||||
|
|
||||||
using (var connection = new MySqlConnection(connectionString))
|
using (var connection = new MySqlConnection(connectionString))
|
||||||
{
|
{
|
||||||
Stopwatch stopwatch = new Stopwatch();
|
Stopwatch stopwatch = new Stopwatch();
|
||||||
@ -32,17 +31,17 @@ namespace DualScreenDemo{
|
|||||||
{
|
{
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
string songNumber = reader["歌曲編號"].ToString();
|
string songNumber = reader["song_id"].ToString();
|
||||||
string song = reader["歌曲名稱"].ToString();
|
string song = reader["song_name"].ToString();
|
||||||
string artistA = reader["歌星 A"].ToString();
|
string artistA = reader["artistA"].ToString();
|
||||||
string artistB = reader["歌星 B"].ToString();
|
string artistB = reader["artistB"].ToString();
|
||||||
string fileName = reader["歌曲檔名"].ToString();
|
string fileName = reader["song_filename"].ToString();
|
||||||
string songFilePathHost1 = Path.Combine(@"\\SVR01\DISK05", fileName); // \SVR01\DISK01\
|
string songFilePathHost1 = Path.Combine(@"\\SVR01\DISK05", fileName); // \SVR01\DISK01\
|
||||||
string songFilePathHost2 = Path.Combine(@"\\SVR02\DISK01", fileName); // \SVR02\DISK01\
|
string songFilePathHost2 = Path.Combine(@"\\SVR02\DISK01", fileName); // \SVR02\DISK01\
|
||||||
string artistASimplified = reader["歌星A簡體"].ToString();
|
string artistASimplified = reader["artistA_simplified"].ToString();
|
||||||
string artistBSimplified = reader["歌星B簡體"].ToString();
|
string artistBSimplified = reader["artistB_simplified"].ToString();
|
||||||
string songSimplified = reader["歌名簡體"].ToString();
|
string songSimplified = reader["song_simplified"].ToString();
|
||||||
int humanVoice = Convert.ToInt32(reader["人聲"]);
|
int humanVoice = Convert.ToInt32(reader["vocal"]);
|
||||||
|
|
||||||
searchResults.Add(new SongData(
|
searchResults.Add(new SongData(
|
||||||
songNumber, song, artistA, artistB,
|
songNumber, song, artistA, artistB,
|
||||||
@ -126,14 +125,9 @@ namespace DualScreenDemo{
|
|||||||
}
|
}
|
||||||
public string SearchFavoriteSongs_Mysql(){
|
public string SearchFavoriteSongs_Mysql(){
|
||||||
string query = $"SELECT " +
|
string query = $"SELECT " +
|
||||||
"sl.歌曲編號, sl.語別, sl.歌曲名稱, sl.點播次數, " +
|
"sl.*"+
|
||||||
"sl.`歌星 A`, sl.`歌星 B`, sl.新增日期, " +
|
|
||||||
"sl.`路徑 1`, sl.`路徑 2`, sl.歌曲檔名, sl.歌曲注音, sl.歌曲拼音, " +
|
|
||||||
"sl.歌星A分類, sl.歌星B分類, sl.歌星A注音, sl.歌星B注音, " +
|
|
||||||
"sl.歌星A簡體, sl.歌星B簡體, sl.歌名簡體, sl.分類, " +
|
|
||||||
"sl.歌星A拼音, sl.歌星B拼音, sl.人聲 " +
|
|
||||||
"FROM FavoriteSongs fs " +
|
"FROM FavoriteSongs fs " +
|
||||||
"JOIN SongLibrary sl ON fs.SongNumber = sl.歌曲編號 " +
|
"JOIN song_library_cache sl ON fs.SongNumber = sl.song_id " +
|
||||||
$"WHERE fs.Phonenumber = '{userPhone}';";
|
$"WHERE fs.Phonenumber = '{userPhone}';";
|
||||||
return query;
|
return query;
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ namespace DualScreenDemo
|
|||||||
private void AlbumButton_Click(object sender, EventArgs e)
|
private void AlbumButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
string name = currentSelectedSong.ArtistA;
|
string name = currentSelectedSong.ArtistA;
|
||||||
string query = $"SELECT * FROM SongLibrary WHERE `歌星 A` = '{name}' ORDER BY `新增日期` DESC";
|
string query = $"SELECT * FROM song_library_cache WHERE artistA = '{name}' ORDER BY add_date DESC";
|
||||||
var selectedSongs = SearchSongs_Mysql(query);
|
var selectedSongs = SearchSongs_Mysql(query);
|
||||||
/*var selectedSongs = allSongs.Where(song => song.ArtistA == currentSelectedSong.ArtistA)
|
/*var selectedSongs = allSongs.Where(song => song.ArtistA == currentSelectedSong.ArtistA)
|
||||||
.OrderByDescending(song => song.AddedTime)
|
.OrderByDescending(song => song.AddedTime)
|
||||||
|
@ -309,11 +309,12 @@ namespace DualScreenDemo
|
|||||||
string searchText = inputBoxZhuYinSongs.Text;
|
string searchText = inputBoxZhuYinSongs.Text;
|
||||||
// 在這裡添加搜尋歌曲的邏輯
|
// 在這裡添加搜尋歌曲的邏輯
|
||||||
// 例如:根據輸入框的內容搜尋歌曲
|
// 例如:根據輸入框的內容搜尋歌曲
|
||||||
|
|
||||||
string query = string.IsNullOrWhiteSpace(searchText)
|
string query = string.IsNullOrWhiteSpace(searchText)
|
||||||
? "SELECT * FROM SongLibrary ORDER BY `點播次數` DESC LIMIT 200;"
|
? "SELECT * FROM song_library_cache ORDER BY `song_id` DESC LIMIT 200;"
|
||||||
: $"SELECT * FROM SongLibrary WHERE `歌曲注音` LIKE '{searchText}%' ORDER BY `點播次數` DESC;";
|
: $"SELECT * FROM song_library_cache WHERE `phonetic_abbr` LIKE '{searchText}%' ORDER BY `song_id`;";
|
||||||
|
|
||||||
var searchResults = SearchSongs_Mysql(query);
|
var searchResults = SearchSongs_Mysql(query);
|
||||||
// 重置分頁
|
// 重置分頁
|
||||||
currentPage = 0;
|
currentPage = 0;
|
||||||
currentSongList = searchResults;
|
currentSongList = searchResults;
|
||||||
|
@ -230,8 +230,8 @@ namespace DualScreenDemo
|
|||||||
string searchText = inputBoxEnglishSongs.Text;
|
string searchText = inputBoxEnglishSongs.Text;
|
||||||
// 檢查是否為空字串或空白字元
|
// 檢查是否為空字串或空白字元
|
||||||
string query = string.IsNullOrWhiteSpace(searchText)
|
string query = string.IsNullOrWhiteSpace(searchText)
|
||||||
? "SELECT * FROM SongLibrary ORDER BY `點播次數` DESC LIMIT 200;"
|
? "SELECT * FROM song_library_cache ORDER BY song_id DESC LIMIT 200;"
|
||||||
: $"SELECT * FROM SongLibrary WHERE `歌曲名稱` LIKE '{searchText}%' ORDER BY `點播次數` DESC;";
|
: $"SELECT * FROM song_library_cache WHERE song_name LIKE '{searchText}%' ORDER BY song_id DESC;";
|
||||||
|
|
||||||
var searchResults = SearchSongs_Mysql(query);
|
var searchResults = SearchSongs_Mysql(query);
|
||||||
// 重置分頁
|
// 重置分頁
|
||||||
|
@ -287,8 +287,8 @@ namespace DualScreenDemo
|
|||||||
// 在這裡添加搜尋歌曲的邏輯
|
// 在這裡添加搜尋歌曲的邏輯
|
||||||
// 例如:根據輸入框的內容搜尋歌曲
|
// 例如:根據輸入框的內容搜尋歌曲
|
||||||
string query = string.IsNullOrWhiteSpace(searchText)
|
string query = string.IsNullOrWhiteSpace(searchText)
|
||||||
? "SELECT * FROM SongLibrary ORDER BY `點播次數` DESC LIMIT 200;"
|
? "SELECT * FROM song_library_cache ORDER BY song_id DESC LIMIT 200;"
|
||||||
: $"SELECT * FROM SongLibrary WHERE `歌曲名稱` LIKE '{searchText}%' ORDER BY `點播次數` DESC;";
|
: $"SELECT * FROM song_library_cache WHERE song_name LIKE '{searchText}%' ORDER BY song_id DESC;";
|
||||||
|
|
||||||
|
|
||||||
var searchResults = SearchSongs_Mysql(query);
|
var searchResults = SearchSongs_Mysql(query);
|
||||||
|
@ -550,7 +550,7 @@ namespace DualScreenDemo
|
|||||||
// 如果輸入框為空,則不進行搜尋
|
// 如果輸入框為空,則不進行搜尋
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
string query = $"SELECT * FROM SongLibrary WHERE `歌曲編號` = '{searchText}' ";
|
string query = $"SELECT * FROM song_library_cache WHERE `song_id` = '{searchText}' ";
|
||||||
|
|
||||||
var searchResults = SearchSongs_Mysql(query);
|
var searchResults = SearchSongs_Mysql(query);
|
||||||
// 重置分頁
|
// 重置分頁
|
||||||
|
@ -266,8 +266,8 @@ namespace DualScreenDemo
|
|||||||
// 在這裡添加搜尋歌曲的邏輯
|
// 在這裡添加搜尋歌曲的邏輯
|
||||||
// 例如:根據輸入框的內容搜尋歌曲
|
// 例如:根據輸入框的內容搜尋歌曲
|
||||||
string query = string.IsNullOrWhiteSpace(searchText)
|
string query = string.IsNullOrWhiteSpace(searchText)
|
||||||
? "SELECT * FROM SongLibrary ORDER BY `點播次數` DESC LIMIT 200;"
|
? "SELECT * FROM song_library_cache ORDER BY song_id DESC LIMIT 200;"
|
||||||
: $"SELECT * FROM SongLibrary WHERE `歌曲拼音` LIKE '{searchText}%' ORDER BY `點播次數` DESC;";
|
: $"SELECT * FROM song_library_cache WHERE pinyin_abbr LIKE '{searchText}%' ORDER BY `song_id` DESC;";
|
||||||
var searchResults = SearchSongs_Mysql(query);
|
var searchResults = SearchSongs_Mysql(query);
|
||||||
// 重置分頁
|
// 重置分頁
|
||||||
currentPage = 0;
|
currentPage = 0;
|
||||||
@ -276,8 +276,6 @@ namespace DualScreenDemo
|
|||||||
// 更新多頁面面板的內容
|
// 更新多頁面面板的內容
|
||||||
multiPagePanel.currentPageIndex = 0;
|
multiPagePanel.currentPageIndex = 0;
|
||||||
multiPagePanel.LoadSongs(currentSongList);
|
multiPagePanel.LoadSongs(currentSongList);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化拼音輸入框 (RichTextBox),並從 config.ini 讀取相關設定。
|
/// 初始化拼音輸入框 (RichTextBox),並從 config.ini 讀取相關設定。
|
||||||
|
@ -477,7 +477,7 @@ namespace DualScreenDemo
|
|||||||
string query;
|
string query;
|
||||||
if (int.TryParse(searchText, out int length))
|
if (int.TryParse(searchText, out int length))
|
||||||
{
|
{
|
||||||
query = $"SELECT * FROM SongLibrary WHERE CHAR_LENGTH(歌曲名稱) = {length} ";
|
query = $"SELECT * FROM song_library_cache WHERE CHAR_LENGTH(song_name) = {length} ";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user