using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Toolkit.Mvvm.ComponentModel; using System.Collections.ObjectModel; using BPASmartClient.CustomResource.Pages.Model; using Microsoft.Toolkit.Mvvm.Input; using System.Diagnostics; using System.IO; namespace BPASmartClient.CustomResource.Pages.ViewModel { public class ReportViewModel { ReportHelper reportHelper = new ReportHelper(); public ReportViewModel() { AddCommand = new RelayCommand(() => { for (int i = 0; i < 30; i++) { ReportData.Add(new ReportTestModel() { data1 = new Random().Next(1000, 2000), data2 = (byte)new Random().Next(0, 240), data3 = Convert.ToBoolean(new Random().Next(0, 1)), data4 = new Random().Next(3000, 4000).ToString(), data5 = (float)new Random().NextDouble() * 100, data6 = (ushort)new Random().Next(5000, 6000) }); } //ReportData = reportHelper.Reports; }); SaveCommand = new RelayCommand(() => { reportHelper.Save($"aa.pry"); }); ReadCommand = new RelayCommand(() => { ReportData.Clear(); var res = reportHelper.GetData($"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\ProductionData\\aa.pry"); if (res != null) { foreach (var item in res) { ReportData.Add(item); } } }); } public ObservableCollection ReportData { get; set; } = new ObservableCollection(); public RelayCommand AddCommand { get; set; } public RelayCommand SaveCommand { get; set; } public RelayCommand ReadCommand { get; set; } } }