This commit is contained in:
Chenx221 2023-10-06 16:42:40 +08:00
parent c7cd4794c5
commit 6a3afcad98
8 changed files with 189 additions and 98 deletions

View File

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34031.279
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AsmrManage", "AsmrManage\AsmrManage.csproj", "{7D569CE3-1810-4036-B166-2723176A65F0}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AsmrManage", "AsmrManage\AsmrManage.csproj", "{7D569CE3-1810-4036-B166-2723176A65F0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

Binary file not shown.

View File

@ -2,7 +2,7 @@
namespace AsmrManage
{
public class AppConfig
public class AppConfig //应用配置
{
public string DatabaseFilePath { get; set; } = string.Empty; //asmr.db 位置
public string DBBrowserPath { get; set; } = string.Empty; //DBBrowser 位置

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace AsmrManage
{
public class AsmrData
public class AsmrData //存放比较数据
{
public string file_rj_str { get; set; } = string.Empty;
public string file_d_str { get; set; } = string.Empty;

View File

@ -33,4 +33,13 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="7za.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="x64\7za.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -44,11 +44,6 @@
checkBox7 = new CheckBox();
checkBox6 = new CheckBox();
checkBox5 = new CheckBox();
groupBox4 = new GroupBox();
button11 = new Button();
label7 = new Label();
button10 = new Button();
label8 = new Label();
groupBox3 = new GroupBox();
richTextBox1 = new RichTextBox();
tabPage2 = new TabPage();
@ -117,7 +112,6 @@
tabControl1.SuspendLayout();
tabPage1.SuspendLayout();
groupBox5.SuspendLayout();
groupBox4.SuspendLayout();
groupBox3.SuspendLayout();
tabPage2.SuspendLayout();
groupBox2.SuspendLayout();
@ -158,7 +152,6 @@
tabPage1.Controls.Add(textBox6);
tabPage1.Controls.Add(label9);
tabPage1.Controls.Add(groupBox5);
tabPage1.Controls.Add(groupBox4);
tabPage1.Controls.Add(groupBox3);
tabPage1.Location = new Point(4, 24);
tabPage1.Name = "tabPage1";
@ -172,7 +165,7 @@
//
label12.AutoSize = true;
label12.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
label12.Location = new Point(22, 165);
label12.Location = new Point(81, 185);
label12.Name = "label12";
label12.Size = new Size(61, 21);
label12.TabIndex = 15;
@ -181,7 +174,7 @@
// label11
//
label11.AutoSize = true;
label11.Location = new Point(6, 138);
label11.Location = new Point(36, 160);
label11.Name = "label11";
label11.Size = new Size(62, 15);
label11.TabIndex = 14;
@ -190,7 +183,7 @@
// label10
//
label10.AutoSize = true;
label10.Location = new Point(6, 73);
label10.Location = new Point(21, 78);
label10.Name = "label10";
label10.Size = new Size(33, 15);
label10.TabIndex = 13;
@ -198,26 +191,29 @@
//
// comboBox1
//
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
comboBox1.FormattingEnabled = true;
comboBox1.Items.AddRange(new object[] { "H_RJ", "H_D", "H_VJ", "NonH_RJ" });
comboBox1.Location = new Point(6, 91);
comboBox1.Items.AddRange(new object[] { "Auto", "H_RJ", "H_D", "H_VJ", "NonH_RJ" });
comboBox1.Location = new Point(21, 96);
comboBox1.Name = "comboBox1";
comboBox1.Size = new Size(121, 23);
comboBox1.TabIndex = 12;
//
// button14
//
button14.Location = new Point(293, 43);
button14.Location = new Point(308, 48);
button14.Name = "button14";
button14.Size = new Size(23, 23);
button14.TabIndex = 10;
button14.Text = "X";
button14.TextAlign = ContentAlignment.MiddleRight;
button14.UseVisualStyleBackColor = true;
button14.Click += button14_Click;
//
// button13
//
button13.Enabled = false;
button13.Location = new Point(159, 218);
button13.Location = new Point(345, 94);
button13.Name = "button13";
button13.Size = new Size(157, 32);
button13.TabIndex = 9;
@ -227,7 +223,7 @@
//
// button12
//
button12.Location = new Point(159, 142);
button12.Location = new Point(345, 18);
button12.Name = "button12";
button12.Size = new Size(157, 70);
button12.TabIndex = 8;
@ -237,7 +233,7 @@
//
// textBox6
//
textBox6.Location = new Point(6, 43);
textBox6.Location = new Point(21, 48);
textBox6.Name = "textBox6";
textBox6.Size = new Size(281, 23);
textBox6.TabIndex = 7;
@ -245,7 +241,7 @@
// label9
//
label9.AutoSize = true;
label9.Location = new Point(6, 25);
label9.Location = new Point(21, 30);
label9.Name = "label9";
label9.Size = new Size(77, 15);
label9.TabIndex = 6;
@ -257,9 +253,9 @@
groupBox5.Controls.Add(checkBox7);
groupBox5.Controls.Add(checkBox6);
groupBox5.Controls.Add(checkBox5);
groupBox5.Location = new Point(322, 112);
groupBox5.Location = new Point(322, 138);
groupBox5.Name = "groupBox5";
groupBox5.Size = new Size(200, 145);
groupBox5.Size = new Size(200, 119);
groupBox5.TabIndex = 5;
groupBox5.TabStop = false;
groupBox5.Text = "选项";
@ -277,11 +273,12 @@
// checkBox7
//
checkBox7.AutoSize = true;
checkBox7.Enabled = false;
checkBox7.Location = new Point(6, 72);
checkBox7.Name = "checkBox7";
checkBox7.Size = new Size(170, 19);
checkBox7.Size = new Size(168, 19);
checkBox7.TabIndex = 2;
checkBox7.Text = "自动判断类别(支持H_*)";
checkBox7.Text = "自动判断类别(Auto)(仅H)";
checkBox7.UseVisualStyleBackColor = true;
//
// checkBox6
@ -304,58 +301,6 @@
checkBox5.Text = "查找后自动添加缺少项";
checkBox5.UseVisualStyleBackColor = true;
//
// groupBox4
//
groupBox4.Controls.Add(button11);
groupBox4.Controls.Add(label7);
groupBox4.Controls.Add(button10);
groupBox4.Controls.Add(label8);
groupBox4.Location = new Point(322, 6);
groupBox4.Name = "groupBox4";
groupBox4.Size = new Size(200, 100);
groupBox4.TabIndex = 4;
groupBox4.TabStop = false;
groupBox4.Text = "数据库连接";
//
// button11
//
button11.Enabled = false;
button11.Location = new Point(98, 49);
button11.Name = "button11";
button11.Size = new Size(102, 51);
button11.TabIndex = 5;
button11.Text = "结束";
button11.UseVisualStyleBackColor = true;
//
// label7
//
label7.AutoSize = true;
label7.Location = new Point(6, 19);
label7.Name = "label7";
label7.Size = new Size(36, 15);
label7.TabIndex = 1;
label7.Text = "状态:";
//
// button10
//
button10.Location = new Point(0, 49);
button10.Name = "button10";
button10.Size = new Size(102, 51);
button10.TabIndex = 2;
button10.Text = "开始";
button10.UseVisualStyleBackColor = true;
button10.Click += button10_Click;
//
// label8
//
label8.AutoSize = true;
label8.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
label8.Location = new Point(45, 19);
label8.Name = "label8";
label8.Size = new Size(77, 21);
label8.TabIndex = 3;
label8.Text = "Unknown";
//
// groupBox3
//
groupBox3.Controls.Add(richTextBox1);
@ -889,27 +834,29 @@
//
// button16
//
button16.Location = new Point(469, 353);
button16.Location = new Point(451, 353);
button16.Name = "button16";
button16.Size = new Size(53, 37);
button16.Size = new Size(71, 37);
button16.TabIndex = 2;
button16.Text = "清空";
button16.UseVisualStyleBackColor = true;
button16.Click += button16_Click;
//
// button15
//
button15.Location = new Point(469, 267);
button15.Location = new Point(451, 267);
button15.Name = "button15";
button15.Size = new Size(53, 80);
button15.Size = new Size(71, 80);
button15.TabIndex = 1;
button15.Text = "保存日志";
button15.UseVisualStyleBackColor = true;
button15.Click += button15_Click;
//
// richTextBox2
//
richTextBox2.Location = new Point(6, 267);
richTextBox2.Name = "richTextBox2";
richTextBox2.Size = new Size(457, 123);
richTextBox2.Size = new Size(439, 123);
richTextBox2.TabIndex = 0;
richTextBox2.Text = "";
//
@ -1057,8 +1004,6 @@
tabPage1.PerformLayout();
groupBox5.ResumeLayout(false);
groupBox5.PerformLayout();
groupBox4.ResumeLayout(false);
groupBox4.PerformLayout();
groupBox3.ResumeLayout(false);
tabPage2.ResumeLayout(false);
groupBox2.ResumeLayout(false);
@ -1117,11 +1062,6 @@
private Button button7;
private GroupBox groupBox3;
private RichTextBox richTextBox1;
private Button button10;
private Label label7;
private GroupBox groupBox4;
private Button button11;
private Label label8;
private Button button13;
private Button button12;
private TextBox textBox6;

View File

@ -1,11 +1,8 @@
using DiffPlex.DiffBuilder.Model;
using DiffPlex.DiffBuilder;
using DiffPlex;
using OfficeOpenXml;
using System.Data.SQLite;
using System.Diagnostics;
using Microsoft.VisualBasic;
using System.Collections.Generic;
namespace AsmrManage
{
@ -180,6 +177,7 @@ namespace AsmrManage
private void TabControl1_SelectedIndexChanged(object sender, EventArgs e) //切换标签页
{
ResetPage2();
ResetPage3();
ResetPage4();
if (tabControl1.SelectedTab == tabPage4)
{
@ -199,6 +197,23 @@ namespace AsmrManage
textBox4.Text = string.Empty;
textBox5.Text = string.Empty;
} //刷新P4
private void ResetPage3() //刷新P3
{
textBox7.Text = string.Empty;
label18.Text = string.Empty;
label19.Text = string.Empty;
label20.Text = string.Empty;
label21.Text = string.Empty;
label26.Text = string.Empty;
label27.Text = string.Empty;
label28.Text = string.Empty;
label29.Text = string.Empty;
checkBox9.Checked = false;
checkBox10.Checked = false;
checkBox11.Checked = false;
checkBox12.Checked = false;
richTextBox2.Text = string.Empty;
}
private void ResetPage2()
{
@ -264,7 +279,7 @@ namespace AsmrManage
}
}
private void button5_Click(object sender, EventArgs e)
private void button5_Click(object sender, EventArgs e) //p4 EXE文件位置选框2
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Title = "请选择DB Browser for SQLite主程序";
@ -276,7 +291,7 @@ namespace AsmrManage
}
}
private void button6_Click(object sender, EventArgs e)
private void button6_Click(object sender, EventArgs e) //p4 调用db browser预览数据库
{
if (Program.config == null) { Program.config = ConfigManager.LoadConfig(); }
string db_path = Program.config.DatabaseFilePath;
@ -315,9 +330,90 @@ namespace AsmrManage
}
private void button12_Click(object sender, EventArgs e)
private void button12_Click(object sender, EventArgs e) //P1查找
{
//查找前检查
//验证数据库配置文件是否正确
Program.config = ConfigManager.LoadConfig();
string DbPath = Program.config.DatabaseFilePath;
if (!File.Exists(DbPath))
{
Logp1("DB文件路径错误请先检查配置文件");
return;
}
//获取查找/添加关键词,检查是否符合规则
string keyword = textBox6.Text.Trim();
string pattern = "^(RJ|VJ|D)[0-9]+$"; // 匹配以RJ、VJ、D开头后跟数字的模式
if (System.Text.RegularExpressions.Regex.IsMatch(keyword, pattern))
{
keyword = keyword.ToUpper(); // 将关键词转为大写
}
else
{
Logp1("输入内容格式有误,请检查格式是否正确");
return;
}
//获取类别选择
//现支持Auto,H_RJ,H_D,H_VJ,NonH_RJ
//其中Auto不支持NonH_RJ
object selectedValue = comboBox1.SelectedItem;
string selectedText;
if (selectedValue != null)
{
selectedText = selectedValue.ToString();
switch (selectedText)
{
case "H_RJ":
case "NonH_RJ":
if (System.Text.RegularExpressions.Regex.IsMatch(keyword, @"^RJ\d+$"))
{
// RJ + 数字 的情况
break;
}
Logp1("输入内容与选择的类别不匹配");
return;
case "H_D":
if (System.Text.RegularExpressions.Regex.IsMatch(keyword, @"^D\d+$"))
{
// D + 数字 的情况
break;
}
Logp1("输入内容与选择的类别不匹配");
return;
case "H_VJ":
if (System.Text.RegularExpressions.Regex.IsMatch(keyword, @"^VJ\d+$"))
{
// VJ + 数字 的情况
break;
}
Logp1("输入内容与选择的类别不匹配");
return;
default:
Logp1("程序异常");
return;
}
}
else
{
Logp1("未选择类别,请先选择类别");
return;
}
//获取选项值
bool Feature_Auto_Add = checkBox5.Checked; //查找后缺少时自动添加
bool Feature_Auto_Clear = checkBox6.Checked; //添加后自动清空输入框
//bool Feature_Auto_Detect_Type = checkBox7.Checked; //自动检测类型 //功能已移动
bool Feature_Auto_Backup = checkBox8.Checked; //自动备份数据库
//执行备份(如果有需要)
if(Feature_Auto_Backup)
{
// string DbPath = Program.config.DatabaseFilePath; //数据库所在位置
}
}
private void button17_Click(object sender, EventArgs e) //P3 读取信息
@ -375,6 +471,10 @@ namespace AsmrManage
foreach (string directory in directories2)
{
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))
{
nonhrjDirectories.Add(directoryName);
@ -455,7 +555,7 @@ namespace AsmrManage
}
private static void SaveDataP3(List<string> rjDirectories, List<string> dDirectories, List<string> vjDirectories, List<string> nonhrjDirectories, List<string> rjData, List<string> dData, List<string> vjData, List<string> nonhrjData)
private static void SaveDataP3(List<string> rjDirectories, List<string> dDirectories, List<string> vjDirectories, List<string> nonhrjDirectories, List<string> rjData, List<string> dData, List<string> vjData, List<string> nonhrjData) //读取配套任务,保存读取到的数据用以后期比较
{
NaturalOrderComparer comparer = new NaturalOrderComparer();
rjDirectories.Sort(comparer);
@ -482,6 +582,11 @@ namespace AsmrManage
richTextBox2.AppendText(message + Environment.NewLine);
richTextBox2.ScrollToCaret();
}
private void Logp1(string message) //p1 log function
{
richTextBox1.AppendText(message + Environment.NewLine);
richTextBox1.ScrollToCaret();
}
private void button18_Click(object sender, EventArgs e) //p3比较
{
@ -509,7 +614,7 @@ namespace AsmrManage
}
private void DiffContent(string before, string after)
private void DiffContent(string before, string after) //内容比较,给出差异细节并输出
{
var diff_rj = InlineDiffBuilder.Diff(before, after);
foreach (var line in diff_rj.Lines)
@ -525,5 +630,42 @@ namespace AsmrManage
}
}
}
private void button15_Click(object sender, EventArgs e) //save p3 log
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Log Files|*.log";
saveFileDialog.Title = "Save Log File";
saveFileDialog.FileName = DateTime.Now.ToString("yyyy-MM-dd") + ".log";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
string filePath = saveFileDialog.FileName;
try
{
using (StreamWriter writer = new StreamWriter(filePath))
{
writer.Write(richTextBox2.Text);
}
MessageBox.Show("日志已成功保存。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show("保存日志时发生错误:" + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void button16_Click(object sender, EventArgs e) //清空p1查找关键词框
{
richTextBox2.Text = String.Empty;
}
private void button14_Click(object sender, EventArgs e)
{
textBox6.Text = String.Empty;
}
}
}

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace AsmrManage
{
internal class NaturalOrderComparer : IComparer<string>
internal class NaturalOrderComparer : IComparer<string> //自然排序(自定义规则)
{
public int Compare(string? x, string? y)
{
@ -17,7 +17,7 @@ namespace AsmrManage
return numX.CompareTo(numY);
}
private int ExtractNumber(string? input)
private int ExtractNumber(string? input) // 截取数字部分
{
if (input == null)
{