|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using HKCardOut.Helper;
- using HKCardOUT.Helper;
- using HKCardOUT.Logic.Model;
- using HKCardOUT.Logic.Service;
- using Stylet;
- using StyletIoC;
- using System;
- using System.Collections.ObjectModel;
- using System.Threading;
-
- namespace HKCardOUT.ViewModels
- {
- public class RootViewModel : Conductor<IScreen>
- {
- IContainer Container;
- public RootViewModel(IContainer Container)
- {
- this.Container = Container;
- MainThread();
- }
-
- protected override void OnViewLoaded()
- {
- ThreadManage.GetInstance().Start(() =>
- {
- Result = new ObservableCollection<SaleLog>(this.Container.Get<HKCore>().PullDaySaleLog());
- Thread.Sleep(3000);
- }, "消费记录查询");
- }
-
- #region 属性
- ObservableCollection<SaleLog> _Result;
- public ObservableCollection<SaleLog> Result
- {
- get => _Result;
- set => SetAndNotify(ref _Result, value);
- }
- #endregion
-
- #region 方法
- private void MainThread()
- {
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- try
- {
- //1.检测网络上下线
- bool network = HKHelper.GetInstance().GetNetworkState();
- if (network != DataBus.NetWordState)
- {
- if (network) HandyControl.Controls.Growl.InfoGlobal("网络连接成功");
- else HandyControl.Controls.Growl.InfoGlobal("系统已离线,请连接网络!!!");
- DataBus.NetWordState = network;
- }
- Thread.Sleep(3000);
- }
- catch (Exception ex)
- {
- HandyControl.Controls.Growl.InfoGlobal(ex.Message);
- }
- }), "循环状态监测线程", false);
- }
- #endregion
- }
- }
|