superstar_v2/DBObj/SongData.cs

134 lines
5.0 KiB
C#
Raw Normal View History

2025-07-08 13:37:12 +08:00
using DualScreenDemo;
using System;
using System.IO;
2025-04-07 16:54:10 +08:00
namespace DBObj
{
public class SongData
{
2025-07-08 18:13:36 +08:00
public string Number { get; set; }
public string Name { get; set; }
public string Artist_A { get; set; }
private string Artist_B { get; set; }
2025-05-21 10:29:18 +08:00
public string FileName { get; set; }
2025-07-08 18:13:36 +08:00
public string Artist_A_Simplified { get; set; }
public string Artist_B_Simplified { get; set; }
public string Name_Simplified { get; set; }
2025-05-21 10:29:18 +08:00
public int HumanVoice { get; set; }
2025-07-08 13:37:12 +08:00
public bool isPublicSong { get; set; }
public PlayState state;
2025-04-07 16:54:10 +08:00
2025-04-21 11:33:31 +08:00
/*
2025-04-07 16:54:10 +08:00
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;
2025-04-21 11:33:31 +08:00
// Category = category;
2025-04-07 16:54:10 +08:00
Song = song;
2025-04-21 11:33:31 +08:00
// Plays = plays;
2025-04-07 16:54:10 +08:00
ArtistA = artistA;
ArtistB = artistB;
2025-04-21 11:33:31 +08:00
//ArtistACategory = artistACategory;
//ArtistBCategory = artistBCategory;
//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;
}
*/
2025-07-08 13:37:12 +08:00
public SongData(string songNumber, string song, string filename, int humanVoice, bool isPublic)
{
2025-07-08 18:13:36 +08:00
Number = songNumber;
Name = song;
FileName = filename;
HumanVoice = humanVoice;
2025-07-08 13:37:12 +08:00
isPublicSong = isPublic;
}
public SongData(string songNumber, string song, string artistA, string artistB, string filename, string artistASimplified, string artistBSimplified, string songSimplified, int humanVoice)
2025-04-21 11:33:31 +08:00
{
2025-07-08 18:13:36 +08:00
Number = songNumber;
Name = song;
Artist_A = artistA;
Artist_B = artistB;
FileName = filename;
Artist_A_Simplified = artistASimplified;
Artist_B_Simplified = artistBSimplified;
Name_Simplified = songSimplified;
HumanVoice = humanVoice;
2025-07-08 13:37:12 +08:00
isPublicSong = false;
}
2025-07-08 18:13:36 +08:00
public string getName(bool IsSimplified=false)
{
return IsSimplified ? Name_Simplified : Name;
}
public int getNameLength()
{
return Name.Length;
}
public string next_artist_text()
{
return !string.IsNullOrWhiteSpace(Artist_B)
? String.Format("下一首:{0} {1} {2}", Artist_A, Artist_B, Name)
: String.Format("下一首:{0} {1}", Artist_A, Name);
}
public string artist_text()
{
return !string.IsNullOrWhiteSpace(Artist_B)
? $"{Artist_A} - {Artist_B}"
: Artist_A;
}
public string name_text()
{
return !string.IsNullOrWhiteSpace(Artist_B)
? String.Format("{0} - {1} - {2}", Artist_A, Artist_B, Name)
: String.Format("{0} - {1}", Artist_A, Name);
}
public string getArtist_A(bool IsSimplified)
{
return IsSimplified ? Artist_A_Simplified : Artist_A;
}
public string getArtist_B(bool IsSimplified)
{
return IsSimplified ? Artist_B_Simplified : Artist_B;
}
public string getFile()
{
return FindExistingPath(FileName);
}
2025-07-08 13:37:12 +08:00
private string FindExistingPath(string filename)
{
var servers = new[] { @"\\svr01\", @"\\svr02\", @"\\svr01\e", @"\\svr02\e" };
2025-07-08 18:13:36 +08:00
foreach (var server in servers)
{
2025-07-08 13:37:12 +08:00
string fullPath = Path.Combine(server, filename);
if (File.Exists(fullPath)) return fullPath;
}
2025-07-08 18:13:36 +08:00
return null; // 找不到就回原本的 filename不加路徑
2025-07-08 13:37:12 +08:00
}
public void SetState(PlayState s) => state = s;
public PlayState GetState()
{
return state;
2025-04-07 16:54:10 +08:00
}
2025-07-08 18:13:36 +08:00
2025-04-07 16:54:10 +08:00
public override string ToString()
{
2025-07-08 13:37:12 +08:00
2025-07-08 18:13:36 +08:00
return !string.IsNullOrWhiteSpace(Artist_B)
? String.Format("{0} - {1} - {2}", Artist_A, Artist_B, Name)
: String.Format("{0} - {1}", Artist_A, Name);
2025-04-07 16:54:10 +08:00
}
}
}