RecipeService.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ServiceModel;
  4. using Aitex.Core.RT.Event;
  5. using Aitex.Core.RT.Key;
  6. using Aitex.Core.RT.OperationCenter;
  7. using Aitex.Core.RT.RecipeCenter;
  8. using MECF.Framework.Common.Equipment;
  9. namespace MECF.Framework.Common.RecipeCenter
  10. {
  11. class RecipeService : IRecipeService
  12. {
  13. /// <summary>
  14. /// Load a recipe from server to client for editing.
  15. /// </summary>
  16. /// <param name="chamId"></param>
  17. /// <param name="recipeName"></param>
  18. /// <returns></returns>
  19. public string LoadRecipe(ModuleName chamId, string recipeName)
  20. {
  21. EV.PostInfoLog(chamId.ToString(), string.Format("Read {0} recipe {1}.",chamId, recipeName));
  22. return RecipeFileManager.Instance.LoadRecipe(chamId.ToString(), recipeName, false);
  23. }
  24. /// <summary>
  25. /// Delete a recipe by recipe name
  26. /// </summary>
  27. /// <param name="chamId"></param>
  28. /// <param name="recipeName"></param>
  29. /// <returns></returns>
  30. public bool DeleteRecipe(ModuleName chamId, string recipeName)
  31. {
  32. if (KeyManager.Instance.IsExpired)
  33. {
  34. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  35. return false;
  36. }
  37. //if (!ChamberOperationService.IsSuperEnter()) return false;
  38. EV.PostInfoLog(chamId.ToString(), string.Format("Delete {0} recipe {1}.",chamId, recipeName));
  39. return RecipeFileManager.Instance.DeleteRecipe(chamId.ToString(), recipeName);
  40. }
  41. /// <summary>
  42. /// Get recipe list in xml format
  43. /// </summary>
  44. /// <param name="chamId"></param>
  45. /// <param name="includingUsedRecipe"></param>
  46. /// <returns></returns>
  47. public string GetXmlRecipeList(ModuleName chamId, bool includingUsedRecipe)
  48. {
  49. return RecipeFileManager.Instance.GetXmlRecipeList(chamId.ToString(), includingUsedRecipe);
  50. }
  51. /// <summary>
  52. /// Get recipe data by recipe name
  53. /// </summary>
  54. /// <param name="chamId"></param>
  55. /// <param name="includingUsedRecipe"></param>
  56. /// <returns></returns>
  57. public IEnumerable<string> GetRecipes(ModuleName chamId, bool includingUsedRecipe)
  58. {
  59. return RecipeFileManager.Instance.GetRecipes(chamId.ToString(), includingUsedRecipe);
  60. }
  61. /// <summary>
  62. /// Rename recipe
  63. /// </summary>
  64. /// <param name="chamId"></param>
  65. /// <param name="oldName"></param>
  66. /// <param name="newName"></param>
  67. /// <returns></returns>
  68. public bool RenameRecipe(ModuleName chamId, string oldName, string newName)
  69. {
  70. if (KeyManager.Instance.IsExpired)
  71. {
  72. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  73. return false;
  74. }
  75. EV.PostInfoLog(chamId.ToString(), string.Format("Rename {0} recipe {1} to {2}.",chamId, oldName, newName));
  76. //if (!ChamberOperationService.IsSuperEnter()) return false;
  77. return RecipeFileManager.Instance.RenameRecipe(chamId.ToString(), oldName, newName);
  78. }
  79. /// <summary>
  80. /// delete a recipe folder
  81. /// </summary>
  82. /// <param name="chamId"></param>
  83. /// <param name="folderName"></param>
  84. /// <returns></returns>
  85. public bool DeleteFolder(ModuleName chamId, string folderName)
  86. {
  87. if (KeyManager.Instance.IsExpired)
  88. {
  89. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  90. return false;
  91. }
  92. //if (!ChamberOperationService.IsSuperEnter()) return false;
  93. EV.PostInfoLog(chamId.ToString(), string.Format("Delete {0} recipe folder {1}.",chamId, folderName));
  94. return RecipeFileManager.Instance.DeleteFolder(chamId.ToString(), folderName);
  95. }
  96. /// <summary>
  97. /// save recipe content
  98. /// </summary>
  99. /// <param name="chamId"></param>
  100. /// <param name="recipeName"></param>
  101. /// <param name="recipeContent"></param>
  102. /// <returns></returns>
  103. public bool SaveRecipe(ModuleName chamId, string recipeName, string recipeContent)
  104. {
  105. if (KeyManager.Instance.IsExpired)
  106. {
  107. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  108. return false;
  109. }
  110. EV.PostInfoLog(chamId.ToString(), string.Format("Modify and save {0} recipe {1}.",chamId, recipeName));
  111. return RecipeFileManager.Instance.SaveRecipe(chamId.ToString(), recipeName, recipeContent, false, false);
  112. }
  113. /// <summary>
  114. /// save recipe content
  115. /// </summary>
  116. /// <param name="chamId"></param>
  117. /// <param name="recipeName"></param>
  118. /// <param name="recipeContent"></param>
  119. /// <returns></returns>
  120. public bool SaveAsRecipe(ModuleName chamId, string recipeName, string recipeContent)
  121. {
  122. if (KeyManager.Instance.IsExpired)
  123. {
  124. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  125. return false;
  126. }
  127. EV.PostInfoLog(chamId.ToString(), string.Format("Modify and save as {0} recipe {1}.",chamId, recipeName));
  128. return RecipeFileManager.Instance.SaveAsRecipe(chamId.ToString(), recipeName, recipeContent);
  129. }
  130. /// <summary>
  131. /// create a new recipe folder
  132. /// </summary>
  133. /// <param name="chamId"></param>
  134. /// <param name="folderName"></param>
  135. /// <returns></returns>
  136. public bool CreateFolder(ModuleName chamId, string folderName)
  137. {
  138. if (KeyManager.Instance.IsExpired)
  139. {
  140. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  141. return false;
  142. }
  143. EV.PostInfoLog(chamId.ToString(), string.Format("Create {0} recipe foler {1}.",chamId, folderName));
  144. return RecipeFileManager.Instance.CreateFolder(chamId.ToString(), folderName);
  145. }
  146. /// <summary>
  147. /// Rename recipe folder name
  148. /// </summary>
  149. /// <param name="chamId"></param>
  150. /// <param name="oldName"></param>
  151. /// <param name="newName"></param>
  152. /// <returns></returns>
  153. public bool RenameFolder(ModuleName chamId, string oldName, string newName)
  154. {
  155. if (KeyManager.Instance.IsExpired)
  156. {
  157. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  158. return false;
  159. }
  160. EV.PostInfoLog(chamId.ToString(), string.Format("Rename {0} recipe folder {1} to {2}.",chamId, oldName, newName));
  161. return RecipeFileManager.Instance.RenameFolder(chamId.ToString(), oldName, newName);
  162. }
  163. /// <summary>
  164. /// get reactor's recipe format define file
  165. /// </summary>
  166. /// <param name="chamId"></param>
  167. /// <returns></returns>
  168. public string GetRecipeFormatXml(ModuleName chamId)
  169. {
  170. return RecipeFileManager.Instance.GetRecipeFormatXml(chamId.ToString());
  171. }
  172. /// <summary>
  173. /// get reactor's template recipe file
  174. /// </summary>
  175. /// <param name="chamId"></param>
  176. /// <returns></returns>
  177. public string GetRecipeTemplate(ModuleName chamId)
  178. {
  179. return RecipeFileManager.Instance.GetRecipeTemplate(chamId.ToString());
  180. }
  181. /// <summary>
  182. /// 获取当前反应腔正在运行的Recipe信息
  183. /// </summary>
  184. /// <param name="chamId"></param>
  185. /// <returns>recipeName + recipeContent</returns>
  186. public Tuple<string, string> LoadRunTimeRecipeInfo(ModuleName chamId)
  187. {
  188. return null;
  189. //var pm = PmManager.GetReactor(chamId);
  190. //if (pm != null) return pm.LoadRunTimeRecipeInfo();
  191. //return Singleton<PMEntity>.Instance.GetRecipeInfo();
  192. }
  193. public string GetRecipeByBarcode(ModuleName chamId, string barcode)
  194. {
  195. return "";
  196. //return RecipeFileManager.Instance.GetRecipeByBarcode(chamId.ToString(), barcode);
  197. }
  198. public string GetXmlSequenceList(ModuleName chamId )
  199. {
  200. return RecipeFileManager.Instance.GetXmlSequenceList(chamId.ToString() );
  201. }
  202. public string GetSequence(string sequenceName)
  203. {
  204. return RecipeFileManager.Instance.GetSequence(sequenceName, true, false);
  205. }
  206. public List<string> GetSequenceNameList()
  207. {
  208. return RecipeFileManager.Instance.GetSequenceNameList();
  209. }
  210. public bool DeleteSequence(string sequenceName)
  211. {
  212. return RecipeFileManager.Instance.DeleteSequence(sequenceName);
  213. }
  214. public bool SaveSequence(string sequenceName, string sequenceContent)
  215. {
  216. return RecipeFileManager.Instance.SaveSequence(sequenceName, sequenceContent, false);
  217. }
  218. public bool SaveAsSequence(string sequenceName, string sequenceContent)
  219. {
  220. return RecipeFileManager.Instance.SaveAsSequence(sequenceName, sequenceContent);
  221. }
  222. public bool RenameSequence(string oldName, string newName)
  223. {
  224. return RecipeFileManager.Instance.RenameSequence(oldName, newName);
  225. }
  226. public string GetSequenceFormatXml()
  227. {
  228. return RecipeFileManager.Instance.GetSequenceFormatXml();
  229. }
  230. public bool RenameSequenceFolder(string oldName, string newName)
  231. {
  232. return RecipeFileManager.Instance.RenameSequenceFolder(oldName, newName);
  233. }
  234. public bool CreateSequenceFolder(string folderName)
  235. {
  236. return RecipeFileManager.Instance.CreateSequenceFolder(folderName);
  237. }
  238. public bool DeleteSequenceFolder(string folderName)
  239. {
  240. return RecipeFileManager.Instance.DeleteSequenceFolder(folderName);
  241. }
  242. #region extended recipe interface
  243. public string LoadRecipeByPath(string pathName, string recipeName)
  244. {
  245. return RecipeFileManager.Instance.LoadRecipe(pathName, recipeName, false);
  246. }
  247. public bool DeleteRecipeByPath(string pathName, string recipeName)
  248. {
  249. return RecipeFileManager.Instance.DeleteRecipe(pathName, recipeName);
  250. }
  251. public string GetXmlRecipeListByPath(string pathName, bool includingUsedRecipe)
  252. {
  253. return RecipeFileManager.Instance.GetXmlRecipeList(pathName, includingUsedRecipe);
  254. }
  255. public IEnumerable<string> GetRecipesByPath(string pathName, bool includingUsedRecipe)
  256. {
  257. return RecipeFileManager.Instance.GetRecipes(pathName, includingUsedRecipe);
  258. }
  259. public bool RenameRecipeByPath(string pathName, string oldName, string newName)
  260. {
  261. return RecipeFileManager.Instance.RenameRecipe(pathName, oldName, newName);
  262. }
  263. public bool DeleteFolderByPath(string pathName, string folderName)
  264. {
  265. return RecipeFileManager.Instance.DeleteFolder(pathName, folderName);
  266. }
  267. public bool SaveRecipeByPath(string pathName, string recipeName, string recipeContent)
  268. {
  269. return RecipeFileManager.Instance.SaveRecipe(pathName, recipeName, recipeContent, false, false);
  270. }
  271. public bool SaveAsRecipeByPath(string pathName, string recipeName, string recipeContent)
  272. {
  273. return RecipeFileManager.Instance.SaveAsRecipe(pathName, recipeName, recipeContent);
  274. }
  275. public bool CreateFolderByPath(string pathName, string folderName)
  276. {
  277. return RecipeFileManager.Instance.CreateFolder(pathName, folderName);
  278. }
  279. public bool RenameFolderByPath(string pathName, string oldName, string newName)
  280. {
  281. return RecipeFileManager.Instance.RenameFolder(pathName, oldName, newName);
  282. }
  283. public string GetRecipeFormatXmlByPath(string pathName)
  284. {
  285. return RecipeFileManager.Instance.GetRecipeFormatXml(pathName);
  286. }
  287. public string GetRecipeTemplateByPath(string pathName)
  288. {
  289. return RecipeFileManager.Instance.GetRecipeTemplate(pathName);
  290. }
  291. public Tuple<string, string> LoadRunTimeRecipeInfoByPath(string pathName)
  292. {
  293. return null;
  294. }
  295. public string GetRecipeByBarcodeByPath(string pathName, string barcode)
  296. {
  297. return "";
  298. }
  299. /// <summary>
  300. /// move recipe content
  301. /// </summary>
  302. /// <param name="chamId"></param>
  303. /// <param name="recipeName"></param>
  304. /// <returns></returns>
  305. public bool MoveRecipeFile(ModuleName chamId, string recipeName, string tragetFolderName)
  306. {
  307. if (KeyManager.Instance.IsExpired)
  308. {
  309. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  310. return false;
  311. }
  312. EV.PostInfoLog(chamId.ToString(), string.Format("Move {0} recipe {1}。", chamId, recipeName));
  313. return RecipeFileManager.Instance.MoveRecipeFile(chamId.ToString(), recipeName, tragetFolderName, false, false);
  314. }
  315. #endregion
  316. }
  317. }