using Aitex.Core.Common; using Aitex.Core.RT.Log; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Xml; using System.Xml.Linq; using MECF.Framework.Common.Equipment; using System.IO; namespace Aitex.Sorter.Common { [DataContract] [Serializable] public class JZFLDRecipeXml : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } private string name; [DataMember] public string Name { get { return name; } set { name = value; OnPropertyChanged("Name"); } } private string _subRecipeName; public string SubRecipeName { get { return _subRecipeName; } set { _subRecipeName = value; OnPropertyChanged("SubRecipeName"); } } private int _unloaderSlotsNumber = 25; [DataMember] public int UnloaderSlotsNumber { get { return _unloaderSlotsNumber; } set { _unloaderSlotsNumber = value; OnPropertyChanged("UnloaderSlotsNumber"); } } private bool _isLP1Loader; [DataMember] public bool IsLP1Loader { get { return _isLP1Loader; } set { _isLP1Loader = value; OnPropertyChanged("IsLP1Loader"); } } private bool _isLP2Loader; [DataMember] public bool IsLP2Loader { get { return _isLP2Loader; } set { _isLP2Loader = value; OnPropertyChanged("IsLP2Loader"); } } private bool _isLP3Loader; [DataMember] public bool IsLP3Loader { get { return _isLP3Loader; } set { _isLP3Loader = value; OnPropertyChanged("IsLP3Loader"); } } private bool _isLP4Loader; [DataMember] public bool IsLP4Loader { get { return _isLP4Loader; } set { _isLP4Loader = value; OnPropertyChanged("IsLP4Loader"); } } private bool _isLP5Loader; [DataMember] public bool IsLP5Loader { get { return _isLP5Loader; } set { _isLP5Loader = value; OnPropertyChanged("IsLP5Loader"); } } private bool _isLP6Loader; [DataMember] public bool IsLP6Loader { get { return _isLP6Loader; } set { _isLP6Loader = value; OnPropertyChanged("IsLP6Loader"); } } private bool _isLP7Loader; [DataMember] public bool IsLP7Loader { get { return _isLP7Loader; } set { _isLP7Loader = value; OnPropertyChanged("IsLP7Loader"); } } private bool _isLP8Loader; [DataMember] public bool IsLP8Loader { get { return _isLP8Loader; } set { _isLP8Loader = value; OnPropertyChanged("IsLP8Loader"); } } private bool _isLP1CollectErrorWafer; [DataMember] public bool IsLP1CollectErrorWafer { get { return _isLP1CollectErrorWafer; } set { _isLP1CollectErrorWafer = value; OnPropertyChanged("IsLP1CollectErrorWafer"); } } private bool _isLP2CollectErrorWafer; [DataMember] public bool IsLP2CollectErrorWafer { get { return _isLP2CollectErrorWafer; } set { _isLP2CollectErrorWafer = value; OnPropertyChanged("IsLP2CollectErrorWafer"); } } private bool _isLP3CollectErrorWafer; [DataMember] public bool IsLP3CollectErrorWafer { get { return _isLP3CollectErrorWafer; } set { _isLP3CollectErrorWafer = value; OnPropertyChanged("IsLP3CollectErrorWafer"); } } private bool _isLP4CollectErrorWafer; [DataMember] public bool IsLP4CollectErrorWafer { get { return _isLP4CollectErrorWafer; } set { _isLP4CollectErrorWafer = value; OnPropertyChanged("IsLP4CollectErrorWafer"); } } private bool _isLP5CollectErrorWafer; [DataMember] public bool IsLP5CollectErrorWafer { get { return _isLP5CollectErrorWafer; } set { _isLP5CollectErrorWafer = value; OnPropertyChanged("IsLP5CollectErrorWafer"); } } private bool _isLP6CollectErrorWafer; [DataMember] public bool IsLP6CollectErrorWafer { get { return _isLP6CollectErrorWafer; } set { _isLP6CollectErrorWafer = value; OnPropertyChanged("IsLP6CollectErrorWafer"); } } private bool _isLP7CollectErrorWafer; [DataMember] public bool IsLP7CollectErrorWafer { get { return _isLP7CollectErrorWafer; } set { _isLP7CollectErrorWafer = value; OnPropertyChanged("IsLP7CollectErrorWafer"); } } private bool _isLP8CollectErrorWafer; [DataMember] public bool IsLP8CollectErrorWafer { get { return _isLP8CollectErrorWafer; } set { _isLP8CollectErrorWafer = value; OnPropertyChanged("IsLP8CollectErrorWafer"); } } private string _unloader1Information; public string Unloader1Information { get { return _unloader1Information; } set { _unloader1Information = value; OnPropertyChanged("Unloader1Information"); } } private string _unloader2Information; public string Unloader2Information { get { return _unloader2Information; } set { _unloader2Information = value; OnPropertyChanged("Unloader2Information"); } } private string _unloader3Information; public string Unloader3Information { get { return _unloader3Information; } set { _unloader3Information = value; OnPropertyChanged("Unloader3Information"); } } private string _unloader4Information; public string Unloader4Information { get { return _unloader4Information; } set { _unloader4Information = value; OnPropertyChanged("Unloader4Information"); } } private string _unloader5Information; public string Unloader5Information { get { return _unloader5Information; } set { _unloader5Information = value; OnPropertyChanged("Unloader5Information"); } } private string _unloader6Information; public string Unloader6Information { get { return _unloader6Information; } set { _unloader6Information = value; OnPropertyChanged("Unloader6Information"); } } private string _unloader7Information; public string Unloader7Information { get { return _unloader7Information; } set { _unloader7Information = value; OnPropertyChanged("Unloader7Information"); } } private string _unloader8Information; public string Unloader8Information { get { return _unloader8Information; } set { _unloader8Information = value; OnPropertyChanged("Unloader8Information"); } } public JZFLDRecipeXml(string name = "") { Name = name; } public JZFLDRecipeXml(string content, string name = "") { Name = name; SetContent(content); } public bool SetContent(string content) { try { var doc = XDocument.Parse(content); ParseContent(doc); } catch (Exception e) { LOG.Write(e); return false; } return true; } public string GetContent() { var doc = new XDocument(); var root = new XElement("Recipe"); var element = new XElement("JZFLDRecipe" , new XAttribute("SubRecipeName", SubRecipeName??"") , new XAttribute("UnloaderSlotsNumber", UnloaderSlotsNumber) , new XAttribute("IsLP1Loader", IsLP1Loader.ToString()) , new XAttribute("IsLP2Loader", IsLP2Loader.ToString()) , new XAttribute("IsLP3Loader", IsLP3Loader.ToString()) , new XAttribute("IsLP4Loader", IsLP4Loader.ToString()) , new XAttribute("IsLP5Loader", IsLP5Loader.ToString()) , new XAttribute("IsLP6Loader", IsLP6Loader.ToString()) , new XAttribute("IsLP7Loader", IsLP7Loader.ToString()) , new XAttribute("IsLP8Loader", IsLP8Loader.ToString()) , new XAttribute("IsLP1CollectErrorWafer", IsLP1CollectErrorWafer.ToString()) , new XAttribute("IsLP2CollectErrorWafer", IsLP2CollectErrorWafer.ToString()) , new XAttribute("IsLP3CollectErrorWafer", IsLP3CollectErrorWafer.ToString()) , new XAttribute("IsLP4CollectErrorWafer", IsLP4CollectErrorWafer.ToString()) , new XAttribute("IsLP5CollectErrorWafer", IsLP5CollectErrorWafer.ToString()) , new XAttribute("IsLP6CollectErrorWafer", IsLP6CollectErrorWafer.ToString()) , new XAttribute("IsLP7CollectErrorWafer", IsLP7CollectErrorWafer.ToString()) , new XAttribute("IsLP8CollectErrorWafer", IsLP8CollectErrorWafer.ToString()) , new XAttribute("Unloader1Information", Unloader1Information?? ",,,,,,,,,") , new XAttribute("Unloader2Information", Unloader2Information?? ",,,,,,,,,") , new XAttribute("Unloader3Information", Unloader3Information?? ",,,,,,,,,") , new XAttribute("Unloader4Information", Unloader4Information?? ",,,,,,,,,") , new XAttribute("Unloader5Information", Unloader5Information?? ",,,,,,,,,") , new XAttribute("Unloader6Information", Unloader6Information?? ",,,,,,,,,") , new XAttribute("Unloader7Information", Unloader7Information?? ",,,,,,,,,") , new XAttribute("Unloader8Information", Unloader8Information?? ",,,,,,,,,") ); root.Add(element); doc.Add(root); return doc.ToString(); } private void ParseContent(XDocument doc) { try { var node = doc.Root.Element("JZFLDRecipe"); if (node == null) { LOG.Write(string.Format("recipe not valid")); return; } string strValue; int intValue; bool bValue; SubRecipeName = (node.Attribute("SubRecipeName") == null? "": node.Attribute("SubRecipeName").Value); strValue = node.Attribute("UnloaderSlotsNumber").Value; int.TryParse(strValue, out intValue); UnloaderSlotsNumber = intValue; strValue = node.Attribute("IsLP1Loader").Value; bool.TryParse(strValue, out bValue); IsLP1Loader = bValue; strValue = node.Attribute("IsLP2Loader").Value; bool.TryParse(strValue, out bValue); IsLP2Loader = bValue; strValue = node.Attribute("IsLP3Loader").Value; bool.TryParse(strValue, out bValue); IsLP3Loader = bValue; strValue = node.Attribute("IsLP4Loader").Value; bool.TryParse(strValue, out bValue); IsLP4Loader = bValue; strValue = node.Attribute("IsLP5Loader").Value; bool.TryParse(strValue, out bValue); IsLP5Loader = bValue; strValue = node.Attribute("IsLP6Loader").Value; bool.TryParse(strValue, out bValue); IsLP6Loader = bValue; strValue = node.Attribute("IsLP7Loader").Value; bool.TryParse(strValue, out bValue); IsLP7Loader = bValue; strValue = node.Attribute("IsLP8Loader").Value; bool.TryParse(strValue, out bValue); IsLP8Loader = bValue; strValue = node.Attribute("IsLP8Loader").Value; bool.TryParse(strValue, out bValue); IsLP8Loader = bValue; if(node.Attribute("IsLP1CollectErrorWafer")!=null) { strValue = node.Attribute("IsLP1CollectErrorWafer").Value; bool.TryParse(strValue, out bValue); IsLP1CollectErrorWafer = bValue; } if (node.Attribute("IsLP2CollectErrorWafer") != null) { strValue = node.Attribute("IsLP2CollectErrorWafer").Value; bool.TryParse(strValue, out bValue); IsLP2CollectErrorWafer = bValue; } if (node.Attribute("IsLP3CollectErrorWafer") != null) { strValue = node.Attribute("IsLP3CollectErrorWafer").Value; bool.TryParse(strValue, out bValue); IsLP3CollectErrorWafer = bValue; } if (node.Attribute("IsLP4CollectErrorWafer") != null) { strValue = node.Attribute("IsLP4CollectErrorWafer").Value; bool.TryParse(strValue, out bValue); IsLP4CollectErrorWafer = bValue; } if (node.Attribute("IsLP5CollectErrorWafer") != null) { strValue = node.Attribute("IsLP5CollectErrorWafer").Value; bool.TryParse(strValue, out bValue); IsLP5CollectErrorWafer = bValue; } if (node.Attribute("IsLP6CollectErrorWafer") != null) { strValue = node.Attribute("IsLP6CollectErrorWafer").Value; bool.TryParse(strValue, out bValue); IsLP6CollectErrorWafer = bValue; } if (node.Attribute("IsLP7CollectErrorWafer") != null) { strValue = node.Attribute("IsLP7CollectErrorWafer").Value; bool.TryParse(strValue, out bValue); IsLP7CollectErrorWafer = bValue; } if (node.Attribute("IsLP8CollectErrorWafer") != null) { strValue = node.Attribute("IsLP8CollectErrorWafer").Value; bool.TryParse(strValue, out bValue); IsLP8CollectErrorWafer = bValue; } strValue = node.Attribute("IsLP8CollectErrorWafer").Value; bool.TryParse(strValue, out bValue); IsLP8CollectErrorWafer = bValue; Unloader1Information = node.Attribute("Unloader1Information").Value; Unloader2Information = node.Attribute("Unloader2Information").Value; Unloader3Information = node.Attribute("Unloader3Information").Value; Unloader4Information = node.Attribute("Unloader4Information").Value; Unloader5Information = node.Attribute("Unloader5Information").Value; Unloader6Information = node.Attribute("Unloader6Information").Value; Unloader7Information = node.Attribute("Unloader7Information").Value; Unloader8Information = node.Attribute("Unloader8Information").Value; } catch (Exception ex) { LOG.Write(ex); } } private T GetValue(XElement element, string Name) { var attr = element.Attribute(Name); if (attr != null) { return (T)Convert.ChangeType(attr.Value, typeof(T)); } return default(T); } } }