123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764 |
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.ComponentModel;
- using System.Data;
- using System.Linq;
- using System.Windows.Forms;
- using System.Windows.Input;
- using MECF.Framework.Common.CommonData;
- using MECF.Framework.Common.DataCenter;
- using OpenSEMI.ClientBase;
- using OpenSEMI.ClientBase.Command;
- using SciChart.Core.Extensions;
- namespace VirgoUI.Client.Models.DataLog.WaferHistory
- {
- public class WaferHistoryDBViewModel : BaseModel
- {
- public WaferHistoryDBViewModel()
- {
- SelectionChangedCommand = new BaseCommand<WaferHistoryItem>(SelectionChanged);
- QueryCommand = new BaseCommand<object>(QueryLots);
- ToChartCommand = new BaseCommand<object>(GoToChart);
- HistoryData = new ObservableCollection<LazyTreeItem<WaferHistoryItem>>();
- InitTime();
- }
- private ObservableCollection<LazyTreeItem<WaferHistoryItem>> _historyData;
- public ObservableCollection<LazyTreeItem<WaferHistoryItem>> HistoryData
- {
- get { return _historyData; }
- set
- {
- _historyData = value;
- NotifyOfPropertyChange("HistoryData");
- }
- }
- private WaferHistoryItem _selectedItem;
- public WaferHistoryItem SelectedItem
- {
- get { return _selectedItem; }
- set
- {
- _selectedItem = value;
- NotifyOfPropertyChange("SelectedItem");
- }
- }
- private ObservableCollection<WaferHistoryLot> _lots = new ObservableCollection<WaferHistoryLot>();
- public ObservableCollection<WaferHistoryLot> Lots
- {
- get { return _lots; }
- set
- {
- _lots = value;
- NotifyOfPropertyChange("Lots");
- }
- }
- private ObservableCollection<WaferHistoryWafer> _wafers = new ObservableCollection<WaferHistoryWafer>();
- public ObservableCollection<WaferHistoryWafer> Wafers
- {
- get { return _wafers; }
- set
- {
- _wafers = value;
- NotifyOfPropertyChange("Wafers");
- }
- }
- private ObservableCollection<WaferHistoryMovement> _movements = new ObservableCollection<WaferHistoryMovement>();
- public ObservableCollection<WaferHistoryMovement> Movements
- {
- get { return _movements; }
- set
- {
- _movements = value;
- NotifyOfPropertyChange("Movements");
- }
- }
- private WaferHistoryRecipe _recipe;
- public WaferHistoryRecipe Recipe
- {
- get { return _recipe; }
- set
- {
- _recipe = value;
- NotifyOfPropertyChange("Recipe");
- }
- }
- public ObservableCollection<WaferHistoryRecipe> _recipes = new ObservableCollection<WaferHistoryRecipe>();
- public ObservableCollection<WaferHistoryRecipe> Recipes
- {
- get { return _recipes; }
- set
- {
- _recipes = value;
- NotifyOfPropertyChange("Recipes");
- }
- }
- private DateTime _searchBeginTime;
- public DateTime SearchBeginTime
- {
- get { return _searchBeginTime; }
- set
- {
- _searchBeginTime = value;
- NotifyOfPropertyChange("SearchBeginTime");
- }
- }
- private DateTime _searchEndTime;
- public DateTime SearchEndTime
- {
- get { return _searchEndTime; }
- set
- {
- _searchEndTime = value;
- NotifyOfPropertyChange("SearchEndTime");
- }
- }
- private string keyWord;
- private WaferHistoryDBView view;
- public string KeyWord
- {
- get { return keyWord; }
- set
- {
- keyWord = value;
- NotifyOfPropertyChange("KeyWord");
- }
- }
- public ICommand SelectionChangedCommand { get; set; }
- public ICommand QueryCommand { get; set; }
- public ICommand ToChartCommand { get; set; }
- void InitTime()
- {
- SearchBeginTime = DateTime.Now.Date;
- SearchEndTime = DateTime.Now.Date.AddDays(1).Date;
- }
- void QueryLots(object e)
- {
- this.SearchBeginTime = this.view.wfTimeFrom.Value;
- this.SearchEndTime = this.view.wfTimeTo.Value;
- if (SearchBeginTime > SearchEndTime)
- {
- MessageBox.Show("Time range invalid, start time should be early than end time");
- return;
- }
- Lots = new ObservableCollection<WaferHistoryLot>(QueryLot(SearchBeginTime, SearchEndTime, KeyWord));//.OrderByDescending(lot => lot.StartTime).ToArray();
- HistoryData.Clear();
- var lotsItem = new WaferHistoryItem() { Name = "Lots", };
- var root = new LazyTreeItem<WaferHistoryItem>(lotsItem, x => LoadSubItem(x));
- root.SubItems = new ObservableCollection<LazyTreeItem<WaferHistoryItem>>(Lots.Select(x => new LazyTreeItem<WaferHistoryItem>(new WaferHistoryItem() { ID = x.ID, Name = x.Name, StartTime = x.StartTime, EndTime = x.EndTime, Type = WaferHistoryItemType.Lot }, LoadSubItem)));
- root.IsExpanded = true;
- HistoryData.Add(root);
- SelectedItem = lotsItem;
- }
- /// <summary>
- /// Notify chart page to prepare datas
- /// </summary>
- /// <param name="o"></param>
- void GoToChart(object o)
- {
- WaferHistoryItem item = o as WaferHistoryItem;
- if (o is WaferHistoryLot waferLot)
- {
- item.Type = WaferHistoryItemType.Lot;
- SelectionChanged(item);
- WaferHistoryItem selectItem = null;
- foreach (var root in HistoryData)
- {
- foreach (var subroot in root.SubItems)
- {
- var data = subroot.Data as WaferHistoryItem;
- if (data != null && data.Name != null && data.Name == item.Name)
- {
- selectItem = data;
- subroot.IsExpanded = true;
- break;
- }
- }
- if (selectItem != null)
- break;
- }
- }
- else if (o is WaferHistoryWafer wafer)
- {
- item.Type = WaferHistoryItemType.Wafer;
- //导航切换到chart页面
- BaseApp.Instance.SwitchPage("DataLog", "ProcessHistory", wafer);
- return;
- }
- else if (o is WaferHistoryRecipe)
- {
- item.Type = WaferHistoryItemType.Recipe;
- }
- else if (o is string name)
- {
- var query = _recipes.FirstOrDefault(t => t.Recipe == name);
- if (query is null) return;
- WaferHistoryWafer wafer1 = new WaferHistoryWafer();
- wafer1.StartTime = query.StartTime;
- wafer1.EndTime = query.EndTime;
- BaseApp.Instance.SwitchPage("DataLog", "ProcessHistory", wafer1);
- }
- else if (o is DateTime startTime)
- {
- var query = _recipes.FirstOrDefault(t => t.StartTime.CompareTo(startTime) == 0);
- if (query is null) return;
- WaferHistoryWafer wafer1 = new WaferHistoryWafer();
- wafer1.StartTime = query.StartTime;
- wafer1.EndTime = query.EndTime;
- BaseApp.Instance.SwitchPage("DataLog", "ProcessHistory", wafer1);
- }
- //
- //WaferHistoryRecipe chartQuery = null;
- //if (o is string name)
- //{
- // var query = _recipes.FirstOrDefault(t => t.Recipe == name);
- // if (query is null) return;
- // chartQuery = query;
- //}
- //if (o is WaferHistoryLot waferLot)
- //{
- // DateTime start = waferLot.StartTime;
- // double.TryParse(waferLot.Duration, out double duration);
- // DateTime end = start.AddSeconds(duration);
- // chartQuery = new WaferHistoryRecipe() { StartTime = start, EndTime = end, /*Chamber = waferLot.CarrierID */};
- //}
- //else if (o is WaferHistoryWafer wafer)
- //{
- // chartQuery = new WaferHistoryRecipe() { StartTime = wafer.StartTime, EndTime = wafer.EndTime/*,Chamber = waferLot.CarrierID*/ };
- //}
- //导航切换到chart页面
- //BaseApp.Instance.SwitchPage("DataLog", "DataHistory", chartQuery);
- }
- public List<WaferHistoryLot> QueryLot(DateTime from, DateTime to, string key)
- {
- List<WaferHistoryLot> result = new List<WaferHistoryLot>();
- string sql = $"SELECT * FROM \"lot_data\" where \"start_time\" >= '{from:yyyy/MM/dd HH:mm:ss.fff}' and \"start_time\" <= '{to:yyyy/MM/dd HH:mm:ss.fff}' ";
- if (!string.IsNullOrWhiteSpace(key))
- sql += $" and lower(\"name\") like '%{key.ToLower()}%'";
- sql += "order by \"start_time\" ASC;";
- //Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- //{
- DataTable dbData = QueryDataClient.Instance.Service.QueryData(sql);
- if (dbData != null && dbData.Rows.Count > 0)
- {
- for (int i = 0; i < dbData.Rows.Count; i++)
- {
- WaferHistoryLot item = new WaferHistoryLot();
- string name = dbData.Rows[i]["name"].ToString();
- string time = "";
- item.WaferCount = (int)dbData.Rows[i]["total_wafer_count"];
- item.ID = dbData.Rows[i]["guid"].ToString();
- if (!dbData.Rows[i]["start_time"].Equals(DBNull.Value))
- {
- item.StartTime = ((DateTime)dbData.Rows[i]["start_time"]);
- time = item.StartTime.ToString("yyyy-MM-dd HH:mm:ss");
- }
- if (!dbData.Rows[i]["end_time"].Equals(DBNull.Value))
- {
- item.EndTime = ((DateTime)dbData.Rows[i]["end_time"]);
- }
- item.InputPort = dbData.Rows[i]["input_port"].ToString();
- item.Name = $"{name}-{time}";
- item.LotID = $"{name}";
- result.Add(item);
- }
- }
- //}));
- return result;
- }
- public List<WaferHistoryWafer> QueryLotWafer(WaferHistoryItem whItem)
- {
- List<WaferHistoryWafer> result = new List<WaferHistoryWafer>();
- //string sql = $"select data.*,process_data.process_status from (SELECT * FROM wafer_data,lot_wafer_data where lot_wafer_data.lot_data_guid = '{lotGuid}' and lot_wafer_data.wafer_data_guid = wafer_data.guid order by wafer_data.create_time ASC; as data )" +
- // $" LEFT JOIN process_data ON process_data.wafer_data_guid=data.wafer_id";
- string sql = $"SELECT wafer_data.*,lot_wafer_data.*,process_data.process_status as status FROM wafer_data LEFT JOIN lot_wafer_data ON lot_wafer_data.wafer_data_guid = wafer_data.guid " +
- $"LEFT JOIN process_data ON process_data.wafer_data_guid = wafer_data.guid where lot_wafer_data.lot_data_guid = '{whItem.ID}' order by wafer_data.create_time ASC";
- Wafers.Clear();
- //Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- //{
- DataTable dbData = QueryDataClient.Instance.Service.QueryData(sql);
- Dictionary<string, int> itemPtr = new Dictionary<string, int>();
- List<string> itemNameList = new List<string>();
- if (dbData != null && dbData.Rows.Count > 0)
- {
- for (int i = 0; i < dbData.Rows.Count; i++)
- {
- WaferHistoryWafer item = new WaferHistoryWafer();
- item.ID = dbData.Rows[i]["guid"].ToString();
- if (!itemPtr.ContainsKey(item.ID))
- {
- itemPtr.Add(item.ID, 0);
- }
- var itemLoadPort = dbData.Rows[i]["create_station"].ToString();
- var itemSlot = dbData.Rows[i]["create_slot"].ToString();
- //item.CarrierID = dbData.Rows[i]["rfid"].ToString();
- item.LotID = dbData.Rows[i]["lot_id"].ToString();
- item.SlotID = dbData.Rows[i]["create_slot"].ToString();
- var itemWaferID = dbData.Rows[i]["wafer_id"].ToString();
- item.Sequence = dbData.Rows[i]["sequence_name"].ToString();
- item.Status = dbData.Rows[i]["status"].ToString();
- sql = $"SELECT * FROM \"wafer_move_history\" where \"wafer_data_guid\" = '{item.ID}' and \"arrive_time\" >= '{whItem.StartTime:yyyy/MM/dd HH:mm:ss.fff}' and \"arrive_time\" <= '{whItem.EndTime:yyyy/MM/dd HH:mm:ss.fff}' order by \"arrive_time\" ASC limit 1000;";
- DataTable dbDataMovement = QueryDataClient.Instance.Service.QueryData(sql);
- if (dbDataMovement != null && dbDataMovement.Rows.Count >= 2 && dbDataMovement.Rows.Count > itemPtr[item.ID])
- {
- item.StartTime = (DateTime)dbDataMovement.Rows[itemPtr[item.ID]]["arrive_time"];
- for (int j = itemPtr[item.ID]; j < dbDataMovement.Rows.Count; j++)
- {
- if (dbDataMovement.Rows[j]["station"].ToString().StartsWith("LP"))
- {
- item.EndTime = (DateTime)dbDataMovement.Rows[j]["arrive_time"];
- itemPtr[item.ID] = j + 1;
- break;
- }
- }
- }
- else
- {
- if (!dbData.Rows[i]["create_time"].Equals(DBNull.Value))
- {
- item.StartTime = ((DateTime)dbData.Rows[i]["create_time"]);
- }
- if (!dbData.Rows[i]["delete_time"].Equals(DBNull.Value))
- item.EndTime = ((DateTime)dbData.Rows[i]["delete_time"]);
- }
- item.Name = $"{itemLoadPort} - {itemSlot} - {itemWaferID}";
- item.Type = WaferHistoryItemType.Wafer;
- if (!itemNameList.Contains(item.Name))
- {
- Wafers.Add(item);
- result.Add(item);
- itemNameList.Add(item.Name);
- }
- }
- }
- //}));
- return result;
- }
- public List<WaferHistoryRecipe> QueryWaferRecipe(WaferHistoryItem whItem)
- {
- List<WaferHistoryRecipe> result = new List<WaferHistoryRecipe>();
- string sql = $"SELECT * FROM \"process_data\" where \"wafer_data_guid\" = '{whItem.ID}'and \"process_begin_time\" >= '{whItem.StartTime:yyyy/MM/dd HH:mm:ss.fff}' and \"process_begin_time\" <= '{whItem.EndTime:yyyy/MM/dd HH:mm:ss.fff}' order by \"process_begin_time\" ASC;";
- Recipes.Clear();
- //Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- //{
- DataTable dbData = QueryDataClient.Instance.Service.QueryData(sql);
- if (dbData != null && dbData.Rows.Count > 0)
- {
- for (int i = 0; i < dbData.Rows.Count; i++)
- {
- WaferHistoryRecipe item = new WaferHistoryRecipe();
- item.ID = dbData.Rows[i]["guid"].ToString();
- var itemName = dbData.Rows[i]["recipe_name"].ToString();
- if (!dbData.Rows[i]["process_begin_time"].Equals(DBNull.Value))
- item.StartTime = (DateTime)dbData.Rows[i]["process_begin_time"];
- if (dbData.Rows[i].Table.Columns.Contains("process_end_time") && !dbData.Rows[i]["process_end_time"].Equals(DBNull.Value))
- item.EndTime = (DateTime)dbData.Rows[i]["process_end_time"];
- if (dbData.Rows[i].Table.Columns.Contains("recipe_setting_time") && !dbData.Rows[i]["recipe_setting_time"].Equals(DBNull.Value))
- item.SettingTime = dbData.Rows[i]["recipe_setting_time"].ToString();
- item.ActualTime = item.Duration;
- item.Recipe = itemName;
- item.Chamber = dbData.Rows[i]["process_in"].ToString();
- item.Name = itemName;
- item.Type = WaferHistoryItemType.Recipe;
- Recipes.Add(item);
- result.Add(item);
- }
- }
- //}));
- return result;
- }
- public List<WaferHistoryMovement> QueryWaferMovement(WaferHistoryItem whItem)
- {
- List<WaferHistoryMovement> result = new List<WaferHistoryMovement>();
- string sql = $"SELECT * FROM \"wafer_move_history\" where \"wafer_data_guid\" = '{whItem.ID}'and \"arrive_time\" >= '{whItem.StartTime:yyyy/MM/dd HH:mm:ss.fff}' and \"arrive_time\" <= '{whItem.EndTime:yyyy/MM/dd HH:mm:ss.fff}' order by \"arrive_time\" ASC limit 1000;";
- Movements.Clear();
- //Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- //{
- DataTable dbData = QueryDataClient.Instance.Service.QueryData(sql);
- if (dbData != null && dbData.Rows.Count > 0)
- {
- for (int i = 0; i < dbData.Rows.Count - 1; i++)
- {
- WaferHistoryMovement item = new WaferHistoryMovement();
- item.Source = $"station : {dbData.Rows[i]["station"]} slot : {dbData.Rows[i]["slot"]}";
- item.Destination = $"station : {dbData.Rows[i + 1]["station"]} slot : {dbData.Rows[i + 1]["slot"]}";
- item.InTime = dbData.Rows[i]["arrive_time"].ToString();
- result.Add(item);
- Movements.Add(item);
- }
- }
- //}));
- return result;
- }
- public WaferHistoryRecipe QueryRecipe(WaferHistoryItem whItem)
- {
- WaferHistoryRecipe result = new WaferHistoryRecipe();
- string sql = $"SELECT * FROM \"process_data\" where \"guid\" = '{whItem.ID}'and \"process_begin_time\" >= '{whItem.StartTime:yyyy/MM/dd HH:mm:ss.fff}' and \"process_begin_time\" <= '{whItem.EndTime:yyyy/MM/dd HH:mm:ss.fff}';";
- //Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- //{
- DataTable dbData = QueryDataClient.Instance.Service.QueryData(sql);
- if (dbData != null && dbData.Rows.Count > 0)
- {
- for (int i = 0; i < dbData.Rows.Count; i++)
- {
- WaferHistoryRecipe item = new WaferHistoryRecipe();
- item.ID = dbData.Rows[i]["guid"].ToString();
- var itemName = dbData.Rows[i]["recipe_name"].ToString();
- if (!dbData.Rows[i]["process_begin_time"].Equals(DBNull.Value))
- item.StartTime = (DateTime)dbData.Rows[i]["process_begin_time"];
- if (!dbData.Rows[i]["process_end_time"].Equals(DBNull.Value))
- item.EndTime = (DateTime)dbData.Rows[i]["process_end_time"];
- if (dbData.Rows[i].Table.Columns.Contains("recipe_setting_time") && !dbData.Rows[i]["recipe_setting_time"].Equals(DBNull.Value))
- item.SettingTime = dbData.Rows[i]["recipe_setting_time"].ToString();
- item.ActualTime = item.Duration;
- item.Recipe = itemName;
- item.Chamber = dbData.Rows[i]["process_in"].ToString();
- item.Name = itemName;
- item.Type = WaferHistoryItemType.Recipe;
- result = item;
- }
- }
- sql = $"SELECT * FROM \"recipe_step_data\" where \"process_data_guid\" = '{whItem.ID}' and \"step_begin_time\" >= '{whItem.StartTime:yyyy/MM/dd HH:mm:ss.fff}' and \"step_begin_time\" <= '{whItem.EndTime:yyyy/MM/dd HH:mm:ss.fff}' order by step_number ASC;";
- dbData = QueryDataClient.Instance.Service.QueryData(sql);
- List<RecipeStep> steps = new List<RecipeStep>();
- if (dbData != null && dbData.Rows.Count > 0)
- {
- for (int i = 0; i < dbData.Rows.Count; i++)
- {
- RecipeStep item = new RecipeStep();
- item.No = int.Parse(dbData.Rows[i]["step_number"].ToString());
- item.Name = dbData.Rows[i]["step_name"].ToString();
- if (!dbData.Rows[i]["step_begin_time"].Equals(DBNull.Value))
- item.StartTime = (DateTime)dbData.Rows[i]["step_begin_time"];
- if (!dbData.Rows[i]["step_end_time"].Equals(DBNull.Value))
- item.EndTime = (DateTime)dbData.Rows[i]["step_end_time"];
- item.ActualTime = item.EndTime.CompareTo(item.StartTime) <= 0 ? "" : item.EndTime.Subtract(item.StartTime).TotalSeconds.ToString();
- item.SettingTime = dbData.Rows[i]["step_time"].ToString();
- steps.Add(item);
- }
- }
- sql = $"SELECT * FROM \"step_fdc_data\" where \"process_data_guid\" = '{whItem.ID}' and \"create_time\" >= '{whItem.StartTime:yyyy/MM/dd HH:mm:ss.fff}' and \"create_time\" <= '{whItem.EndTime:yyyy/MM/dd HH:mm:ss.fff}'order by step_number ASC;";
- dbData = QueryDataClient.Instance.Service.QueryData(sql);
- List<RecipeStepFdcData> fdcs = new List<RecipeStepFdcData>();
- if (dbData != null && dbData.Rows.Count > 0)
- {
- for (int i = 0; i < dbData.Rows.Count; i++)
- {
- RecipeStepFdcData item = new RecipeStepFdcData();
- item.StepNumber = int.Parse(dbData.Rows[i]["step_number"].ToString());
- item.Name = dbData.Rows[i]["parameter_name"].ToString();
- foreach (var name in _mapGasNameKey)
- {
- if (item.Name.Contains(name.Value) && _mapGasNameValue.ContainsKey(name.Key))
- item.Name = item.Name.Replace(name.Value, (string)_mapGasNameValue[name.Key]);
- }
-
- if (!dbData.Rows[i]["sample_count"].Equals(DBNull.Value))
- item.SampleCount = (int)dbData.Rows[i]["sample_count"];
- if (!dbData.Rows[i]["setpoint"].Equals(DBNull.Value))
- item.SetPoint = (float)dbData.Rows[i]["setpoint"];
- if (!dbData.Rows[i]["min_value"].Equals(DBNull.Value))
- item.MinValue = (float)dbData.Rows[i]["min_value"];
- if (!dbData.Rows[i]["max_value"].Equals(DBNull.Value))
- item.MaxValue = (float)dbData.Rows[i]["max_value"];
- if (!dbData.Rows[i]["std_value"].Equals(DBNull.Value))
- item.StdValue = (float)dbData.Rows[i]["std_value"];
- if (!dbData.Rows[i]["mean_value"].Equals(DBNull.Value))
- item.MeanValue = (float)dbData.Rows[i]["mean_value"];
- fdcs.Add(item);
- }
- }
- result.Steps = steps;
- result.Fdcs = fdcs;
- Recipe = result;
- return result;
- }
- private void SelectionChanged(WaferHistoryItem item)
- {
- switch (item.Type)
- {
- case WaferHistoryItemType.Lot:
- QueryLotWafer(item);
- break;
- case WaferHistoryItemType.Wafer:
- QueryWaferRecipe(item);
- QueryWaferMovement(item);
- break;
- case WaferHistoryItemType.Recipe:
- QueryRecipe(item);
- break;
- default:
- break;
- }
- SelectedItem = item;
- }
- protected List<LazyTreeItem<WaferHistoryItem>> LoadSubItem(WaferHistoryItem item)
- {
- switch (item.Type)
- {
- case WaferHistoryItemType.Lot:
- var wafers = QueryLotWafer(item);
- return wafers.Select(x => new LazyTreeItem<WaferHistoryItem>(x, y => LoadSubItem(y))).OrderBy(s => s.Data.StartTime).ToList();
- case WaferHistoryItemType.Wafer:
- var recipes = QueryWaferRecipe(item);
- return recipes.Select(x => new LazyTreeItem<WaferHistoryItem>(x, y => LoadSubItem(y))).OrderBy(s => s.Data.StartTime).ToList();
- default:
- break;
- }
- return new List<LazyTreeItem<WaferHistoryItem>> { };
- }
- protected override void OnViewLoaded(object _view)
- {
- base.OnViewLoaded(_view);
- this.view = (WaferHistoryDBView)_view;
- this.view.wfTimeFrom.Value = this.SearchBeginTime;
- this.view.wfTimeTo.Value = this.SearchEndTime;
- QueryLots(new object());
- SelectionChanged(SelectedItem);
- }
- private Dictionary<string, object> _mapGasNameValue = new Dictionary<string, object>();
- private Dictionary<string, string> _mapGasNameKey = new Dictionary<string, string>()
- {
- {"PMA.MfcGas1.GasName", "PMA.IoMfc.MfcGas1"},
- {"PMA.MfcGas2.GasName", "PMA.IoMfc.MfcGas2"},
- {"PMA.MfcGas3.GasName", "PMA.IoMfc.MfcGas3"},
- {"PMA.MfcGas4.GasName", "PMA.IoMfc.MfcGas4"},
- {"PMA.MfcGas5.GasName", "PMA.IoMfc.MfcGas5"},
- {"PMB.MfcGas1.GasName", "PMB.IoMfc.MfcGas1"},
- {"PMB.MfcGas2.GasName", "PMB.IoMfc.MfcGas2"},
- {"PMB.MfcGas3.GasName", "PMB.IoMfc.MfcGas3"},
- {"PMB.MfcGas4.GasName", "PMB.IoMfc.MfcGas4"},
- {"PMB.MfcGas5.GasName", "PMB.IoMfc.MfcGas5"},
- };
- protected override void OnActivate()
- {
- base.OnActivate();
- _mapGasNameValue = QueryDataClient.Instance.Service.PollConfig(_mapGasNameKey.Keys);
- }
- }
- public class LazyTreeItem<T> : INotifyPropertyChanged where T : ITreeItem<T>, new()
- {
- private LazyTreeItem<T> dummyChild;
- private T data;
- private Func<T, List<LazyTreeItem<T>>> loader;
- private LazyTreeItem()
- {
- data = new T();
- data.ID = Guid.NewGuid().ToString();
- }
- public LazyTreeItem(T data, Func<T, List<LazyTreeItem<T>>> loader)
- {
- this.data = data;
- this.loader = loader;
- dummyChild = new LazyTreeItem<T>();
- SubItems = new ObservableCollection<LazyTreeItem<T>>();
- SubItems.Add(dummyChild);
- }
- public T Data
- {
- get
- {
- return data;
- }
- }
- public ObservableCollection<LazyTreeItem<T>> SubItems
- {
- get; set;
- }
- private bool isExpanded;
- public event PropertyChangedEventHandler PropertyChanged;
- private void OnPropertyChanged(string name)
- {
- if (PropertyChanged != null)
- {
- PropertyChanged.Invoke(this, new PropertyChangedEventArgs(name));
- }
- }
- public bool HasDummyChild
- {
- get { return SubItems.Count == 1 && SubItems.First().data.ID == dummyChild.data.ID; }
- }
- public bool IsExpanded
- {
- get { return isExpanded; }
- set
- {
- if (value != isExpanded)
- {
- isExpanded = value;
- OnPropertyChanged("IsExpanded");
- }
- if (HasDummyChild)
- {
- SubItems.Remove(dummyChild);
- var items = loader(data);
- items.ForEachDo(x => SubItems.Add(x));
- }
- }
- }
- }
- }
|