chr
2024-08-20 b62a2f5ad99995ec01da71b9f93be7284023171b
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
                    {