终端一体化运控平台
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 

116 rader
4.0 KiB

  1. using System;
  2. using System.Collections.ObjectModel;
  3. using System.Linq;
  4. using System.Threading;
  5. using BPA.Message;
  6. using BPA.Message.Enum;
  7. using BPA.Helper;
  8. using BPASmartClient.Model;
  9. namespace BPASmartClient.ViewModel
  10. {
  11. public class OrderListDialogViewModel : NotifyBase
  12. {
  13. public static bool IsAutoClose = false;
  14. public OrderListDialogViewModel()
  15. {
  16. Init();
  17. }
  18. private void Init()
  19. {
  20. CloseButton();
  21. CancelButton();
  22. ConfirmButton();
  23. if (Json<KeepDataBase>.Data.orderLists.Count > 0)
  24. {
  25. MessageLog.GetInstance.Show($"重启软件前订单剩余{Json<KeepDataBase>.Data.orderLists.Count}个");
  26. TaskManage.GetInstance.Start(new Action(() =>
  27. {
  28. Thread.Sleep(10000);
  29. if (!IsAutoClose) ActionManage.GetInstance.Send("Close", false);
  30. }), "延时退出");
  31. }
  32. }
  33. /// <summary>
  34. /// 关闭按钮
  35. /// </summary>
  36. private void CloseButton()
  37. {
  38. CloseCommand = new BPARelayCommand(() =>
  39. {
  40. Json<KeepDataBase>.Data.orderLists.Clear();
  41. ActionManage.GetInstance.Send("Close", false);
  42. Json<KeepDataBase>.Save();
  43. });
  44. }
  45. /// <summary>
  46. /// 取消按钮
  47. /// </summary>
  48. private void CancelButton()
  49. {
  50. CancelCommand = new BPARelayCommand(() =>
  51. {
  52. Json<KeepDataBase>.Data.orderLists.Clear();
  53. ActionManage.GetInstance.Send("Close", false);
  54. Json<KeepDataBase>.Save();
  55. });
  56. }
  57. /// <summary>
  58. /// 确定按钮
  59. /// </summary>
  60. private void ConfirmButton()
  61. {
  62. ConfirmCommand = new BPARelayCommand(() =>
  63. {
  64. Json<KeepDataBase>.Data.orderLists.Clear();
  65. //var res = orderStatusLists.Where(p => p.IsSelected == true).ToList();
  66. var res = orderStatusLists.Where(p => p.morkOrderPushes.Where(s => s.IsSelected == true).ToList().Count > 0).ToList();
  67. if (res != null)
  68. {
  69. Json<KeepDataBase>.Data.orderLists.Clear();
  70. foreach (var item in orderStatusLists)
  71. {
  72. ObservableCollection<MorkOrder> morkOrders = new ObservableCollection<MorkOrder>();
  73. foreach (var mork in item.morkOrderPushes)
  74. {
  75. if (mork.IsSelected) morkOrders.Add(mork);
  76. }
  77. Json<KeepDataBase>.Data.orderLists.Add(new OrderData()
  78. {
  79. DeviceId = item.DeviceId,
  80. IsAllSelect = item.IsAllSelect,
  81. morkOrderPushes = morkOrders,
  82. });
  83. /*
  84. foreach (var mo in morkOrders)
  85. {
  86. DoOrderEvent de = new DoOrderEvent();
  87. de.DeviceId = int.Parse(item.DeviceId);
  88. de.MorkOrder = mo.OrderPush;
  89. EventBus.GetInstance().Publish(de);
  90. }*/
  91. }
  92. }
  93. ActionManage.GetInstance.Send("Close", true);
  94. });
  95. }
  96. public BPARelayCommand CloseCommand { get; set; }
  97. public BPARelayCommand CancelCommand { get; set; }
  98. public BPARelayCommand ConfirmCommand { get; set; }
  99. public ObservableCollection<OrderData> orderStatusLists
  100. {
  101. get { return Json<KeepDataBase>.Data.orderLists; }
  102. set { Json<KeepDataBase>.Data.orderLists = value; }
  103. }
  104. }
  105. }