diff --git a/BPASmartClient.Message/MessageLog.cs b/BPASmartClient.Message/MessageLog.cs index 8db96b0a..468a7995 100644 --- a/BPASmartClient.Message/MessageLog.cs +++ b/BPASmartClient.Message/MessageLog.cs @@ -66,7 +66,7 @@ namespace BPASmartClient.Message /// /// 设备过程日志委托 /// - public Action DeviceProcessLogNotify { get; set; } + public Action DeviceProcessLogNotify { get; set; } /// /// 设备日志信息字典 @@ -84,7 +84,7 @@ namespace BPASmartClient.Message DPLogInfo.TryAdd(id, info); Debug.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")}:{info}"); //ExLogInfo = $"{DateTime.Now.ToString("HH:mm:ss")}:{info} \n\r {ExLogInfo}"; - if (DeviceProcessLogNotify != null) DeviceProcessLogNotify(info); + if (DeviceProcessLogNotify != null) DeviceProcessLogNotify(id,info); } } #endregion diff --git a/BPASmartClient.ViewModel/LogViewModel.cs b/BPASmartClient.ViewModel/LogViewModel.cs index d4dea169..1f26dd4a 100644 --- a/BPASmartClient.ViewModel/LogViewModel.cs +++ b/BPASmartClient.ViewModel/LogViewModel.cs @@ -44,12 +44,10 @@ namespace BPASmartClient.ViewModel public static LogViewModel GetInstance() => _Instance ?? (_Instance = new LogViewModel()); private LogViewModel() { - //3.初始化日志 logHelper.Fun_InitLog(System.AppDomain.CurrentDomain.BaseDirectory); - + if (LogDataGrid==null) LogDataGrid = new ObservableCollection(); - if (LogDataGrid==null) - LogDataGrid = new ObservableCollection(); + //一般日志 MessageLog.GetInstance.InfoNotify = new Action((s) => { System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => @@ -58,6 +56,18 @@ namespace BPASmartClient.ViewModel logHelper.GetLogConfigInstance().WriteLog(LogLevel.INFO, s); })); }); + + //设备日志 + MessageLog.GetInstance.DeviceProcessLogNotify = new Action((id,s) => + { + System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => + { + LogDataGrid.Insert(0, new LogModel { message = s, type = "DeviceLog" }); + logHelper.GetLogConfigInstance().WriteLog(LogLevel.DEBUG, s); + })); + }); + + //错误日志 MessageLog.GetInstance.ExInfoNotify = new Action((s) => { System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => @@ -74,6 +84,8 @@ namespace BPASmartClient.ViewModel }); })); }); + + ExcelCommand = new RelayCommand(() => { ExcellOrder();