diff --git a/AsmrManage/AsmrManage/AsmrData.cs b/AsmrManage/AsmrManage/AsmrData.cs new file mode 100644 index 0000000..dc8be65 --- /dev/null +++ b/AsmrManage/AsmrManage/AsmrData.cs @@ -0,0 +1,21 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AsmrManage +{ + public class AsmrData + { + public string file_rj_str { get; set; } = string.Empty; + public string file_d_str { get; set; } = string.Empty; + public string file_vj_str { get; set; } = string.Empty; + public string file_nonhrj_str { get; set; } = string.Empty; + public string db_rj_str { get; set; } = string.Empty; + public string db_d_str { get; set; } = string.Empty; + public string db_vj_str { get; set; } = string.Empty; + public string db_nonhrj_str { get; set; } = string.Empty; + + } +} diff --git a/AsmrManage/AsmrManage/Form1.cs b/AsmrManage/AsmrManage/Form1.cs index b2326e4..b4512b6 100644 --- a/AsmrManage/AsmrManage/Form1.cs +++ b/AsmrManage/AsmrManage/Form1.cs @@ -5,6 +5,7 @@ using OfficeOpenXml; using System.Data.SQLite; using System.Diagnostics; using Microsoft.VisualBasic; +using System.Collections.Generic; namespace AsmrManage { @@ -449,6 +450,13 @@ namespace AsmrManage label28.Text = vjData.Count.ToString(); label29.Text = nonhrjData.Count.ToString(); + SaveDataP3(rjDirectories, dDirectories, vjDirectories, nonhrjDirectories, rjData, dData, vjData, nonhrjData); + Logp3("读取完毕"); + + } + + private static void SaveDataP3(List rjDirectories, List dDirectories, List vjDirectories, List nonhrjDirectories, List rjData, List dData, List vjData, List nonhrjData) + { NaturalOrderComparer comparer = new NaturalOrderComparer(); rjDirectories.Sort(comparer); dDirectories.Sort(comparer); @@ -458,10 +466,17 @@ namespace AsmrManage dData.Sort(comparer); vjData.Sort(comparer); nonhrjData.Sort(comparer); - - Logp3("读取完毕"); - + Program.data ??= new AsmrData(); + Program.data.file_rj_str = string.Join(Environment.NewLine, rjDirectories); + Program.data.file_d_str = string.Join(Environment.NewLine, dDirectories); + Program.data.file_vj_str = string.Join(Environment.NewLine, vjDirectories); + Program.data.file_nonhrj_str = string.Join(Environment.NewLine, nonhrjDirectories); + Program.data.db_rj_str = string.Join(Environment.NewLine, rjData); + Program.data.db_d_str = string.Join(Environment.NewLine, dData); + Program.data.db_vj_str = string.Join(Environment.NewLine, vjData); + Program.data.db_nonhrj_str = string.Join(Environment.NewLine, nonhrjData); } + private void Logp3(string message) //p3 log function { richTextBox2.AppendText(message + Environment.NewLine); @@ -470,61 +485,44 @@ namespace AsmrManage 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 set1 = new HashSet() { "A", "B", "C" }; - HashSet set2 = new HashSet() { "B", "C", "D" }; - - // 将 HashSet 转换为 List(也可以选择转换为数组) - List list1 = new List(set1); - List list2 = new List(set2); - - // 创建一个比较器 - //InlineDiffBuilder.Diff(); - - - // 获取差异细节 - List addedItems = new List(); - List deletedItems = new List(); - List modifiedItems = new List(); - - //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) + Program.data ??= new AsmrData(); + if (checkBox9.Checked) { - Console.WriteLine(item); + Logp3("# H_RJ差异情况:"); + DiffContent(Program.data.file_rj_str, Program.data.db_rj_str); + } + if (checkBox10.Checked) + { + Logp3("# H_D差异情况:"); + DiffContent(Program.data.file_d_str, Program.data.db_d_str); + } + if (checkBox11.Checked) + { + Logp3("# H_VJ差异情况:"); + DiffContent(Program.data.file_vj_str, Program.data.db_vj_str); + } + if (checkBox12.Checked) + { + Logp3("# NonH_RJ差异情况:"); + DiffContent(Program.data.file_nonhrj_str, Program.data.db_nonhrj_str); } - Console.WriteLine("Deleted Items:"); - foreach (string item in deletedItems) - { - Console.WriteLine(item); - } + } - Console.WriteLine("Modified Items:"); - foreach (string item in modifiedItems) + private void DiffContent(string before, string after) + { + var diff_rj = InlineDiffBuilder.Diff(before, after); + foreach (var line in diff_rj.Lines) { - Console.WriteLine(item); + switch (line.Type) + { + case ChangeType.Inserted: + Logp3("+ " + line.Text); + break; + case ChangeType.Deleted: + Logp3("- " + line.Text); + break; + } } } } diff --git a/AsmrManage/AsmrManage/Program.cs b/AsmrManage/AsmrManage/Program.cs index 6f9b923..25f4a5e 100644 --- a/AsmrManage/AsmrManage/Program.cs +++ b/AsmrManage/AsmrManage/Program.cs @@ -6,6 +6,7 @@ namespace AsmrManage /// The main entry point for the application. /// public static AppConfig? config; + public static AsmrData? data; [STAThread] static void Main() {