终端一体化运控平台
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

77 satır
3.0 KiB

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