using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Windows; using System.Windows.Input; using System.Xml; using Aitex.Core.RT.Log; using Aitex.Core.RT.RecipeCenter; using Aitex.Core.RT.SCCore; using Aitex.Core.UI.MVVM; using Aitex.UI.RecipeEditor; using MECF.Framework.UI.Client.ClientBase; using OpenSEMI.ClientBase; namespace EfemDualUI.Views.PMs { class RecipeEditorViewModel : ModuleUiViewModelBase, ISupportMultipleSystem { #region 控件used public ICommand OpenLocalRecipeCommand { get; set; } public ICommand RightClickCommand { get; set; } public ICommand RecipeHelpDocCommand { get; set; } public ICommand SaveRecipeCommand { get; set; } public ICommand UndoCommand { get; set; } public ICommand RedoCommand { get; set; } public ICommand ExpandGroupCommand { get; set; } public ICommand CollapseGroupCommand { get; set; } public ICommand ToggleHideSameCommand { get; set; } public ICommand RecipeExport2ExcelCommand { get; set; } public ICommand ShowDetailedErrInfoCommand { get; set; } public ICommand EditRecipeInfoCommand { get; set; } public Visibility SingleAppElementVisibility { get; set; } public Visibility RecipeInfoTextVisibility { get; set; } public bool IsUndoEnabled { get; set; } public bool IsRedoEnabled { get; set; } public object RecipeHead { get; set; } public string Errors { get; set; } public string RecipeInfo { get; set; } public ObservableCollection RecipeRows { get; set; } public Visibility IsBarcodeVisibility { get; set; } #endregion 控件used private IUiRecipeManager _recipeManager; private string _chamberId; private SCValue _config = new SCValue(); private string _currentRecipeName = string.Empty; public RecipeEditorViewModel( ) { // _config.SetKeys(new List() { SCName.BarcodeConfig_EnableBarcode }); } public RecipeEditorViewModel(IUiRecipeManager recipeManager, string chamberId) { _recipeManager = recipeManager; _chamberId = chamberId; // _config.SetKeys(new List() { SCName.BarcodeConfig_EnableBarcode }); } public string ChamberId { set { _chamberId = value; } get { return _chamberId; } } /// /// Recipe template /// public string RecipeTemplate { get { return _recipeManager.GetRecipeTemplate(_chamberId); } } public bool IsBarcodeEnabled { get { return false; } } public Dictionary RecipePermission { get { try { string recipetemplate = RecipeTemplate; System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.LoadXml(RecipeTemplate); Dictionary ret = new Dictionary(); XmlNodeList nodeList = doc.SelectNodes("TableRecipeData/Step"); foreach (XmlNode node in nodeList) { AitexTableRecipeFormatCatalogGroup group = new AitexTableRecipeFormatCatalogGroup(); if (node.BaseURI.ToLower() != "mos") { group.DisplayName = node.BaseURI; bool hasper = false; bool.TryParse(node.Attributes["Permission"].Value, out hasper); group.HasPermission = hasper; ret.Add(group.DisplayName, group); } } return ret; } catch (Exception ex) { LOG.Write(ex); } return new Dictionary(); } } public string RecipeVersion() { try { System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.LoadXml(RecipeTemplate); return doc.DocumentElement.Attributes["RecipeVersion"].Value; } catch (Exception ex) { LOG.Write(ex); } return "1.0"; } /// /// Recipe format /// public string RecipeFormat { get { return _recipeManager.GetRecipeFormatXml(_chamberId); } } /// /// Name list of all recipes. /// public IEnumerable RecipeNames { get { return _recipeManager.GetRecipes(_chamberId, true); } } /// /// Name list of all recipes. /// public string CurrentRecipeName { get { return _currentRecipeName; } set { if (value != _currentRecipeName) _currentRecipeName = value; InvokePropertyChanged("CurrentRecipeName"); } } /// /// Load recipe data by recipe name /// /// /// public string LoadRecipe(string receipeName) { return _recipeManager.LoadRecipe(_chamberId, receipeName); } /// /// Get a list of all recipe names. /// /// public IEnumerable GetRecipes() { return _recipeManager.GetRecipes(_chamberId, true); } /// /// delete a recipe by recipe name /// /// /// public bool DeleteRecipe(string recipeName) { return _recipeManager.DeleteRecipe(_chamberId, recipeName); } /// /// Save recipe by recipe name and recipe data /// /// /// /// public bool SaveRecipe(string recipeName, string recipeContent) { return _recipeManager.SaveRecipe(_chamberId, recipeName, recipeContent); } /// /// Save recipe by recipe name and recipe data /// /// /// /// public bool SaveRecipeDouble(string recipeName, string recipeContent) { return _recipeManager.SaveRecipe(_chamberId, recipeName, recipeContent) && _recipeManager.SaveRecipe(_chamberId == "PMA" ? "PMB" : "PMA", recipeName, recipeContent); } /// /// SaveAs recipe by recipe name and recipe data /// /// /// /// public bool SaveAsRecipe(string recipeName, string recipeContent) { return _recipeManager.SaveAsRecipe(_chamberId, recipeName, recipeContent); } /// /// Rename recipe /// /// /// /// public bool RenameRecipe(string oldName, string newName) { return _recipeManager.RenameRecipe(_chamberId, oldName, newName); } /// /// Create recipe folder /// /// /// /// public bool CreateFolder(string folderName) { return _recipeManager.CreateFolder(_chamberId, folderName); } /// /// move recipe file /// /// /// /// public bool MoveRecipeFile(string folderName, string tragetFolderName) { return _recipeManager.MoveRecipeFile(_chamberId, folderName, tragetFolderName); } /// /// Get recipe list in xml format /// /// public string GetXmlRecipeList() { return _recipeManager.GetXmlRecipeList(_chamberId, true) ?? ""; } /// /// Delete recipe folder /// /// /// public bool DeleteFolder(string foldName) { return _recipeManager.DeleteFolder(_chamberId, foldName); } /// /// Rename recipe folder /// /// /// /// public bool RenameFolder(string oldName, string newName) { return _recipeManager.RenameFolder(_chamberId, oldName, newName); } public void UpdateAllConfig() { //_config.Update(VirgoUiSystem.Instance.WCF.Query.PollConfig(_config.GetKeys())); } } }