From df475857ef6214c184d9ed831a393a1afc73277c Mon Sep 17 00:00:00 2001 From: chr <chr@chr.com> Date: 星期二, 27 八月 2024 13:05:29 +0800 Subject: [PATCH] 优化; --- PdmSwPlugin.DrawApprove/DrawApprove.xaml.cs | 35 +++-- PdmSwPlugin.Main/Constant/PluginConst.cs | 2 PdmSwPlugin.Main/MainControl.xaml.cs | 4 PdmSwPlugin.PDM/PdmControl.xaml.cs | 162 ++++++++++++++++++-------- .vs/SwPlugin/v17/DocumentLayout.json | 142 ++++++----------------- 5 files changed, 172 insertions(+), 173 deletions(-) diff --git a/.vs/SwPlugin/v17/DocumentLayout.json b/.vs/SwPlugin/v17/DocumentLayout.json index 1859f5b..9c7062c 100644 --- a/.vs/SwPlugin/v17/DocumentLayout.json +++ b/.vs/SwPlugin/v17/DocumentLayout.json @@ -3,7 +3,7 @@ "WorkspaceRootPath": "C:\\Workspace\\PdmSwPlugin2\\", "Documents": [ { - "AbsoluteMoniker": "D:0:0:{6E609A8C-583B-4607-A510-FA84218C4A31}|PdmSwPlugin.Main\\PdmSwPlugin.Main.csproj|C:\\Workspace\\PdmSwPlugin2\\pdmswplugin.main\\constant\\pluginconst.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "AbsoluteMoniker": "D:0:0:{6E609A8C-583B-4607-A510-FA84218C4A31}|PdmSwPlugin.Main\\PdmSwPlugin.Main.csproj|c:\\workspace\\pdmswplugin2\\pdmswplugin.main\\constant\\pluginconst.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", "RelativeMoniker": "D:0:0:{6E609A8C-583B-4607-A510-FA84218C4A31}|PdmSwPlugin.Main\\PdmSwPlugin.Main.csproj|solutionrelative:pdmswplugin.main\\constant\\pluginconst.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" }, { @@ -11,32 +11,16 @@ "RelativeMoniker": "D:0:0:{1033FBD8-8700-4CD0-808A-BB97DB057A6B}|PdmSwPlugin.PDM\\PdmSwPlugin.PDM.csproj|solutionrelative:pdmswplugin.pdm\\pdmcontrol.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" }, { - "AbsoluteMoniker": "D:0:0:{BE239D32-7253-4D19-8793-159E98545B55}|PdmSwPlugin.DrawApprove\\PdmSwPlugin.DrawApprove.csproj|c:\\workspace\\pdmswplugin2\\pdmswplugin.drawapprove\\drawaudithiscontrol.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", - "RelativeMoniker": "D:0:0:{BE239D32-7253-4D19-8793-159E98545B55}|PdmSwPlugin.DrawApprove\\PdmSwPlugin.DrawApprove.csproj|solutionrelative:pdmswplugin.drawapprove\\drawaudithiscontrol.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" - }, - { - "AbsoluteMoniker": "D:0:0:{E17EF6B6-EE83-45AA-B0C0-E3A097089E97}|PdmSwPlugin.Common\\PdmSwPlugin.Common.csproj|C:\\Workspace\\PdmSwPlugin2\\pdmswplugin.common\\entity\\drawaudit\\drawaudit.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", - "RelativeMoniker": "D:0:0:{E17EF6B6-EE83-45AA-B0C0-E3A097089E97}|PdmSwPlugin.Common\\PdmSwPlugin.Common.csproj|solutionrelative:pdmswplugin.common\\entity\\drawaudit\\drawaudit.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" - }, - { - "AbsoluteMoniker": "D:0:0:{6E609A8C-583B-4607-A510-FA84218C4A31}|PdmSwPlugin.Main\\PdmSwPlugin.Main.csproj|c:\\workspace\\pdmswplugin2\\pdmswplugin.main\\swaddin\\maincontrol.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", - "RelativeMoniker": "D:0:0:{6E609A8C-583B-4607-A510-FA84218C4A31}|PdmSwPlugin.Main\\PdmSwPlugin.Main.csproj|solutionrelative:pdmswplugin.main\\swaddin\\maincontrol.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" - }, - { - "AbsoluteMoniker": "D:0:0:{6E609A8C-583B-4607-A510-FA84218C4A31}|PdmSwPlugin.Main\\PdmSwPlugin.Main.csproj|c:\\workspace\\pdmswplugin2\\pdmswplugin.main\\maincontrol.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", - "RelativeMoniker": "D:0:0:{6E609A8C-583B-4607-A510-FA84218C4A31}|PdmSwPlugin.Main\\PdmSwPlugin.Main.csproj|solutionrelative:pdmswplugin.main\\maincontrol.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" - }, - { - "AbsoluteMoniker": "D:0:0:{BE239D32-7253-4D19-8793-159E98545B55}|PdmSwPlugin.DrawApprove\\PdmSwPlugin.DrawApprove.csproj|C:\\Workspace\\PdmSwPlugin2\\pdmswplugin.drawapprove\\drawapprove.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "AbsoluteMoniker": "D:0:0:{BE239D32-7253-4D19-8793-159E98545B55}|PdmSwPlugin.DrawApprove\\PdmSwPlugin.DrawApprove.csproj|c:\\workspace\\pdmswplugin2\\pdmswplugin.drawapprove\\drawapprove.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", "RelativeMoniker": "D:0:0:{BE239D32-7253-4D19-8793-159E98545B55}|PdmSwPlugin.DrawApprove\\PdmSwPlugin.DrawApprove.csproj|solutionrelative:pdmswplugin.drawapprove\\drawapprove.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" }, { - "AbsoluteMoniker": "D:0:0:{BE239D32-7253-4D19-8793-159E98545B55}|PdmSwPlugin.DrawApprove\\PdmSwPlugin.DrawApprove.csproj|C:\\Workspace\\PdmSwPlugin2\\pdmswplugin.drawapprove\\drawapprove.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}", - "RelativeMoniker": "D:0:0:{BE239D32-7253-4D19-8793-159E98545B55}|PdmSwPlugin.DrawApprove\\PdmSwPlugin.DrawApprove.csproj|solutionrelative:pdmswplugin.drawapprove\\drawapprove.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}" + "AbsoluteMoniker": "D:0:0:{E17EF6B6-EE83-45AA-B0C0-E3A097089E97}|PdmSwPlugin.Common\\PdmSwPlugin.Common.csproj|c:\\workspace\\pdmswplugin2\\pdmswplugin.common\\util\\dmsldfileextentionchecker.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{E17EF6B6-EE83-45AA-B0C0-E3A097089E97}|PdmSwPlugin.Common\\PdmSwPlugin.Common.csproj|solutionrelative:pdmswplugin.common\\util\\dmsldfileextentionchecker.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" }, { - "AbsoluteMoniker": "D:0:0:{E17EF6B6-EE83-45AA-B0C0-E3A097089E97}|PdmSwPlugin.Common\\PdmSwPlugin.Common.csproj|C:\\Workspace\\PdmSwPlugin2\\pdmswplugin.common\\entity\\drawaudit\\drawauditorder.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", - "RelativeMoniker": "D:0:0:{E17EF6B6-EE83-45AA-B0C0-E3A097089E97}|PdmSwPlugin.Common\\PdmSwPlugin.Common.csproj|solutionrelative:pdmswplugin.common\\entity\\drawaudit\\drawauditorder.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + "AbsoluteMoniker": "D:0:0:{7ACEDAA9-2DE8-4485-837A-E7D58812A6DC}|PdmSw\\PdmSw.csproj|c:\\workspace\\pdmswplugin2\\pdmsw\\settings\\pluginsetting.xml||{FA3CD31E-987B-443A-9B81-186104E8DAC1}", + "RelativeMoniker": "D:0:0:{7ACEDAA9-2DE8-4485-837A-E7D58812A6DC}|PdmSw\\PdmSw.csproj|solutionrelative:pdmsw\\settings\\pluginsetting.xml||{FA3CD31E-987B-443A-9B81-186104E8DAC1}" } ], "DocumentGroupContainers": [ @@ -46,70 +30,8 @@ "DocumentGroups": [ { "DockedWidth": 200, - "SelectedChildIndex": 5, + "SelectedChildIndex": 0, "Children": [ - { - "$type": "Document", - "DocumentIndex": 2, - "Title": "DrawAuditHisControl.xaml.cs", - "DocumentMoniker": "C:\\Workspace\\PdmSwPlugin2\\PdmSwPlugin.DrawApprove\\DrawAuditHisControl.xaml.cs", - "RelativeDocumentMoniker": "PdmSwPlugin.DrawApprove\\DrawAuditHisControl.xaml.cs", - "ToolTip": "C:\\Workspace\\PdmSwPlugin2\\PdmSwPlugin.DrawApprove\\DrawAuditHisControl.xaml.cs", - "RelativeToolTip": "PdmSwPlugin.DrawApprove\\DrawAuditHisControl.xaml.cs", - "ViewState": "AQIAABYBAAAAAAAAAAAiwCgBAAAgAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2024-08-21T08:12:02.317Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 4, - "Title": "MainControl.cs", - "DocumentMoniker": "C:\\Workspace\\PdmSwPlugin2\\PdmSwPlugin.Main\\SwAddIn\\MainControl.cs", - "RelativeDocumentMoniker": "PdmSwPlugin.Main\\SwAddIn\\MainControl.cs", - "ToolTip": "C:\\Workspace\\PdmSwPlugin2\\PdmSwPlugin.Main\\SwAddIn\\MainControl.cs", - "RelativeToolTip": "PdmSwPlugin.Main\\SwAddIn\\MainControl.cs", - "ViewState": "AQIAAHAAAAAAAAAAAAAAAHgAAABHAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2024-08-21T07:59:50.181Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 5, - "Title": "MainControl.xaml.cs", - "DocumentMoniker": "C:\\Workspace\\PdmSwPlugin2\\PdmSwPlugin.Main\\MainControl.xaml.cs", - "RelativeDocumentMoniker": "PdmSwPlugin.Main\\MainControl.xaml.cs", - "ToolTip": "C:\\Workspace\\PdmSwPlugin2\\PdmSwPlugin.Main\\MainControl.xaml.cs", - "RelativeToolTip": "PdmSwPlugin.Main\\MainControl.xaml.cs", - "ViewState": "AQIAAKAAAAAAAAAAAAAowBEAAAAAAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2024-08-21T07:59:44.275Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 7, - "Title": "DrawApprove.xaml", - "DocumentMoniker": "C:\\Workspace\\PdmSwPlugin2\\PdmSwPlugin.DrawApprove\\DrawApprove.xaml", - "RelativeDocumentMoniker": "PdmSwPlugin.DrawApprove\\DrawApprove.xaml", - "ToolTip": "C:\\Workspace\\PdmSwPlugin2\\PdmSwPlugin.DrawApprove\\DrawApprove.xaml", - "RelativeToolTip": "PdmSwPlugin.DrawApprove\\DrawApprove.xaml", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|", - "WhenOpened": "2024-08-20T03:02:33.757Z" - }, - { - "$type": "Document", - "DocumentIndex": 8, - "Title": "DrawAuditOrder.cs", - "DocumentMoniker": "C:\\Workspace\\PdmSwPlugin2\\PdmSwPlugin.Common\\Entity\\DrawAudit\\DrawAuditOrder.cs", - "RelativeDocumentMoniker": "PdmSwPlugin.Common\\Entity\\DrawAudit\\DrawAuditOrder.cs", - "ToolTip": "C:\\Workspace\\PdmSwPlugin2\\PdmSwPlugin.Common\\Entity\\DrawAudit\\DrawAuditOrder.cs", - "RelativeToolTip": "PdmSwPlugin.Common\\Entity\\DrawAudit\\DrawAuditOrder.cs", - "ViewState": "AQIAAAAAAAAAAAAAAAAAAAkAAAAFAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2024-08-20T02:13:49.926Z" - }, { "$type": "Document", "DocumentIndex": 0, @@ -120,7 +42,33 @@ "RelativeToolTip": "PdmSwPlugin.Main\\Constant\\PluginConst.cs", "ViewState": "AQIAAAAAAAAAAAAAAAAAAAgAAAAAAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2024-08-18T12:05:54.617Z", + "WhenOpened": "2024-08-27T02:20:56.948Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 3, + "Title": "DMSldFileExtentionChecker.cs", + "DocumentMoniker": "C:\\Workspace\\PdmSwPlugin2\\PdmSwPlugin.Common\\Util\\DMSldFileExtentionChecker.cs", + "RelativeDocumentMoniker": "PdmSwPlugin.Common\\Util\\DMSldFileExtentionChecker.cs", + "ToolTip": "C:\\Workspace\\PdmSwPlugin2\\PdmSwPlugin.Common\\Util\\DMSldFileExtentionChecker.cs", + "RelativeToolTip": "PdmSwPlugin.Common\\Util\\DMSldFileExtentionChecker.cs", + "ViewState": "AQIAAAsAAAAAAAAAAAAYwBMAAAA2AAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2024-08-27T01:56:05.638Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 4, + "Title": "PluginSetting.xml", + "DocumentMoniker": "C:\\Workspace\\PdmSwPlugin2\\PdmSw\\Settings\\PluginSetting.xml", + "RelativeDocumentMoniker": "PdmSw\\Settings\\PluginSetting.xml", + "ToolTip": "C:\\Workspace\\PdmSwPlugin2\\PdmSw\\Settings\\PluginSetting.xml", + "RelativeToolTip": "PdmSw\\Settings\\PluginSetting.xml", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAAcAAAAmAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003576|", + "WhenOpened": "2024-08-27T01:51:40.382Z", "EditorCaption": "" }, { @@ -131,34 +79,22 @@ "RelativeDocumentMoniker": "PdmSwPlugin.PDM\\PdmControl.xaml.cs", "ToolTip": "C:\\Workspace\\PdmSwPlugin2\\PdmSwPlugin.PDM\\PdmControl.xaml.cs", "RelativeToolTip": "PdmSwPlugin.PDM\\PdmControl.xaml.cs", - "ViewState": "AQIAAFMEAAAAAAAAAAAAALEGAAAAAAAA", + "ViewState": "AQIAAJQCAAAAAAAAAAAYwJ0CAAA1AAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2024-08-18T08:40:17.518Z", + "WhenOpened": "2024-08-27T01:28:33.744Z", "EditorCaption": "" }, { "$type": "Document", - "DocumentIndex": 6, + "DocumentIndex": 2, "Title": "DrawApprove.xaml.cs", "DocumentMoniker": "C:\\Workspace\\PdmSwPlugin2\\PdmSwPlugin.DrawApprove\\DrawApprove.xaml.cs", "RelativeDocumentMoniker": "PdmSwPlugin.DrawApprove\\DrawApprove.xaml.cs", "ToolTip": "C:\\Workspace\\PdmSwPlugin2\\PdmSwPlugin.DrawApprove\\DrawApprove.xaml.cs", "RelativeToolTip": "PdmSwPlugin.DrawApprove\\DrawApprove.xaml.cs", - "ViewState": "AQIAAAEBAAAAAAAAAAAkwBcBAAA2AAAA", + "ViewState": "AQIAAM8AAAAAAAAAAAAgwLcAAAAAAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2024-08-18T08:30:42.283Z" - }, - { - "$type": "Document", - "DocumentIndex": 3, - "Title": "DrawAudit.cs", - "DocumentMoniker": "C:\\Workspace\\PdmSwPlugin2\\PdmSwPlugin.Common\\Entity\\DrawAudit\\DrawAudit.cs", - "RelativeDocumentMoniker": "PdmSwPlugin.Common\\Entity\\DrawAudit\\DrawAudit.cs", - "ToolTip": "C:\\Workspace\\PdmSwPlugin2\\PdmSwPlugin.Common\\Entity\\DrawAudit\\DrawAudit.cs", - "RelativeToolTip": "PdmSwPlugin.Common\\Entity\\DrawAudit\\DrawAudit.cs", - "ViewState": "AQIAAAYAAAAAAAAAAAAAABAAAAAWAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2024-08-18T08:28:05.337Z", + "WhenOpened": "2024-08-26T06:10:46.307Z", "EditorCaption": "" } ] diff --git a/PdmSwPlugin.DrawApprove/DrawApprove.xaml.cs b/PdmSwPlugin.DrawApprove/DrawApprove.xaml.cs index 1b6b817..551bee0 100644 --- a/PdmSwPlugin.DrawApprove/DrawApprove.xaml.cs +++ b/PdmSwPlugin.DrawApprove/DrawApprove.xaml.cs @@ -4,6 +4,7 @@ using PdmSwPlugin.Common; using PdmSwPlugin.Common.Entity.DrawAudit; using PdmSwPlugin.Common.Entity.Pdm; +using PdmSwPlugin.Common.Entity.System; using PdmSwPlugin.Common.Interface; using PdmSwPlugin.Common.Setting; using PdmSwPlugin.Common.Util; @@ -170,8 +171,8 @@ } catch (Exception ex) { - Logger.Error("UI update failed.", ex); - this.Error($"UI鏇存柊鍒楄〃澶辫触锛佸紓甯�:{ex}"); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion}, UI update failed.", ex); + this.Error($"V{PdmUser.LoginUser.pluginVersion}锛孶I鏇存柊鍒楄〃澶辫触锛佸紓甯�:{ex}"); dataSource = new ObservableCollection<DrawAudit>(); } finally @@ -240,7 +241,7 @@ } else if (err != 0) { - Logger.Error($"OpenDoc6 Failed,Error:{err}.See Solidworks Doc."); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion}, OpenDoc6 Failed,Error:{err}.See Solidworks Doc."); } else if (warn == 128) { @@ -270,10 +271,11 @@ ""); } - private string GetRealFilePath(string dbPath) + private string GetRealFilePath(string relativePath) { - string fileName = Path.GetFileName(dbPath); - string filePath = Path.Combine(PluginSetting.Instance.SwFilePath, fileName); + // string fileName = Path.GetFileName(dbPath); + // string filePath = Path.Combine(PluginSetting.Instance.SwFilePath, dbPath); + string filePath = PluginSetting.Instance.SwFilePath + relativePath; return filePath; } @@ -287,7 +289,8 @@ this.Error($"鏈嶅姟鍣ㄤ腑鏈壘鍒板浘绾告枃浠讹紝璺緞:{filePath}"); return; } - OpenDocMayError(filePath, (int)swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_ReadOnly, + + OpenDocMayError(filePath, (int)FileExtentionChecker.Check(filePath, out _), (int)swOpenDocOptions_e.swOpenDocOptions_ReadOnly, ""); } @@ -300,8 +303,8 @@ } catch (Exception ex) { - Logger.Error("Get draw audit data list failed.", ex); - this.Error($"鍒锋柊鍒楄〃澶辫触锛佸紓甯�:{ex.Message}"); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion}, Get draw audit data list failed.", ex); + this.Error($"V{PdmUser.LoginUser.pluginVersion}锛屽埛鏂板垪琛ㄥけ璐ワ紒寮傚父:{ex.Message}"); return new List<DrawAudit>(); } } @@ -310,14 +313,14 @@ { try { - string modelPath = Path.Combine(PluginSetting.Instance.SwFilePath, Path.GetFileName(da.d3RelativePath)); - string drawingPath = Path.Combine(PluginSetting.Instance.SwFilePath, Path.GetFileName(da.d2RelativePath)); + string modelPath = GetRealFilePath(da.d3RelativePath); + string drawingPath = GetRealFilePath(da.d2RelativePath); SwApp.CloseDoc(modelPath); SwApp.CloseDoc(drawingPath); } catch (Exception exx) { - Logger.Error("Auto close open doc failed.", exx); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion}, Auto close open doc failed.", exx); } } @@ -371,8 +374,8 @@ } catch (Exception ex) { - Logger.Error("Draw complete failed.", ex); - this.Error($"瀹℃牳澶辫触锛亄ex.Message}"); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion}, Draw complete failed.", ex); + this.Error($"V{PdmUser.LoginUser.pluginVersion}锛屽鏍稿け璐ワ紒{ex.Message}"); } finally { @@ -441,8 +444,8 @@ } catch (Exception ex) { - Logger.Error("Get draw audit history failed.", ex); - this.Error($"鑾峰彇瀹℃牳鍘嗗彶澶辫触锛亄ex.Message}"); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion},Get draw audit history failed.", ex); + this.Error($"V{PdmUser.LoginUser.pluginVersion}锛岃幏鍙栧鏍稿巻鍙插け璐ワ紒{ex.Message}"); } finally { diff --git a/PdmSwPlugin.Main/Constant/PluginConst.cs b/PdmSwPlugin.Main/Constant/PluginConst.cs index d74daf9..6ac8707 100644 --- a/PdmSwPlugin.Main/Constant/PluginConst.cs +++ b/PdmSwPlugin.Main/Constant/PluginConst.cs @@ -3,6 +3,6 @@ public class PluginConst { public static readonly string AppId = "DF23E96F-A469-4302-8367-7FA2F798CD09"; - public static readonly string Version = "0.0.0.37"; + public static readonly string Version = "0.0.0.39"; } } diff --git a/PdmSwPlugin.Main/MainControl.xaml.cs b/PdmSwPlugin.Main/MainControl.xaml.cs index 22ff9f2..050ac1d 100644 --- a/PdmSwPlugin.Main/MainControl.xaml.cs +++ b/PdmSwPlugin.Main/MainControl.xaml.cs @@ -174,6 +174,8 @@ pluginVersion = PluginConst.Version }); PdmUser user = res.HandleResult(); + user.appId = PluginConst.AppId; + user.pluginVersion = PluginConst.Version; callback(user); } catch (Exception e) @@ -257,6 +259,8 @@ { Result<PdmUser> res = HttpClientCreator.PostSyncAction<PdmUser>("openApi/wpf/login", param); PdmUser user = res.HandleResult(); + user.appId = PluginConst.AppId; + user.pluginVersion = PluginConst.Version; Dispatcher.Invoke(() => { PdmUser.SetLoginUser(user); diff --git a/PdmSwPlugin.PDM/PdmControl.xaml.cs b/PdmSwPlugin.PDM/PdmControl.xaml.cs index b6ccdbe..c57212f 100644 --- a/PdmSwPlugin.PDM/PdmControl.xaml.cs +++ b/PdmSwPlugin.PDM/PdmControl.xaml.cs @@ -35,6 +35,7 @@ using System.Windows.Interop; using PdmSwPlugin.Commmon.Control; using PdmSwPlugin.Common.Entity.System; +using System.Windows.Documents; namespace PdmSwPlugin.PDM { @@ -158,8 +159,8 @@ { // FillBomInfo(boms, bomInfos, drawInfos); model.BomTree = new ObservableCollection<PdmBom>(); - Logger.Error("鍒锋柊BOM鍒楄〃澶辫触!", e); - this.Warning(e.Message); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion}, Refresh Bom List Failed.", e); + this.Error($"V{PdmUser.LoginUser.pluginVersion}锛屽埛鏂板け璐�:{e.Message}"); return new ObservableCollection<PdmBom>(); } } @@ -335,8 +336,8 @@ } catch (Exception ex) { - Logger.Error("妫�鍏OM澶辫触!", ex); - this.Show(ex.Message, true); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion}锛孋heck In Bom Failed.", ex); + this.Error($"V{PdmUser.LoginUser.pluginVersion}锛屾鍏om澶辫触锛亄ex.Message}"); } finally { @@ -378,8 +379,8 @@ } catch (Exception ex) { - Logger.Error("妫�鍏OM澶辫触!", ex); - this.Show(ex.Message, true); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion}, Check In BOM Failed.", ex); + this.Error($"V{PdmUser.LoginUser.pluginVersion}锛屾鍏OM澶辫触锛亄ex.Message}"); } finally { @@ -437,8 +438,8 @@ } catch (Exception ex) { - Logger.Error("闄勫甫鍥剧焊妫�鍏OM澶辫触锛�", ex); - this.Show(ex.Message, true); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion}, Check In Bom With File Failed.", ex); + this.Error($"V{PdmUser.LoginUser.pluginVersion}锛屾鍏ュけ璐ワ紒{ex.Message}"); } finally { @@ -537,7 +538,7 @@ foreach (PdmBom bom in errors.Keys) { Exception err = errors[bom]; - Logger.Error($"[{bom.partModel}]涓婁紶鍥剧焊閿欒!", err); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion},[{bom.partModel}] Upload Draw Failed.", err); Msg += $"[{bom.partModel}]涓婁紶鍥剧焊閿欒!{err.Message}\r\n"; } this.Show(Msg); @@ -558,8 +559,8 @@ } catch (Exception ex) { - Logger.Error("闄勫甫鍥剧焊妫�鍏OM澶辫触!", ex); - this.Show(ex.Message, true); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion}, Check In BOM With File Failed.", ex); + this.Error($"V{PdmUser.LoginUser.pluginVersion}锛屾鍏ュけ璐ワ紒{ex.Message}"); } finally { @@ -809,8 +810,8 @@ } catch (Exception ex) { - Logger.Error("瀵煎嚭寤烘枡鏂囨。澶辫触!", ex); - this.Show(ex.Message, true); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion}, Export Material Excel Failed.", ex); + this.Error($"V{PdmUser.LoginUser.pluginVersion}锛屽鍑哄缓鏂欐枃妗eけ璐ワ紒{ex.Message}"); } } @@ -964,13 +965,13 @@ string refPath = SwDMUtil.GetDrawingRef(drawFilePath, out string errMsg); if (refPath == null) { - Logger.Error($"銆恵drawFilePath}銆戣鍙栧伐绋嬪浘寮曠敤璺緞澶辫触 銆恵errMsg}銆�"); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion}, [{drawFilePath}] Read slddrw Ref Path Failed.[{errMsg}]"); } else { refPath = Path.GetFileName(refPath); } - Logger.Debug($"鏂囨。璺緞锛氥�恵filepath}銆慭r\n" + + Logger.Debug($"V{PdmUser.LoginUser.pluginVersion}锛屾枃妗h矾寰勶細銆恵filepath}銆慭r\n" + $"宸ョ▼鍥捐矾寰�:銆恵drawFilePath}銆慭r\n" + $"鏂囦欢鍏ㄧО锛氥�恵allProperties["鏂囦欢鍏ㄧО"]}銆慭r\n" + $"寮曠敤璺緞锛氥�恵refPath}銆�"); @@ -993,7 +994,7 @@ } catch (Exception e) { - Logger.Error($"銆恵filepath}銆戣鍙栬川閲忓睘鎬уけ璐�", e); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion},[{filepath}] Read Mass Properties Failed.", e); } allProperties["鍥剧焊绫诲瀷"] = bom.produceWay;//bom.BomInfo.jgj; @@ -1045,7 +1046,7 @@ { bom.drawInfo.checkRuleResult = 2; bom.drawInfo.errMessages = new List<string> { e.Message }; - Logger.Error($"銆恵bom.filePath}銆戣鍙栧睘鎬уけ璐�", e); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion},[{bom.filePath}] Read MASS Properies Failed.", e); } finally { @@ -1130,8 +1131,8 @@ } catch (Exception ex) { - Logger.Error("PDM check rule failed.", ex); - this.Show($"鍥剧焊妫�鏌ユ墽琛屽け璐ワ細{ex.Message}", true); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion}, PDM check rule failed.", ex); + this.Error($"V{PdmUser.LoginUser.pluginVersion}锛屽浘绾告鏌ユ墽琛屽け璐ワ紒{ex.Message}"); } finally { @@ -1238,14 +1239,15 @@ } catch (Exception ex) { - Logger.Error($"璇锋眰瀹℃壒鍗曞彿澶辫触", ex); - this.Error($"璇锋眰瀹℃壒鍗曞彿澶辫触! {ex.Message}"); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion}, Request AuditOrder Code Failed.", ex); + this.Error($"V{PdmUser.LoginUser.pluginVersion}锛岃姹傚鎵瑰崟鍙峰け璐�! {ex.Message}"); return; } ConcurrentQueue<string> errs = new ConcurrentQueue<string>(); CountdownEvent counter = new CountdownEvent(boms.Count); int successCount = 0; + ConcurrentQueue<string> pathCache = new ConcurrentQueue<string>(boms.Select(b => b.filePath).ToList()); foreach (PdmBom bom in boms) { Task.Run(() => @@ -1253,35 +1255,13 @@ try { MaskAdorner.ShowMessage(content, $"姝e湪涓婁紶銆恵bom.partNo}銆�..."); - string d3FilePath = bom.d3FilePath; - string d2FilePath = d3FilePath.Replace(Path.GetExtension(d3FilePath), ".slddrw"); - if (string.IsNullOrEmpty(d3FilePath) || !File.Exists(d3FilePath)) - { - throw new Exception($"鏈壘鍒�3D鍥剧焊"); - } - if (string.IsNullOrEmpty(d2FilePath) || !File.Exists(d2FilePath)) - { - throw new Exception($"鏈壘鍒板伐绋嬪浘绾�"); - } - - FileInfo fileInfo; - MultipartFormDataContent httpContent = new MultipartFormDataContent(); - httpContent.Add(new StringContent(bom.partNo), "materialCode"); - httpContent.Add(new StringContent(bom.partNo), "materialModel"); - httpContent.Add(new StringContent(daOrder.id), "orderId"); - fileInfo = new FileInfo(d3FilePath); - FileInfo file2Info = new FileInfo(d2FilePath); - httpContent.Add(new ByteArrayContent(FileUtil.toByteArray(d3FilePath)), "d3File", fileInfo.Name); - httpContent.Add(new ByteArrayContent(FileUtil.toByteArray(d2FilePath)), "d2File", file2Info.Name); - - Result<DrawAudit> res = Client.PostSyncAction<DrawAudit>("drawAudit/add", httpContent); - DrawAudit da = res.HandleResult(); + UploadDraw(daOrder, bom, pathCache); Interlocked.Increment(ref successCount); } catch (Exception ex) { - Logger.Error($"鐗╂枡銆恵bom.partModel}銆戝彂璧峰鎵瑰け璐ワ紒", ex); - errs.Enqueue($"鐗╂枡銆恵bom.partModel}銆戝彂璧峰鎵瑰け璐ワ紒寮傚父锛歿ex.Message}"); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion}, [{bom.partModel}] Request Audit Failed.", ex); + errs.Enqueue($"鐗╂枡銆恵bom.partModel}銆戝彂璧峰鎵瑰け璐ワ紒{ex.Message}"); } finally { @@ -1305,7 +1285,7 @@ } catch (Exception ig) { - Logger.Error("鍙戦�侀�佸娑堟伅寮傚父", ig); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion}, Send Audit Socket Failed.", ig); } } // 鍒锋柊鏈嶅姟鍣ㄤ笂鐨凚OM淇℃伅 @@ -1321,8 +1301,8 @@ } catch (Exception ex) { - Logger.Error("Request audit failed", ex); - this.Error($"鍙戣捣瀹℃壒寮傚父锛亄ex}"); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion}, Request audit failed", ex); + this.Error($"V{PdmUser.LoginUser.pluginVersion}锛屽彂璧峰鎵瑰紓甯革紒{ex}"); } finally { @@ -1330,6 +1310,82 @@ MaskAdorner.HideMask(content); } }); + } + + /// <summary> + /// 涓婁紶鍥剧焊鎿嶄綔 + /// </summary> + /// <param name="daOrder"></param> + /// <param name="bom"></param> + private void UploadDraw(DrawAuditOrder daOrder, PdmBom bom, ConcurrentQueue<string> pathCache) + { + if (bom.BomInfo.drawingType == (int)swDocumentTypes_e.swDocASSEMBLY && bom.children != null && bom.children.Count > 0) + { + foreach (PdmBom child in bom.children) + { + UploadChildDraw(daOrder, child, true, pathCache); + } + } + UploadSingleDraw(daOrder, bom, false); + } + + /// <summary> + /// 涓婁紶瀛愰浂浠跺浘绾革紝鏈夐�掑綊 + /// </summary> + /// <param name="daOrder"></param> + /// <param name="bom"></param> + /// <param name="justUpload"></param> + private void UploadChildDraw(DrawAuditOrder daOrder, PdmBom bom, bool justUpload, ConcurrentQueue<string> pathCache) + { + if (bom.BomInfo.drawingType == (int)swDocumentTypes_e.swDocASSEMBLY && bom.children != null && bom.children.Count > 0) + { + foreach (PdmBom child in bom.children) + { + UploadChildDraw(daOrder, child, justUpload, pathCache); + } + } + if (!pathCache.Contains(bom.filePath)) + { + UploadSingleDraw(daOrder, bom, justUpload); + pathCache.Append(bom.filePath); + } + } + + /// <summary> + /// 涓婁紶鍗曞紶鍥剧焊 + /// </summary> + /// <param name="daOrder"></param> + /// <param name="bom"></param> + /// <param name="justUpload"></param> + /// <exception cref="Exception"></exception> + private void UploadSingleDraw(DrawAuditOrder daOrder, PdmBom bom, bool justUpload) + { + string d3FilePath = bom.d3FilePath; + string d2FilePath = d3FilePath.Replace(Path.GetExtension(d3FilePath), ".slddrw"); + if (string.IsNullOrEmpty(d3FilePath) || !File.Exists(d3FilePath)) + { + throw new Exception($"[{bom.partModel}]鏈壘鍒�3D鍥剧焊"); + } + // !justUpload锛堥渶瑕佸鏍革級瑕佸垽鏂�2D鍥剧焊瀛樹笉瀛樺湪 + if (!justUpload && (string.IsNullOrEmpty(d2FilePath) || !File.Exists(d2FilePath))) + { + throw new Exception($"[{bom.partModel}]鏈壘鍒板伐绋嬪浘绾�"); + } + MultipartFormDataContent httpContent = new MultipartFormDataContent(); + httpContent.Add(new StringContent(bom.partNo), "materialCode"); + httpContent.Add(new StringContent(bom.partNo), "materialModel"); + httpContent.Add(new StringContent(daOrder.id), "orderId"); + httpContent.Add(new StringContent(justUpload.ToString()), "justUpload"); + FileInfo fileInfo = new FileInfo(d3FilePath); + httpContent.Add(new ByteArrayContent(FileUtil.toByteArray(d3FilePath)), "d3File", fileInfo.Name); + // !justUpload锛堥渶瑕佸鏍革級瑕佷笂浼�2D鍥� + if (!justUpload) + { + FileInfo file2Info = new FileInfo(d2FilePath); + httpContent.Add(new ByteArrayContent(FileUtil.toByteArray(d2FilePath)), "d2File", file2Info.Name); + } + Result<DrawAudit> res = Client.PostSyncAction<DrawAudit>("drawAudit/add", httpContent); + DrawAudit da = res.HandleResult(); } private void Exclude_Click(object sender, RoutedEventArgs e) @@ -1498,8 +1554,8 @@ } catch (Exception ex) { - Logger.Error("Get draw audit history failed.", ex); - this.Error($"鑾峰彇瀹℃牳鍘嗗彶澶辫触锛亄ex.Message}"); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion}, Get draw audit history failed.", ex); + this.Error($"V{PdmUser.LoginUser.pluginVersion}锛岃幏鍙栧鏍稿巻鍙插け璐ワ紒{ex.Message}"); } finally { @@ -1655,8 +1711,8 @@ catch (Exception ex) { PtrCheckHandler?.Invoke(null, ex, false); - Logger.Error("PDM check rule failed.", ex); - this.Show($"鍥剧焊妫�鏌ユ墽琛屽け璐ワ細{ex.Message}", true); + Logger.Error($"V{PdmUser.LoginUser.pluginVersion}, PDM check rule failed.", ex); + this.Error($"V{PdmUser.LoginUser.pluginVersion}锛屽浘绾告鏌ユ墽琛屽け璐ワ細{ex.Message}"); } finally { -- Gitblit v1.9.1