From 78c2ba4261f4a38f8722814d30b921027b0626d6 Mon Sep 17 00:00:00 2001 From: lihanbo Date: Sat, 29 Mar 2025 11:39:45 +0800 Subject: [PATCH] =?UTF-8?q?105040=20Update=20=E5=A2=9E=E5=8A=A0=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Utils/MotorExcelHelper.cs | 4 ++ .../ViewModel/LectotypeViewModel.cs | 53 ++++++++++++------- 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MotorExcelHelper.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MotorExcelHelper.cs index 3ce2cfc..83e45ff 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MotorExcelHelper.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MotorExcelHelper.cs @@ -21,6 +21,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils var bytes = File.ReadAllBytes(file); dataFileStream = new MemoryStream(bytes); } + else + { + throw new FileNotFoundException(file); + } } public List GetCableDatas(string brand = Brands.SANLING_HK_KT) { diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs index 90c6c03..3746078 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs @@ -5,6 +5,7 @@ using EPLAN.Harness.Core.Utils; using EPLAN.Harness.ProjectCore; using EPLAN.Harness.ProjectCore.Occurrences; using EPLAN.Harness.ProjectCore.Occurrences.Designer; +using HandyControl.Controls; using HandyControl.Tools.Extension; using Sinvo.EplanHpD.Plugin.Service; using Sinvo.EplanHpD.Plugin.Service.Model; @@ -176,24 +177,28 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged public Task LoadData() { - if (string.IsNullOrEmpty(docId)) + try { - return Task.CompletedTask; - } - // 当前的工作区 - var designer = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(designer => designer.ID == docId); - // 获取项目名 - DocName = GetDocName(designer); - LectotypeManager.CURRENT_DOC_NAME = DocName; - LectotypeManager.CURRENT_DOC_CREATE_TIME = new DateTimeOffset(designer.CreatedDateDateTime).ToUnixTimeMilliseconds().ToString(); - // 获取所有存在的 - var wires = designer.GetOrganizerOccurrences(designer.ID); - //OriWires = wires.ToList(); - // 所有的线材 - // OccCableForked 多芯线? 对应设计器中Cables(电缆)下的内容 - // OccWire 导线 对应设计器中Wires(导线)下的内容 - List cables = [.. wires + + if (string.IsNullOrEmpty(docId)) + { + return Task.CompletedTask; + } + // 当前的工作区 + var designer = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(designer => designer.ID == docId); + // 获取项目名 + DocName = GetDocName(designer); + LectotypeManager.CURRENT_DOC_NAME = DocName; + LectotypeManager.CURRENT_DOC_CREATE_TIME = new DateTimeOffset(designer.CreatedDateDateTime).ToUnixTimeMilliseconds().ToString(); + + // 获取所有存在的 + var wires = designer.GetOrganizerOccurrences(designer.ID); + //OriWires = wires.ToList(); + // 所有的线材 + // OccCableForked 多芯线? 对应设计器中Cables(电缆)下的内容 + // OccWire 导线 对应设计器中Wires(导线)下的内容 + List cables = [.. wires .Where(it => it.GetType() == typeof(OccCableForked) //|| it.GetType() == typeof(OccWire) @@ -241,9 +246,19 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged //.Where(it => !string.IsNullOrEmpty(it.AxisNo)) .OrderBy(it => it?.CurrentLine ?? 0)]; - Wires = StuffData(cables); - designer.SelectSet.NodeSelected += SelectSet_NodeSelected; - return Task.CompletedTask; + Wires = StuffData(cables); + designer.SelectSet.NodeSelected += SelectSet_NodeSelected; + return Task.CompletedTask; + } + catch (Exception ex) + { + HandyControl.Controls.MessageBox.Show(ex.ToString()); + return Task.CompletedTask; + } + finally + { + + } } private void SelectSet_NodeSelected(object sender, EPLAN.Harness.Common.Events.EventArgs e)