From 45c004d4bb5a6f73843a8e8020523f4df14a14e4 Mon Sep 17 00:00:00 2001 From: Chr <haoran.cheng@skonda.com.cn> Date: 星期二, 20 八月 2024 19:17:07 +0800 Subject: [PATCH] 完善消息通知程序; --- PdmSwPlugin.DrawApprove/DrawApprove.xaml.cs | 108 +++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 87 insertions(+), 21 deletions(-) diff --git a/PdmSwPlugin.DrawApprove/DrawApprove.xaml.cs b/PdmSwPlugin.DrawApprove/DrawApprove.xaml.cs index 6c27ce6..1b6b817 100644 --- a/PdmSwPlugin.DrawApprove/DrawApprove.xaml.cs +++ b/PdmSwPlugin.DrawApprove/DrawApprove.xaml.cs @@ -64,8 +64,36 @@ public ObservableCollection<DrawAudit> dataSource { get => _dataSource; - set => RaiseAndSetIfChanged(ref _dataSource, value); + set + { + RaiseAndSetIfChanged(ref _dataSource, value); + if (value == null) + { + StatusBarText = $"鍏� 0 鏉�"; + } + else + { + StatusBarText = $"鍏� {value.Count} 鏉�"; + } + RefreshSelectedCount(); + } } + + private string _SelectBomText = "宸查�変腑 0 鏉�"; + public string SelectBomText + { + get => _SelectBomText; + set => RaiseAndSetIfChanged(ref _SelectBomText, value); + } + + private string _StatusBarText = "鍏� 0 鏉�"; + + public string StatusBarText + { + get { return _StatusBarText; } + set => RaiseAndSetIfChanged(ref _StatusBarText, value); + } + public DrawApproveControl() : this(null) @@ -100,7 +128,32 @@ { data.selected = cb.IsChecked.Value; } + int count = cb.IsChecked.Value ? (dataSource == null ? 0 : dataSource.Count) : 0; + SelectBomText = $"宸查�変腑 {count} 鏉�"; } + + private void RefreshSelectedCount() + { + if (dataSource == null || dataSource.Count <= 0) + { + SelectBomText = "宸查�変腑 0 鏉�"; + return; + } + int count = dataSource.Where(e => e.selected).Count(); + SelectBomText = $"宸查�変腑 {count} 鏉�"; + } + + /// <summary> + /// 鍗曚釜鐐归�変簨浠� + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void SingleCheckBox_Event(object sender, RoutedEventArgs e) + { + RefreshSelectedCount(); + } + + private void Button_Click(object sender, RoutedEventArgs e) { @@ -207,39 +260,34 @@ { Button btn = sender as Button; DrawAudit da = btn.DataContext as DrawAudit; - string fileName = Path.GetFileName(da.d2RelativePath); - if (string.IsNullOrEmpty(fileName)) + string filePath = GetRealFilePath(da.d2RelativePath); + if (!File.Exists(filePath)) { - this.Error("鏃犳晥鏂囦欢鍚�"); + this.Error($"鏈嶅姟鍣ㄤ腑鏈壘鍒板伐绋嬪浘鏂囦欢锛岃矾寰�:{filePath}"); return; } - fileName = Path.Combine(PluginSetting.Instance.SwFilePath, fileName); - if (!File.Exists(fileName)) - { - this.Error($"鏈嶅姟鍣ㄤ腑鏈壘鍒板伐绋嬪浘鏂囦欢锛岃矾寰�:{fileName}"); - return; - } - OpenDocMayError(fileName, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_ReadOnly, + OpenDocMayError(filePath, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_ReadOnly, ""); + } + + private string GetRealFilePath(string dbPath) + { + string fileName = Path.GetFileName(dbPath); + string filePath = Path.Combine(PluginSetting.Instance.SwFilePath, fileName); + return filePath; } private void OpenDoc_Click(object sender, RoutedEventArgs e) { Button btn = sender as Button; DrawAudit da = btn.DataContext as DrawAudit; - string fileName = Path.GetFileName(da.d3RelativePath); - if (string.IsNullOrEmpty(fileName)) + string filePath = GetRealFilePath(da.d3RelativePath); + if (!File.Exists(filePath)) { - this.Error("鏃犳晥鏂囦欢鍚�"); + this.Error($"鏈嶅姟鍣ㄤ腑鏈壘鍒板浘绾告枃浠讹紝璺緞:{filePath}"); return; } - fileName = Path.Combine(PluginSetting.Instance.SwFilePath, fileName); - if (!File.Exists(fileName)) - { - this.Error($"鏈嶅姟鍣ㄤ腑鏈壘鍒板伐绋嬪浘鏂囦欢锛岃矾寰�:{fileName}"); - return; - } - OpenDocMayError(fileName, (int)swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_ReadOnly, + OpenDocMayError(filePath, (int)swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_ReadOnly, ""); } @@ -295,6 +343,23 @@ { try { + string filePath = GetRealFilePath(da.d3RelativePath); + if (!File.Exists(filePath)) + { + this.Error($"鏈嶅姟鍣ㄤ腑鏈壘鍒板浘绾告枃浠讹紝璺緞:{filePath}"); + return; + } + + double[] massData = SwDMUtil.GetMassProperty(filePath, out string errMsg); + if (massData == null) + { + this.Error($"鑾峰彇鍥剧焊涓�鑷存�ф暟鎹け璐ワ紒{errMsg}"); + return; + } + da.fileName = Path.GetFileName(filePath); + da.volume = NumberUtil.HandleMass(massData[3]); + da.surfaceArea = NumberUtil.HandleMass(massData[4]); + da.mass = NumberUtil.HandleMass(massData[5]); da.pass = true; Result<object> res = Client.PostSyncAction<object>(da, "drawAudit/complete"); object obj = res.HandleResult(); @@ -307,6 +372,7 @@ catch (Exception ex) { Logger.Error("Draw complete failed.", ex); + this.Error($"瀹℃牳澶辫触锛亄ex.Message}"); } finally { -- Gitblit v1.9.1