终端一体化运控平台
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

64 linhas
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. }