|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using BPASmartClient.Message;
- using FryPot_DosingSystem.Model;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Media;
-
- namespace FryPot_DosingSystem.ViewModel
- {
- internal class LogViewModel:ObservableObject
- {
- public static LogViewModel _instance;
- public static LogViewModel GetInstance=>_instance?? (_instance = new LogViewModel());
- private string _logTime;
- public string LogTime { get { return _logTime; } set { _logTime = value; OnPropertyChanged(); } }
-
- private string _logType;
- public string LogType { get { return _logType; } set { _logType = value; OnPropertyChanged(); } }
-
- private string _logMessage;
- public string LogMessage { get { return _logMessage; } set { _logMessage = value; OnPropertyChanged(); } }
-
- private Brush _foreColor;
- public Brush ForeColor { get { return _foreColor; } set { _foreColor = value; OnPropertyChanged(); } }
-
- public ObservableCollection<LogModel> LogDatas { get; set; } = new ObservableCollection<LogModel>();
-
- public LogViewModel()
- {
- Inite();
- }
- public void Inite()
- {
- //一般日志 MessageLog.GetInstance.Show("");
- MessageLog.GetInstance.InfoNotify = new Action<string>((s) =>
- {
- System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
- {
- LogModel logModel = new LogModel { LogMessage= s, LogType = "一般日志" };
- LogDatas.Add(logModel);
- }));
- });
- //设备日志 MessageLog.GetInstance.DeviceProcessLogShow(id,message)
- MessageLog.GetInstance.DeviceProcessLogNotify = new Action<string, string>((id, s) =>
- {
- System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
- {
- LogModel logModel = new LogModel { LogMessage = s, LogType = "设备日志" };
- LogDatas.Add(logModel);
- }));
- });
- //设备告警日志 MessageLog.GetInstance.AddDeviceAlarmLogShow(id,message)
- MessageLog.GetInstance.DeviceAlarmLogNotify = new Action<string, string>((id, s) =>
- {
- System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
- {
- LogModel logModel = new LogModel { LogMessage = id, LogType = "报警日志" };
- LogDatas.Add(logModel);
- }));
- });
- //错误日志MessageLog.GetInstance.ShowEx(message)
- MessageLog.GetInstance.ExInfoNotify = new Action<string>((s) =>
- {
- System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
- {
- LogModel logModel = new LogModel { LogMessage = s, LogType = "错误日志" };
- LogDatas.Add(logModel);
- }));
- });
- }
- }
- }
|