终端一体化运控平台
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.
 
 
 

64 line
2.1 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Microsoft.Toolkit.Mvvm.ComponentModel;
  7. using System.Collections.ObjectModel;
  8. using BPASmartClient.CustomResource.Pages.Model;
  9. using Microsoft.Toolkit.Mvvm.Input;
  10. using System.Diagnostics;
  11. using System.IO;
  12. namespace BPASmartClient.CustomResource.Pages.ViewModel
  13. {
  14. public class ReportViewModel
  15. {
  16. ReportHelper reportHelper = new ReportHelper();
  17. public ReportViewModel()
  18. {
  19. AddCommand = new RelayCommand(() =>
  20. {
  21. for (int i = 0; i < 30; i++)
  22. {
  23. ReportData.Add(new ReportTestModel()
  24. {
  25. data1 = new Random().Next(1000, 2000),
  26. data2 = (byte)new Random().Next(0, 240),
  27. data3 = Convert.ToBoolean(new Random().Next(0, 1)),
  28. data4 = new Random().Next(3000, 4000).ToString(),
  29. data5 = (float)new Random().NextDouble() * 100,
  30. data6 = (ushort)new Random().Next(5000, 6000)
  31. });
  32. }
  33. //ReportData = reportHelper.Reports;
  34. });
  35. SaveCommand = new RelayCommand(() =>
  36. {
  37. reportHelper.Save($"aa.pry");
  38. });
  39. ReadCommand = new RelayCommand(() =>
  40. {
  41. ReportData.Clear();
  42. var res = reportHelper.GetData($"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\ProductionData\\aa.pry");
  43. if (res != null)
  44. {
  45. foreach (var item in res)
  46. {
  47. ReportData.Add(item);
  48. }
  49. }
  50. });
  51. }
  52. public ObservableCollection<ReportBase> ReportData { get; set; } = new ObservableCollection<ReportBase>();
  53. public RelayCommand AddCommand { get; set; }
  54. public RelayCommand SaveCommand { get; set; }
  55. public RelayCommand ReadCommand { get; set; }
  56. }
  57. }