终端一体化运控平台
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

LogOrAlarmIOTViewModel.cs 3.8 KiB

pirms 2 gadiem
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 2 gadiem
pirms 1 gada
pirms 2 gadiem
pirms 1 gada
pirms 1 gada
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using BPASmartClient.Business;
  2. using BPASmartClient.CustomResource.UserControls;
  3. using BPASmartClient.CustomResource.UserControls.MessageShow;
  4. using BPA.Helper;
  5. using BPASmartClient.IoT;
  6. using DataVAPI.Tool.IOT;
  7. using BPA.Helper;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Collections.ObjectModel;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using System.Windows.Media;
  15. namespace BPASmartClient.ViewModel
  16. {
  17. public class LogOrAlarmIOTViewModel : NotifyBase
  18. {
  19. #region 单一变量
  20. private volatile static LogOrAlarmIOTViewModel _Instance;
  21. public static LogOrAlarmIOTViewModel GetInstance() => _Instance ?? (_Instance = new LogOrAlarmIOTViewModel());
  22. private LogOrAlarmIOTViewModel()
  23. {
  24. Init();
  25. }
  26. #endregion
  27. #region 变量
  28. public string api = "https://bpa.black-pa.com:21527/datav/api/Log/QueryLogFile?DeviceName=";
  29. public string DataVApiAddress { set; get; }
  30. private ObservableCollection<FileModel> _LogModels; public ObservableCollection<FileModel> LogDataFile
  31. {
  32. get
  33. {
  34. return _LogModels;
  35. }
  36. set
  37. {
  38. if (_LogModels == value)
  39. return;
  40. _LogModels = value;
  41. OnPropertyChanged("LogDataFile");
  42. }
  43. }
  44. #endregion
  45. #region Command
  46. public BPARelayCommand QueryCommand { get; set; }
  47. #endregion
  48. #region 函数
  49. public void Init()
  50. {
  51. DataVApiAddress = InternetInfo.DataVApiAddress;
  52. LogDataFile = new ObservableCollection<FileModel>();
  53. //查询
  54. QueryCommand = new BPARelayCommand(() =>
  55. {
  56. Res();
  57. });
  58. }
  59. public void Res()
  60. {
  61. if (DataVClient.GetInstance().DeviceDataV != null && DataVClient.GetInstance().DeviceDataV.deviceTable != null)
  62. {
  63. try
  64. {
  65. LogDataFile.Clear();
  66. api = $"{DataVApiAddress}/api/Log/QueryLogFile?DeviceName={DataVClient.GetInstance().DeviceDataV.deviceTable.devicename}"; ;
  67. string json = APIHelper.GetInstance.GetRequest(api);
  68. JsonMsg<List<FileModel>> jsonMsg = Tools.JsonToObjectTools<JsonMsg<List<FileModel>>>(json);
  69. jsonMsg.obj?.data?.ForEach(file =>
  70. {
  71. LogDataFile.Add(file);
  72. });
  73. NoticeDemoViewModel.OpenMsg(EnumPromptType.Info, MainViewModel.GetInstance().window, "提示", $"查询成功,文件数{LogDataFile.Count}!");
  74. }
  75. catch (Exception ex)
  76. {
  77. NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, MainViewModel.GetInstance().window, "提示", $"查询失败!");
  78. }
  79. }
  80. }
  81. #endregion
  82. }
  83. public class FileModel : NotifyBase
  84. {
  85. public string downloadUrl { get; set; }
  86. public string fileId { get; set; }
  87. public string name { get; set; }
  88. public string size { get; set; }
  89. public string utcCreatedOn { get; set; }
  90. private Brush _foreground;
  91. public Brush foreground
  92. {
  93. get
  94. {
  95. return _foreground;
  96. }
  97. set
  98. {
  99. if (_foreground == value)
  100. return;
  101. _foreground = value;
  102. OnPropertyChanged("foreground");
  103. }
  104. }
  105. public FileModel()
  106. {
  107. foreground = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#21bb2e"));
  108. }
  109. }
  110. }