using BPA.Helper; using BPA.Message; using BPA.Message.Enum; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace BPASmartClient.ScreenLib { public class ScreenSplitMealsControl2ViewModel : NotifyBase { #region 变量 /// /// 广告地址 /// public Uri GgAdder { get { return _GgAdder; } set { _GgAdder = value; OnPropertyChanged(); } } private Uri _GgAdder = new Uri(System.Configuration.ConfigurationManager.AppSettings["GgAdder"].ToString()); /// /// 界面数据绑定 /// public ScreenModelSplitMeals ViewData { get { return _ViewData; } set { _ViewData = value; OnPropertyChanged(); } } private ScreenModelSplitMeals _ViewData = new ScreenModelSplitMeals(); /// /// 当前刷新数据类型 /// public ScreenDeviceType type = ScreenDeviceType.分餐机; /// /// 订单总数 /// public int OrderCount { get { return _OrderCount; } set { _OrderCount = value; OnPropertyChanged(); } } private int _OrderCount = 0; private DateTime _CurrentTime = DateTime.Now; /// /// 当前时间 /// public DateTime CurrentTime { get { return _CurrentTime; } set { _CurrentTime = value; OnPropertyChanged(); } } #endregion public ScreenSplitMealsControl2ViewModel() { TaskManage.GetInstance.StartLong(new Action(() => { System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => { if (Main.GetInstance.mqttDatasDic.ContainsKey(type)) { ScreenModelSplitMeals modelMaxWok = Main.GetInstance.mqttDatasDic[type] as ScreenModelSplitMeals; if (modelMaxWok != null && modelMaxWok.Alarm != null) modelMaxWok.Alarm = modelMaxWok.Alarm?.OrderByDescending(k => DateTime.Parse(k.AlarmTime)).ToList(); ViewData = modelMaxWok; OrderCount = modelMaxWok.SplitMeals_CreditCardCount_3 + modelMaxWok.SplitMeals_CreditCardCount_4; } CurrentTime = DateTime.Now; })); Thread.Sleep(100); }), $"{DateTime.Now}_2,线程服务"); } } }