update
This commit is contained in:
parent
e9c6a26f39
commit
8a1f2b5a7b
@ -11,6 +11,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="DiffPlex" Version="1.7.1" />
|
||||||
<PackageReference Include="EPPlus" Version="6.2.10" />
|
<PackageReference Include="EPPlus" Version="6.2.10" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="System.Data.SQLite" Version="1.0.118" />
|
<PackageReference Include="System.Data.SQLite" Version="1.0.118" />
|
||||||
|
1222
AsmrManage/AsmrManage/Form1.Designer.cs
generated
1222
AsmrManage/AsmrManage/Form1.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,10 @@
|
|||||||
|
using DiffPlex.DiffBuilder.Model;
|
||||||
|
using DiffPlex.DiffBuilder;
|
||||||
|
using DiffPlex;
|
||||||
using OfficeOpenXml;
|
using OfficeOpenXml;
|
||||||
using System.Data.SQLite;
|
using System.Data.SQLite;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using Microsoft.VisualBasic;
|
||||||
|
|
||||||
namespace AsmrManage
|
namespace AsmrManage
|
||||||
{
|
{
|
||||||
@ -314,5 +318,214 @@ namespace AsmrManage
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void button17_Click(object sender, EventArgs e) //P3 读取信息
|
||||||
|
{
|
||||||
|
string driveLetter = textBox7.Text.Trim().ToUpper(); // 获取用户输入的盘符并转换为大写
|
||||||
|
string drivePath = $"{driveLetter}:\\"; // 组合成盘符路径
|
||||||
|
|
||||||
|
string filePath = Path.Combine(drivePath, "asmr_storage.txt"); // 组合路径
|
||||||
|
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
Logp3("标识符已找到,即将开始读取信息");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logp3("指定路径下未找到标识符,无法进行下一步操作");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string folderPath = Path.Combine(drivePath, "H");
|
||||||
|
string folderPath2 = Path.Combine(drivePath, "Non-H");
|
||||||
|
|
||||||
|
// 获取指定文件夹下的所有目录
|
||||||
|
string[] directories = Directory.GetDirectories(folderPath);
|
||||||
|
string[] directories2 = Directory.GetDirectories(folderPath2);
|
||||||
|
|
||||||
|
// 创建List来保存不同前缀的目录名称
|
||||||
|
List<string> rjDirectories = new List<string>();
|
||||||
|
List<string> dDirectories = new List<string>();
|
||||||
|
List<string> vjDirectories = new List<string>();
|
||||||
|
List<string> nonhrjDirectories = new List<string>();
|
||||||
|
|
||||||
|
// 遍历目录,根据前缀添加到对应的List中
|
||||||
|
foreach (string directory in directories)
|
||||||
|
{
|
||||||
|
string directoryName = Path.GetFileName(directory);
|
||||||
|
if (directoryName.EndsWith(".fin") || directoryName.EndsWith(".now"))
|
||||||
|
{
|
||||||
|
directoryName = directoryName.Substring(0, directoryName.Length - 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (directoryName.StartsWith("RJ", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
rjDirectories.Add(directoryName);
|
||||||
|
}
|
||||||
|
else if (directoryName.StartsWith("D", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
dDirectories.Add(directoryName);
|
||||||
|
}
|
||||||
|
else if (directoryName.StartsWith("VJ", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
vjDirectories.Add(directoryName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (string directory in directories2)
|
||||||
|
{
|
||||||
|
string directoryName = Path.GetFileName(directory);
|
||||||
|
if (directoryName.StartsWith("RJ", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
nonhrjDirectories.Add(directoryName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
label18.Text = rjDirectories.Count.ToString();
|
||||||
|
label19.Text = dDirectories.Count.ToString();
|
||||||
|
label20.Text = vjDirectories.Count.ToString();
|
||||||
|
label21.Text = nonhrjDirectories.Count.ToString();
|
||||||
|
|
||||||
|
Program.config ??= ConfigManager.LoadConfig();
|
||||||
|
string connectionString = $"Data Source={Program.config.DatabaseFilePath};Version=3"; // SQLite数据库连接字符串
|
||||||
|
|
||||||
|
// 创建List来保存不同类型的数据
|
||||||
|
List<string> rjData = new List<string>();
|
||||||
|
List<string> dData = new List<string>();
|
||||||
|
List<string> vjData = new List<string>();
|
||||||
|
List<string> nonhrjData = new List<string>();
|
||||||
|
|
||||||
|
// 连接SQLite数据库
|
||||||
|
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
|
||||||
|
{
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
// 获取H_RJ表中的数据
|
||||||
|
using (SQLiteCommand command = new SQLiteCommand("SELECT asmr_id FROM H_RJ", connection))
|
||||||
|
using (SQLiteDataReader reader = command.ExecuteReader())
|
||||||
|
{
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
string asmrName = reader.GetString(0);
|
||||||
|
rjData.Add(asmrName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取H_D表中的数据
|
||||||
|
using (SQLiteCommand command = new SQLiteCommand("SELECT asmr_id FROM H_D", connection))
|
||||||
|
using (SQLiteDataReader reader = command.ExecuteReader())
|
||||||
|
{
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
string asmrName = reader.GetString(0);
|
||||||
|
dData.Add(asmrName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取H_VJ表中的数据
|
||||||
|
using (SQLiteCommand command = new SQLiteCommand("SELECT asmr_id FROM H_VJ", connection))
|
||||||
|
using (SQLiteDataReader reader = command.ExecuteReader())
|
||||||
|
{
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
string asmrName = reader.GetString(0);
|
||||||
|
vjData.Add(asmrName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取NonH_RJ表中的数据
|
||||||
|
using (SQLiteCommand command = new SQLiteCommand("SELECT asmr_id FROM NonH_RJ", connection))
|
||||||
|
using (SQLiteDataReader reader = command.ExecuteReader())
|
||||||
|
{
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
string asmrName = reader.GetString(0);
|
||||||
|
nonhrjData.Add(asmrName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
connection.Close();
|
||||||
|
}
|
||||||
|
label26.Text = rjData.Count.ToString();
|
||||||
|
label27.Text = dData.Count.ToString();
|
||||||
|
label28.Text = vjData.Count.ToString();
|
||||||
|
label29.Text = nonhrjData.Count.ToString();
|
||||||
|
|
||||||
|
NaturalOrderComparer comparer = new NaturalOrderComparer();
|
||||||
|
rjDirectories.Sort(comparer);
|
||||||
|
dDirectories.Sort(comparer);
|
||||||
|
vjDirectories.Sort(comparer);
|
||||||
|
nonhrjDirectories.Sort(comparer);
|
||||||
|
rjData.Sort(comparer);
|
||||||
|
dData.Sort(comparer);
|
||||||
|
vjData.Sort(comparer);
|
||||||
|
nonhrjData.Sort(comparer);
|
||||||
|
|
||||||
|
Logp3("读取完毕");
|
||||||
|
|
||||||
|
}
|
||||||
|
private void Logp3(string message) //p3 log function
|
||||||
|
{
|
||||||
|
richTextBox2.AppendText(message + Environment.NewLine);
|
||||||
|
richTextBox2.ScrollToCaret();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button18_Click(object sender, EventArgs e) //p3比较
|
||||||
|
{
|
||||||
|
bool diff_rj_enable = checkBox9.Checked;
|
||||||
|
bool diff_d_enable = checkBox10.Checked;
|
||||||
|
bool diff_vj_enable = checkBox11.Checked;
|
||||||
|
bool diff_nonhrj_enable = checkBox12.Checked;
|
||||||
|
|
||||||
|
// 假设你有两个 HashSet
|
||||||
|
HashSet<string> set1 = new HashSet<string>() { "A", "B", "C" };
|
||||||
|
HashSet<string> set2 = new HashSet<string>() { "B", "C", "D" };
|
||||||
|
|
||||||
|
// 将 HashSet 转换为 List(也可以选择转换为数组)
|
||||||
|
List<string> list1 = new List<string>(set1);
|
||||||
|
List<string> list2 = new List<string>(set2);
|
||||||
|
|
||||||
|
// 创建一个比较器
|
||||||
|
//InlineDiffBuilder.Diff();
|
||||||
|
|
||||||
|
|
||||||
|
// 获取差异细节
|
||||||
|
List<string> addedItems = new List<string>();
|
||||||
|
List<string> deletedItems = new List<string>();
|
||||||
|
List<string> modifiedItems = new List<string>();
|
||||||
|
|
||||||
|
//foreach (var line in diffModel.Lines)
|
||||||
|
//{
|
||||||
|
// if (line.Type == ChangeType.Inserted)
|
||||||
|
// {
|
||||||
|
// addedItems.Add(line.Text);
|
||||||
|
// }
|
||||||
|
// else if (line.Type == ChangeType.Deleted)
|
||||||
|
// {
|
||||||
|
// deletedItems.Add(line.Text);
|
||||||
|
// }
|
||||||
|
// else if (line.Type == ChangeType.Modified)
|
||||||
|
// {
|
||||||
|
// modifiedItems.Add(line.Text);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
// 打印输出差异细节
|
||||||
|
Console.WriteLine("Added Items:");
|
||||||
|
foreach (string item in addedItems)
|
||||||
|
{
|
||||||
|
Console.WriteLine(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Deleted Items:");
|
||||||
|
foreach (string item in deletedItems)
|
||||||
|
{
|
||||||
|
Console.WriteLine(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Modified Items:");
|
||||||
|
foreach (string item in modifiedItems)
|
||||||
|
{
|
||||||
|
Console.WriteLine(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
49
AsmrManage/AsmrManage/NaturalOrderComparer.cs
Normal file
49
AsmrManage/AsmrManage/NaturalOrderComparer.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AsmrManage
|
||||||
|
{
|
||||||
|
internal class NaturalOrderComparer : IComparer<string>
|
||||||
|
{
|
||||||
|
public int Compare(string? x, string? y)
|
||||||
|
{
|
||||||
|
// 提取字符串中的数字部分并将其转换为数字进行比较
|
||||||
|
int numX = ExtractNumber(x);
|
||||||
|
int numY = ExtractNumber(y);
|
||||||
|
|
||||||
|
return numX.CompareTo(numY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int ExtractNumber(string? input)
|
||||||
|
{
|
||||||
|
if (input == null)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
string number = string.Empty;
|
||||||
|
foreach (char c in input)
|
||||||
|
{
|
||||||
|
if (char.IsDigit(c))
|
||||||
|
{
|
||||||
|
number += c;
|
||||||
|
}
|
||||||
|
else if (number.Length > 0)
|
||||||
|
{
|
||||||
|
// 已经提取到数字部分,遇到非数字字符则停止提取
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (int.TryParse(number, out int result))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 默认情况下,无法提取数字,则返回 0
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user