Browse Source

日志更新

样式分支
fyf 2 years ago
parent
commit
bc51448627
2 changed files with 18 additions and 6 deletions
  1. +2
    -2
      BPASmartClient.Message/MessageLog.cs
  2. +16
    -4
      BPASmartClient.ViewModel/LogViewModel.cs

+ 2
- 2
BPASmartClient.Message/MessageLog.cs View File

@@ -66,7 +66,7 @@ namespace BPASmartClient.Message
/// <summary> /// <summary>
/// 设备过程日志委托 /// 设备过程日志委托
/// </summary> /// </summary>
public Action<string> DeviceProcessLogNotify { get; set; }
public Action<string, string> DeviceProcessLogNotify { get; set; }


/// <summary> /// <summary>
/// 设备日志信息字典 /// 设备日志信息字典
@@ -84,7 +84,7 @@ namespace BPASmartClient.Message
DPLogInfo.TryAdd(id, info); DPLogInfo.TryAdd(id, info);
Debug.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")}:{info}"); Debug.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")}:{info}");
//ExLogInfo = $"{DateTime.Now.ToString("HH:mm:ss")}:{info} \n\r {ExLogInfo}"; //ExLogInfo = $"{DateTime.Now.ToString("HH:mm:ss")}:{info} \n\r {ExLogInfo}";
if (DeviceProcessLogNotify != null) DeviceProcessLogNotify(info);
if (DeviceProcessLogNotify != null) DeviceProcessLogNotify(id,info);
} }
} }
#endregion #endregion


+ 16
- 4
BPASmartClient.ViewModel/LogViewModel.cs View File

@@ -44,12 +44,10 @@ namespace BPASmartClient.ViewModel
public static LogViewModel GetInstance() => _Instance ?? (_Instance = new LogViewModel()); public static LogViewModel GetInstance() => _Instance ?? (_Instance = new LogViewModel());
private LogViewModel() private LogViewModel()
{ {
//3.初始化日志
logHelper.Fun_InitLog(System.AppDomain.CurrentDomain.BaseDirectory); logHelper.Fun_InitLog(System.AppDomain.CurrentDomain.BaseDirectory);
if (LogDataGrid==null) LogDataGrid = new ObservableCollection<LogModel>();


if (LogDataGrid==null)
LogDataGrid = new ObservableCollection<LogModel>();
//一般日志
MessageLog.GetInstance.InfoNotify = new Action<string>((s) => MessageLog.GetInstance.InfoNotify = new Action<string>((s) =>
{ {
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
@@ -58,6 +56,18 @@ namespace BPASmartClient.ViewModel
logHelper.GetLogConfigInstance().WriteLog(LogLevel.INFO, s); logHelper.GetLogConfigInstance().WriteLog(LogLevel.INFO, s);
})); }));
}); });

//设备日志
MessageLog.GetInstance.DeviceProcessLogNotify = new Action<string,string>((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<string>((s) => MessageLog.GetInstance.ExInfoNotify = new Action<string>((s) =>
{ {
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
@@ -74,6 +84,8 @@ namespace BPASmartClient.ViewModel
}); });
})); }));
}); });


ExcelCommand = new RelayCommand(() => ExcelCommand = new RelayCommand(() =>
{ {
ExcellOrder(); ExcellOrder();


Loading…
Cancel
Save