终端一体化运控平台
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

138 líneas
3.8 KiB

  1. using BPASmartClient.Business;
  2. using BPA.Helper;
  3. using BPASmartClient.Model;
  4. using BPA.Helper;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Reflection;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows;
  12. using System.Windows.Input;
  13. using System.Windows.Threading;
  14. namespace BPASmartClient.ViewModel
  15. {
  16. /// <summary>
  17. /// 主界面
  18. /// </summary>
  19. public class MainViewModel : NotifyBase
  20. {
  21. /// <summary>
  22. /// 网络连接状态
  23. /// </summary>
  24. private bool _NetworkConnectState = true;
  25. public bool NetworkConnectState
  26. {
  27. get
  28. {
  29. return _NetworkConnectState;
  30. }
  31. set
  32. {
  33. if (_NetworkConnectState == value)
  34. return;
  35. _NetworkConnectState = value;
  36. OnPropertyChanged("NetworkConnectState");
  37. }
  38. }
  39. /// <summary>
  40. /// 是否告警
  41. /// </summary>
  42. public AlarmModel IsAlarm { get; set; }
  43. public System.Windows.Window window;
  44. public DispatcherTimer dispatcherTimer;
  45. #region 单一
  46. private volatile static MainViewModel _Instance;
  47. public static MainViewModel GetInstance() => _Instance ?? (_Instance = new MainViewModel());
  48. #endregion
  49. public MainViewModel()
  50. {
  51. IsAlarm = new AlarmModel();
  52. OrderStatusViewModel.Init();
  53. //设备告警日志
  54. MessageLog.GetInstance.AlarmLogNotify = new Action(() =>
  55. {
  56. System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
  57. {
  58. IsAlarm.IsCheck = MessageLog.GetInstance.DPAlarmInfo.Count > 0;
  59. IsAlarm.ListNum = MessageLog.GetInstance.DPAlarmInfo.Count;
  60. }));
  61. });
  62. dispatcherTimer = new DispatcherTimer();
  63. dispatcherTimer.Tick += delegate
  64. {
  65. System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
  66. {
  67. NetworkConnectState = UniversalHelper.GetInstance().GetNetworkState();
  68. CurrentOrderCount = Json<KeepDataBase>.Data.orderLists.Count;
  69. }));
  70. };
  71. dispatcherTimer.Interval = TimeSpan.FromSeconds(1);
  72. dispatcherTimer.Start();
  73. }
  74. public int CurrentOrderCount { get { return _mCurrentOrderCount; } set { _mCurrentOrderCount = value; OnPropertyChanged(); } }
  75. private int _mCurrentOrderCount;
  76. public bool AutoStart { get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } }
  77. public bool IsVerty { get { return Json<KeepDataBase>.Data.IsVerify; } set { Json<KeepDataBase>.Data.IsVerify = value; OnPropertyChanged(); } }
  78. }
  79. public class AlarmModel : NotifyBase
  80. {
  81. /// <summary>
  82. /// 是否告警
  83. /// </summary>
  84. private bool _IsCheck = false;
  85. public bool IsCheck
  86. {
  87. get
  88. {
  89. return _IsCheck;
  90. }
  91. set
  92. {
  93. if (_IsCheck == value)
  94. return;
  95. _IsCheck = value;
  96. OnPropertyChanged("IsCheck");
  97. }
  98. }
  99. /// <summary>
  100. /// 告警数量
  101. /// </summary>
  102. private int _ListNum = 0;
  103. public int ListNum
  104. {
  105. get
  106. {
  107. return _ListNum;
  108. }
  109. set
  110. {
  111. if (_ListNum == value)
  112. return;
  113. _ListNum = value;
  114. OnPropertyChanged("ListNum");
  115. }
  116. }
  117. public AlarmModel()
  118. {
  119. }
  120. }
  121. }