WaferHistoryViewModel.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Windows;
  5. using Aitex.Core.RT.Log;
  6. using Aitex.Sorter.Common;
  7. using Virgo_DUI.Client.Models.Sys;
  8. using MECF.Framework.Common.DataCenter;
  9. using OpenSEMI.ClientBase;
  10. namespace Virgo_DUI.Client.Models.DataLog.WaferHistory
  11. {
  12. public class WaferHistoryViewModel : BaseModel
  13. {
  14. public DateTime BeginDate { get; set; }
  15. public DateTime UIBeginTime { get; set; }
  16. public DateTime EndDate { get; set; }
  17. public DateTime UIEndTime { get; set; }
  18. public ObservableCollection<HistoryProcessData> ProcessData { get; set; }
  19. public ObservableCollection<HistoryCarrierData> CarrierData { get; set; }
  20. public WaferHistoryViewModel()
  21. {
  22. this.DisplayName = "Wafer History";
  23. this.ProcessData = new ObservableCollection<HistoryProcessData>();
  24. this.CarrierData = new ObservableCollection<HistoryCarrierData>();
  25. var now = DateTime.Now;
  26. EndDate = now;
  27. BeginDate = now;
  28. UIBeginTime = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0, 0);
  29. UIEndTime = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59, 999);
  30. }
  31. public void Query()
  32. {
  33. this.UpdateProcessData(BeginTime, EndTime);
  34. this.UpdateCarrierData(BeginTime, EndTime);
  35. }
  36. public void UpdateProcessData(DateTime begin, DateTime end)
  37. {
  38. try
  39. {
  40. string sql = string.Format(
  41. "SELECT * FROM \"process_data\" where \"process_begin_time\" >= '{0}' and \"process_begin_time\" <= '{1}' order by \"process_begin_time\" ASC;",
  42. begin.ToString("yyyy/MM/dd HH:mm:ss.fff"), end.ToString("yyyy/MM/dd HH:mm:ss.fff"));
  43. List<HistoryProcessData> result = QueryDataClient.Instance.Service. QueryDBProcess(sql);
  44. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  45. {
  46. ProcessData = new ObservableCollection<HistoryProcessData>();
  47. if (result != null)
  48. {
  49. foreach (HistoryProcessData ev in result)
  50. {
  51. ProcessData.Add(ev);
  52. }
  53. }
  54. NotifyOfPropertyChange("ProcessData");
  55. }));
  56. }
  57. catch (Exception e)
  58. {
  59. LOG.Write(e);
  60. }
  61. }
  62. public void UpdateCarrierData(DateTime begin, DateTime end)
  63. {
  64. try
  65. {
  66. string sql = string.Format(
  67. "SELECT * FROM \"carrier_data\" where \"load_time\" >= '{0}' and \"load_time\" <= '{1}' order by \"load_time\" ASC;",
  68. begin.ToString("yyyy/MM/dd HH:mm:ss.fff"), end.ToString("yyyy/MM/dd HH:mm:ss.fff"));
  69. List<HistoryCarrierData> result = QueryDataClient.Instance.Service.QueryDBCarrier(sql);
  70. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  71. {
  72. CarrierData = new ObservableCollection<HistoryCarrierData>();
  73. if (result != null)
  74. {
  75. foreach (HistoryCarrierData ev in result)
  76. {
  77. CarrierData.Add(ev);
  78. }
  79. }
  80. NotifyOfPropertyChange("CarrierData");
  81. }));
  82. }
  83. catch (Exception e)
  84. {
  85. LOG.Write(e);
  86. }
  87. }
  88. private HistoryCarrierData selectedHistoryProcessData;
  89. public HistoryCarrierData SelectedHistoryProcessData
  90. {
  91. get { return this.selectedHistoryProcessData; }
  92. set
  93. {
  94. this.selectedHistoryProcessData = value;
  95. }
  96. }
  97. private HistoryCarrierData selectedHistoryCarrierData;
  98. public HistoryCarrierData SelectedHistoryCarrierData
  99. {
  100. get { return this.selectedHistoryCarrierData; }
  101. set
  102. {
  103. this.selectedHistoryCarrierData = value;
  104. }
  105. }
  106. private DateTime BeginTime
  107. {
  108. get
  109. {
  110. return new DateTime(BeginDate.Year, BeginDate.Month, BeginDate.Day,
  111. UIBeginTime.Hour, UIBeginTime.Minute, UIBeginTime.Second);
  112. }
  113. }
  114. private DateTime EndTime
  115. {
  116. get
  117. {
  118. return new DateTime(EndDate.Year, EndDate.Month, EndDate.Day,
  119. UIEndTime.Hour, UIEndTime.Minute, UIEndTime.Second, 999);
  120. }
  121. }
  122. }
  123. }