|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- using System;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Threading;
- using BPA.Message;
- using BPA.Message.Enum;
- using BPA.Helper;
- using BPASmartClient.Model;
-
- namespace BPASmartClient.ViewModel
- {
- public class OrderListDialogViewModel : NotifyBase
- {
- public static bool IsAutoClose = false;
- public OrderListDialogViewModel()
- {
- Init();
- }
-
- private void Init()
- {
- CloseButton();
- CancelButton();
- ConfirmButton();
- if (Json<KeepDataBase>.Data.orderLists.Count > 0)
- {
- MessageLog.GetInstance.Show($"ǰʣ{Json<KeepDataBase>.Data.orderLists.Count}");
- TaskManage.GetInstance.Start(new Action(() =>
- {
- Thread.Sleep(10000);
- if (!IsAutoClose) ActionManage.GetInstance.Send(false, "Close");
- }), "ʱ˳");
- }
- }
-
- /// <summary>
- /// رհť
- /// </summary>
- private void CloseButton()
- {
- CloseCommand = new BPARelayCommand(() =>
- {
- Json<KeepDataBase>.Data.orderLists.Clear();
- ActionManage.GetInstance.Send(false, "Close");
- Json<KeepDataBase>.Save();
- });
- }
-
- /// <summary>
- /// ȡť
- /// </summary>
- private void CancelButton()
- {
- CancelCommand = new BPARelayCommand(() =>
- {
- Json<KeepDataBase>.Data.orderLists.Clear();
- ActionManage.GetInstance.Send(false, "Close");
- Json<KeepDataBase>.Save();
- });
- }
-
- /// <summary>
- /// ȷť
- /// </summary>
- private void ConfirmButton()
- {
- ConfirmCommand = new BPARelayCommand(() =>
- {
- Json<KeepDataBase>.Data.orderLists.Clear();
- //var res = orderStatusLists.Where(p => p.IsSelected == true).ToList();
- var res = orderStatusLists.Where(p => p.morkOrderPushes.Where(s => s.IsSelected == true).ToList().Count > 0).ToList();
-
- if (res != null)
- {
- Json<KeepDataBase>.Data.orderLists.Clear();
- foreach (var item in orderStatusLists)
- {
- ObservableCollection<MorkOrder> morkOrders = new ObservableCollection<MorkOrder>();
- foreach (var mork in item.morkOrderPushes)
- {
- if (mork.IsSelected) morkOrders.Add(mork);
- }
- Json<KeepDataBase>.Data.orderLists.Add(new OrderData()
- {
- DeviceId = item.DeviceId,
- IsAllSelect = item.IsAllSelect,
- morkOrderPushes = morkOrders,
- });
- /*
- foreach (var mo in morkOrders)
- {
- DoOrderEvent de = new DoOrderEvent();
- de.DeviceId = int.Parse(item.DeviceId);
- de.MorkOrder = mo.OrderPush;
- EventBus.GetInstance.Publish(de);
- }*/
- }
- }
- ActionManage.GetInstance.Send(true, "Close");
- });
- }
-
- public BPARelayCommand CloseCommand { get; set; }
-
- public BPARelayCommand CancelCommand { get; set; }
-
- public BPARelayCommand ConfirmCommand { get; set; }
-
- public ObservableCollection<OrderData> orderStatusLists
- {
- get { return Json<KeepDataBase>.Data.orderLists; }
- set { Json<KeepDataBase>.Data.orderLists = value; }
- }
- }
- }
|