From 65970751b34ad9eb91277ced360b3e80309caae7 Mon Sep 17 00:00:00 2001 From: lihanbo Date: Thu, 7 Nov 2024 12:14:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=A4=9A=E4=B8=AA=E6=96=87?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=96=B0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=92=8C=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 `CheckTest.cs` 文件中,添加了三个新的测试方法:`CheckWireErpNrTest`、`ChecImprintTest` 和 `CheckSizeTest`。 在 `AssemblyInfo.cs` 文件中,将程序集版本和文件版本从 `1.0.0.5` 更新为 `1.0.0.6`。 在 `StuffTest.cs` 文件中,添加了一个新的断言 `Assert.IsTrue(result.Where(it => it.Imprint == "EC5L3").First().WireColor == "BK");`。 在 `LectotypeWindow.xaml` 文件中,添加了一个新的 `Window` 定义,包括资源字典、按钮和 `TabControl` 控件。 在 `LectotypeWindow.xaml.cs` 文件中,添加了 `LectotypeWindow` 类的定义和相关的事件处理方法。 在 `MainWindow.xaml` 文件中,移除了旧的样式定义,添加了新的资源字典引用,并更新了 `GroupBox` 为 `hc:Card` 控件,调整了按钮样式和 `DataGrid` 的样式。 在 `MainWindow.xaml` 文件中,更新了 `DataGrid` 的 `RowStyle` 和 `CellStyle`,并添加了新的触发器和样式设置。 在 `MainWindow.xaml` 文件中,更新了检查配置项的布局,使用 `hc:Card` 控件替换了 `GroupBox`,并调整了文本块的样式和布局。 在 `MainWindow.xaml.cs` 文件中: * 在 `MainWindow` 类中添加了对 `model.IsError` 的检查,如果为 `true`,则将 `model.IsIgnore` 设置为 `true`。 * 在 `Copy_Click` 方法中添加了 `try-catch` 块来捕获异常,并在捕获到异常时显示错误消息。 * 在 `GoToSource_Click` 方法中添加了 `try-catch` 块来捕获异常,并在捕获到异常时显示错误消息。 * 将 `Array.Empty()` 替换为 `[]`。 在 `CheckedModel.cs` 文件中: * 注释掉了 `SetProperty` 方法中对 `Equals` 方法的检查。 在 `LectotypeModel.cs` 文件中: * 新增了 `LectotypeModel` 类,包含多个属性和相应的 `OnPropertyChanged` 调用。 在 `LineSegmentModel.cs` 文件中: * 新增了 `LineSegmentModel` 类,包含 `LineAxisNo`、`LineType` 和 `LineParagraph` 属性。 在 `AssemblyInfo.cs` 文件中: * 更新了程序集版本号,从 `1.0.0.5` 更新到 `1.0.0.6`。 在 `Sinvo.EplanHpD.Plugin.WPFUI.csproj` 文件中: * 添加了对 `EPLAN.Harness.MathLib` 的引用。 * 添加了 `LectotypeWindow.xaml` 和 `TestWindow.xaml` 及其对应的代码文件。 * 添加了 `HandyControl` 包的引用。 在 `TestWindow.xaml` 文件中: * 新增了 `TestWindow` 窗口的 XAML 定义,包含一个 `DataGrid` 控件。 在 `TestWindow.xaml.cs` 文件中: * 新增了 `TestWindow` 类,包含加载数据的方法。 在 `ExcelHelper.cs` 文件中: * 修改了 `GetWireTerminalMappingTable` 方法,使其在 `Prefix` 为 `null` 时也能匹配。 * 新增了 `GetWireInfo` 方法,用于获取线材信息。 在 `LectotypeViewModel.cs` 文件中: * 新增了 `LectotypeViewModel` 类,包含加载数据的方法和多个辅助方法。 在 `MainViewModel.Check.cs` 文件中: * 在 `ValidateItem` 方法中添加了对 `CheckWireErpNr` 方法的调用。 * 新增了 `CheckWireErpNr` 方法,用于检查线材料号。 * 在 `CheckNumberTube` 方法中添加了对 `item.Imprint` 是否为空的检查。 将 `data.AsParallel().WithDegreeOfParallelism(8).ForAll(entry =>` 修改为 `data.Where(it => it.OrigOcc == "OccWire" && !(it?.Properties["WireName"]?.GetDisplayValue()?.StartsWith("导线") ?? false)).AsParallel().WithDegreeOfParallelism(1).ForAll(entry =>`,以过滤出 `OrigOcc` 为 "OccWire" 且 `WireName` 不以 "导线" 开头的数据,并将并行度设置为 1。 将 `data.FrontTerminalModel = item.ConnectorFrom.Contains(":") ? item.ConnectorFrom.Split(':')[0] : item.ConnectorFrom;` 修改为 `data.FrontTerminalModel = item.ConnectorFrom?.Contains(":") ?? false ? item.ConnectorFrom.Split(':')[0] : item.ConnectorFrom ?? "";`,以处理 `ConnectorFrom` 可能为 null 的情况。 将 `data.RearTerminalModel = item.ConnectorTo.Contains(":") ? item.ConnectorTo.Split(':')[0] : item.ConnectorTo;` 修改为 `data.RearTerminalModel = item.ConnectorTo?.Contains(":") ?? false ? item.ConnectorTo.Split(':')[0] : item.ConnectorTo ?? "";`,以处理 `ConnectorTo` 可能为 null 的情况。 删除了 `if (insulationModels.Any()) { data.Insulation = insulationModels.First(); }` 语句块,简化了代码逻辑。 更新了 `GetWireColorCode` 方法中的注释,将原来的注释替换为更简洁的版本。 --- Sinvo.EplanHpD.Plugin.Test/CheckTest.cs | 32 ++ .../Properties/AssemblyInfo.cs | 4 +- Sinvo.EplanHpD.Plugin.Test/StuffTest.cs | 1 + .../LectotypeWindow.xaml | 113 ++++++ .../LectotypeWindow.xaml.cs | 29 ++ Sinvo.EplanHpD.Plugin.WPFUI/MainWindow.xaml | 355 +++++++++++------- .../MainWindow.xaml.cs | 83 ++-- .../Models/CheckedModel.cs | 2 +- .../Models/LectotypeModel.cs | 225 +++++++++++ .../Models/LineSegmentModel.cs | 21 ++ .../Properties/AssemblyInfo.cs | 6 +- .../Sinvo.EplanHpD.Plugin.WPFUI.csproj | 23 ++ Sinvo.EplanHpD.Plugin.WPFUI/TestWindow.xaml | 29 ++ .../TestWindow.xaml.cs | 38 ++ .../Utils/ExcelHelper.cs | 11 +- .../ViewModel/LectotypeViewModel.cs | 181 +++++++++ .../ViewModel/MainViewModel.Check.cs | 31 ++ .../ViewModel/MainViewModel.cs | 67 ++-- 18 files changed, 1033 insertions(+), 218 deletions(-) create mode 100644 Sinvo.EplanHpD.Plugin.WPFUI/LectotypeWindow.xaml create mode 100644 Sinvo.EplanHpD.Plugin.WPFUI/LectotypeWindow.xaml.cs create mode 100644 Sinvo.EplanHpD.Plugin.WPFUI/Models/LectotypeModel.cs create mode 100644 Sinvo.EplanHpD.Plugin.WPFUI/Models/LineSegmentModel.cs create mode 100644 Sinvo.EplanHpD.Plugin.WPFUI/TestWindow.xaml create mode 100644 Sinvo.EplanHpD.Plugin.WPFUI/TestWindow.xaml.cs create mode 100644 Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs diff --git a/Sinvo.EplanHpD.Plugin.Test/CheckTest.cs b/Sinvo.EplanHpD.Plugin.Test/CheckTest.cs index 5eb2617..b5466e5 100644 --- a/Sinvo.EplanHpD.Plugin.Test/CheckTest.cs +++ b/Sinvo.EplanHpD.Plugin.Test/CheckTest.cs @@ -165,6 +165,38 @@ namespace Sinvo.EplanHpD.Plugin.Test } + [TestMethod] + public void CheckWireErpNrTest() + { + var vm = new MainViewModel(); + var stuffedData = new StuffedDataModel + { + Imprint = "D-PE1231231", + WireModel = "黄绿色RV0.5-CE/定制", + FrontTerminalModel = "C45-1.5-CE/定制", + RearTerminalModel = "RNB2-5-CE/定制", + }; + vm.CheckWireErpNr(stuffedData); + Assert.IsFalse(!stuffedData.IsError); + + } + [TestMethod] + public void ChecImprintTest() + { + var vm = new MainViewModel(); + var stuffedData = new StuffedDataModel + { + Imprint = "", + WireModel = "黄绿色RV0.5-CE/定制", + FrontTerminalModel = "C45-1.5-CE/定制", + RearTerminalModel = "RNB2-5-CE/定制", + }; + vm.CheckAll(new List(){ + stuffedData }); + Assert.IsFalse(!stuffedData.IsError); + + } + [TestMethod] public void CheckSizeTest() { diff --git a/Sinvo.EplanHpD.Plugin.Test/Properties/AssemblyInfo.cs b/Sinvo.EplanHpD.Plugin.Test/Properties/AssemblyInfo.cs index 59f8eb6..f8931e4 100644 --- a/Sinvo.EplanHpD.Plugin.Test/Properties/AssemblyInfo.cs +++ b/Sinvo.EplanHpD.Plugin.Test/Properties/AssemblyInfo.cs @@ -16,5 +16,5 @@ using System.Runtime.InteropServices; [assembly: Guid("aec39474-528b-4da8-b650-99189acb7a2c")] // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.5")] -[assembly: AssemblyFileVersion("1.0.0.5")] +[assembly: AssemblyVersion("1.0.0.6")] +[assembly: AssemblyFileVersion("1.0.0.6")] diff --git a/Sinvo.EplanHpD.Plugin.Test/StuffTest.cs b/Sinvo.EplanHpD.Plugin.Test/StuffTest.cs index 392d110..fee5191 100644 --- a/Sinvo.EplanHpD.Plugin.Test/StuffTest.cs +++ b/Sinvo.EplanHpD.Plugin.Test/StuffTest.cs @@ -97,6 +97,7 @@ Project = "放卷2", Assert.IsTrue(result.Where(it => it.Imprint == "EC5L1").First().WireColor == "LBU"); Assert.IsTrue(result.Where(it => it.Imprint == "EC5L2").First().WireColor == "BUWH"); Assert.IsTrue(result.Where(it => it.Imprint == "EC5L3").First().WireColor == "BK"); + } } } diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/LectotypeWindow.xaml b/Sinvo.EplanHpD.Plugin.WPFUI/LectotypeWindow.xaml new file mode 100644 index 0000000..45245d1 --- /dev/null +++ b/Sinvo.EplanHpD.Plugin.WPFUI/LectotypeWindow.xaml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + +