SequenceRecipeViewModel.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. using Aitex.Core.UI.MVVM;
  2. using Aitex.Core.Utilities;
  3. using CyberX8_MainPages.PMs;
  4. using CyberX8_Themes.UserControls;
  5. using MECF.Framework.Common.DataCenter;
  6. using MECF.Framework.Common.RecipeCenter;
  7. using MECF.Framework.Common.Utilities;
  8. using Prism.Mvvm;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Collections.ObjectModel;
  12. using System.ComponentModel;
  13. using System.Linq;
  14. using System.Windows;
  15. using System.Windows.Input;
  16. namespace CyberX8_MainPages.ViewModels
  17. {
  18. public class SequenceRecipeViewModel : BindableBase
  19. {
  20. #region 常量
  21. private const string ENGINEERING = "Engineering";
  22. private const string SEQUENCE = "seq";
  23. public enum PlatType
  24. {
  25. notch,
  26. flat
  27. }
  28. #endregion
  29. #region 内部变量
  30. /// <summary>
  31. /// Recipe节点字典
  32. /// </summary>
  33. private Dictionary<string, RecipeNode> _recipeNodeDic = new Dictionary<string, RecipeNode>();
  34. /// <summary>
  35. /// 可用RecipeType字典(key-ListBox内容,value-recipeType)
  36. /// </summary>
  37. private Dictionary<string, string> _aviableNodeTypeDic = new Dictionary<string, string>();
  38. /// <summary>
  39. /// Recipe节点集合
  40. /// </summary>
  41. private ObservableCollection<RecipeNode> _recipeNodes;
  42. /// <summary>
  43. /// 子Recipe节点集合
  44. /// </summary>
  45. private ObservableCollection<string> _subRecipeNodes;
  46. /// <summary>
  47. /// uiRecipeManager
  48. /// </summary>
  49. private UiRecipeManager _uiRecipeManager = new UiRecipeManager();
  50. /// <summary>
  51. /// recipe
  52. /// </summary>
  53. private SequenceRecipe _recipe;
  54. /// <summary>
  55. /// 编辑可用性
  56. /// </summary>
  57. private bool _editEnable;
  58. /// <summary>
  59. /// 创建可用性
  60. /// </summary>
  61. private bool _createEnable;
  62. /// <summary>
  63. /// 当前节点
  64. /// </summary>
  65. private RecipeNode _currentNode;
  66. /// <summary>
  67. /// 可用Recipe集合
  68. /// </summary>
  69. private List<string> _avaibleRecipeTypeLst;
  70. /// <summary>
  71. /// Process Recipe集合
  72. /// </summary>
  73. private ObservableCollection<string> _processRecipes;
  74. /// <summary>
  75. /// 选中可用RecipeType
  76. /// </summary>
  77. private string _selectAvaibleRecipeType;
  78. /// <summary>
  79. /// 选中子Recipe
  80. /// </summary>
  81. private string _selectSubRecipe;
  82. /// <summary>
  83. /// 选中索引
  84. /// </summary>
  85. private int _selectedProcessRecipeIndex;
  86. /// <summary>
  87. /// 选中Process Recipe
  88. /// </summary>
  89. private string _selectedProcessRecipe;
  90. /// <summary>
  91. /// <summary>
  92. /// csr 类型集合
  93. /// </summary>
  94. private List<string> _crsTypeLst = null;
  95. /// <summary>
  96. /// <summary>
  97. /// PlatType类型集合
  98. /// </summary>
  99. private List<PlatType> _platTypeLst = null;
  100. /// <summary>
  101. /// Wafer尺寸集合
  102. /// </summary>
  103. private List<int> _waferSizeLst = null;
  104. /// <summary>
  105. /// 是否可用
  106. /// </summary>
  107. private bool _enable = false;
  108. /// <summary>
  109. /// 是否为编辑
  110. /// </summary>
  111. private bool _editAction = false;
  112. /// <summary>
  113. /// 是否为编辑(true-Edit,false-add)
  114. /// </summary>
  115. private bool _isEdit = false;
  116. /// <summary>
  117. /// 属性检验结果字典
  118. /// </summary>
  119. private Dictionary<string, bool> _propertyValidResultDic = new Dictionary<string, bool>();
  120. /// <summary>
  121. /// Selected Flat Type
  122. /// </summary>
  123. private PlatType _selectedPlatType;
  124. /// <summary>
  125. /// Selected CrsType
  126. /// </summary>
  127. private string _selectedCrsType = "";
  128. #endregion
  129. #region 属性
  130. public ObservableCollection<RecipeNode> RecipeNodes
  131. {
  132. get { return _recipeNodes; }
  133. set { SetProperty(ref _recipeNodes, value); }
  134. }
  135. /// <summary>
  136. /// 子Recipe集合
  137. /// </summary>
  138. public ObservableCollection<string> SubRecipeNodes
  139. {
  140. get { return _subRecipeNodes; }
  141. set { SetProperty(ref _subRecipeNodes, value); }
  142. }
  143. /// <summary>
  144. /// Recipe
  145. /// </summary>
  146. public SequenceRecipe Recipe
  147. {
  148. get { return _recipe; }
  149. set { SetProperty(ref _recipe, value); }
  150. }
  151. /// <summary>
  152. /// 创建可用性
  153. /// </summary>
  154. public bool CreateEnable
  155. {
  156. get { return _createEnable; }
  157. set { SetProperty(ref _createEnable, value);}
  158. }
  159. /// <summary>
  160. /// 编辑可用性
  161. /// </summary>
  162. public bool EditEnable
  163. {
  164. get { return _editEnable; }
  165. set { SetProperty(ref _editEnable, value);}
  166. }
  167. /// <summary>
  168. /// 当前节点
  169. /// </summary>
  170. public RecipeNode CurrentNode
  171. {
  172. get { return _currentNode; }
  173. set { SetProperty(ref _currentNode, value);}
  174. }
  175. /// <summary>
  176. /// 可用集合
  177. /// </summary>
  178. public List<string> AvaibleRecipeTypeLst
  179. {
  180. get { return _avaibleRecipeTypeLst; }
  181. set { SetProperty(ref _avaibleRecipeTypeLst, value);}
  182. }
  183. /// <summary>
  184. /// 选中
  185. /// </summary>
  186. public string SelectedAvaibleRecipeType
  187. {
  188. get { return _selectAvaibleRecipeType; }
  189. set
  190. {
  191. SetProperty(ref _selectAvaibleRecipeType, value);
  192. LoadSubRecipeNodes(value);
  193. }
  194. }
  195. /// <summary>
  196. /// 选中子Recipe
  197. /// </summary>
  198. public string SelectedSubRecipe
  199. {
  200. get { return _selectSubRecipe; }
  201. set { SetProperty(ref _selectSubRecipe, value);}
  202. }
  203. /// <summary>
  204. /// 选中Process Recipe索引
  205. /// </summary>
  206. public int SelectedProcessRecipeIndex
  207. {
  208. get { return _selectedProcessRecipeIndex; }
  209. set { SetProperty(ref _selectedProcessRecipeIndex, value); }
  210. }
  211. /// <summary>
  212. /// 选中Process Recipe
  213. /// </summary>
  214. public string SelectedProcessRecipe
  215. {
  216. get { return _selectedProcessRecipe; }
  217. set { SetProperty(ref _selectedProcessRecipe, value); }
  218. }
  219. /// <summary>
  220. /// Process Recipe集合
  221. /// </summary>
  222. public ObservableCollection<string> ProcessRecipes
  223. {
  224. get { return _processRecipes; }
  225. set { SetProperty(ref _processRecipes,value); }
  226. }
  227. /// <summary>
  228. /// crs类型集合
  229. /// </summary>
  230. public List<string> CrsTypeLst
  231. {
  232. get { return _crsTypeLst; }
  233. set { SetProperty(ref _crsTypeLst, value); }
  234. }
  235. /// <summary>
  236. /// PlatType集合
  237. /// </summary>
  238. public List<PlatType> PlatTypeLst
  239. {
  240. get { return _platTypeLst; }
  241. set { SetProperty(ref _platTypeLst, value); }
  242. }
  243. /// <summary>
  244. /// Wafer 尺寸集合
  245. /// </summary>
  246. public List<int> WaferSizeLst
  247. {
  248. get { return _waferSizeLst; }
  249. set { SetProperty(ref _waferSizeLst, value); }
  250. }
  251. /// <summary>
  252. /// 可用性
  253. /// </summary>
  254. public bool Enable
  255. {
  256. get { return _enable; }
  257. set { SetProperty(ref _enable, value); }
  258. }
  259. /// <summary>
  260. /// 属性数据检验结果
  261. /// </summary>
  262. public Dictionary<string, bool> PropertyValidResultDic
  263. {
  264. get { return _propertyValidResultDic; }
  265. set { SetProperty(ref _propertyValidResultDic, value); }
  266. }
  267. /// <summary>
  268. /// Selected Plat Type
  269. /// </summary>
  270. public PlatType SelectedPlatType
  271. {
  272. get { return _selectedPlatType; }
  273. set { SetProperty(ref _selectedPlatType, value); }
  274. }
  275. /// <summary>
  276. /// SelecteCrsType
  277. /// </summary>
  278. public string SelectedCrsType
  279. {
  280. get { return _selectedCrsType; }
  281. set { SetProperty(ref _selectedCrsType, value); }
  282. }
  283. #endregion
  284. #region 指令
  285. [IgnorePropertyChange]
  286. public ICommand OperationCommand
  287. {
  288. get;
  289. private set;
  290. }
  291. [IgnorePropertyChange]
  292. public ICommand CreateCommand { get; private set; }
  293. [IgnorePropertyChange]
  294. public ICommand EditCommand { get; private set; }
  295. [IgnorePropertyChange]
  296. public ICommand AddRecipeCommand { get; private set; }
  297. [IgnorePropertyChange]
  298. public ICommand RemoveRecipeCommand { get; private set; }
  299. [IgnorePropertyChange]
  300. public ICommand MoveUpCommand { get; private set; }
  301. [IgnorePropertyChange]
  302. public ICommand MoveDownCommand { get; private set; }
  303. [IgnorePropertyChange]
  304. public ICommand SaveRecipeCommand { get; private set; }
  305. [IgnorePropertyChange]
  306. public ICommand SaveAsRecipeCommand { get; private set; }
  307. #endregion
  308. /// <summary>
  309. /// 构造函数
  310. /// </summary>
  311. public SequenceRecipeViewModel()
  312. {
  313. OperationCommand = new DelegateCommand<object>(SelectionChangedAction);
  314. CreateCommand = new DelegateCommand<object>(CreateAction);
  315. EditCommand = new DelegateCommand<object>(EditAction);
  316. AddRecipeCommand=new DelegateCommand<object>(AddRecipeAction);
  317. RemoveRecipeCommand = new DelegateCommand<object>(RemoveRecipeAction);
  318. MoveUpCommand=new DelegateCommand<object>(MoveUpAction);
  319. MoveDownCommand=new DelegateCommand<object>(MoveDownAction);
  320. SaveRecipeCommand = new DelegateCommand<object>(SaveAction);
  321. SaveAsRecipeCommand = new DelegateCommand<object>(SaveAsAction);
  322. GetAvaibleRecipeType();
  323. GetComboxLst();
  324. InitializeProprtyValidResultDictionary();
  325. }
  326. /// <summary>
  327. /// 初始化属性数据检验结果字典
  328. /// </summary>
  329. private void InitializeProprtyValidResultDictionary()
  330. {
  331. }
  332. /// <summary>
  333. /// 加载下拉框集合
  334. /// </summary>
  335. private void GetComboxLst()
  336. {
  337. //Wafer尺寸集合
  338. WaferSizeLst = new List<int>();
  339. WaferSizeLst.Add(0);
  340. WaferSizeLst.Add(100);
  341. WaferSizeLst.Add(150);
  342. WaferSizeLst.Add(200);
  343. WaferSizeLst.Add(300);
  344. string crstypeContent = QueryDataClient.Instance.Service.GetConfig($"System.LSType").ToString();
  345. if (!string.IsNullOrEmpty(crstypeContent))
  346. {
  347. CrsTypeLst = crstypeContent.Split(',').ToList();
  348. }
  349. PlatTypeLst = new List<PlatType>();
  350. PlatTypeLst.Add(PlatType.notch);
  351. PlatTypeLst.Add(PlatType.flat);
  352. }
  353. /// <summary>
  354. /// 加载数据
  355. /// </summary>
  356. public void LoadRecipeData()
  357. {
  358. RecipeNodes = _uiRecipeManager.GetRecipesByType(SEQUENCE);
  359. _recipeNodeDic.Clear();
  360. InitializeDictionary(RecipeNodes);
  361. }
  362. /// <summary>
  363. /// 初始化字典
  364. /// </summary>
  365. /// <param name="nodes"></param>
  366. private void InitializeDictionary(ObservableCollection<RecipeNode> nodes)
  367. {
  368. if (nodes != null)
  369. {
  370. foreach (var node in nodes)
  371. {
  372. if (node.NodeType == RecipeNodeType.File)
  373. {
  374. _recipeNodeDic[node.Name] = node;
  375. }
  376. InitializeDictionary(node.Children);
  377. }
  378. }
  379. }
  380. /// <summary>
  381. /// 操作
  382. /// </summary>
  383. /// <param name="param"></param>
  384. private void SelectionChangedAction(object param)
  385. {
  386. if(_recipeNodeDic.ContainsKey(param.ToString()))
  387. {
  388. CurrentNode = _recipeNodeDic[param.ToString()];
  389. if(CurrentNode.NodeType==RecipeNodeType.File)
  390. {
  391. if (CurrentNode.RecipeLocation == ENGINEERING)
  392. {
  393. EditEnable = true;
  394. CreateEnable = true;
  395. }
  396. else
  397. {
  398. EditEnable= false;
  399. CreateEnable = false;
  400. }
  401. }
  402. Recipe =_uiRecipeManager.LoadRecipe<SequenceRecipe>(CurrentNode.RecipeFullFileName);
  403. if (Recipe != null)
  404. {
  405. ProcessRecipes = new ObservableCollection<string>();
  406. if (Recipe.Recipes != null && Recipe.Recipes.Count != 0)
  407. {
  408. ProcessRecipes.AddRange(Recipe.Recipes);
  409. }
  410. SelectedPlatType = (PlatType)Recipe.PlatType;
  411. SelectedCrsType = CrsTypeLst.FirstOrDefault(O => O.Contains(Recipe.CrsType));
  412. }
  413. else
  414. {
  415. MessageBox.Show("Invalid Recipe", "Load Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  416. EditEnable = false;
  417. CreateEnable = false;
  418. }
  419. Enable = false;
  420. }
  421. else
  422. {
  423. if(param.ToString()==ENGINEERING)
  424. {
  425. CreateEnable= true;
  426. }
  427. else
  428. {
  429. CreateEnable = false;
  430. }
  431. CurrentNode = null;
  432. Recipe = null;
  433. ProcessRecipes = null;
  434. EditEnable = false;
  435. Enable = false;
  436. }
  437. _editAction = false;
  438. }
  439. #region Action
  440. /// <summary>
  441. /// 创建
  442. /// </summary>
  443. /// <param name="param"></param>
  444. private void CreateAction(object param)
  445. {
  446. RecipeNameDialog recipeNameDialog = new RecipeNameDialog();
  447. if (recipeNameDialog.ShowDialog().Value)
  448. {
  449. if (!CheckNameExist(recipeNameDialog.RecipeName))
  450. {
  451. Recipe = new SequenceRecipe();
  452. Recipe.CreateDate = DateTime.Now;
  453. Recipe.Ppid = recipeNameDialog.RecipeName;
  454. ProcessRecipes = new ObservableCollection<string>();
  455. Enable = true;
  456. _editAction = false;
  457. }
  458. }
  459. }
  460. /// <summary>
  461. /// 编辑
  462. /// </summary>
  463. /// <param name="param"></param>
  464. private void EditAction(object param)
  465. {
  466. Enable = true;
  467. _editAction= true;
  468. }
  469. /// <summary>
  470. /// 增加Recipe
  471. /// </summary>
  472. /// <param name="param"></param>
  473. private void AddRecipeAction(object param)
  474. {
  475. if (!string.IsNullOrEmpty(SelectedSubRecipe))
  476. {
  477. string[] strAry = SelectedSubRecipe.Split('.');
  478. if(strAry.Length>=3)
  479. {
  480. string str = $"{strAry[1]}.{strAry[2]}";
  481. if (strAry[1].ToLower() != "dep" && strAry[1].ToLower() != "qdr")
  482. {
  483. string first = ProcessRecipes.FirstOrDefault(O => O.Contains(str));
  484. if (!string.IsNullOrEmpty(first))
  485. {
  486. MessageBox.Show("Already exist same Recipe type", "Add Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  487. return;
  488. }
  489. }
  490. else if(strAry[1].ToLower() == "dep")
  491. {
  492. string containResult = ProcessRecipes.FirstOrDefault(O => O == SelectedSubRecipe);
  493. if (!string.IsNullOrEmpty(containResult))
  494. {
  495. MessageBox.Show($"{SelectedSubRecipe} already exist", "Add Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  496. return;
  497. }
  498. }
  499. }
  500. ProcessRecipes.Add(SelectedSubRecipe);
  501. }
  502. }
  503. /// <summary>
  504. /// 移除Recipe
  505. /// </summary>
  506. /// <param name="param"></param>
  507. private void RemoveRecipeAction(object param)
  508. {
  509. if(!string.IsNullOrEmpty(SelectedProcessRecipe)&&ProcessRecipes.Contains(SelectedProcessRecipe))
  510. {
  511. ProcessRecipes.Remove(SelectedProcessRecipe);
  512. }
  513. }
  514. /// <summary>
  515. /// 上移
  516. /// </summary>
  517. /// <param name="param"></param>
  518. private void MoveUpAction(object param)
  519. {
  520. int tmpIndex = SelectedProcessRecipeIndex;
  521. if(SelectedProcessRecipeIndex>0)
  522. {
  523. string up = ProcessRecipes[SelectedProcessRecipeIndex - 1];
  524. ProcessRecipes[SelectedProcessRecipeIndex - 1] = SelectedProcessRecipe;
  525. ProcessRecipes[SelectedProcessRecipeIndex] = up;
  526. SelectedProcessRecipeIndex = tmpIndex - 1;
  527. }
  528. }
  529. /// <summary>
  530. /// 下移
  531. /// </summary>
  532. /// <param name="param"></param>
  533. private void MoveDownAction(object param)
  534. {
  535. int tmpIndex = SelectedProcessRecipeIndex;
  536. if (SelectedProcessRecipeIndex <ProcessRecipes.Count-1)
  537. {
  538. string up = ProcessRecipes[SelectedProcessRecipeIndex + 1];
  539. ProcessRecipes[SelectedProcessRecipeIndex + 1] = SelectedProcessRecipe;
  540. ProcessRecipes[SelectedProcessRecipeIndex] = up;
  541. SelectedProcessRecipeIndex = tmpIndex + 1;
  542. }
  543. }
  544. /// <summary>
  545. /// 保存
  546. /// </summary>
  547. /// <param name="param"></param>
  548. private void SaveAction(object param)
  549. {
  550. if (CheckValid(_isEdit))
  551. {
  552. Recipe.Recipes = new List<string>();
  553. Recipe.Recipes.AddRange(ProcessRecipes);
  554. Recipe.SaveDate = DateTime.Now;
  555. Recipe.PlatType = (int)SelectedPlatType;
  556. Recipe.CrsType = SelectedCrsType;
  557. try
  558. {
  559. _uiRecipeManager.SaveRecipe<SequenceRecipe>(ENGINEERING, Recipe.Ppid, "seq",Recipe);
  560. if (!_editAction)
  561. {
  562. LoadRecipeData();
  563. }
  564. MessageBox.Show("Save Recipe Success", "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Information);
  565. Enable = false;
  566. }
  567. catch (Exception ex)
  568. {
  569. MessageBox.Show(ex.Message, "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  570. }
  571. }
  572. }
  573. /// 另存为
  574. /// </summary>
  575. /// <param name="param"></param>
  576. private void SaveAsAction(object param)
  577. {
  578. if (Recipe == null)
  579. {
  580. MessageBox.Show("Select a Recipe first", "SaveAs Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  581. return;
  582. }
  583. SequenceRecipe recipe = new SequenceRecipe();
  584. if (CheckValid(_isEdit))
  585. {
  586. RecipeNameDialog recipeNameDialog = new RecipeNameDialog();
  587. if (recipeNameDialog.ShowDialog().Value)
  588. {
  589. if (!CheckNameExist(recipeNameDialog.RecipeName))
  590. {
  591. recipe = new SequenceRecipe();
  592. //赋值属性
  593. //recipe.AlignmentAngle = Recipe.AlignmentAngle;
  594. //recipe.CrsType = Recipe.CrsType;
  595. //recipe.FiducialType = Recipe.FiducialType;
  596. //recipe.LastSingleWaferToSideB = Recipe.LastSingleWaferToSideB;
  597. //recipe.SubstrateSize = Recipe.SubstrateSize;
  598. //recipe.SequenceType = Recipe.SequenceType;
  599. //recipe.Recipes = new List<string>();
  600. //foreach (var item in Recipe.Recipes)
  601. //{
  602. // recipe.Recipes.Add(item);
  603. //}
  604. recipe = (SequenceRecipe)PropertyUtil.Clone(Recipe);
  605. recipe.Recipes.Clear();
  606. recipe.Recipes.AddRange(ProcessRecipes);
  607. recipe.CreateDate = DateTime.Now;
  608. recipe.Ppid = recipeNameDialog.RecipeName;
  609. recipe.Description = recipeNameDialog.RecipeDescription;
  610. }
  611. else if (recipeNameDialog.RecipeName != null)
  612. {
  613. MessageBox.Show("Name can not be Null", "Create Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  614. return;
  615. }
  616. else
  617. {
  618. return;
  619. }
  620. }
  621. try
  622. {
  623. _uiRecipeManager.SaveRecipe<SequenceRecipe>(ENGINEERING, recipe.Ppid, "seq", recipe);
  624. LoadRecipeData();
  625. MessageBox.Show("Save As Recipe Success", "SaveAs Recipe", MessageBoxButton.OK, MessageBoxImage.Information);
  626. Enable = false;
  627. }
  628. catch (Exception ex)
  629. {
  630. MessageBox.Show(ex.Message, "Save As Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  631. }
  632. }
  633. }
  634. /// <summary>
  635. /// 检验合法性
  636. /// </summary>
  637. /// <param name="editType"></param>
  638. /// <returns></returns>
  639. private bool CheckValid(bool editType)
  640. {
  641. foreach (string key in _propertyValidResultDic.Keys)
  642. {
  643. bool valid = _propertyValidResultDic[key];
  644. if (!valid)
  645. {
  646. MessageBox.Show($"{key} data invalid", "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  647. return false;
  648. }
  649. }
  650. return true;
  651. }
  652. /// <summary>
  653. /// 检验名称是否已经存在
  654. /// </summary>
  655. /// <param name="name"></param>
  656. /// <returns></returns>
  657. private bool CheckNameExist(string name)
  658. {
  659. foreach (string item in _recipeNodeDic.Keys)
  660. {
  661. if (item == name)
  662. {
  663. MessageBox.Show($"{name} is exsit", "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
  664. return true;
  665. }
  666. }
  667. return false;
  668. }
  669. #endregion
  670. /// <summary>
  671. /// 选择可用RecipeType
  672. /// </summary>
  673. private void GetAvaibleRecipeType()
  674. {
  675. AvaibleRecipeTypeLst = new List<string>();
  676. ActiveRecipeType[] values=(ActiveRecipeType[]) Enum.GetValues(typeof(ActiveRecipeType));
  677. foreach (var item in values)
  678. {
  679. object[] objAttrs = item.GetType().GetField(item.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), true);
  680. if (objAttrs != null &&objAttrs.Length > 0)
  681. {
  682. DescriptionAttribute descAttr = objAttrs[0] as DescriptionAttribute;
  683. AvaibleRecipeTypeLst.Add($"{item}({descAttr.Description})");
  684. _aviableNodeTypeDic.Add($"{item}({descAttr.Description})", item.ToString());
  685. }
  686. }
  687. }
  688. /// <summary>
  689. /// 加载子Recipe集合
  690. /// </summary>
  691. /// <param name="selectedRecipeType"></param>
  692. private void LoadSubRecipeNodes(string selectedRecipeType)
  693. {
  694. if(_aviableNodeTypeDic.ContainsKey(selectedRecipeType))
  695. {
  696. SubRecipeNodes = new ObservableCollection<string>();
  697. string recipeType = _aviableNodeTypeDic[selectedRecipeType].ToLower();
  698. ObservableCollection<RecipeNode> tmpRecipeNodes = _uiRecipeManager.GetEngineeringRecipesByType(recipeType);
  699. foreach(RecipeNode item in tmpRecipeNodes)
  700. {
  701. SubRecipeNodes.Add(item.FileName);
  702. }
  703. }
  704. }
  705. }
  706. }