RecipeService.cs 18 KB

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