RecipeService.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Aitex.Core.RT.Event;
  6. using Aitex.Core.RT.Key;
  7. using Aitex.Core.RT.OperationCenter;
  8. using Aitex.Core.RT.RecipeCenter;
  9. using Aitex.Core.Util;
  10. using Aitex.Triton160.Common;
  11. using Aitex.Triton160.Common.Interface;
  12. using Aitex.Triton160.RT.Module;
  13. namespace Aitex.Triton160.RT.WCF
  14. {
  15. class RecipeService : IRecipeService
  16. {
  17. /// <summary>
  18. /// Load a recipe from server to client for editing.
  19. /// </summary>
  20. /// <param name="chamId"></param>
  21. /// <param name="recipeName"></param>
  22. /// <returns></returns>
  23. public string LoadRecipe(ModuleName chamId, string recipeName)
  24. {
  25. OP.Record(chamId.ToString(), string.Format("读取{0}工艺程序{1}。", ModuleNameString.ToCstring(chamId), recipeName));
  26. return RecipeFileManager.Instance.LoadRecipe(chamId.ToString(), recipeName, false);
  27. }
  28. /// <summary>
  29. /// Delete a recipe by recipe name
  30. /// </summary>
  31. /// <param name="chamId"></param>
  32. /// <param name="recipeName"></param>
  33. /// <returns></returns>
  34. public bool DeleteRecipe(ModuleName chamId, string recipeName)
  35. {
  36. if (KeyManager.Instance.IsExpired)
  37. {
  38. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  39. return false;
  40. }
  41. //if (!ChamberOperationService.IsSuperEnter()) return false;
  42. OP.Record(chamId.ToString(), string.Format("删除{0}工艺程序{1}。", ModuleNameString.ToCstring(chamId), recipeName));
  43. return RecipeFileManager.Instance.DeleteRecipe(chamId.ToString(), recipeName);
  44. }
  45. /// <summary>
  46. /// move recipe content
  47. /// </summary>
  48. /// <param name="chamId"></param>
  49. /// <param name="recipeName"></param>
  50. /// <returns></returns>
  51. public bool MoveRecipeFile(ModuleName chamId, string recipeName, string tragetFolderName)
  52. {
  53. if (KeyManager.Instance.IsExpired)
  54. {
  55. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  56. return false;
  57. }
  58. EV.PostInfoLog(chamId.ToString(), string.Format("Move {0} recipe {1}。", chamId, recipeName));
  59. return RecipeFileManager.Instance.MoveRecipeFile(chamId.ToString(), recipeName, tragetFolderName, false, false);
  60. }
  61. /// <summary>
  62. /// Get recipe list in xml format
  63. /// </summary>
  64. /// <param name="chamId"></param>
  65. /// <param name="includingUsedRecipe"></param>
  66. /// <returns></returns>
  67. public string GetXmlRecipeList(ModuleName chamId, bool includingUsedRecipe)
  68. {
  69. return RecipeFileManager.Instance.GetXmlRecipeList(chamId.ToString(), includingUsedRecipe);
  70. }
  71. /// <summary>
  72. /// Get recipe data by recipe name
  73. /// </summary>
  74. /// <param name="chamId"></param>
  75. /// <param name="includingUsedRecipe"></param>
  76. /// <returns></returns>
  77. public IEnumerable<string> GetRecipes(ModuleName chamId, bool includingUsedRecipe)
  78. {
  79. return RecipeFileManager.Instance.GetRecipes(chamId.ToString(), includingUsedRecipe);
  80. }
  81. /// <summary>
  82. /// Rename recipe
  83. /// </summary>
  84. /// <param name="chamId"></param>
  85. /// <param name="oldName"></param>
  86. /// <param name="newName"></param>
  87. /// <returns></returns>
  88. public bool RenameRecipe(ModuleName chamId, string oldName, string newName)
  89. {
  90. if (KeyManager.Instance.IsExpired)
  91. {
  92. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  93. return false;
  94. }
  95. OP.Record(chamId.ToString(), string.Format("重命名{0}工艺程序{1}为{2}。", ModuleNameString.ToCstring(chamId), oldName, newName));
  96. //if (!ChamberOperationService.IsSuperEnter()) return false;
  97. return RecipeFileManager.Instance.RenameRecipe(chamId.ToString(), oldName, newName);
  98. }
  99. /// <summary>
  100. /// delete a recipe folder
  101. /// </summary>
  102. /// <param name="chamId"></param>
  103. /// <param name="folderName"></param>
  104. /// <returns></returns>
  105. public bool DeleteFolder(ModuleName chamId, string folderName)
  106. {
  107. if (KeyManager.Instance.IsExpired)
  108. {
  109. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  110. return false;
  111. }
  112. //if (!ChamberOperationService.IsSuperEnter()) return false;
  113. OP.Record(chamId.ToString(), string.Format("删除{0}工艺程序文件夹{1}。", ModuleNameString.ToCstring(chamId), folderName));
  114. return RecipeFileManager.Instance.DeleteFolder(chamId.ToString(), folderName);
  115. }
  116. /// <summary>
  117. /// save recipe content
  118. /// </summary>
  119. /// <param name="chamId"></param>
  120. /// <param name="recipeName"></param>
  121. /// <param name="recipeContent"></param>
  122. /// <returns></returns>
  123. public bool SaveRecipe(ModuleName chamId, string recipeName, string recipeContent)
  124. {
  125. if (KeyManager.Instance.IsExpired)
  126. {
  127. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  128. return false;
  129. }
  130. OP.Record(chamId.ToString(), string.Format("修改并保存{0}工艺程序{1}。", ModuleNameString.ToCstring(chamId), recipeName));
  131. return RecipeFileManager.Instance.SaveRecipe(chamId.ToString(), recipeName, recipeContent, false, true);
  132. }
  133. /// <summary>
  134. /// save recipe content
  135. /// </summary>
  136. /// <param name="chamId"></param>
  137. /// <param name="recipeName"></param>
  138. /// <param name="recipeContent"></param>
  139. /// <returns></returns>
  140. public bool SaveAsRecipe(ModuleName chamId, string recipeName, string recipeContent)
  141. {
  142. if (KeyManager.Instance.IsExpired)
  143. {
  144. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  145. return false;
  146. }
  147. OP.Record(chamId.ToString(), string.Format("修改并另存为{0}工艺程序{1}。", ModuleNameString.ToCstring(chamId), recipeName));
  148. return RecipeFileManager.Instance.SaveAsRecipe(chamId.ToString(), recipeName, recipeContent);
  149. }
  150. /// <summary>
  151. /// create a new recipe folder
  152. /// </summary>
  153. /// <param name="chamId"></param>
  154. /// <param name="folderName"></param>
  155. /// <returns></returns>
  156. public bool CreateFolder(ModuleName chamId, string folderName)
  157. {
  158. if (KeyManager.Instance.IsExpired)
  159. {
  160. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  161. return false;
  162. }
  163. OP.Record(chamId.ToString(), string.Format("创建{0}工艺程序文件夹{1}。", ModuleNameString.ToCstring(chamId), folderName));
  164. return RecipeFileManager.Instance.CreateFolder(chamId.ToString(), folderName);
  165. }
  166. /// <summary>
  167. /// Rename recipe folder name
  168. /// </summary>
  169. /// <param name="chamId"></param>
  170. /// <param name="oldName"></param>
  171. /// <param name="newName"></param>
  172. /// <returns></returns>
  173. public bool RenameFolder(ModuleName chamId, string oldName, string newName)
  174. {
  175. if (KeyManager.Instance.IsExpired)
  176. {
  177. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  178. return false;
  179. }
  180. OP.Record(chamId.ToString(), string.Format("重命名{0}工艺程序文件夹{1}为{2}。", ModuleNameString.ToCstring(chamId), oldName, newName));
  181. return RecipeFileManager.Instance.RenameFolder(chamId.ToString(), oldName, newName);
  182. }
  183. /// <summary>
  184. /// get reactor's recipe format define file
  185. /// </summary>
  186. /// <param name="chamId"></param>
  187. /// <returns></returns>
  188. public string GetRecipeFormatXml(ModuleName chamId)
  189. {
  190. return RecipeFileManager.Instance.GetRecipeFormatXml(chamId.ToString());
  191. }
  192. /// <summary>
  193. /// get reactor's template recipe file
  194. /// </summary>
  195. /// <param name="chamId"></param>
  196. /// <returns></returns>
  197. public string GetRecipeTemplate(ModuleName chamId)
  198. {
  199. return RecipeFileManager.Instance.GetRecipeTemplate(chamId.ToString());
  200. }
  201. /// <summary>
  202. /// 获取当前反应腔正在运行的Recipe信息
  203. /// </summary>
  204. /// <param name="chamId"></param>
  205. /// <returns>recipeName + recipeContent</returns>
  206. public Tuple<string, string> LoadRunTimeRecipeInfo(ModuleName chamId)
  207. {
  208. //return null;
  209. //var pm = PmManager.GetReactor(chamId);
  210. //if (pm != null) return pm.LoadRunTimeRecipeInfo();
  211. return Singleton<PMEntity>.Instance.GetRecipeInfo();
  212. }
  213. public string GetRecipeByBarcode(ModuleName chamId, string barcode)
  214. {
  215. return RecipeFileManager.Instance.GetRecipeByBarcode(chamId.ToString(), barcode);
  216. }
  217. }
  218. }