UiRecipeManager.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using Aitex.Core.RT.RecipeCenter;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.Common.RecipeCenter;
  7. using Newtonsoft.Json;
  8. namespace CyberX8_MainPages.PMs
  9. {
  10. class UiRecipeManager : IUiRecipeManager
  11. {
  12. public string LoadRecipe(string chamId, string receipeName)
  13. {
  14. return RecipeClient.Instance.Service.LoadRecipe(ModuleNameString.ToEnum(chamId), receipeName);
  15. }
  16. public string LoadRecipeByPath(string path)
  17. {
  18. return RecipeClient.Instance.Service.LoadRecipeByPath(path);
  19. }
  20. public Tuple<string, string> LoadRunTimeRecipeInfo(string chamId)
  21. {
  22. return RecipeClient.Instance.Service.LoadRunTimeRecipeInfo(ModuleNameString.ToEnum(chamId));
  23. }
  24. public IEnumerable<string> GetRecipes(string chamId, bool includeUsedRecipe)
  25. {
  26. return RecipeClient.Instance.Service.GetRecipes(ModuleNameString.ToEnum(chamId), includeUsedRecipe);
  27. }
  28. public ObservableCollection<RecipeNode> GetRecipesByType(string recipeType)
  29. {
  30. return RecipeClient.Instance.Service.GetRecipesByType(recipeType);
  31. }
  32. public ObservableCollection<RecipeNode> GetEngineeringRecipesByType(string recipeType)
  33. {
  34. return RecipeClient.Instance.Service.GetEngineeringRecipesByType(recipeType);
  35. }
  36. public ObservableCollection<RecipeNode> GetRecipeByDirectoryList(List<string> recipeType)
  37. {
  38. return RecipeClient.Instance.Service.GetRecipeByDirectoryList(recipeType);
  39. }
  40. /// <summary>
  41. /// 通过绝对路径删除recipe
  42. /// </summary>
  43. /// <param name="fullPath"></param>
  44. /// <returns></returns>
  45. public bool DeleteRecipeByFullPath(string fullPath)
  46. {
  47. return RecipeClient.Instance.Service.DeleteRecipeByFullPath(fullPath);
  48. }
  49. /// <summary>
  50. /// Promot recipe
  51. /// </summary>
  52. /// <param name="fullPath"></param>
  53. /// <returns></returns>
  54. public bool PromoteRecipe(List<string> FilePaths)
  55. {
  56. return RecipeClient.Instance.Service.PromoteRecipe(FilePaths);
  57. }
  58. /// <summary>
  59. /// 加载 recipe
  60. /// </summary>
  61. /// <param name="recipeFullName"></param>
  62. /// <returns></returns>
  63. public T LoadRecipe<T>(string recipeFullName)
  64. {
  65. Type type = typeof(T);
  66. string recipeContent =RecipeClient.Instance.Service.LoadGenericityRecipe(type.ToString(),recipeFullName);
  67. if(!string.IsNullOrEmpty(recipeContent))
  68. {
  69. return JsonConvert.DeserializeObject<T>(recipeContent);
  70. }
  71. else
  72. {
  73. return default(T);
  74. }
  75. }
  76. /// <summary>
  77. /// 保存 recipe
  78. /// </summary>
  79. /// <param name="recipeFullName"></param>
  80. /// <returns></returns>
  81. public void SaveRecipe<T>(string root, string recipeName,string recipeType, object recipe)
  82. {
  83. Type type = typeof(T);
  84. string str=JsonConvert.SerializeObject(recipe);
  85. RecipeClient.Instance.Service.SaveRecipeTypeRecipe(root, recipeName,recipeType, str,type.ToString());
  86. }
  87. public bool DeleteRecipe(string chamId, string recipeName)
  88. {
  89. return RecipeClient.Instance.Service.DeleteRecipe(ModuleNameString.ToEnum(chamId), recipeName);
  90. }
  91. public bool SaveAsRecipe(string chamId, string recipeName, string recipeContent)
  92. {
  93. return RecipeClient.Instance.Service.SaveAsRecipe(ModuleNameString.ToEnum(chamId), recipeName, recipeContent);
  94. }
  95. public bool SaveAsRecipe2(string chamId,string type, string recipeName, string recipeContent)
  96. {
  97. return RecipeClient.Instance.Service.SaveAsRecipe2(ModuleNameString.ToEnum(chamId),type, recipeName, recipeContent);
  98. }
  99. public bool SaveRecipe(string chamId, string recipeName, string recipeContent)
  100. {
  101. return RecipeClient.Instance.Service.SaveRecipe(ModuleNameString.ToEnum(chamId), recipeName, recipeContent);
  102. }
  103. public bool RenameRecipe(string chamId, string oldName, string newName)
  104. {
  105. return RecipeClient.Instance.Service.RenameRecipe(ModuleNameString.ToEnum(chamId), oldName, newName);
  106. }
  107. public bool CreateFolder(string chamId, string folderName)
  108. {
  109. return RecipeClient.Instance.Service.CreateFolder(ModuleNameString.ToEnum(chamId), folderName);
  110. }
  111. public bool MoveRecipeFile(string chamId, string folderName, string tragetFolderName)
  112. {
  113. return RecipeClient.Instance.Service.MoveRecipeFile(ModuleNameString.ToEnum(chamId), folderName, tragetFolderName);
  114. }
  115. public bool DeleteFolder(string chamId, string foldName)
  116. {
  117. return RecipeClient.Instance.Service.DeleteFolder(ModuleNameString.ToEnum(chamId), foldName);
  118. }
  119. public string GetXmlRecipeList(string chamId, bool includingUsedRecipe)
  120. {
  121. return RecipeClient.Instance.Service.GetXmlRecipeList(ModuleNameString.ToEnum(chamId), includingUsedRecipe);
  122. }
  123. public bool RenameFolder(string chamId, string oldName, string newName)
  124. {
  125. return RecipeClient.Instance.Service.RenameFolder(ModuleNameString.ToEnum(chamId), oldName, newName);
  126. }
  127. public string GetRecipeFormatXml(string chamId)
  128. {
  129. return RecipeClient.Instance.Service.GetRecipeFormatXml(ModuleNameString.ToEnum(chamId));
  130. }
  131. public string GetRecipeTemplate(string chamId)
  132. {
  133. return RecipeClient.Instance.Service.GetRecipeTemplate(ModuleNameString.ToEnum(chamId));
  134. }
  135. }
  136. }