using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using BPA.Helper; using System.Collections.ObjectModel; using BPASmartClient.CustomResource.Pages.Model; using System.Diagnostics; using System.IO; namespace BPASmartClient.CustomResource.Pages.ViewModel { public class ReportViewModel { ReportHelper reportHelper = new ReportHelper(); public ReportViewModel() { AddCommand = new BPARelayCommand(() => { 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 BPARelayCommand(() => { reportHelper.Save($"aa.pry"); }); ReadCommand = new BPARelayCommand(() => { 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 BPARelayCommand AddCommand { get; set; } public BPARelayCommand SaveCommand { get; set; } public BPARelayCommand ReadCommand { get; set; } } }