RecipeService.cs 13 KB

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