导表工具修改

This commit is contained in:
2025-10-09 17:55:51 +08:00
parent c1a3df2192
commit 547d234ad3
11 changed files with 423 additions and 574 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,3 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AExcelWorkbook_002Ecs_002Fl_003AC_0021_003FUsers_003FFIREBAT_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F26685bcb566c4c14b12da150da20d45842b010_003F40_003Ff5039b99_003FExcelWorkbook_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AJsonConvert_002Ecs_002Fl_003AC_0021_003FUsers_003FFIREBAT_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F00b3a5efdbc34c2f9c398fe4911d40e8b09a8_003F2e_003Fa774a145_003FJsonConvert_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ALogManager_002Ecs_002Fl_003AC_0021_003FUsers_003FFIREBAT_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fc5462be99aec4b8dbd0143c73a99d4d1e0000_003F10_003Fa592ee39_003FLogManager_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANativeWindow_002Ecs_002Fl_003AC_0021_003FUsers_003FFIREBAT_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F257c19112c5249f9bf699efc998471b6cef910_003F44_003Fcc810871_003FNativeWindow_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANativeWindow_002Ecs_002Fl_003AC_0021_003FUsers_003FFIREBAT_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F257c19112c5249f9bf699efc998471b6cef910_003F44_003Fcc810871_003FNativeWindow_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANativeWindow_002Ecs_002Fl_003AC_0021_003FUsers_003FFIREBAT_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fde7e5d9f3eff8e93316bbae6f9743ff9f72884862e5d612aaaba84bf9aa3a8_003FNativeWindow_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,5 @@
using OfficeOpenXml;
namespace NBConfigBuilder;
/// <summary>
@@ -9,20 +11,29 @@ public sealed class ExcelTable
/// 表格的名称。
/// </summary>
public readonly string Name;
/// <summary>
/// 客户端列信息,使用排序字典存储列名和列索引列表。
/// </summary>
public readonly SortedDictionary<string, List<int>> ClientColInfos = new();
/// <summary>
/// 服务器端列信息,使用排序字典存储列名和列索引列表。
/// </summary>
public readonly SortedDictionary<string, List<int>> ServerColInfos = new();
/// <summary>
/// 表数据
/// </summary>
public readonly ExcelWorksheet Sheet;
/// <summary>
/// 构造函数初始化Excel表格对象并设置表格名称。
/// </summary>
/// <param name="name">表格名称。</param>
public ExcelTable(string name)
/// <param name="sheet">表格。</param>
public ExcelTable(ExcelWorksheet sheet)
{
Name = name;
Name = sheet.Name;
Sheet = sheet;
}
}

View File

@@ -10,8 +10,13 @@ public static class ExcelTemplate
using System.Reflection;
using System.Collections.Generic;
using System.Collections.Concurrent;
#if FANTASY_NET
using Fantasy.ConfigTable;
using Fantasy.Serialize;
#else
using NBC;
using NBC.Serialize;
#endif
// ReSharper disable CollectionNeverUpdated.Global
// ReSharper disable UnusedAutoPropertyAccessor.Global
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

View File

@@ -1,22 +1,22 @@
using OfficeOpenXml;
namespace NBConfigBuilder;
public sealed class ExcelWorksheets(ExcelExporter excelExporter)
{
public bool TryGetValue(string worksheetName, out ExcelWorksheet excelWorksheet)
{
if (excelExporter.Worksheets.TryGetValue(worksheetName, out excelWorksheet))
{
return true;
}
var computeHash64 = HashCodeHelper.ComputeHash64(worksheetName);
if (!excelExporter.VersionInfo.WorksheetNames.Contains(computeHash64))
{
Log.Info($"{worksheetName} is not exist!");
}
return false;
}
}
// using OfficeOpenXml;
//
// namespace NBConfigBuilder;
//
// public sealed class ExcelWorksheets(ExcelExporter excelExporter)
// {
// public bool TryGetValue(string worksheetName, out ExcelWorksheet excelWorksheet)
// {
// if (excelExporter.Worksheets.TryGetValue(worksheetName, out excelWorksheet))
// {
// return true;
// }
//
// var computeHash64 = HashCodeHelper.ComputeHash64(worksheetName);
// if (!excelExporter.VersionInfo.WorksheetNames.Contains(computeHash64))
// {
// Log.Info($"{worksheetName} is not exist!");
// }
//
// return false;
// }
// }

View File

@@ -1,17 +0,0 @@
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
namespace NBConfigBuilder;
/// <summary>
/// 导出信息类,用于存储导出操作的名称和文件信息。
/// </summary>
public class ExportInfo
{
/// <summary>
/// 导出操作的名称。
/// </summary>
public string Name;
/// <summary>
/// 导出操作生成的文件信息。
/// </summary>
public FileInfo FileInfo;
}

View File

@@ -100,7 +100,7 @@
checkBoxGenClient.Name = "checkBoxGenClient";
checkBoxGenClient.Size = new Size(87, 21);
checkBoxGenClient.TabIndex = 5;
checkBoxGenClient.Text = "生产服务端";
checkBoxGenClient.Text = "生成客户端";
checkBoxGenClient.UseVisualStyleBackColor = true;
//
// label2
@@ -137,7 +137,7 @@
checkBoxGenServer.Name = "checkBoxGenServer";
checkBoxGenServer.Size = new Size(87, 21);
checkBoxGenServer.TabIndex = 9;
checkBoxGenServer.Text = "生产客户端";
checkBoxGenServer.Text = "生成服务端";
checkBoxGenServer.UseVisualStyleBackColor = true;
//
// buttonSelectServerPath

View File

@@ -1,4 +1,5 @@
using System.Text.Json;
using System.Threading.Tasks;
namespace NBConfigBuilder
{
@@ -7,6 +8,9 @@ namespace NBConfigBuilder
// 配置文件路径
private readonly string configPath =
Path.Combine(Path.GetDirectoryName(Application.ExecutablePath) ?? string.Empty, "config.json");
// 保存原始标题
private string _originalTitle;
public Form1()
{
@@ -14,16 +18,64 @@ namespace NBConfigBuilder
// 设置窗口大小不可变
this.FormBorderStyle = FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
// 保存原始标题
_originalTitle = this.Text;
// 加载保存的配置
LoadConfig();
}
private void buttonRun_Click(object sender, EventArgs e)
private async void buttonRun_Click(object sender, EventArgs e)
{
// 保存当前配置
SaveConfig();
new ExcelExporter(ExportType.AllExcel).Run();
// 禁用按钮防止重复点击
buttonRun.Enabled = false;
buttonRun.Text = "执行中...";
try
{
// 保存当前配置
SaveConfig();
// 创建导出器并设置进度回调
var exporter = new ExcelExporter(ExportType.AllExcel);
exporter.SetProgressCallback(UpdateProgress);
// 运行导出器
await Task.Run(() => exporter.Run());
// 显示成功消息
MessageBox.Show("配置导出完成!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
// 显示错误消息
MessageBox.Show($"导出过程中发生错误:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
// 恢复按钮状态和标题
buttonRun.Enabled = true;
buttonRun.Text = "执行";
this.Text = _originalTitle;
}
}
/// <summary>
/// 更新进度显示
/// </summary>
/// <param name="message">进度消息</param>
private void UpdateProgress(string message)
{
// 确保在UI线程上更新界面
if (InvokeRequired)
{
Invoke(new Action<string>(UpdateProgress), message);
return;
}
// 更新标题栏显示进度
this.Text = $"{_originalTitle} - {message}";
}
private void buttonSelectExcelPath_Click(object sender, EventArgs e)