终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

77 rivejä
3.1 KiB

  1. using BPASmartClient.Message;
  2. using FryPot_DosingSystem.Model;
  3. using Microsoft.Toolkit.Mvvm.ComponentModel;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Collections.ObjectModel;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Media;
  11. namespace FryPot_DosingSystem.ViewModel
  12. {
  13. internal class LogViewModel:ObservableObject
  14. {
  15. public static LogViewModel _instance;
  16. public static LogViewModel GetInstance=>_instance?? (_instance = new LogViewModel());
  17. private string _logTime;
  18. public string LogTime { get { return _logTime; } set { _logTime = value; OnPropertyChanged(); } }
  19. private string _logType;
  20. public string LogType { get { return _logType; } set { _logType = value; OnPropertyChanged(); } }
  21. private string _logMessage;
  22. public string LogMessage { get { return _logMessage; } set { _logMessage = value; OnPropertyChanged(); } }
  23. private Brush _foreColor;
  24. public Brush ForeColor { get { return _foreColor; } set { _foreColor = value; OnPropertyChanged(); } }
  25. public ObservableCollection<LogModel> LogDatas { get; set; } = new ObservableCollection<LogModel>();
  26. public LogViewModel()
  27. {
  28. Inite();
  29. }
  30. public void Inite()
  31. {
  32. //一般日志 MessageLog.GetInstance.Show("");
  33. MessageLog.GetInstance.InfoNotify = new Action<string>((s) =>
  34. {
  35. System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
  36. {
  37. LogModel logModel = new LogModel { LogMessage= s, LogType = "一般日志" };
  38. LogDatas.Add(logModel);
  39. }));
  40. });
  41. //设备日志 MessageLog.GetInstance.DeviceProcessLogShow(id,message)
  42. MessageLog.GetInstance.DeviceProcessLogNotify = new Action<string, string>((id, s) =>
  43. {
  44. System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
  45. {
  46. LogModel logModel = new LogModel { LogMessage = s, LogType = "设备日志" };
  47. LogDatas.Add(logModel);
  48. }));
  49. });
  50. //设备告警日志 MessageLog.GetInstance.AddDeviceAlarmLogShow(id,message)
  51. MessageLog.GetInstance.DeviceAlarmLogNotify = new Action<string, string>((id, s) =>
  52. {
  53. System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
  54. {
  55. LogModel logModel = new LogModel { LogMessage = id, LogType = "报警日志" };
  56. LogDatas.Add(logModel);
  57. }));
  58. });
  59. //错误日志MessageLog.GetInstance.ShowEx(message)
  60. MessageLog.GetInstance.ExInfoNotify = new Action<string>((s) =>
  61. {
  62. System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
  63. {
  64. LogModel logModel = new LogModel { LogMessage = s, LogType = "错误日志" };
  65. LogDatas.Add(logModel);
  66. }));
  67. });
  68. }
  69. }
  70. }