using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Windows; using Aitex.Core.RT.Log; using Aitex.Sorter.Common; using MECF.Framework.Common.CommonData; using VirgoUI.Client.Models.Sys; using MECF.Framework.Common.DataCenter; using OpenSEMI.ClientBase; namespace VirgoUI.Client.Models.DataLog.WaferHistory { public class WaferHistoryViewModel : BaseModel { public DateTime BeginDate { get; set; } public DateTime UIBeginTime { get; set; } public DateTime EndDate { get; set; } public DateTime UIEndTime { get; set; } public ObservableCollection ProcessData { get; set; } public ObservableCollection CarrierData { get; set; } public WaferHistoryViewModel() { this.DisplayName = "Wafer History"; this.ProcessData = new ObservableCollection(); this.CarrierData = new ObservableCollection(); var now = DateTime.Now; EndDate = now; BeginDate = now; UIBeginTime = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0, 0); UIEndTime = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59, 999); } public void Query() { this.UpdateProcessData(BeginTime, EndTime); this.UpdateCarrierData(BeginTime, EndTime); } public void UpdateProcessData(DateTime begin, DateTime end) { try { string sql = string.Format( "SELECT * FROM \"process_data\" where \"process_begin_time\" >= '{0}' and \"process_begin_time\" <= '{1}' order by \"process_begin_time\" ASC;", begin.ToString("yyyy/MM/dd HH:mm:ss.fff"), end.ToString("yyyy/MM/dd HH:mm:ss.fff")); List result = QueryDataClient.Instance.Service. QueryDBProcess(sql); Application.Current.Dispatcher.BeginInvoke(new Action(() => { ProcessData = new ObservableCollection(); if (result != null) { foreach (HistoryProcessData ev in result) { ProcessData.Add(ev); } } NotifyOfPropertyChange("ProcessData"); })); } catch (Exception e) { LOG.Write(e); } } public void UpdateCarrierData(DateTime begin, DateTime end) { try { string sql = string.Format( "SELECT * FROM \"carrier_data\" where \"load_time\" >= '{0}' and \"load_time\" <= '{1}' order by \"load_time\" ASC;", begin.ToString("yyyy/MM/dd HH:mm:ss.fff"), end.ToString("yyyy/MM/dd HH:mm:ss.fff")); List result = QueryDataClient.Instance.Service.QueryDBCarrier(sql); Application.Current.Dispatcher.BeginInvoke(new Action(() => { CarrierData = new ObservableCollection(); if (result != null) { foreach (HistoryCarrierData ev in result) { CarrierData.Add(ev); } } NotifyOfPropertyChange("CarrierData"); })); } catch (Exception e) { LOG.Write(e); } } private HistoryCarrierData selectedHistoryProcessData; public HistoryCarrierData SelectedHistoryProcessData { get { return this.selectedHistoryProcessData; } set { this.selectedHistoryProcessData = value; } } private HistoryCarrierData selectedHistoryCarrierData; public HistoryCarrierData SelectedHistoryCarrierData { get { return this.selectedHistoryCarrierData; } set { this.selectedHistoryCarrierData = value; } } private DateTime BeginTime { get { return new DateTime(BeginDate.Year, BeginDate.Month, BeginDate.Day, UIBeginTime.Hour, UIBeginTime.Minute, UIBeginTime.Second); } } private DateTime EndTime { get { return new DateTime(EndDate.Year, EndDate.Month, EndDate.Day, UIEndTime.Hour, UIEndTime.Minute, UIEndTime.Second, 999); } } } }