|  |  |  | 
|---|
|  |  |  | using PdmSwPlugin.Commmon.Control; | 
|---|
|  |  |  | using PdmSwPlugin.Common.Entity.System; | 
|---|
|  |  |  | using System.Windows.Documents; | 
|---|
|  |  |  | using System.Windows.Input; | 
|---|
|  |  |  | using NPOI.POIFS.Properties; | 
|---|
|  |  |  | using NPOI.POIFS.Crypt; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | namespace PdmSwPlugin.PDM | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | return allSuccess; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void sb(dynamic[] datas) { | 
|---|
|  |  |  | /*Dictionary<string, DrawInfo> properties = datas[0]; | 
|---|
|  |  |  | string key = datas[1]; | 
|---|
|  |  |  | KeyValuePair<string, DrawInfo> property = datas[2]; | 
|---|
|  |  |  | List<string> temp = datas[3]; | 
|---|
|  |  |  | CountdownEvent counter = datas[4]; | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int iii, ref bool allSuccess | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Logger.Info($"{key} checking rule..."); | 
|---|
|  |  |  | iii++; | 
|---|
|  |  |  | Result<DrawInfo> result = Client.PostSyncAction<DrawInfo>(property.Value, "wpf/bom/openApi/checkRuleSingle"); | 
|---|
|  |  |  | DrawInfo checkResult = result.HandleResult(); | 
|---|
|  |  |  | properties[key].checkRuleResult = checkResult.checkRuleResult; | 
|---|
|  |  |  | properties[key].errMessages = checkResult.errMessages; | 
|---|
|  |  |  | var msgs = checkResult.errMessages; | 
|---|
|  |  |  | if (!properties[key].HistoryData && !checkResult.checkRuleOk) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | allSuccess = false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!properties[key].HistoryData && msgs != null && msgs.Count > 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | lock (temp) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | foreach (string msg in msgs) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | temp.Add($"物料【{key}】未通过规则检查!{msg}"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | MaskAdorner.ShowMessage(content, $"物料【{key}】检查完成"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | properties[key].checkRuleResult = 2; | 
|---|
|  |  |  | properties[key].errMessages = new List<string> { "发起检查失败,请重试" }; | 
|---|
|  |  |  | lock (temp) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | temp.Add($"物料【{key}】发起检查失败,请重试"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | allSuccess = false; | 
|---|
|  |  |  | MaskAdorner.ShowMessage(content, $"物料【{key}】检查完成"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | finally | 
|---|
|  |  |  | { | 
|---|
|  |  |  | counter.Signal(); | 
|---|
|  |  |  | }*/ | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public bool DoCheckRuleAsync(out List<string> messages) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var temp = new List<string>(); | 
|---|
|  |  |  | bool allSuccess = true; | 
|---|
|  |  |  | Dictionary<string, DrawInfo> properties = GetAllProperties(temp); | 
|---|
|  |  |  | MaskAdorner.ShowMessage(content, "正在请求数据..."); | 
|---|
|  |  |  | var factory = LimitedConcurrencyLevelTaskScheduler.Factory; | 
|---|
|  |  |  | CountdownEvent counter = new CountdownEvent(properties.Count); | 
|---|
|  |  |  | int iii = 1; | 
|---|
|  |  |  | foreach (KeyValuePair<string, DrawInfo> property in properties) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string key = property.Key; | 
|---|
|  |  |  | _ = ThreadPool.QueueUserWorkItem( | 
|---|
|  |  |  | (WaitCallback)delegate | 
|---|
|  |  |  | { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Logger.Error($"{key} checking rule..."); | 
|---|
|  |  |  | iii++; | 
|---|
|  |  |  | Result<DrawInfo> result = Client.PostSyncAction<DrawInfo>(property.Value, "wpf/bom/openApi/checkRuleSingle"); | 
|---|
|  |  |  | DrawInfo checkResult = result.HandleResult(); | 
|---|
|  |  |  | properties[key].checkRuleResult = checkResult.checkRuleResult; | 
|---|
|  |  |  | properties[key].errMessages = checkResult.errMessages; | 
|---|
|  |  |  | var msgs = checkResult.errMessages; | 
|---|
|  |  |  | if (!properties[key].HistoryData && !checkResult.checkRuleOk) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | allSuccess = false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!properties[key].HistoryData && msgs != null && msgs.Count > 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | lock (temp) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | foreach (string msg in msgs) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | temp.Add($"物料【{key}】未通过规则检查!{msg}"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | MaskAdorner.ShowMessage(content, $"物料【{key}】检查完成"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | properties[key].checkRuleResult = 2; | 
|---|
|  |  |  | properties[key].errMessages = new List<string> { "发起检查失败,请重试" }; | 
|---|
|  |  |  | lock (temp) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | temp.Add($"物料【{key}】发起检查失败,请重试"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | allSuccess = false; | 
|---|
|  |  |  | MaskAdorner.ShowMessage(content, $"物料【{key}】检查完成"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | finally | 
|---|
|  |  |  | { | 
|---|
|  |  |  | counter.Signal(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /* factory.StartNew(() => | 
|---|
|  |  |  | { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | });*/ | 
|---|
|  |  |  | } | 
|---|
|  |  |  | counter.Wait(); | 
|---|
|  |  |  | counter.Dispose(); | 
|---|
|  |  |  | messages = temp; | 
|---|
|  |  |  | return allSuccess; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void ShowExWindow(MultiExWindow exWin) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | IntPtr winformWindow = Process.GetCurrentProcess().MainWindowHandle; | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | // 执行规则检查并获取结果 | 
|---|
|  |  |  | RefreshBomList(SwApp.IActiveDoc2); | 
|---|
|  |  |  | if (model.bomTreeReader.CacheList.Count <= 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | throw new CantCheckInException(new List<string> { "请打开一张图纸" }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | DoCheckRule(out _); | 
|---|
|  |  |  | // 筛选所有在物料明细表中,不跳过检查并且检查未通过的,类型是加工件的未通过审核的,加工件审核通过的但图纸变更的 | 
|---|
|  |  |  | List<string> errs = model.bomTreeReader.CacheList.Select(b => b.NeedStopCheckIn()) | 
|---|