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

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