RecipeService.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.ServiceModel;
  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 MECF.Framework.Common.Equipment;
  10. namespace MECF.Framework.Common.RecipeCenter
  11. {
  12. 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. EV.PostInfoLog(chamId.ToString(), 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 (KeyManager.Instance.IsExpired)
  34. {
  35. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  36. return false;
  37. }
  38. //if (!ChamberOperationService.IsSuperEnter()) return false;
  39. EV.PostInfoLog(chamId.ToString(), string.Format("Delete {0} recipe {1}.", chamId, recipeName));
  40. return RecipeFileManager.Instance.DeleteRecipe(chamId.ToString(), recipeName);
  41. }
  42. /// <summary>
  43. /// Get recipe list in xml format
  44. /// </summary>
  45. /// <param name="chamId"></param>
  46. /// <param name="includingUsedRecipe"></param>
  47. /// <returns></returns>
  48. public string GetXmlRecipeList(ModuleName chamId, bool includingUsedRecipe)
  49. {
  50. return RecipeFileManager.Instance.GetXmlRecipeList(chamId.ToString(), includingUsedRecipe);
  51. }
  52. /// <summary>
  53. /// Get recipe data by recipe name
  54. /// </summary>
  55. /// <param name="chamId"></param>
  56. /// <param name="includingUsedRecipe"></param>
  57. /// <returns></returns>
  58. public IEnumerable<string> GetRecipes(ModuleName chamId, bool includingUsedRecipe)
  59. {
  60. return RecipeFileManager.Instance.GetRecipes(chamId.ToString(), includingUsedRecipe);
  61. }
  62. /// <summary>
  63. /// Rename recipe
  64. /// </summary>
  65. /// <param name="chamId"></param>
  66. /// <param name="oldName"></param>
  67. /// <param name="newName"></param>
  68. /// <returns></returns>
  69. public bool RenameRecipe(ModuleName chamId, string oldName, string newName)
  70. {
  71. if (KeyManager.Instance.IsExpired)
  72. {
  73. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  74. return false;
  75. }
  76. EV.PostInfoLog(chamId.ToString(), string.Format("Rename {0} recipe {1} to {2}.", chamId, oldName, newName));
  77. //if (!ChamberOperationService.IsSuperEnter()) return false;
  78. return RecipeFileManager.Instance.RenameRecipe(chamId.ToString(), oldName, newName);
  79. }
  80. public bool BackupRecipe(string fileOriginalPath, string fileDestinationPath, bool isSaveLinkRecipe, List<string> recipeNames)
  81. {
  82. if (KeyManager.Instance.IsExpired)
  83. {
  84. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  85. return false;
  86. }
  87. EV.PostInfoLog(fileOriginalPath.ToString(), string.Format("Backup {0} recipe .", fileOriginalPath));
  88. //if (!ChamberOperationService.IsSuperEnter()) return false;
  89. return RecipeFileManager.Instance.BackupRecipe(fileOriginalPath, fileDestinationPath, isSaveLinkRecipe, recipeNames);
  90. }
  91. public bool CheckBackRecipeIsLinkRecipe(string fileOriginalPath, List<string> recipeNames)
  92. {
  93. if (KeyManager.Instance.IsExpired)
  94. {
  95. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  96. return false;
  97. }
  98. EV.PostInfoLog(fileOriginalPath.ToString(), string.Format("Backup IsLinkRecipe {0} recipe .", fileOriginalPath));
  99. return RecipeFileManager.Instance.CheckBackRecipeIsLinkRecipe(fileOriginalPath,recipeNames);
  100. }
  101. public List<string> RestoreRecipeFolderList()
  102. {
  103. return RecipeFileManager.Instance.RestoreRecipeFolderList();
  104. }
  105. public string GetXmlRestoreRecipeList(string fileType, bool includingUsedRecipe)
  106. {
  107. return RecipeFileManager.Instance.GetXmlRestoreRecipeList(fileType, includingUsedRecipe);
  108. }
  109. public string LoadRestoreRecipe(string pathName, string recipeName)
  110. {
  111. EV.PostInfoLog(pathName, string.Format("Read {0} recipe {1}.", pathName, recipeName));
  112. return RecipeFileManager.Instance.LoadRestoreRecipe(pathName, recipeName, false);
  113. }
  114. public bool RestoreRecipe(string chamId,bool isSaveLink, List<string> recipeNames)
  115. {
  116. if (KeyManager.Instance.IsExpired)
  117. {
  118. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  119. return false;
  120. }
  121. EV.PostInfoLog(chamId.ToString(), string.Format("Restore {0} recipe .", chamId));
  122. return RecipeFileManager.Instance.RestoreRecipe(chamId.ToString(), isSaveLink,recipeNames);
  123. }
  124. public bool SigRestoreRecipe(string chamId, List<string> recipeNames)
  125. {
  126. if (KeyManager.Instance.IsExpired)
  127. {
  128. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  129. return false;
  130. }
  131. EV.PostInfoLog(chamId.ToString(), string.Format("SigRestoreRecipe {0} recipe .", chamId));
  132. return RecipeFileManager.Instance.SigRestoreRecipe(chamId.ToString(), recipeNames);
  133. }
  134. /// <summary>
  135. /// delete a recipe folder
  136. /// </summary>
  137. /// <param name="chamId"></param>
  138. /// <param name="folderName"></param>
  139. /// <returns></returns>
  140. public bool DeleteFolder(ModuleName chamId, string folderName)
  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. //if (!ChamberOperationService.IsSuperEnter()) return false;
  148. EV.PostInfoLog(chamId.ToString(), string.Format("Delete {0} recipe folder {1}.", chamId, folderName));
  149. return RecipeFileManager.Instance.DeleteFolder(chamId.ToString(), folderName);
  150. }
  151. /// <summary>
  152. /// save recipe content
  153. /// </summary>
  154. /// <param name="chamId"></param>
  155. /// <param name="recipeName"></param>
  156. /// <param name="recipeContent"></param>
  157. /// <returns></returns>
  158. public bool SaveRecipe(ModuleName chamId, string recipeName, string recipeContent)
  159. {
  160. if (KeyManager.Instance.IsExpired)
  161. {
  162. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  163. return false;
  164. }
  165. EV.PostInfoLog(chamId.ToString(), string.Format("Modify and save {0} recipe {1}.", chamId, recipeName));
  166. return RecipeFileManager.Instance.SaveRecipe(chamId.ToString(), recipeName, recipeContent, false, false);
  167. }
  168. /// <summary>
  169. /// save recipe content
  170. /// </summary>
  171. /// <param name="chamId"></param>
  172. /// <param name="recipeName"></param>
  173. /// <param name="recipeContent"></param>
  174. /// <returns></returns>
  175. public bool SaveAsRecipe(ModuleName chamId, string recipeName, string recipeContent)
  176. {
  177. if (KeyManager.Instance.IsExpired)
  178. {
  179. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  180. return false;
  181. }
  182. EV.PostInfoLog(chamId.ToString(), string.Format("Modify and save as {0} recipe {1}.", chamId, recipeName));
  183. return RecipeFileManager.Instance.SaveAsRecipe(chamId.ToString(), recipeName, recipeContent);
  184. }
  185. /// <summary>
  186. /// create a new recipe folder
  187. /// </summary>
  188. /// <param name="chamId"></param>
  189. /// <param name="folderName"></param>
  190. /// <returns></returns>
  191. public bool CreateFolder(ModuleName chamId, string folderName)
  192. {
  193. if (KeyManager.Instance.IsExpired)
  194. {
  195. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  196. return false;
  197. }
  198. EV.PostInfoLog(chamId.ToString(), string.Format("Create {0} recipe foler {1}.", chamId, folderName));
  199. return RecipeFileManager.Instance.CreateFolder(chamId.ToString(), folderName);
  200. }
  201. /// <summary>
  202. /// Rename recipe folder name
  203. /// </summary>
  204. /// <param name="chamId"></param>
  205. /// <param name="oldName"></param>
  206. /// <param name="newName"></param>
  207. /// <returns></returns>
  208. public bool RenameFolder(ModuleName chamId, string oldName, string newName)
  209. {
  210. if (KeyManager.Instance.IsExpired)
  211. {
  212. EV.PostMessage("System", EventEnum.DefaultWarning, "Software is expired. Can not do the operation");
  213. return false;
  214. }
  215. EV.PostInfoLog(chamId.ToString(), string.Format("Rename {0} recipe folder {1} to {2}.", chamId, oldName, newName));
  216. return RecipeFileManager.Instance.RenameFolder(chamId.ToString(), oldName, newName);
  217. }
  218. /// <summary>
  219. /// get reactor's recipe format define file
  220. /// </summary>
  221. /// <param name="chamId"></param>
  222. /// <returns></returns>
  223. public string GetRecipeFormatXml(ModuleName chamId)
  224. {
  225. return RecipeFileManager.Instance.GetRecipeFormatXml(chamId.ToString());
  226. }
  227. public Dictionary<string, ObservableCollection<RecipeTemplateColumnBase>> GetGroupRecipeTemplate()
  228. {
  229. return RecipeFileManager.Instance.GetGroupRecipeTemplate();
  230. }
  231. /// <summary>
  232. /// get reactor's template recipe file
  233. /// </summary>
  234. /// <param name="chamId"></param>
  235. /// <returns></returns>
  236. public string GetRecipeTemplate(ModuleName chamId)
  237. {
  238. return RecipeFileManager.Instance.GetRecipeTemplate(chamId.ToString());
  239. }
  240. /// <summary>
  241. /// 获取当前反应腔正在运行的Recipe信息
  242. /// </summary>
  243. /// <param name="chamId"></param>
  244. /// <returns>recipeName + recipeContent</returns>
  245. public Tuple<string, string> LoadRunTimeRecipeInfo(ModuleName chamId)
  246. {
  247. return null;
  248. //var pm = PmManager.GetReactor(chamId);
  249. //if (pm != null) return pm.LoadRunTimeRecipeInfo();
  250. //return Singleton<PMEntity>.Instance.GetRecipeInfo();
  251. }
  252. public string GetRecipeByBarcode(ModuleName chamId, string barcode)
  253. {
  254. return "";
  255. //return RecipeFileManager.Instance.GetRecipeByBarcode(chamId.ToString(), barcode);
  256. }
  257. public string GetXmlSequenceList(ModuleName chamId)
  258. {
  259. return RecipeFileManager.Instance.GetXmlSequenceList(chamId.ToString());
  260. }
  261. public string GetSequence(string sequenceName)
  262. {
  263. return RecipeFileManager.Instance.GetSequence(sequenceName, true);
  264. }
  265. public List<string> GetSequenceNameList()
  266. {
  267. return RecipeFileManager.Instance.GetSequenceNameList();
  268. }
  269. public bool DeleteSequence(string sequenceName)
  270. {
  271. return RecipeFileManager.Instance.DeleteSequence(sequenceName);
  272. }
  273. public bool SaveSequence(string sequenceName, string sequenceContent)
  274. {
  275. return RecipeFileManager.Instance.SaveSequence(sequenceName, sequenceContent, false);
  276. }
  277. public bool SaveAsSequence(string sequenceName, string sequenceContent)
  278. {
  279. return RecipeFileManager.Instance.SaveAsSequence(sequenceName, sequenceContent);
  280. }
  281. public bool RenameSequence(string oldName, string newName)
  282. {
  283. return RecipeFileManager.Instance.RenameSequence(oldName, newName);
  284. }
  285. public string GetSequenceFormatXml()
  286. {
  287. return RecipeFileManager.Instance.GetSequenceFormatXml();
  288. }
  289. public bool RenameSequenceFolder(string oldName, string newName)
  290. {
  291. return RecipeFileManager.Instance.RenameSequenceFolder(oldName, newName);
  292. }
  293. public bool CreateSequenceFolder(string folderName)
  294. {
  295. return RecipeFileManager.Instance.CreateSequenceFolder(folderName);
  296. }
  297. public bool DeleteSequenceFolder(string folderName)
  298. {
  299. return RecipeFileManager.Instance.DeleteSequenceFolder(folderName);
  300. }
  301. #region extended recipe interface
  302. public string LoadRecipeByPath(string pathName, string recipeName)
  303. {
  304. return RecipeFileManager.Instance.LoadRecipe(pathName, recipeName, false);
  305. }
  306. public string LoadRecipeByFullPath(string fullPath)
  307. {
  308. return RecipeFileManager.Instance.LoadRecipeByFullPath(fullPath);
  309. }
  310. public bool DeleteRecipeByPath(string pathName, string recipeName)
  311. {
  312. return RecipeFileManager.Instance.DeleteRecipe(pathName, recipeName);
  313. }
  314. public string GetXmlRecipeListByPath(string pathName, bool includingUsedRecipe)
  315. {
  316. return RecipeFileManager.Instance.GetXmlRecipeList(pathName, includingUsedRecipe);
  317. }
  318. public IEnumerable<string> GetRecipesByPath(string pathName, bool includingUsedRecipe)
  319. {
  320. return RecipeFileManager.Instance.GetRecipes(pathName, includingUsedRecipe);
  321. }
  322. public bool RenameRecipeByPath(string pathName, string oldName, string newName)
  323. {
  324. return RecipeFileManager.Instance.RenameRecipe(pathName, oldName, newName);
  325. }
  326. public bool DeleteFolderByPath(string pathName, string folderName)
  327. {
  328. return RecipeFileManager.Instance.DeleteFolder(pathName, folderName);
  329. }
  330. public bool SaveRecipeByPath(string pathName, string recipeName, string recipeContent)
  331. {
  332. return RecipeFileManager.Instance.SaveRecipe(pathName, recipeName, recipeContent, false, false);
  333. }
  334. public bool SaveAsRecipeByPath(string pathName, string recipeName, string recipeContent)
  335. {
  336. return RecipeFileManager.Instance.SaveAsRecipe(pathName, recipeName, recipeContent);
  337. }
  338. public bool CreateFolderByPath(string pathName, string folderName)
  339. {
  340. return RecipeFileManager.Instance.CreateFolder(pathName, folderName);
  341. }
  342. public bool RenameFolderByPath(string pathName, string oldName, string newName)
  343. {
  344. return RecipeFileManager.Instance.RenameFolder(pathName, oldName, newName);
  345. }
  346. public string GetRecipeFormatXmlByPath(string pathName)
  347. {
  348. return RecipeFileManager.Instance.GetRecipeFormatXml(pathName);
  349. }
  350. public string GetRecipeTemplateByPath(string pathName)
  351. {
  352. return RecipeFileManager.Instance.GetRecipeTemplate(pathName);
  353. }
  354. public Tuple<string, string> LoadRunTimeRecipeInfoByPath(string pathName)
  355. {
  356. return null;
  357. }
  358. public string GetRecipeByBarcodeByPath(string pathName, string barcode)
  359. {
  360. return "";
  361. }
  362. public List<string> CheckRecipe(string prefix, string recipeName)
  363. {
  364. RecipeFileManager.Instance.CheckRecipe(prefix, recipeName, out List<string> reasons);
  365. return reasons;
  366. }
  367. public bool CheckRecipe(string prefix, string recipeName, out List<string> reasons)
  368. {
  369. throw new NotImplementedException();
  370. }
  371. #endregion
  372. }
  373. }