HistoryViewModel.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using OHV.Common.Model;
  2. using OHV.SqliteDAL;
  3. using Prism.Commands;
  4. using Prism.Mvvm;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Collections.ObjectModel;
  8. using System.Linq;
  9. using System.Security.Permissions;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows.Input;
  13. namespace OHV.Module.MainViews.Views
  14. {
  15. public class HistoryViewModel : BindableBase
  16. {
  17. SqliteManager sql;
  18. List<HisAlarm> _alarmList;
  19. public List<HisAlarm> AlarmList
  20. {
  21. get { return this._alarmList; }
  22. set { this.SetProperty( ref this._alarmList , value ); }
  23. }
  24. public ICommand AlarmResetCommand { get; set; }
  25. public HistoryViewModel( SqliteManager _sql )
  26. {
  27. this.sql = _sql;
  28. //this.AlarmResetCommand = new DelegateCommand( ExecuteAlarmResetCommand );
  29. var ll = sql.HisAlarmDAL.GetAll();
  30. if ( ll == null )
  31. this.AlarmList = new List<HisAlarm>();
  32. else
  33. this.AlarmList = ll.OrderByDescending( x => x.OccurTime ).ToList();
  34. //this.sql.HisAlarmDAL.OnChangeTable += HisAlarmDAL_ChangedProperty;
  35. }
  36. private void HisAlarmDAL_ChangedProperty()
  37. {
  38. if ( this.AlarmList == null )
  39. return;
  40. this.AlarmList.Clear();
  41. this.AlarmList = null;
  42. this.AlarmList = sql.HisAlarmDAL.GetAll().OrderByDescending( x => x.OccurTime ).ToList();
  43. }
  44. public void RefashList()
  45. {
  46. if ( this.AlarmList == null )
  47. return;
  48. this.AlarmList.Clear();
  49. this.AlarmList = null;
  50. this.AlarmList = sql.HisAlarmDAL.GetAll().OrderByDescending( x => x.OccurTime ).ToList();
  51. }
  52. public void Init( )
  53. {
  54. //RefashList();
  55. }
  56. }
  57. }