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.

66 regels
2.0 KiB

  1. using HKCardOut.Helper;
  2. using HKCardOUT.Helper;
  3. using HKCardOUT.Logic.Model;
  4. using HKCardOUT.Logic.Service;
  5. using Stylet;
  6. using StyletIoC;
  7. using System;
  8. using System.Collections.ObjectModel;
  9. using System.Threading;
  10. namespace HKCardOUT.ViewModels
  11. {
  12. public class RootViewModel : Conductor<IScreen>
  13. {
  14. IContainer Container;
  15. public RootViewModel(IContainer Container)
  16. {
  17. this.Container = Container;
  18. MainThread();
  19. }
  20. protected override void OnViewLoaded()
  21. {
  22. ThreadManage.GetInstance().Start(() =>
  23. {
  24. Result = new ObservableCollection<SaleLog>(this.Container.Get<HKCore>().PullDaySaleLog());
  25. Thread.Sleep(3000);
  26. }, "消费记录查询");
  27. }
  28. #region 属性
  29. ObservableCollection<SaleLog> _Result;
  30. public ObservableCollection<SaleLog> Result
  31. {
  32. get => _Result;
  33. set => SetAndNotify(ref _Result, value);
  34. }
  35. #endregion
  36. #region 方法
  37. private void MainThread()
  38. {
  39. ThreadManage.GetInstance().StartLong(new Action(() =>
  40. {
  41. try
  42. {
  43. //1.检测网络上下线
  44. bool network = HKHelper.GetInstance().GetNetworkState();
  45. if (network != DataBus.NetWordState)
  46. {
  47. if (network) HandyControl.Controls.Growl.InfoGlobal("网络连接成功");
  48. else HandyControl.Controls.Growl.InfoGlobal("系统已离线,请连接网络!!!");
  49. DataBus.NetWordState = network;
  50. }
  51. Thread.Sleep(3000);
  52. }
  53. catch (Exception ex)
  54. {
  55. HandyControl.Controls.Growl.InfoGlobal(ex.Message);
  56. }
  57. }), "循环状态监测线程", false);
  58. }
  59. #endregion
  60. }
  61. }