静态分析没有问题了。但是一尝试扫描文件夹就炸。怀疑是权限问题,但不确定。
This commit is contained in:
2026-05-26 14:14:11 +08:00
parent 0f73dfdb84
commit 87afe57bfa
23 changed files with 1251 additions and 7 deletions
+82
View File
@@ -464,5 +464,87 @@ public static class Database
return connection.ExecuteScalar<int>(sql, parameters);
}
/// <summary>
/// 获取所有唯一的分类值
/// </summary>
public static IEnumerable<string> GetAllCategories()
{
using IDbConnection connection = GetConnection();
connection.Open();
const string sql = "SELECT DISTINCT category FROM audio_files WHERE category IS NOT NULL AND category != '' ORDER BY category;";
return connection.Query<string>(sql);
}
/// <summary>
/// 解析 Keywords 字段,返回所有唯一的标签
/// </summary>
public static IEnumerable<string> GetAllKeywords()
{
using IDbConnection connection = GetConnection();
connection.Open();
const string sql = "SELECT keywords FROM audio_files WHERE keywords IS NOT NULL AND keywords != '';";
var rows = connection.Query<string>(sql);
var allKeywords = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
foreach (var row in rows)
{
if (string.IsNullOrWhiteSpace(row)) continue;
foreach (var part in row.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries))
{
if (!string.IsNullOrWhiteSpace(part))
allKeywords.Add(part);
}
}
return allKeywords.OrderBy(k => k, StringComparer.OrdinalIgnoreCase);
}
/// <summary>
/// 更新音频文件的可编辑字段
/// </summary>
public static bool UpdateEntry(AudioFileMeta meta)
{
try
{
using IDbConnection connection = GetConnection();
connection.Open();
const string sql = """
UPDATE audio_files SET
rating = @Rating,
notes = @Notes,
keywords = @Keywords,
category = @Category,
subcategory = @Subcategory,
description = @Description,
comments = @Comments,
fx_name = @FxName,
genre = @Genre,
style = @Style,
mood = @Mood,
library = @Library,
project_name = @ProjectName,
designer = @Designer,
recordist = @Recordist,
publisher = @Publisher,
manufacturer = @Manufacturer,
microphone = @Microphone,
location = @Location,
user1 = @User1,
user2 = @User2,
user3 = @User3,
user4 = @User4,
user5 = @User5,
user6 = @User6,
user7 = @User7,
user8 = @User8
WHERE id = @Id;
""";
connection.Execute(sql, meta);
return true;
}
catch (Exception)
{
return false;
}
}
#endregion
}