MaintenanceJobViewModel.cs 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using Aitex.Core.Util;
  2. using Caliburn.Micro;
  3. using MECF.Framework.Common.DataCenter;
  4. using MECF.Framework.Common.OperationCenter;
  5. using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
  6. using MECF.Framework.UI.Client.CenterViews.Editors.Sequence;
  7. using MECF.Framework.UI.Client.ClientBase;
  8. using OpenSEMI.ClientBase;
  9. using System.Collections.ObjectModel;
  10. using System.Windows;
  11. namespace FurnaceUI.Views.Jobs
  12. {
  13. public class MaintenanceJobViewModel : ModuleUiViewModelBase
  14. {
  15. [Subscription("Boat.Status")]
  16. public string BoatStatus { get; set; }
  17. public bool IsBoatEnabled => BoatStatus == "Idle";
  18. public bool IsPermission { get => this.Permission == 3; }
  19. public Visibility ExecButtonVisibility { get; set; } = Visibility.Visible;
  20. public Visibility CloseButtonVisibility { get; set; } = Visibility.Hidden;
  21. public string SelectButtonContent { get; set; } = "Process Recipe Select";
  22. private string selectedProcessRecipe;
  23. public string SelectedProcessRecipe
  24. {
  25. set
  26. {
  27. selectedProcessRecipe = value;
  28. NotifyOfPropertyChange("SelectedProcessRecipe");
  29. }
  30. get
  31. {
  32. return selectedProcessRecipe;
  33. }
  34. }
  35. public string SelectedSupportedProcessType { get; set; } = "SupportedProcessType";
  36. public string SelectedProcessType { get; set; } = "Process";
  37. public void ClosedCmd(string cmdPar)
  38. {
  39. (GetView() as Window).Close();
  40. }
  41. public void SelectProcessRecipe()
  42. {
  43. RecipeSelectDialogViewModel dialog = new RecipeSelectDialogViewModel();
  44. dialog.DisplayName = "Select Recipe";
  45. var recipeProvider = new RecipeProvider();
  46. var processType = QueryDataClient.Instance.Service.GetConfig($"System.Recipe.{SelectedSupportedProcessType}");
  47. if (processType == null)
  48. {
  49. processType = SelectedProcessType;
  50. }
  51. var ProcessTypeFileList = new ObservableCollection<ProcessTypeFileItem>();
  52. string[] recipeProcessType = ((string)processType).Split(',');
  53. var type = new ProcessTypeFileItem();
  54. type.ProcessType = recipeProcessType[0];
  55. var prefix = $"Furnace\\{recipeProcessType[0]}";
  56. var recipes = recipeProvider.GetXmlRecipeList(prefix);
  57. type.FileListByProcessType = RecipeSequenceTreeBuilder.BuildFileNode(prefix, "", false, recipes)[0].Files;
  58. ProcessTypeFileList.Add(type);
  59. dialog.ProcessTypeFileList = ProcessTypeFileList;
  60. WindowManager wm = new WindowManager();
  61. bool? bret = wm.ShowDialog(dialog);
  62. if ((bool)bret)
  63. {
  64. //var array = dialog.DialogResult.Split(new char[] { '\\' });
  65. //SelectedProcessRecipe = array[array.Length - 1];
  66. SelectedProcessRecipe = dialog.DialogResult;
  67. }
  68. }
  69. public void ExecCommand()
  70. {
  71. if (string.IsNullOrWhiteSpace(SelectedProcessRecipe))
  72. {
  73. DialogBox.ShowWarning("{0} cannot be empty.", "Process Recipe");
  74. return;
  75. }
  76. int length = SelectedProcessRecipe.Split('\\').Length;
  77. InvokeClient.Instance.Service.DoOperation("PM1.RunRecipe", SelectedProcessRecipe);
  78. }
  79. }
  80. }