From e5dded0b507b41d24a6a718b0850222691eb4e33 Mon Sep 17 00:00:00 2001 From: liuwf Date: Wed, 16 Oct 2024 12:43:08 +0800 Subject: [PATCH] =?UTF-8?q?fix-=E4=BC=98=E5=8C=96=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlnMesnac.WPF/MessageTips/Msg.cs | 37 +++++++++++-------- .../ViewModel/ManualDeliveryViewModel.cs | 34 ++++++++++++++--- 2 files changed, 50 insertions(+), 21 deletions(-) diff --git a/SlnMesnac.WPF/MessageTips/Msg.cs b/SlnMesnac.WPF/MessageTips/Msg.cs index d73c3fe..86c9319 100644 --- a/SlnMesnac.WPF/MessageTips/Msg.cs +++ b/SlnMesnac.WPF/MessageTips/Msg.cs @@ -24,25 +24,30 @@ namespace SlnMesnac.WPF.MessageTips { try { - if (messageAdorner != null) + Application.Current.Dispatcher.Invoke(() => { + if (messageAdorner != null && messageAdorner.IsLoaded) + { + messageAdorner.PushMessage(message, msgtype, outTime); + return; + } + Window win = null; + if (Application.Current.Windows.Count > 0) + { + win = Application.Current.Windows.OfType().FirstOrDefault(o => o.IsActive); + if (win == null) + win = Application.Current.Windows.OfType().First(o => o.IsActive); + } + + var layer = GetAdornerLayer(win); + if (layer == null) + throw new Exception("not AdornerLayer is null"); + messageAdorner = new MessageAdorner(layer); + layer.Add(messageAdorner); messageAdorner.PushMessage(message, msgtype, outTime); - return; - } - Window win = null; - if (Application.Current.Windows.Count > 0) - { - win = Application.Current.Windows.OfType().FirstOrDefault(o => o.IsActive); - if (win == null) - win = Application.Current.Windows.OfType().First(o => o.IsActive); - } - var layer = GetAdornerLayer(win); - if (layer == null) - throw new Exception("not AdornerLayer is null"); - messageAdorner = new MessageAdorner(layer); - layer.Add(messageAdorner); - messageAdorner.PushMessage(message, msgtype, outTime); + }); + }catch(Exception ex) { Console.WriteLine("MsgShow异常:"+ex.Message); diff --git a/SlnMesnac.WPF/ViewModel/ManualDeliveryViewModel.cs b/SlnMesnac.WPF/ViewModel/ManualDeliveryViewModel.cs index 9c899b5..023f755 100644 --- a/SlnMesnac.WPF/ViewModel/ManualDeliveryViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/ManualDeliveryViewModel.cs @@ -158,12 +158,22 @@ namespace SlnMesnac.WPF.ViewModel WmsBaseLocation? shallowLocation = sqlSugarClient.AsTenant().GetConnection("mes").Queryable().Where(it => it.WarehouseId == 311 && it.LocRow == row && it.LocColumn == targetLocation.LocColumn).First(); if (shallowLocation == null) { - Msg.MsgShow($"未找到当前深库位对应的浅库位,请重新选择", 2, 3); + Application.Current.Dispatcher.Invoke(() => + { + Msg.MsgShow($"未找到当前深库位对应的浅库位,请重新选择", 2, 3); + + }); + return; } if(shallowLocation.LocationStatus != "1") { - Msg.MsgShow($"当前库位对应的浅库位{shallowLocation.LocationCode}状态异常,禁止出库", 2, 3); + Application.Current.Dispatcher.Invoke(() => + { + Msg.MsgShow($"当前库位对应的浅库位{shallowLocation.LocationCode}状态异常,禁止出库", 2, 3); + + }); + return; } @@ -204,15 +214,24 @@ namespace SlnMesnac.WPF.ViewModel else { - Msg.MsgShow("输入的库位有误,请重新输入", 2, 5); + Application.Current.Dispatcher.Invoke(() => + { + Msg.MsgShow("输入的库位有误,请重新输入", 2, 5); + + }); + return; } } catch (Exception ex) { + Application.Current.Dispatcher.Invoke(() => + { + Msg.MsgShow($"保存异常:{ex.Message}", 2, 5); - Msg.MsgShow($"保存异常:{ex.Message}", 2, 5); + }); + } } @@ -269,7 +288,12 @@ namespace SlnMesnac.WPF.ViewModel var deepHas = wmsRawPreferredOutService.Query(x => x.LocationCode == deepLocation.LocationCode).FirstOrDefault(); if(deepHas != null) { - Msg.MsgShow($"当前库位对应的深库位{deepLocation.LocationCode}在出库队列,请先删除", 2, 3); + Application.Current.Dispatcher.Invoke(() => + { + Msg.MsgShow($"当前库位对应的深库位{deepLocation.LocationCode}在出库队列,请先删除", 2, 3); + + }); + return; } }