fix-优化消息提示框

dev
liuwf 4 weeks ago
parent 1ac584ee02
commit e5dded0b50

@ -24,25 +24,30 @@ namespace SlnMesnac.WPF.MessageTips
{ {
try 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<Window>().FirstOrDefault(o => o.IsActive);
if (win == null)
win = Application.Current.Windows.OfType<Window>().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); messageAdorner.PushMessage(message, msgtype, outTime);
return;
}
Window win = null;
if (Application.Current.Windows.Count > 0)
{
win = Application.Current.Windows.OfType<Window>().FirstOrDefault(o => o.IsActive);
if (win == null)
win = Application.Current.Windows.OfType<Window>().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) }catch(Exception ex)
{ {
Console.WriteLine("MsgShow异常:"+ex.Message); Console.WriteLine("MsgShow异常:"+ex.Message);

@ -158,12 +158,22 @@ namespace SlnMesnac.WPF.ViewModel
WmsBaseLocation? shallowLocation = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<WmsBaseLocation>().Where(it => it.WarehouseId == 311 && it.LocRow == row && it.LocColumn == targetLocation.LocColumn).First(); WmsBaseLocation? shallowLocation = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<WmsBaseLocation>().Where(it => it.WarehouseId == 311 && it.LocRow == row && it.LocColumn == targetLocation.LocColumn).First();
if (shallowLocation == null) if (shallowLocation == null)
{ {
Msg.MsgShow($"未找到当前深库位对应的浅库位,请重新选择", 2, 3); Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow($"未找到当前深库位对应的浅库位,请重新选择", 2, 3);
});
return; return;
} }
if(shallowLocation.LocationStatus != "1") if(shallowLocation.LocationStatus != "1")
{ {
Msg.MsgShow($"当前库位对应的浅库位{shallowLocation.LocationCode}状态异常,禁止出库", 2, 3); Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow($"当前库位对应的浅库位{shallowLocation.LocationCode}状态异常,禁止出库", 2, 3);
});
return; return;
} }
@ -204,15 +214,24 @@ namespace SlnMesnac.WPF.ViewModel
else else
{ {
Msg.MsgShow("输入的库位有误,请重新输入", 2, 5); Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("输入的库位有误,请重新输入", 2, 5);
});
return; return;
} }
} }
catch (Exception ex) 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(); var deepHas = wmsRawPreferredOutService.Query(x => x.LocationCode == deepLocation.LocationCode).FirstOrDefault();
if(deepHas != null) if(deepHas != null)
{ {
Msg.MsgShow($"当前库位对应的深库位{deepLocation.LocationCode}在出库队列,请先删除", 2, 3); Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow($"当前库位对应的深库位{deepLocation.LocationCode}在出库队列,请先删除", 2, 3);
});
return; return;
} }
} }

Loading…
Cancel
Save