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; } }