using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Windows; using Aitex.Core.RT.SCCore; using Aitex.Core.UI.ControlDataContext; using Aitex.Core.Utilities; using Aitex.Triton160.Common; namespace Aitex.Triton160.UI.ViewModel { class DataLogViewModel : UIViewModelBase { private string _culture = CultureSupported.English; public class DbSusceptorDetails { public string Time { get; set; } public string ItemType { get; set; } public string ItemData { get; set; } public string ItemDescription { get; set; } } public ProcessDataChartDataItem ProcessChartData { get; set; } public ObservableCollection RecipeList { get; set; } public List DataLogList { get; set; } public List ProcessData { get; set; } public DataLogViewModel() : base("DataLogViewModel") { ProcessChartData = new ProcessDataChartDataItem(60000); Triton160UiSystem.Instance.CultureChanged += CultureChanged; SCLocal.SetKeys(new List() { SCName.GasLineConfig_Gas1Enable, SCName.GasLineConfig_Gas1Name, SCName.GasLineConfig_Gas2Enable, SCName.GasLineConfig_Gas2Name, SCName.GasLineConfig_Gas3Enable, SCName.GasLineConfig_Gas3Name, SCName.GasLineConfig_Gas4Enable, SCName.GasLineConfig_Gas4Name, SCName.GasLineConfig_Gas5Enable, SCName.GasLineConfig_Gas5Name, SCName.RfConfig_EnablePulsingFunction, SCName.PressureControlConfig_EnableThrottleValve, SCName.PressureControlConfig_PumpEnableN2Pressure, SCName.PressureControlConfig_PumpEnableWaterFlow, }); } private void CultureChanged(string s) { _culture = s; } public void UpdateRecipeList(DateTime from, DateTime to) { ObservableCollection lst = new ObservableCollection(); List result = Triton160UiSystem.Instance.WCF.Query.GetHistoryRecipeList(from, to); if (result != null) result.ForEach(lst.Add); RecipeList = lst; InvokePropertyChanged("RecipeList"); } public void UpdateDataLogList(DateTime from, DateTime to, string recipe, string lot) { DataLogList = Triton160UiSystem.Instance.WCF.Query.GetHistoryDataLogList(from, to, recipe, lot); InvokePropertyChanged("DataLogList"); } public void UpdateData(DataLogItem dataLog) { if (dataLog == null) { ProcessChartData.ClearData(); return; } List keys = new List(); Application.Current.Dispatcher.Invoke(new Action(() => { Dictionary> dicItems = GetDataElements(_culture); keys = dicItems.Keys.ToList(); ProcessChartData.UpdateColumns(dicItems); })); ProcessData = Triton160UiSystem.Instance.WCF.Query.GetHistoryData(keys, dataLog.RecipeRunGuid); Application.Current.Dispatcher.Invoke(new Action(() => { ProcessChartData.SetInfo(dataLog.LotName); ProcessChartData.UpdateData(ProcessData); })); } } }