using MECF.Framework.Common.DataCenter; using System; using System.Collections.Generic; using System.Data; using System.Windows.Media; using System.Linq; using Prism.Commands; using Prism.Mvvm; using Venus_MainPages.Unity; using Venus_MainPages.Views; using System.Collections.ObjectModel; using System.Windows.Threading; using System.Windows; using Aitex.Core.RT.Log; using Aitex.Core.UI.ControlDataContext; using WPF.Themes.UserControls; using System.IO; using Newtonsoft.Json; using System.Runtime.Serialization; using Microsoft.VisualBasic.Logging; using ExcelLibrary.BinaryFileFormat; using ExcelLibrary.SpreadSheet; using Venus_Themes.UserControls; using System.Windows.Forms; namespace Venus_MainPages.ViewModels { public class KeplerProcessHistoryViewModel : BindableBase { #region 私有字段 private KeplerProcessHistoryView view; List keys = new List(); RealtimeProvider _provider = new RealtimeProvider(); private ObservableCollection _ParameterNodes; DispatcherTimer timer = new DispatcherTimer(); ObservableCollection _PdKeyDataObservation = new ObservableCollection(); public List RecipesAdd = new List(); public List solidColorBrushes = new List(); //DateTime currentTime; private RecipeItem selectedRecipeItem; private bool m_IsShowStep; private int m_PageCount; private int m_onePageCounts = 7; private int m_Total; private bool m_FirstLoadFlag = true; private Dictionary> resultDictionary; private string _lastSelectChamber; #endregion #region 属性 public List ProcessData { get; set; } public List CheboxRecipes { get; set; } public ProcessDataChartDataItem ProcessChartData { get; set; } public DateTime StartDateTime { get; set; } public DateTime EndDateTime { get; set; } public string SelectedValuePM { get; set; } public string RecipeName { get; set; } public ObservableCollection OldPdKeyDataCollection { get; set; } public ObservableCollection Recipes { get; set; } public class Recipeslist { public string BoxName { get; set; } } public class RecipeAdd { public string Recipesname { get; set; } } public ObservableCollection ParameterNodes { get { return _ParameterNodes; } set { SetProperty(ref _ParameterNodes, value); } } public ObservableCollection PdKeyDataCollection { get { return _PdKeyDataObservation; } set { SetProperty(ref _PdKeyDataObservation, value); } } public bool IsShowStep { get { return m_IsShowStep; } set { SetProperty(ref m_IsShowStep, value); } } public int PageCount { get { return m_PageCount; } set { SetProperty(ref m_PageCount, value); } } public int Total { get { return m_Total; } set { SetProperty(ref m_Total, value); } } #endregion #region 命令 private DelegateCommand _LoadCommandPD; public DelegateCommand LoadCommandPD => _LoadCommandPD ?? (_LoadCommandPD = new DelegateCommand(OnLoadPd)); private DelegateCommand _SearchRecipeCommand; public DelegateCommand SearchRecipeCommand => _SearchRecipeCommand ?? (_SearchRecipeCommand = new DelegateCommand(SearchRecipes)); private DelegateCommand _PdParameterCheckCommand; public DelegateCommand PdParameterCheckCommand => _PdParameterCheckCommand ?? (_PdParameterCheckCommand = new DelegateCommand(OnParameterCheck)); private DelegateCommand _DataGridSelectionChangedCommand; public DelegateCommand DataGridSelectionChangedCommand => _DataGridSelectionChangedCommand ?? (_DataGridSelectionChangedCommand = new DelegateCommand(OnDataGridSelectionChanged)); private DelegateCommand _SearchDataCommand; public DelegateCommand SearchDataCommand => _SearchDataCommand ?? (_SearchDataCommand = new DelegateCommand(OnSearchData)); private DelegateCommand _ClearDataCommand; public DelegateCommand ClearDataCommand => _ClearDataCommand ?? (_ClearDataCommand = new DelegateCommand(OnClearData)); //private DelegateCommand _ExportRecipesCommand; //public DelegateCommand ExportRecipesCommand => //_ExportRecipesCommand ?? (_ExportRecipesCommand = new DelegateCommand(OnExportRecipes)); private DelegateCommand _RecipeDataExportCommand; public DelegateCommand RecipeDataExportCommand => _RecipeDataExportCommand ?? (_RecipeDataExportCommand = new DelegateCommand(OnExportRecipeData)); #endregion #region 构造函数 public KeplerProcessHistoryViewModel() { ProcessData = new List() { }; ProcessChartData = new ProcessDataChartDataItem(60000); Recipes = new ObservableCollection(); timer.Interval = TimeSpan.FromSeconds(0.5); OldPdKeyDataCollection = new ObservableCollection(); CheboxRecipes = new List(); solidColorBrushes.Add(new SolidColorBrush(Colors.Green)); solidColorBrushes.Add(new SolidColorBrush(Colors.Red)); solidColorBrushes.Add(new SolidColorBrush(Colors.Blue)); solidColorBrushes.Add(new SolidColorBrush(Colors.Orange)); solidColorBrushes.Add(new SolidColorBrush(Colors.Yellow)); solidColorBrushes.Add(new SolidColorBrush(Colors.YellowGreen)); solidColorBrushes.Add(new SolidColorBrush(Colors.AliceBlue)); solidColorBrushes.Add(new SolidColorBrush(Colors.Chocolate)); solidColorBrushes.Add(new SolidColorBrush(Colors.Cyan)); solidColorBrushes.Add(new SolidColorBrush(Colors.DarkGreen)); } #endregion #region 命令方法 private void OnLoadPd(Object eventView) { if (m_FirstLoadFlag) { m_FirstLoadFlag = false; this.view = (KeplerProcessHistoryView)eventView; this.view.wfTimeFrom.Value = DateTime.Today; this.view.wfTimeTo.Value = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 23, 59, 59, 999); this.LoadRecipeCheckBox(); this.view.pageControl.CurrentPageChanged += PageControl_CurrentPageChanged; } } private void PageControl_CurrentPageChanged(int currentPage) { PageChanged(currentPage); } public void PageChanged(int CurrentPage) { Recipes.Clear(); string sql = $"SELECT * FROM \"process_data\" where \"process_begin_time\" >='{StartDateTime.ToString("yyyy/MM/dd HH:mm:ss.fff")}' and \"process_begin_time\" <='{EndDateTime.ToString("yyyy/MM/dd HH:mm:ss.fff")}' "; if (!string.IsNullOrEmpty(SelectedValuePM)) { string[] pms = SelectedValuePM.Split(','); if (pms.Length > 0) { sql += " and (FALSE "; foreach (var pm in pms) { sql += $" OR \"process_in\"='{pm}' "; } sql += " ) "; } } if (!string.IsNullOrEmpty(RecipeName)) { sql += string.Format(" and lower(\"recipe_name\") like '%{0}%'", RecipeName.ToLower()); } sql += $" order by \"process_begin_time\" ASC limit {m_onePageCounts} offset {(CurrentPage - 1) * m_onePageCounts};"; DataTable dbData = QueryDataClient.Instance.Service.QueryData(sql); if (dbData == null || dbData.Rows.Count == 0) return; for (int i = 0; i < dbData.Rows.Count; i++) { RecipeItem item = new RecipeItem(); item.Selected = false; item.Recipe = dbData.Rows[i]["recipe_name"].ToString(); item.Guid = dbData.Rows[i]["guid"].ToString(); item.RecipeRunGuid = dbData.Rows[i]["wafer_data_guid"].ToString(); item.Chamber = dbData.Rows[i]["process_in"].ToString(); item.Status = dbData.Rows[i]["process_status"].ToString(); item.SlotID = dbData.Rows[i]["slot_id"].ToString(); item.RecipeType = dbData.Rows[i]["recipe_type"].ToString(); item.WaferId = dbData.Rows[i]["wafer_data_guid"].ToString(); item.LotType = dbData.Rows[i]["lot_type"].ToString(); item.LotID = dbData.Rows[i]["lot_id"].ToString(); item.CarrierId = dbData.Rows[i]["carrier_id"].ToString(); if (!dbData.Rows[i]["process_begin_time"].Equals(DBNull.Value)) item.StartTime = ((DateTime)dbData.Rows[i]["process_begin_time"]).ToString("yyyy-MM-dd HH:mm:ss"); if (!dbData.Rows[i]["process_end_time"].Equals(DBNull.Value)) item.EndTime = ((DateTime)dbData.Rows[i]["process_end_time"]).ToString("yyyy-MM-dd HH:mm:ss"); Recipes.Add(item); } } private void LoadRecipeCheckBox() { List chamber = new List() { "PMA", "PMB", "PMC", "PMD" }; CheboxRecipes.Clear(); foreach (string item in chamber) { string path = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", item); if (Directory.Exists(path)) { string[] dir = Directory.GetFiles(path); for (int i = 0; i < dir.Length; i++) { CheboxRecipes.Add(new Recipeslist { BoxName = Path.GetFileName(dir[i]) }); } } } } public void SearchRecipes() { SearchRecipe(this.view.wfTimeFrom.Value, this.view.wfTimeTo.Value); } public void searchlot(string id) { Recipes.Clear(); try { string sql1 = string.Format($"SELECT * FROM \"lot_wafer_data\" where guid ='{id}'; "); DataTable dbData1 = QueryDataClient.Instance.Service.QueryData(sql1); string lot_data_guid = dbData1.Rows[0]["wafer_data_guid"].ToString(); string sql = string.Format($"SELECT * FROM \"process_data\" where wafer_data_guid ='{lot_data_guid}'"); if (!string.IsNullOrEmpty(SelectedValuePM)) { string[] pms = SelectedValuePM.Split(','); if (pms.Length > 0) { sql += " and (FALSE "; foreach (var pm in pms) { sql += $" OR \"process_in\"='{pm}' "; } sql += " ) "; } } if (!string.IsNullOrEmpty(RecipeName)) { sql += string.Format(" and lower(\"recipe_name\") like '%{0}%'", RecipeName.ToLower()); } sql += " order by \"process_begin_time\" ASC;"; DataTable dbData = QueryDataClient.Instance.Service.QueryData(sql); System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => { if (dbData == null || dbData.Rows.Count == 0) return; for (int i = 0; i < dbData.Rows.Count; i++) { RecipeItem item = new RecipeItem(); item.Selected = false; item.Recipe = dbData.Rows[i]["recipe_name"].ToString(); item.CarrierId = dbData.Rows[i]["carrier_id"].ToString(); item.Guid = dbData.Rows[i]["guid"].ToString(); item.RecipeRunGuid = dbData.Rows[i]["wafer_data_guid"].ToString(); item.Chamber = dbData.Rows[i]["process_in"].ToString(); item.Status = dbData.Rows[i]["process_status"].ToString(); item.SlotID = dbData.Rows[i]["slot_id"].ToString(); item.LotID = dbData.Rows[i]["lot_id"].ToString(); item.WaferId = dbData.Rows[i]["wafer_data_guid"].ToString(); item.LotType = dbData.Rows[i]["lot_type"].ToString(); item.RecipeType = dbData.Rows[i]["recipe_type"].ToString(); if (!dbData.Rows[i]["process_begin_time"].Equals(DBNull.Value)) item.StartTime = ((DateTime)dbData.Rows[i]["process_begin_time"]).ToString("yyyy-MM-dd HH:mm:ss"); if (!dbData.Rows[i]["process_end_time"].Equals(DBNull.Value)) item.EndTime = ((DateTime)dbData.Rows[i]["process_end_time"]).ToString("yyyy-MM-dd HH:mm:ss"); Recipes.Add(item); } })); } catch (Exception e) { LOG.WriteExeption(e); } } public void SearchRecipe(DateTime start, DateTime end) { this.StartDateTime = start; this.EndDateTime = end; Recipes.Clear(); try { string sqlGetCount = $"SELECT COUNT(*) FROM \"process_data\" where \"process_begin_time\" >='{StartDateTime.ToString("yyyy/MM/dd HH:mm:ss.fff")}' and \"process_begin_time\" <='{EndDateTime.ToString("yyyy/MM/dd HH:mm:ss.fff")}' "; if (!string.IsNullOrEmpty(SelectedValuePM)) { string[] pms = SelectedValuePM.Split(','); if (pms.Length > 0) { sqlGetCount += " and (FALSE "; foreach (var pm in pms) { sqlGetCount += $" OR \"process_in\"='{pm}' "; } sqlGetCount += " ) "; } } if (!string.IsNullOrEmpty(RecipeName)) { sqlGetCount += string.Format(" and lower(\"recipe_name\") like '%{0}%'", RecipeName.ToLower()); } sqlGetCount += " ;"; Total = QueryDataClient.Instance.Service.GetDBEventAllCount(sqlGetCount); PageCount = (Total / m_onePageCounts) + 1; string sql = $"SELECT * FROM \"process_data\" where \"process_begin_time\" >='{StartDateTime.ToString("yyyy/MM/dd HH:mm:ss.fff")}' and \"process_begin_time\" <='{EndDateTime.ToString("yyyy/MM/dd HH:mm:ss.fff")}' "; if (!string.IsNullOrEmpty(SelectedValuePM)) { string[] pms = SelectedValuePM.Split(','); if (pms.Length > 0) { sql += " and (FALSE "; foreach (var pm in pms) { sql += $" OR \"process_in\"='{pm}' "; } sql += " ) "; } } if (!string.IsNullOrEmpty(RecipeName)) { sql += string.Format(" and lower(\"recipe_name\") like '%{0}%'", RecipeName.ToLower()); } sql += $" order by \"process_begin_time\" ASC "; if (PageCount > 5) { sql += $" limit {m_onePageCounts} offset {(1 - 1) * m_onePageCounts};"; } DataTable dbData = QueryDataClient.Instance.Service.QueryData(sql); if (dbData == null || dbData.Rows.Count == 0) return; for (int i = 0; i < dbData.Rows.Count; i++) { RecipeItem item = new RecipeItem(); item.Selected = false; item.Recipe = dbData.Rows[i]["recipe_name"].ToString(); item.Guid = dbData.Rows[i]["guid"].ToString(); item.RecipeRunGuid = dbData.Rows[i]["wafer_data_guid"].ToString(); item.Chamber = dbData.Rows[i]["process_in"].ToString(); item.Status = dbData.Rows[i]["process_status"].ToString(); item.SlotID = dbData.Rows[i]["slot_id"].ToString(); item.RecipeType = dbData.Rows[i]["recipe_type"].ToString(); item.LotID = dbData.Rows[i]["lot_id"].ToString(); item.CarrierId = dbData.Rows[i]["carrier_id"].ToString(); item.WaferId = dbData.Rows[i]["wafer_data_guid"].ToString(); item.LotType = dbData.Rows[i]["lot_type"].ToString(); if (!dbData.Rows[i]["process_begin_time"].Equals(DBNull.Value)) item.StartTime = ((DateTime)dbData.Rows[i]["process_begin_time"]).ToString("yyyy-MM-dd HH:mm:ss"); if (!dbData.Rows[i]["process_end_time"].Equals(DBNull.Value)) item.EndTime = ((DateTime)dbData.Rows[i]["process_end_time"]).ToString("yyyy-MM-dd HH:mm:ss"); Recipes.Add(item); } } catch (Exception e) { LOG.WriteExeption(e); } } private void CalKeys(ParameterNode parameterNode) { if (parameterNode.ChildNodes.Count > 0) { foreach (var item in parameterNode.ChildNodes) { CalKeys(item); } } else { if (parameterNode.Selected == true) { keys.Add(parameterNode.Name); } } } private Dictionary> GetData(List keys, DateTime from, DateTime to) { string sql = "select time AS InternalTimeStamp"; foreach (var dataId in keys) { sql += "," + string.Format("\"{0}\"", dataId); } sql += string.Format(" from \"{0}\" where time > {1} and time <= {2} order by time asc", from.ToString("yyyyMMdd") + "." + "Data", from.Ticks, to.Ticks); DataTable dataTable = QueryDataClient.Instance.Service.QueryData(sql); Dictionary> historyData = new Dictionary>(); if (dataTable == null || dataTable.Rows.Count == 0) return null; DateTime dt = new DateTime(); Dictionary colName = new Dictionary(); for (int colNo = 0; colNo < dataTable.Columns.Count; colNo++) { colName.Add(colNo, dataTable.Columns[colNo].ColumnName); historyData[dataTable.Columns[colNo].ColumnName] = new List(); } for (int rowNo = 0; rowNo < dataTable.Rows.Count; rowNo++) { PointCollection points = new PointCollection(); var row = dataTable.Rows[rowNo]; for (int i = 0; i < dataTable.Columns.Count; i++) { HistoryDataItem data = new HistoryDataItem(); if (i == 0) { long ticks = (long)row[i]; dt = new DateTime(ticks); continue; } else { string dataId = colName[i]; if (row[i] is DBNull || row[i] == null) { data.dateTime = dt; data.dbName = colName[i]; data.value = 0; } else if (row[i] is bool) { data.dateTime = dt; data.dbName = colName[i]; data.value = (bool)row[i] ? 1 : 0; } else { data.dateTime = dt; data.dbName = colName[i]; data.value = float.Parse(row[i].ToString()); } } historyData[data.dbName].Add(data); } } foreach (var item in historyData) { item.Value.Sort((x, y) => DateTime.Compare(x.dateTime, y.dateTime)); } return historyData; } private bool RefreshTreeStatusToChild(ParameterNode node) { if (node.ChildNodes.Count > 0) { for (int i = 0; i < node.ChildNodes.Count; i++) { ParameterNode n = node.ChildNodes[i]; n.Selected = node.Selected; if (!RefreshTreeStatusToChild(n)) { //uncheck left node for (int j = i; j < node.ChildNodes.Count; j++) { node.ChildNodes[j].Selected = !node.Selected; } //node.Selected = !node.Selected; return false; } } } //else //{ // if (node.Selected == true) // { // keys.Add(node.Name); // } // else // { // keys.Remove(node.Name); // } //} return true; } private void RefreshTreeStatusToParent(ParameterNode node) { if (node.ParentNode != null) { if (node.Selected) { bool flag = true; for (int i = 0; i < node.ParentNode.ChildNodes.Count; i++) { if (!node.ParentNode.ChildNodes[i].Selected) { flag = false; //as least one child is unselected break; } } if (flag) node.ParentNode.Selected = true; } else { node.ParentNode.Selected = false; } RefreshTreeStatusToParent(node.ParentNode); } } public static T DeepCopyJson(T obj) { // 序列化 string json = JsonConvert.SerializeObject(obj); // 反序列化 return JsonConvert.DeserializeObject(json); } private void OnParameterCheck(object obj) { ParameterNode node = obj as ParameterNode; if (!RefreshTreeStatusToChild(node)) { node.Selected = !node.Selected; } else { RefreshTreeStatusToParent(node); } keys.Clear(); for (int i = 0; i < ParameterNodes.Count; i++) { CalKeys(ParameterNodes[i]); } if (keys.Count > 10) { WPFMessageBox.ShowWarning("最多显示10个数据"); return; } OldPdKeyDataCollection.Clear(); OldPdKeyDataCollection = DeepCopyJson(PdKeyDataCollection); PdKeyDataCollection.Clear(); for (int i = 0; i < keys.Count; i++) { if (i == 10) { break; } PdKeyDataCollection.Add(new PdKeyData() { Key = keys[i], Color = solidColorBrushes[i], UniqueId = i }); } //Compare(OldPdKeyDataCollection, PdKeyDataCollection); //PdKeyDataCollection = DeepCopyJson(OldPdKeyDataCollection); } public void Compare(ObservableCollection olddata, ObservableCollection newdata) { if (newdata != null) { for (int i = 0; i < newdata.Count; i++) { var lists = olddata.ToList().Find(t => t.Key == newdata[i].Key); if (lists == null) { olddata.Add(new PdKeyData() { Key = newdata[i].Key, Color = solidColorBrushes[i], UniqueId = olddata.Count + 1 }); } } for (int i = 0; i < olddata.Count; i++) { var lists = newdata.ToList().Find(t => t.Key == olddata[i].Key); if (lists == null) { olddata.Remove(olddata[i]); } } } } public void UpdateData(RecipeItem dataLog) { OnClearData(); //CheckRecipe(dataLog.Guid); } public void CheckRecipe(string RecipeGuid) { string sql = $"SELECT * FROM \"recipe_step_data\" where \"process_data_guid\" = '{RecipeGuid}' order by step_number ASC;"; var dbData = QueryDataClient.Instance.Service.QueryData(sql); List steps = new List(); if (dbData != null && dbData.Rows.Count > 0) { for (int i = 0; i < dbData.Rows.Count; i++) { StepData item = new StepData(); 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(); //annotation.Add(VerLine(Brushes.Blue, item.StartTime, Brushes.Blue, $"{item.No}:{item.Name}")); } } } public void OnDataGridSelectionChanged(object obj) { selectedRecipeItem = obj as RecipeItem; if (selectedRecipeItem == null) { return; } if (selectedRecipeItem?.Chamber != _lastSelectChamber) { ParameterNodes = new ObservableCollection(_provider.GetParameters().Where(x => x.Name == selectedRecipeItem?.Chamber)); _lastSelectChamber = selectedRecipeItem.Chamber; } } public void OnSearchData() { ProcessData.Clear(); this.view.MyDrawGraphicsControl.ClearPlotPoints(); var Keys = new List(); PdKeyDataCollection.ToList().ForEach(key => { Keys.Add(key.Key); }); if (keys.Count == 0) { return; } if (selectedRecipeItem == null) { return; } resultDictionary = GetData(Keys.Distinct().ToList(), Convert.ToDateTime(selectedRecipeItem?.StartTime), Convert.ToDateTime(selectedRecipeItem?.EndTime).AddSeconds(1)); if (resultDictionary == null) { return; } List cls = new List(); for (int i = 0; i < Keys.Count; i++) { PointCollection points = new PointCollection(); int k = 1; resultDictionary[Keys[i]].ForEach(point => { ProcessData.Add(new HistoryDataItem() { dateTime = point.dateTime, dbName = Keys[i], value = point.value }); points.Add(new Point() { X = point.dateTime.ToOADate(), Y = point.value }); k += 1; }); cls.Add(points); } for (int i = 0; i < PdKeyDataCollection.Count(); i++) { var _color = PdKeyDataCollection[i].Color.Color; view.MyDrawGraphicsControl.m_PenCollencteions[i] = new System.Drawing.Pen(System.Drawing.Color.FromArgb(_color.A, _color.R, _color.G, _color.B), 2); } this.view.MyDrawGraphicsControl.PointCollections = cls; this.view.MyDrawGraphicsControl.FitControl(); this.view.MyDrawGraphicsControl.YPoints.Clear(); //var item = QueryDataClient.Instance.Service.GetHistorySteps(Convert.ToDateTime(selectedRecipeItem?.StartTime), Convert.ToDateTime(selectedRecipeItem?.EndTime)); //if (item!=null) //{ // item.ForEach(x => // { // this.view.MyDrawGraphicsControl.YPoints.Add(new Venus_Core.StepItem() { StartValue = x.StartTime.ToOADate(), Information = $"{x.RecipeId}:{x.StepNo}" }); // }); //} if (IsShowStep) { var item2 = QueryDataClient.Instance.Service.GetHistorySteps(Convert.ToDateTime(selectedRecipeItem?.StartTime), Convert.ToDateTime(selectedRecipeItem?.EndTime)); item2?.ForEach(x => { if (x.RecipeId == selectedRecipeItem.Chamber) { this.view.MyDrawGraphicsControl.YPoints.Add(new Venus_Core.StepItem() { StartValue = x.StartTime.ToOADate(), Information = $"{x.RecipeId}\n{x.StepNo}\n{x.StartTime.ToString("HH:mm:ss:fff")}" }); } }); } } private void CloseAll(ObservableCollection parameterNodes) { if (parameterNodes != null) { foreach (var item in parameterNodes) { item.Selected = false; if (item.ChildNodes.Count > 0) { CloseAll(item.ChildNodes); } } } } private void OnClearData() { this.view.MyDrawGraphicsControl.YPoints.Clear(); this.view.MyDrawGraphicsControl.ClearPlotPoints(); PdKeyDataCollection.Clear(); CloseAll(ParameterNodes); } public void ColorChanged() { for (int i = 0; i < PdKeyDataCollection.Count(); i++) { var _color = PdKeyDataCollection[i].Color.Color; this.view.MyDrawGraphicsControl.m_PenCollencteions[i] = new System.Drawing.Pen(System.Drawing.Color.FromArgb(_color.A, _color.R, _color.G, _color.B), 2); } } //private void OnExportRecipes() //{ // try // { // Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); // dlg.DefaultExt = ".xls"; // Default file extension // dlg.Filter = "Excel数据表格文件(*.xls)|*.xls"; // Filter files by extension // Nullable result = dlg.ShowDialog();// Show open file dialog box // if (result == true) // Process open file dialog box results // { // System.Data.DataSet ds = new System.Data.DataSet(); // ds.Tables.Add(new System.Data.DataTable("Recipes")); // ds.Tables[0].Columns.Add("Start"); // ds.Tables[0].Columns.Add("End"); // ds.Tables[0].Columns.Add("Chamber"); // ds.Tables[0].Columns.Add("Guid"); // ds.Tables[0].Columns.Add("WaferID"); // ds.Tables[0].Columns.Add("Recipe"); // ds.Tables[0].Columns.Add("Status"); // foreach (var item in Recipes) // { // var row = ds.Tables[0].NewRow(); // row[0] = item.StartTime; // row[1] = item.EndTime; // row[2] = item.Chamber; // row[3] = item.Guid; // row[4] = item.LotID; // row[5] = item.Recipe; // row[6] = item.Status; // ds.Tables[0].Rows.Add(row); // } // ds.WriteXml(dlg.FileName); // } // } // catch // { // MessageBox.Show("导出系统日志发生错误", "导出失败", MessageBoxButton.OK, MessageBoxImage.Warning); // } //} private void OnExportRecipeData() { try { RecipeItem log = (this.view.dataGrid_RecipeList.SelectedItem) as RecipeItem; if (log == null) { WPFMessageBox.ShowError("没有数据,先从列表中选择一个批次"); return; } Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.DefaultExt = ".xls"; // Default file extension dlg.Filter = "数据表格文件|*.xls"; // Filter files by extension dlg.FileName = string.Format("{0}-{1}", StartDateTime.ToString("yyyyMMdd"), log.Recipe.Replace(" ", "").Replace("/", "")); Nullable result = dlg.ShowDialog();// Show open file dialog box if (result != true) // Process open file dialog box results return; System.Data.DataSet ds = new System.Data.DataSet(); ds.Tables.Add(new System.Data.DataTable("RecipeData")); int columnIndex = 0; int rowIndex = 0; ds.Tables[0].Columns.Add($"Time"); foreach (var item in resultDictionary) { rowIndex = 0; if (item.Value.Count == 0) { continue; } ds.Tables[0].Columns.Add(item.Key); item.Value.ForEach(x => { if (columnIndex == 0) { var row = ds.Tables[0].NewRow(); row[0] = x.dateTime; row[columnIndex + 1] = x.value; ds.Tables[0].Rows.Add(row); } else { ds.Tables[0].Rows[rowIndex][columnIndex + 1] = x.value; } rowIndex += 1; }); columnIndex += 1; } ds.WriteXml(dlg.FileName); } catch (Exception ex) { WPFMessageBox.ShowError($"导出系统日志发生错误{ex.Message}"); } } } #endregion #region 数据类 //public class RecipeItem : BindableBase //{ // public bool Selected { get; set; } // public string Recipe { get; set; } // public string Guid { get; set; } // public string RecipeRunGuid { get; set; } // public string Chamber { get; set; } // public string Status { get; set; } // public string StartTime { get; set; } // public string EndTime { get; set; } // public string LotID { get; set; } // public string SlotID { get; set; } // public string RecipeType { get; set; } // public string CarrierId { get; set; } //} //public class StepData //{ // [DataMember] // public int No { get; set; } // [DataMember] // public string Name { get; set; } // [DataMember] // public DateTime StartTime { get; set; } // [DataMember] // public DateTime EndTime { get; set; } // [DataMember] // public string ActualTime { get; set; } // [DataMember] // public string SettingTime { get; set; } //} //public class PdKeyData : BindableBase, ICloneable //{ // public string Key { get; set; } // public SolidColorBrush _Color; // public SolidColorBrush Color // { // get { return _Color; } // set { SetProperty(ref _Color, value); } // } // public int UniqueId { get; set; } // public object Clone() // { // return MemberwiseClone(); // } //} #endregion }