RecipeEditorViewModel.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Windows;
  5. using System.Windows.Input;
  6. using System.Xml;
  7. using Aitex.Core.RT.Log;
  8. using Aitex.Core.RT.RecipeCenter;
  9. using Aitex.Core.RT.SCCore;
  10. using Aitex.Core.UI.MVVM;
  11. using Aitex.UI.RecipeEditor;
  12. using MECF.Framework.UI.Client.ClientBase;
  13. using OpenSEMI.ClientBase;
  14. namespace EfemDualUI.Views.PMs
  15. {
  16. class RecipeEditorViewModel : ModuleUiViewModelBase, ISupportMultipleSystem
  17. {
  18. #region 控件used
  19. public ICommand OpenLocalRecipeCommand { get; set; }
  20. public ICommand RightClickCommand { get; set; }
  21. public ICommand RecipeHelpDocCommand { get; set; }
  22. public ICommand SaveRecipeCommand { get; set; }
  23. public ICommand UndoCommand { get; set; }
  24. public ICommand RedoCommand { get; set; }
  25. public ICommand ExpandGroupCommand { get; set; }
  26. public ICommand CollapseGroupCommand { get; set; }
  27. public ICommand ToggleHideSameCommand { get; set; }
  28. public ICommand RecipeExport2ExcelCommand { get; set; }
  29. public ICommand ShowDetailedErrInfoCommand { get; set; }
  30. public ICommand EditRecipeInfoCommand { get; set; }
  31. public Visibility SingleAppElementVisibility { get; set; }
  32. public Visibility RecipeInfoTextVisibility { get; set; }
  33. public bool IsUndoEnabled { get; set; }
  34. public bool IsRedoEnabled { get; set; }
  35. public object RecipeHead { get; set; }
  36. public string Errors { get; set; }
  37. public string RecipeInfo { get; set; }
  38. public ObservableCollection<RecipeRow> RecipeRows { get; set; }
  39. public Visibility IsBarcodeVisibility
  40. {
  41. get; set;
  42. }
  43. #endregion 控件used
  44. private IUiRecipeManager _recipeManager;
  45. private string _chamberId;
  46. private SCValue _config = new SCValue();
  47. private string _currentRecipeName = string.Empty;
  48. public RecipeEditorViewModel( )
  49. {
  50. // _config.SetKeys(new List<string>() { SCName.BarcodeConfig_EnableBarcode });
  51. }
  52. public RecipeEditorViewModel(IUiRecipeManager recipeManager, string chamberId)
  53. {
  54. _recipeManager = recipeManager;
  55. _chamberId = chamberId;
  56. // _config.SetKeys(new List<string>() { SCName.BarcodeConfig_EnableBarcode });
  57. }
  58. public string ChamberId
  59. {
  60. set { _chamberId = value; }
  61. get { return _chamberId; }
  62. }
  63. /// <summary>
  64. /// Recipe template
  65. /// </summary>
  66. public string RecipeTemplate
  67. {
  68. get
  69. {
  70. return _recipeManager.GetRecipeTemplate(_chamberId);
  71. }
  72. }
  73. public bool IsBarcodeEnabled
  74. {
  75. get
  76. {
  77. return false;
  78. }
  79. }
  80. public Dictionary<string, AitexTableRecipeFormatCatalogGroup> RecipePermission
  81. {
  82. get
  83. {
  84. try
  85. {
  86. string recipetemplate = RecipeTemplate;
  87. System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
  88. doc.LoadXml(RecipeTemplate);
  89. Dictionary<string, AitexTableRecipeFormatCatalogGroup> ret = new Dictionary<string, AitexTableRecipeFormatCatalogGroup>();
  90. XmlNodeList nodeList = doc.SelectNodes("TableRecipeData/Step");
  91. foreach (XmlNode node in nodeList)
  92. {
  93. AitexTableRecipeFormatCatalogGroup group = new AitexTableRecipeFormatCatalogGroup();
  94. if (node.BaseURI.ToLower() != "mos")
  95. {
  96. group.DisplayName = node.BaseURI;
  97. bool hasper = false;
  98. bool.TryParse(node.Attributes["Permission"].Value, out hasper);
  99. group.HasPermission = hasper;
  100. ret.Add(group.DisplayName, group);
  101. }
  102. }
  103. return ret;
  104. }
  105. catch (Exception ex)
  106. {
  107. LOG.Write(ex);
  108. }
  109. return new Dictionary<string, AitexTableRecipeFormatCatalogGroup>();
  110. }
  111. }
  112. public string RecipeVersion()
  113. {
  114. try
  115. {
  116. System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
  117. doc.LoadXml(RecipeTemplate);
  118. return doc.DocumentElement.Attributes["RecipeVersion"].Value;
  119. }
  120. catch (Exception ex)
  121. {
  122. LOG.Write(ex);
  123. }
  124. return "1.0";
  125. }
  126. /// <summary>
  127. /// Recipe format
  128. /// </summary>
  129. public string RecipeFormat
  130. {
  131. get
  132. {
  133. return _recipeManager.GetRecipeFormatXml(_chamberId);
  134. }
  135. }
  136. /// <summary>
  137. /// Name list of all recipes.
  138. /// </summary>
  139. public IEnumerable<string> RecipeNames
  140. {
  141. get
  142. {
  143. return _recipeManager.GetRecipes(_chamberId, true);
  144. }
  145. }
  146. /// <summary>
  147. /// Name list of all recipes.
  148. /// </summary>
  149. public string CurrentRecipeName { get { return _currentRecipeName; } set { if (value != _currentRecipeName) _currentRecipeName = value; InvokePropertyChanged("CurrentRecipeName"); } }
  150. /// <summary>
  151. /// Load recipe data by recipe name
  152. /// </summary>
  153. /// <param name="receipeName"></param>
  154. /// <returns></returns>
  155. public string LoadRecipe(string receipeName)
  156. {
  157. return _recipeManager.LoadRecipe(_chamberId, receipeName);
  158. }
  159. /// <summary>
  160. /// Get a list of all recipe names.
  161. /// </summary>
  162. /// <returns></returns>
  163. public IEnumerable<string> GetRecipes()
  164. {
  165. return _recipeManager.GetRecipes(_chamberId, true);
  166. }
  167. /// <summary>
  168. /// delete a recipe by recipe name
  169. /// </summary>
  170. /// <param name="recipeName"></param>
  171. /// <returns></returns>
  172. public bool DeleteRecipe(string recipeName)
  173. {
  174. return _recipeManager.DeleteRecipe(_chamberId, recipeName);
  175. }
  176. /// <summary>
  177. /// Save recipe by recipe name and recipe data
  178. /// </summary>
  179. /// <param name="recipeName"></param>
  180. /// <param name="recipe"></param>
  181. /// <returns></returns>
  182. public bool SaveRecipe(string recipeName, string recipeContent)
  183. {
  184. return _recipeManager.SaveRecipe(_chamberId, recipeName, recipeContent);
  185. }
  186. /// <summary>
  187. /// Save recipe by recipe name and recipe data
  188. /// </summary>
  189. /// <param name="recipeName"></param>
  190. /// <param name="recipe"></param>
  191. /// <returns></returns>
  192. public bool SaveRecipeDouble(string recipeName, string recipeContent)
  193. {
  194. return _recipeManager.SaveRecipe(_chamberId, recipeName, recipeContent) && _recipeManager.SaveRecipe(_chamberId == "PMA" ? "PMB" : "PMA", recipeName, recipeContent);
  195. }
  196. /// <summary>
  197. /// SaveAs recipe by recipe name and recipe data
  198. /// </summary>
  199. /// <param name="recipeName"></param>
  200. /// <param name="recipe"></param>
  201. /// <returns></returns>
  202. public bool SaveAsRecipe(string recipeName, string recipeContent)
  203. {
  204. return _recipeManager.SaveAsRecipe(_chamberId, recipeName, recipeContent);
  205. }
  206. /// <summary>
  207. /// Rename recipe
  208. /// </summary>
  209. /// <param name="oldName"></param>
  210. /// <param name="newName"></param>
  211. /// <returns></returns>
  212. public bool RenameRecipe(string oldName, string newName)
  213. {
  214. return _recipeManager.RenameRecipe(_chamberId, oldName, newName);
  215. }
  216. /// <summary>
  217. /// Create recipe folder
  218. /// </summary>
  219. /// <param name="oldName"></param>
  220. /// <param name="newName"></param>
  221. /// <returns></returns>
  222. public bool CreateFolder(string folderName)
  223. {
  224. return _recipeManager.CreateFolder(_chamberId, folderName);
  225. }
  226. /// <summary>
  227. /// move recipe file
  228. /// </summary>
  229. /// <param name="folderName"></param>
  230. /// <param name="tragetFolderName"></param>
  231. /// <returns></returns>
  232. public bool MoveRecipeFile(string folderName, string tragetFolderName)
  233. {
  234. return _recipeManager.MoveRecipeFile(_chamberId, folderName, tragetFolderName);
  235. }
  236. /// <summary>
  237. /// Get recipe list in xml format
  238. /// </summary>
  239. /// <returns></returns>
  240. public string GetXmlRecipeList()
  241. {
  242. return _recipeManager.GetXmlRecipeList(_chamberId, true) ?? "";
  243. }
  244. /// <summary>
  245. /// Delete recipe folder
  246. /// </summary>
  247. /// <param name="foldName"></param>
  248. /// <returns></returns>
  249. public bool DeleteFolder(string foldName)
  250. {
  251. return _recipeManager.DeleteFolder(_chamberId, foldName);
  252. }
  253. /// <summary>
  254. /// Rename recipe folder
  255. /// </summary>
  256. /// <param name="oldName"></param>
  257. /// <param name="newName"></param>
  258. /// <returns></returns>
  259. public bool RenameFolder(string oldName, string newName)
  260. {
  261. return _recipeManager.RenameFolder(_chamberId, oldName, newName);
  262. }
  263. public void UpdateAllConfig()
  264. {
  265. //_config.Update(VirgoUiSystem.Instance.WCF.Query.PollConfig(_config.GetKeys()));
  266. }
  267. }
  268. }