using Aitex.Core.RT.Log; using Aitex.Core.RT.SCCore; using Aitex.Core.Util; using Caliburn.Micro; using Caliburn.Micro.Core; using FurnaceUI.Common; using FurnaceUI.Models; using MECF.Framework.Common.DataCenter; using MECF.Framework.Common.OperationCenter; using MECF.Framework.Common.SubstrateTrackings; using MECF.Framework.UI.Client.CenterViews.Editors.Recipe; using MECF.Framework.UI.Client.CenterViews.Editors.Sequence; using OpenSEMI.ClientBase; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Net.Sockets; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Xml; namespace FurnaceUI.Views.Jobs { public class CarrierInformation : PropertyChangedBase { private string _no; public string No { get { return _no; } set { _no = value; NotifyOfPropertyChange("No"); } } private string _type; public string Type { get { return _type; } set { _type = value; NotifyOfPropertyChange("Type"); } } private string _moduleName; public string ModuleName { get { return _moduleName; } set { _moduleName = value; NotifyOfPropertyChange("ModuleName"); } } private string _carrierID; public string CarrierID { get { return _carrierID; } set { _carrierID = value; NotifyOfPropertyChange("CarrierID"); } } private string _waferCount; public string WaferCount { get => _waferCount; set { _waferCount = value; NotifyOfPropertyChange("WaferCount"); } } private string _existSlot; public string ExistSlot { get => _existSlot; set { _existSlot = value; NotifyOfPropertyChange("ExistSlot"); } } private string _slotMap; public string SlotMap { get => _slotMap; set { _slotMap = value; NotifyOfPropertyChange("SlotMap"); } } private string _strSlot; public string StrSlot { get => _strSlot; set { _strSlot = value; NotifyOfPropertyChange(nameof(StrSlot)); } } private string _loadPortName; public string LoadPortName { get => _loadPortName; set { _loadPortName = value; NotifyOfPropertyChange("LoadPortName"); } } } public class JOBProcessStockViewModel : FurnaceModuleUIViewModelBase { public string PCarrierPara { get; set; } public string M1CarrierPara { get; set; } public string M2CarrierPara { get; set; } public ObservableCollection SelectCarrierList { get; set; } = new ObservableCollection(); public ObservableCollection SelectCarrierListTemp { get; set; } = new ObservableCollection(); public Dictionary SCValueDict = new Dictionary(); private string _cjID; public string CJID { get { return _cjID; } set { _cjID = value; NotifyOfPropertyChange("CJID"); } } private string _pjID; public string PJID { get { return _pjID; } set { _pjID = value; NotifyOfPropertyChange("PJID"); } } public JOBProcessStockViewModel() { } private readonly RecipeProvider _recipeProvider = new RecipeProvider(); public RecipeDataJob CurrentRecipe { get; set; } = new RecipeDataJob(); public string ExecCommand { get; set; } public bool IsCheckButtonVisible { get; set; } = false; public bool IsWithUnloadButtonVisible { get; set; } public bool IsStockNumberChangeButtonVisible { get; set; } public bool IsLotIDInputEnable { get; set; } = true; private string _waferType = "P"; #region Stocker Carrier Info [Subscription("Stocker1.Carrier")] public CarrierInfo Stocker1CarrierData { get; set; } [Subscription("Stocker2.Carrier")] public CarrierInfo Stocker2CarrierData { get; set; } [Subscription("Stocker3.Carrier")] public CarrierInfo Stocker3CarrierData { get; set; } [Subscription("Stocker4.Carrier")] public CarrierInfo Stocker4CarrierData { get; set; } [Subscription("Stocker5.Carrier")] public CarrierInfo Stocker5CarrierData { get; set; } [Subscription("Stocker6.Carrier")] public CarrierInfo Stocker6CarrierData { get; set; } [Subscription("Stocker7.Carrier")] public CarrierInfo Stocker7CarrierData { get; set; } [Subscription("Stocker8.Carrier")] public CarrierInfo Stocker8CarrierData { get; set; } [Subscription("Stocker9.Carrier")] public CarrierInfo Stocker9CarrierData { get; set; } [Subscription("Stocker10.Carrier")] public CarrierInfo Stocker10CarrierData { get; set; } [Subscription("Stocker11.Carrier")] public CarrierInfo Stocker11CarrierData { get; set; } [Subscription("Stocker12.Carrier")] public CarrierInfo Stocker12CarrierData { get; set; } [Subscription("Stocker13.Carrier")] public CarrierInfo Stocker13CarrierData { get; set; } [Subscription("Stocker14.Carrier")] public CarrierInfo Stocker14CarrierData { get; set; } [Subscription("Stocker15.Carrier")] public CarrierInfo Stocker15CarrierData { get; set; } [Subscription("Stocker16.Carrier")] public CarrierInfo Stocker16CarrierData { get; set; } [Subscription("Stocker17.Carrier")] public CarrierInfo Stocker17CarrierData { get; set; } [Subscription("Stocker18.Carrier")] public CarrierInfo Stocker18CarrierData { get; set; } [Subscription("Stocker19.Carrier")] public CarrierInfo Stocker19CarrierData { get; set; } [Subscription("Stocker20.Carrier")] public CarrierInfo Stocker20CarrierData { get; set; } [Subscription("Stocker21.Carrier")] public CarrierInfo Stocker21CarrierData { get; set; } #endregion List _carrierlist = new List(); ObservableCollection _stockerList = new ObservableCollection(); protected override void OnInitialize() { base.OnInitialize(); } protected override void InvokeAfterUpdateProperty(Dictionary data) { base.InvokeAfterUpdateProperty(data); _stockerList.Clear(); if (Stocker1CarrierData != null) { Stocker1CarrierData.StockerIndex = 1; _stockerList.Add(Stocker1CarrierData); } if (Stocker2CarrierData != null) { Stocker2CarrierData.StockerIndex = 2; _stockerList.Add(Stocker2CarrierData); } if (Stocker3CarrierData != null) { Stocker3CarrierData.StockerIndex = 3; _stockerList.Add(Stocker3CarrierData); } if (Stocker4CarrierData != null) { Stocker4CarrierData.StockerIndex = 4; _stockerList.Add(Stocker4CarrierData); } if (Stocker5CarrierData != null) { Stocker5CarrierData.StockerIndex = 5; _stockerList.Add(Stocker5CarrierData); } if (Stocker6CarrierData != null) { Stocker6CarrierData.StockerIndex = 6; _stockerList.Add(Stocker6CarrierData); } if (Stocker7CarrierData != null) { Stocker7CarrierData.StockerIndex = 7; _stockerList.Add(Stocker7CarrierData); } if (Stocker8CarrierData != null) { Stocker8CarrierData.StockerIndex = 8; _stockerList.Add(Stocker8CarrierData); } if (Stocker9CarrierData != null) { Stocker9CarrierData.StockerIndex = 9; _stockerList.Add(Stocker9CarrierData); } if (Stocker10CarrierData != null) { Stocker10CarrierData.StockerIndex = 10; _stockerList.Add(Stocker10CarrierData); } if (Stocker11CarrierData != null) { Stocker11CarrierData.StockerIndex = 11; _stockerList.Add(Stocker11CarrierData); } if (Stocker12CarrierData != null) { Stocker12CarrierData.StockerIndex = 12; _stockerList.Add(Stocker12CarrierData); } if (Stocker13CarrierData != null) { Stocker13CarrierData.StockerIndex = 13; _stockerList.Add(Stocker13CarrierData); } if (Stocker14CarrierData != null) { Stocker14CarrierData.StockerIndex = 14; _stockerList.Add(Stocker14CarrierData); } if (Stocker15CarrierData != null) { Stocker15CarrierData.StockerIndex = 15; _stockerList.Add(Stocker15CarrierData); } if (Stocker16CarrierData != null) { Stocker16CarrierData.StockerIndex = 16; _stockerList.Add(Stocker16CarrierData); } if (Stocker17CarrierData != null) { Stocker17CarrierData.StockerIndex = 17; _stockerList.Add(Stocker17CarrierData); } if (Stocker18CarrierData != null) { Stocker18CarrierData.StockerIndex = 18; _stockerList.Add(Stocker18CarrierData); } } public void SwitchPage(string operation) { var windowManager = IoC.Get(); switch (operation) { case "MaterialSelect": { LoadJOBTwoViewModel loadJobTwoViewModel = new LoadJOBTwoViewModel(); loadJobTwoViewModel.PTypeRadioButtonVisibility = Visibility.Visible; loadJobTwoViewModel.MTypeRadioButtonVisibility = Visibility.Collapsed; loadJobTwoViewModel.SDTypeRadioButtonVisibility = Visibility.Collapsed; loadJobTwoViewModel.EDTypeRadioButtonVisibility = Visibility.Collapsed; loadJobTwoViewModel.ExecCommand = "Load"; loadJobTwoViewModel.ExecText = "Accept"; loadJobTwoViewModel.IsPChecked = true; loadJobTwoViewModel.IsMChecked = false; loadJobTwoViewModel.IsSetValue = true; loadJobTwoViewModel.IsExecuteRTCommand = false; loadJobTwoViewModel.CarrierInformationList.Clear(); if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(loadJobTwoViewModel, null, "Material Select")) { //SelectCarrierList.Clear(); for (int j = 0; j < SelectCarrierList.Count; j++) { if (SelectCarrierList[j].Type.Contains("P")) { SelectCarrierList.RemoveAt(j); j--; } } if (string.IsNullOrEmpty(loadJobTwoViewModel.LoadJobPara)) return; PCarrierPara = loadJobTwoViewModel.LoadJobPara.TrimEnd(';'); string[] Carriers = PCarrierPara.Split(':'); CarrierInformation carrierInfo = new CarrierInformation(); carrierInfo.No = Carriers[0].Replace("Stocker", ""); var item = Carriers[1].Split(','); carrierInfo.Type = CarrierType.P.ToString(); carrierInfo.ModuleName = item[0]; carrierInfo.StrSlot = item[1]; // carrierInfo.CarrierID = item[2]; //carrierInfo.WaferCount = item[3]; carrierInfo.ExistSlot = item[2]; carrierInfo.SlotMap = item[3]; carrierInfo.LoadPortName = item[4]; SelectCarrierList.Add(carrierInfo); } } break; case "SelectM": { _carrierlist.Clear(); foreach (var item in _stockerList) { string configType = (string)QueryDataClient.Instance.Service.GetConfig($"System.Stocker.Stocker{item.StockerIndex}WaferType"); var boolM = configType.StartsWith(CarrierType.M.ToString()) && !item.IsEmpty; var boolNone = configType.StartsWith(CarrierType.None.ToString()) && !item.IsEmpty && item.CarrierType.ToString().Contains(CarrierType.M.ToString()); if (boolNone || boolM) { _carrierlist.Add(item); } } SelectMaterialViewModel selectmaterialViewModel = new SelectMaterialViewModel(); selectmaterialViewModel.carrierlist = _carrierlist; selectmaterialViewModel.CarrierType = "M"; selectmaterialViewModel.SelectCarrierItemList.Clear(); foreach (var item in SelectCarrierList) { selectmaterialViewModel.SelectCarrierItemList.Add(new CarrierMaterialInformation() { ModuleName = item.ModuleName, No = item.No, CarrierType = "M", CarrierId = item.CarrierID, }); }; if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(selectmaterialViewModel, null, "Select M")) { int i = 0; for (int j = 0; j < SelectCarrierList.Count; j++) { if (SelectCarrierList[j].Type.Contains(ConstantsCommon.M)) { SelectCarrierList.RemoveAt(j); j--; } } M1CarrierPara = ""; M2CarrierPara = ""; foreach (CarrierMaterialInformation item in selectmaterialViewModel.SelectCarrierItemList) { CarrierInformation carrierInfo = new CarrierInformation(); carrierInfo.No = item.No; carrierInfo.Type = item.CarrierType; carrierInfo.ModuleName = item.ModuleName; carrierInfo.CarrierID = item.CarrierId; carrierInfo.LoadPortName = ""; carrierInfo.StrSlot = item.StrSlot; if (item.CarrierType == "M1") M1CarrierPara += item.ModuleName + "," + (item.CarrierId == null ? "" : item.CarrierId) + "," + item.StrSlot + ";"; else if (item.CarrierType == "M2") M2CarrierPara += item.ModuleName + "," + (item.CarrierId == null ? "" : item.CarrierId) + "," + item.StrSlot + ";"; SelectCarrierList.Add(carrierInfo); } } } break; } } public void SelectJobRecipe() { RecipeSelectDialogViewModel dialog = new RecipeSelectDialogViewModel(); dialog.DisplayName = "Select Job Recipe"; var recipeProvider = new RecipeProvider(); var processType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedJobType"); if (processType == null) { processType = "Job Recipe"; } var ProcessTypeFileList = new ObservableCollection(); string[] recipeProcessType = ((string)processType).Split(','); for (int i = 0; i < recipeProcessType.Length; i++) { var type = new ProcessTypeFileItem(); type.ProcessType = recipeProcessType[i]; var prefix = $"Furnace\\{recipeProcessType[i]}"; var recipes = recipeProvider.GetXmlRecipeList(prefix); type.FileListByProcessType = RecipeSequenceTreeBuilder.BuildFileNode(prefix, "", false, recipes)[0].Files; ProcessTypeFileList.Add(type); } dialog.ProcessTypeFileList = ProcessTypeFileList; WindowManager wm = new WindowManager(); bool? bret = wm.ShowDialog(dialog); if ((bool)bret) { CurrentRecipe.Clear(); CurrentRecipe.PrefixPath = $"Furnace\\{processType}"; CurrentRecipe.Name = dialog.DialogResult; var recipeContent = _recipeProvider.LoadRecipe(CurrentRecipe.PrefixPath, CurrentRecipe.Name); if (string.IsNullOrEmpty(recipeContent)) { System.Windows.MessageBox.Show($"{CurrentRecipe.PrefixPath}\\{CurrentRecipe.Name} is empty, please confirm the file is valid."); return; } CurrentRecipe.RecipeChamberType = "OriginChamber"; CurrentRecipe.InitData(CurrentRecipe.PrefixPath, CurrentRecipe.Name, recipeContent, "PM1"); CheckIsExistRecipe(CurrentRecipe.ProcessRecipe, CurrentRecipe.LayoutRecipe); } //CheckIsExistRecipe(CurrentRecipe.ProcessRecipe, CurrentRecipe.LayoutRecipe); } private void CheckIsExistRecipe(string processName, string layoutName) { var processPrefixPath = $"Furnace\\Process"; var layoutPrefixPath = $"Furnace\\Layout"; var processContent = _recipeProvider.LoadRecipe(processPrefixPath, processName); var layoutContent = _recipeProvider.LoadRecipe(layoutPrefixPath, layoutName); if (string.IsNullOrEmpty(processContent)) { DialogBox.ShowWarning($"Process Recipe:{processName} is empty, please confirm the file is valid."); } if (string.IsNullOrEmpty(layoutContent)) { DialogBox.ShowWarning($"Layout Recipe:{layoutName} is empty, please confirm the file is valid."); } } private void FromJobRecipeGetProcessAndLayout(string name, object processType) { CurrentRecipe.Clear(); CurrentRecipe.PrefixPath = $"Furnace\\{processType}"; CurrentRecipe.Name = name; var recipeContent = _recipeProvider.LoadRecipe(CurrentRecipe.PrefixPath, CurrentRecipe.Name); if (!string.IsNullOrEmpty(recipeContent)) { CurrentRecipe.RecipeChamberType = "OriginChamber"; CurrentRecipe.InitData(CurrentRecipe.PrefixPath, CurrentRecipe.Name, recipeContent, "PM1"); CurrentRecipe.ProcessRecipe = CurrentRecipe.ProcessRecipe.Substring(CurrentRecipe.ProcessRecipe.LastIndexOf("\\") + 1); CurrentRecipe.LayoutRecipe = CurrentRecipe.LayoutRecipe.Substring(CurrentRecipe.LayoutRecipe.LastIndexOf("\\") + 1); } } protected override void OnViewLoaded(object view) { base.OnViewLoaded(view); //GetValueSC(); GetDefault(); } private void GetDefault() { //var loadJobPara = item.ModuleName + "," + item.CarrierId + "," + item.WaferCount + "," + item.ExistSlot + "," + item.SlotMap + "," + item.LoadPortName + ";"; if (SCValueDict.ContainsKey("CJID")) { CJID = (string)SCValueDict["CJID"]; } if (SCValueDict.ContainsKey("PJID")) { PJID = (string)SCValueDict["PJID"]; } if (SCValueDict.ContainsKey("JobRecipe")) { CurrentRecipe.Name = (string)SCValueDict["JobRecipe"]; var processType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedJobType"); if (processType == null) { processType = "Job Recipe"; } if (!string.IsNullOrEmpty((string)SCValueDict["JobRecipe"])) FromJobRecipeGetProcessAndLayout((string)SCValueDict["JobRecipe"], processType); } //if (SCValueDict.ContainsKey("CarrierPara")) //{ // CurrentRecipe.ProcessRecipe = (string)SCValueDict["CarrierPara"]; //} //if (SCValueDict.ContainsKey("mCarrierPara")) //{ // CurrentRecipe.LayoutRecipe = (string)SCValueDict["mCarrierPara"]; //} if (SCValueDict.ContainsKey("CarrierPara") && !string.IsNullOrEmpty((string)SCValueDict["CarrierPara"])) { PCarrierPara = (string)SCValueDict["CarrierPara"]; SelectCarrierList.Clear(); string[] strCarrierParas = ((string)SCValueDict["CarrierPara"]).Split(';'); foreach (var item in strCarrierParas) { int index = 1; if (!string.IsNullOrEmpty(item)) { string[] carrierInfos = item.Split(','); CarrierInformation carrierInformation = new CarrierInformation(); carrierInformation.No = $"P{index}"; carrierInformation.ModuleName = carrierInfos[0]; carrierInformation.StrSlot = carrierInfos[1]; //carrierInformation.CarrierID = carrierInfos[1]; //carrierInformation.WaferCount = carrierInfos[2]; carrierInformation.ExistSlot = carrierInfos[2]; carrierInformation.SlotMap = carrierInfos[3]; carrierInformation.Type = "P"; carrierInformation.LoadPortName = carrierInfos[4]; SelectCarrierList.Add(carrierInformation); index++; } } } } public void EXECCmd(string cmdPar) { if (string.IsNullOrEmpty(CurrentRecipe.ProcessRecipe)) { DialogBox.ShowWarning("Process recipe is empty"); return; } if (string.IsNullOrEmpty(CurrentRecipe.LayoutRecipe)) { DialogBox.ShowWarning("Layout recipe is empty"); return; } if (string.IsNullOrEmpty(CurrentRecipe.CoolTime)) { DialogBox.ShowWarning("Cool time is empty"); return; } if (string.IsNullOrEmpty(PJID)) { DialogBox.ShowWarning("PJ ID is empty"); return; } if (string.IsNullOrEmpty(CJID)) { DialogBox.ShowWarning("CJ ID is empty"); return; } if (!DialogBox.Confirm("Are you sure to execute?")) return; //参数规则按照以下 string pCarrierPara = string.IsNullOrEmpty(PCarrierPara) ? "" : PCarrierPara.TrimEnd(';'); string m1CarrierPara = string.IsNullOrEmpty(M1CarrierPara) ? "" : M1CarrierPara.TrimEnd(';'); string m2CarrierPara = string.IsNullOrEmpty(M2CarrierPara) ? "" : M2CarrierPara.TrimEnd(';'); string cjID = CJID;//根据输入 string pjID = PJID;//根据输入 string pjVariable = "";//后续完善 Dictionary param = new Dictionary() { {"PJID",pjID }, {"CJID",cjID }, {"JobRecipe", CurrentRecipe.Name }, {"CarrierPara", pCarrierPara}, {"m1CarrierPara", m1CarrierPara}, {"m2CarrierPara", m2CarrierPara}, {"PJVariable", pjVariable}, {"WaferType", "P" } }; InvokeClient.Instance.Service.DoOperation($"System.{ExecCommand}", param); //SetValueToSC(param); // PCarrierPara = ""; // MCarrierPara = ""; (GetView() as Window).Close(); } private void SetValueToSC(Dictionary param) { foreach (var item in param.Keys) { InvokeClient.Instance.Service.DoOperation($"System.SetConfig", $"System.Job.JOBProcessStock.{item}", param[item]); } } private void GetValueSC() { SCValueDict.Clear(); SCValueDict.Add("PJID", null); SCValueDict.Add("CJID", null); SCValueDict.Add("JobRecipe", null); SCValueDict.Add("CarrierPara", null); SCValueDict.Add("mCarrierPara", null); SCValueDict.Add("PJVariable", null); SCValueDict.Add("WaferType", null); foreach (var item in SCValueDict.Keys.ToList()) { SCValueDict[item] = (string)QueryDataClient.Instance.Service.GetConfig($"System.Job.JOBProcessStock.{item}"); } } public void Check() { if (string.IsNullOrEmpty(CurrentRecipe.ProcessRecipe)) { DialogBox.ShowWarning("Process recipe is empty"); return; } if (string.IsNullOrEmpty(CurrentRecipe.LayoutRecipe)) { DialogBox.ShowWarning("Layout recipe is empty"); return; } if (string.IsNullOrEmpty(CurrentRecipe.CoolTime)) { DialogBox.ShowWarning("Cool time is empty"); return; } Dictionary param = new Dictionary() { {"WaferType","P" }, {"Form","Normal" }, {"JobRecipe", CurrentRecipe.Name }, {"ProcessRecipe",CurrentRecipe.ProcessRecipe }, {"LayoutRecipe",CurrentRecipe.LayoutRecipe }, {"CoolTime",$"{CurrentRecipe.CoolTime}" }, }; InvokeClient.Instance.Service.DoOperation($"System.CheckProcess", param); } public void ClosedCmd(string cmdPar) { (GetView() as Window).Close(); } } public class RecipeDataJob : PropertyChangedBase { private string _prefixPath; public string PrefixPath { get => _prefixPath; set { _prefixPath = value; NotifyOfPropertyChange(nameof(PrefixPath)); } } private string _name; public string Name { get => _name; set { _name = value; NotifyOfPropertyChange(nameof(Name)); } } private string _createBy; public string CreateBy { get => _createBy; set { _createBy = value; NotifyOfPropertyChange(nameof(CreateBy)); } } private string _createTime; public string CreateTime { get => _createTime; set { _createTime = value; NotifyOfPropertyChange(nameof(CreateTime)); } } private string _lastReviseBy; public string LastReviseBy { get => _lastReviseBy; set { _lastReviseBy = value; NotifyOfPropertyChange(nameof(LastReviseBy)); } } private string _lastRevisionTime; public string LastRevisionTime { get => _lastRevisionTime; set { _lastRevisionTime = value; NotifyOfPropertyChange(nameof(LastRevisionTime)); } } private string _description; public string Description { get => _description; set { _description = value; NotifyOfPropertyChange(nameof(Description)); } } private string _recipePermission; public string RecipePermission { get { return this._recipePermission; } set { this._recipePermission = value; this.NotifyOfPropertyChange("RecipePermisson"); } } private string _recipeLevel; public string RecipeLevel { get { return this._recipeLevel; } set { this._recipeLevel = value; this.NotifyOfPropertyChange("RecipeLevel"); } } private string _processRecipe; public string ProcessRecipe { get => _processRecipe; set { _processRecipe = value; NotifyOfPropertyChange(nameof(ProcessRecipe)); } } private string _layoutRecipe; public string LayoutRecipe { get => _layoutRecipe; set { _layoutRecipe = value; NotifyOfPropertyChange(nameof(LayoutRecipe)); } } private string _coolTime; public string CoolTime { get => _coolTime; set { _coolTime = value; NotifyOfPropertyChange(nameof(CoolTime)); } } private string _recipeChamberType; public string RecipeChamberType { get => _recipeChamberType; set { _recipeChamberType = value; NotifyOfPropertyChange(nameof(RecipeChamberType)); } } private string _recipeVersion; public string RecipeVersion { get => _recipeVersion; set { _recipeVersion = value; NotifyOfPropertyChange(nameof(RecipeVersion)); } } private XmlDocument _doc; private string _module; private RecipeProvider _recipeProvider = new RecipeProvider(); public RecipeDataJob() { _doc = new XmlDocument(); } public void Clear() { CreateBy = ""; CreateTime = ""; LastReviseBy = ""; LastRevisionTime = ""; Description = ""; RecipeChamberType = ""; RecipeVersion = ""; _module = ""; } public void InitData(string prefixPath, string recipeName, string recipeContent, string module) { PrefixPath = prefixPath; Name = recipeName; _module = module; try { _doc = new XmlDocument(); _doc.LoadXml(recipeContent); if (!LoadHeader(_doc.SelectSingleNode("Aitex/TableRecipeData"))) return; XmlNode nodeModule; nodeModule = _doc.SelectSingleNode("Aitex/TableRecipeData"); XmlElement stepNode = nodeModule as XmlElement; foreach (XmlAttribute att in stepNode.Attributes) { switch (att.Name) { case "CreatedBy": CreateBy = att.Value; break; case "CreationTime": CreateTime = att.Value; break; case "LastRevisedBy": LastReviseBy = att.Value; break; case "LastRevisionTime": LastRevisionTime = att.Value; break; case "Description": Description = att.Value; break; } } nodeModule = _doc.SelectSingleNode($"Aitex/TableRecipeData/Module[@Name='{module}']/Step"); if (nodeModule == null) return; stepNode = nodeModule as XmlElement; foreach (XmlAttribute att in stepNode.Attributes) { switch (att.Name) { case "ProcessRecipe": ProcessRecipe = att.Value; break; case "LayoutRecipe": LayoutRecipe = att.Value; break; case "CoolTime": CoolTime = att.Value; break; } } } catch (Exception ex) { LOG.Write(ex); } } public string GetXmlString() { try { XmlElement nodeData = _doc.SelectSingleNode($"Aitex/TableRecipeData") as XmlElement; if (string.IsNullOrEmpty(LastReviseBy)) nodeData.SetAttribute("LastRevisedBy", LastReviseBy); if (string.IsNullOrEmpty(LastRevisionTime)) nodeData.SetAttribute("LastRevisionTime", LastRevisionTime); if (string.IsNullOrEmpty(Description)) nodeData.SetAttribute("Description", Description); if (string.IsNullOrEmpty(RecipeChamberType)) nodeData.SetAttribute("RecipeChamberType", RecipeChamberType); if (string.IsNullOrEmpty(RecipePermission)) nodeData.SetAttribute("RecipePermission", RecipePermission); if (string.IsNullOrEmpty(RecipeLevel)) nodeData.SetAttribute("RecipeLevel", RecipeLevel); XmlNode nodeModule = _doc.SelectSingleNode($"Aitex/TableRecipeData/Module[@Name='{_module}']"); if (nodeModule == null) { nodeModule = _doc.CreateElement("Module"); nodeData.AppendChild(nodeModule); } nodeModule.RemoveAll(); (nodeModule as XmlElement).SetAttribute("Name", _module); XmlElement nodeStep = _doc.CreateElement("Step"); nodeStep.SetAttribute("ProcessRecipe", ProcessRecipe); nodeStep.SetAttribute("LayoutRecipe", LayoutRecipe); nodeStep.SetAttribute("CoolTime", CoolTime); nodeModule.AppendChild(nodeStep); } catch (Exception ex) { LOG.Write(ex); return _doc.OuterXml; } return _doc.OuterXml; } private bool LoadHeader(XmlNode nodeHeader) { if (nodeHeader == null) return false; if (nodeHeader.Attributes["CreatedBy"] != null) CreateBy = nodeHeader.Attributes["CreatedBy"].Value; if (nodeHeader.Attributes["CreationTime"] != null) CreateTime = nodeHeader.Attributes["CreationTime"].Value; if (nodeHeader.Attributes["LastRevisedBy"] != null) LastReviseBy = nodeHeader.Attributes["LastRevisedBy"].Value; if (nodeHeader.Attributes["LastRevisionTime"] != null) LastRevisionTime = nodeHeader.Attributes["LastRevisionTime"].Value; if (nodeHeader.Attributes["Description"] != null) Description = nodeHeader.Attributes["Description"].Value; string chamberType = string.Empty; if (nodeHeader.Attributes["RecipeChamberType"] != null) chamberType = nodeHeader.Attributes["RecipeChamberType"].Value; if (!string.IsNullOrEmpty(chamberType) && chamberType != RecipeChamberType) { LOG.Write($"{chamberType} is not accordance with {RecipeChamberType}"); return false; } return true; } } }