RecipeServiceClient.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.IO;
  5. using System.ServiceModel;
  6. using Aitex.Core.RT.RecipeCenter;
  7. using Aitex.Core.Util;
  8. using Aitex.Core.WCF;
  9. using MECF.Framework.Common.Equipment;
  10. using CyberX8_Core;
  11. namespace MECF.Framework.Common.RecipeCenter
  12. {
  13. public class RecipeClient : Singleton<RecipeClient>
  14. {
  15. public bool InProcess { get; set; }
  16. private IRecipeService _service;
  17. public IRecipeService Service
  18. {
  19. get
  20. {
  21. if (_service == null)
  22. {
  23. if (InProcess)
  24. _service = new RecipeService();
  25. else
  26. _service = new RecipeServiceClient();
  27. }
  28. return _service;
  29. }
  30. }
  31. }
  32. public class RecipeServiceClient : ServiceClientWrapper<IRecipeService>, IRecipeService
  33. {
  34. public RecipeServiceClient()
  35. : base("Client_IRecipeService", "RecipeService")
  36. {
  37. }
  38. public string LoadRecipe(ModuleName chamId, string recipeName)
  39. {
  40. string result = null;
  41. Invoke(svc => { result = svc.LoadRecipe(chamId, recipeName); });
  42. return result;
  43. }
  44. public bool DeleteRecipeByFullPath(string fullPath)
  45. {
  46. bool result = true;
  47. Invoke(svc => { result = svc.DeleteRecipeByFullPath(fullPath); });
  48. return result;
  49. }
  50. public bool PromoteRecipe(List<string> FilePaths)
  51. {
  52. bool result = true;
  53. Invoke(svc => { result = svc.PromoteRecipe(FilePaths); });
  54. return result;
  55. }
  56. public Tuple<string, string> LoadRunTimeRecipeInfo(ModuleName chamId)
  57. {
  58. Tuple<string, string> result = null;
  59. Invoke(svc => { result = svc.LoadRunTimeRecipeInfo(chamId); });
  60. return result;
  61. }
  62. public IEnumerable<string> GetRecipes(ModuleName chamId, bool includeUsedRecipe)
  63. {
  64. IEnumerable<string> result = null;
  65. Invoke(svc => { result = svc.GetRecipes(chamId, includeUsedRecipe); });
  66. return result;
  67. }
  68. public IEnumerable<string> GetAllRecipes(string chamId)
  69. {
  70. IEnumerable<string> result = null;
  71. Invoke(svc => { result = svc.GetAllRecipes(chamId); });
  72. return result;
  73. }
  74. public ObservableCollection<RecipeNode> GetRecipesByType(string recipeType)
  75. {
  76. ObservableCollection<RecipeNode> result = null;
  77. Invoke(svc => { result = svc.GetRecipesByType(recipeType); });
  78. return result;
  79. }
  80. public ObservableCollection<RecipeNode> GetEngineeringRecipesByType(string recipeType)
  81. {
  82. ObservableCollection<RecipeNode> result = null;
  83. Invoke(svc => { result=svc.GetEngineeringRecipesByType(recipeType);} );
  84. return result;
  85. }
  86. /// <summary>
  87. /// 获取目录集合节点
  88. /// </summary>
  89. /// <param name="directories"></param>
  90. /// <returns></returns>
  91. public ObservableCollection<RecipeNode> GetRecipeByDirectoryList(List<string> directories)
  92. {
  93. ObservableCollection<RecipeNode> result = null;
  94. Invoke(svc => { result = svc.GetRecipeByDirectoryList(directories); });
  95. return result;
  96. }
  97. /// <summary>
  98. /// 加载 Recipe
  99. /// </summary>
  100. /// <param name="recipeFullName"></param>
  101. /// <returns></returns>
  102. [OperationContract]
  103. public string LoadGenericityRecipe(string type, string recipeFullName)
  104. {
  105. string result = null;
  106. Invoke(svc => { result = svc.LoadGenericityRecipe(type,recipeFullName); });
  107. return result;
  108. }
  109. /// <summary>
  110. /// 保存 Recipe
  111. /// </summary>
  112. /// <param name="recipeFullName"></param>
  113. /// <returns></returns>
  114. [OperationContract]
  115. public void SaveRecipeTypeRecipe(string root, string recipeName,string recipeType, string recipe, string dataType)
  116. {
  117. Invoke(svc => svc.SaveRecipeTypeRecipe(root, recipeName,recipeType, recipe,dataType));
  118. }
  119. public string GetXmlRecipeList(ModuleName chamId, bool includeUsedRecipe)
  120. {
  121. string result = null;
  122. Invoke(svc => { result = svc.GetXmlRecipeList(chamId, includeUsedRecipe); });
  123. return result;
  124. }
  125. public bool DeleteRecipe(ModuleName chamId, string recipeName)
  126. {
  127. bool result = false;
  128. Invoke(svc => { result = svc.DeleteRecipe(chamId, recipeName); });
  129. return result;
  130. }
  131. public bool DeleteFolder(ModuleName chamId, string folderName)
  132. {
  133. bool result = false;
  134. Invoke(svc => { result = svc.DeleteFolder(chamId, folderName); });
  135. return result;
  136. }
  137. public bool SaveAsRecipe(ModuleName chamId, string recipeName, string recipeContent)
  138. {
  139. bool result = false;
  140. Invoke(svc => { result = svc.SaveAsRecipe(chamId, recipeName, recipeContent); });
  141. return result;
  142. }
  143. public bool SaveAsRecipe2(ModuleName chamId,string type, string recipeName, string recipeContent)
  144. {
  145. bool result = false;
  146. Invoke(svc => { result = svc.SaveAsRecipe2(chamId,type, recipeName, recipeContent); });
  147. return result;
  148. }
  149. public bool SaveRecipe(ModuleName chamId, string recipeName, string recipeContent)
  150. {
  151. bool result = false;
  152. Invoke(svc => { result = svc.SaveRecipe(chamId, recipeName, recipeContent); });
  153. return result;
  154. }
  155. public bool CreateFolder(ModuleName chamId, string folderName)
  156. {
  157. bool result = false;
  158. Invoke(svc => { result = svc.CreateFolder(chamId, folderName); });
  159. return result;
  160. }
  161. public bool MoveRecipeFile(ModuleName chamId, string folderName, string tragetFolderName)
  162. {
  163. bool result = false;
  164. Invoke(svc => { result = svc.MoveRecipeFile(chamId, folderName, tragetFolderName); });
  165. return result;
  166. }
  167. public bool RenameRecipe(ModuleName chamId, string oldName, string newName)
  168. {
  169. bool result = false;
  170. Invoke(svc => { result = svc.RenameRecipe(chamId, oldName, newName); });
  171. return result;
  172. }
  173. public bool RenameFolder(ModuleName chamId, string oldName, string newName)
  174. {
  175. bool result = false;
  176. Invoke(svc => { result = svc.RenameFolder(chamId, oldName, newName); });
  177. return result;
  178. }
  179. public string GetRecipeFormatXml(ModuleName chamId)
  180. {
  181. string result = null;
  182. Invoke(svc => { result = svc.GetRecipeFormatXml(chamId); });
  183. return result;
  184. }
  185. public string GetRecipeTemplate(ModuleName chamId)
  186. {
  187. string result = string.Empty;
  188. Invoke(svc => { result = svc.GetRecipeTemplate(chamId); });
  189. return result;
  190. }
  191. public string GetRecipeByBarcode(ModuleName chamId, string barcode)
  192. {
  193. string result = string.Empty;
  194. Invoke(svc => { result = svc.GetRecipeByBarcode(chamId, barcode); });
  195. return result;
  196. }
  197. public string GetXmlSequenceList(ModuleName chamId)
  198. {
  199. string result = null;
  200. Invoke(svc => { result = svc.GetXmlSequenceList(chamId); });
  201. return result;
  202. }
  203. public string GetSequence(string sequenceName)
  204. {
  205. string result = string.Empty;
  206. Invoke(svc => { result = svc.GetSequence(sequenceName); });
  207. return result;
  208. }
  209. public List<string> GetSequenceNameList()
  210. {
  211. List<string> result = null;
  212. Invoke(svc => { result = svc.GetSequenceNameList(); });
  213. return result;
  214. }
  215. public bool DeleteSequence(string sequenceName)
  216. {
  217. bool result = false;
  218. Invoke(svc => { result = svc.DeleteSequence(sequenceName); });
  219. return result;
  220. }
  221. public bool SaveSequence(string sequenceName, string sequenceContent)
  222. {
  223. bool result = false;
  224. Invoke(svc => { result = svc.SaveSequence(sequenceName, sequenceContent); });
  225. return result;
  226. }
  227. public bool SaveAsSequence(string sequenceName, string sequenceContent)
  228. {
  229. bool result = false;
  230. Invoke(svc => { result = svc.SaveAsSequence(sequenceName, sequenceContent); });
  231. return result;
  232. }
  233. public bool RenameSequence(string oldName, string newName)
  234. {
  235. bool result = false;
  236. Invoke(svc => { result = svc.RenameSequence(oldName, newName); });
  237. return result;
  238. }
  239. public string GetSequenceFormatXml()
  240. {
  241. string result = string.Empty;
  242. Invoke(svc => { result = svc.GetSequenceFormatXml(); });
  243. return result;
  244. }
  245. public bool RenameSequenceFolder(string oldName, string newName)
  246. {
  247. bool result = false;
  248. Invoke(svc => { result = svc.RenameSequenceFolder(oldName, newName); });
  249. return result;
  250. }
  251. public bool CreateSequenceFolder(string folderName)
  252. {
  253. bool result = false;
  254. Invoke(svc => { result = svc.CreateSequenceFolder(folderName); });
  255. return result;
  256. }
  257. public bool DeleteSequenceFolder(string folderName)
  258. {
  259. bool result = false;
  260. Invoke(svc => { result = svc.DeleteSequenceFolder(folderName); });
  261. return result;
  262. }
  263. #region extended recipe interface
  264. public string LoadRecipeByPath(string path)
  265. {
  266. string result = null;
  267. Invoke(svc => { result = svc.LoadRecipeByPath(path); });
  268. return result;
  269. }
  270. public Tuple<string, string> LoadRunTimeRecipeInfoByPath(string pathName)
  271. {
  272. Tuple<string, string> result = null;
  273. Invoke(svc => { result = svc.LoadRunTimeRecipeInfoByPath(pathName); });
  274. return result;
  275. }
  276. public IEnumerable<string> GetRecipesByPath(string pathName, bool includeUsedRecipe)
  277. {
  278. IEnumerable<string> result = null;
  279. Invoke(svc => { result = svc.GetRecipesByPath(pathName, includeUsedRecipe); });
  280. return result;
  281. }
  282. public string GetXmlRecipeListByPath(string pathName, bool includeUsedRecipe)
  283. {
  284. string result = null;
  285. Invoke(svc => { result = svc.GetXmlRecipeListByPath(pathName, includeUsedRecipe); });
  286. return result;
  287. }
  288. public bool DeleteRecipeByPath(string pathName, string recipeName)
  289. {
  290. bool result = false;
  291. Invoke(svc => { result = svc.DeleteRecipeByPath(pathName, recipeName); });
  292. return result;
  293. }
  294. public bool DeleteFolderByPath(string pathName, string folderName)
  295. {
  296. bool result = false;
  297. Invoke(svc => { result = svc.DeleteFolderByPath(pathName, folderName); });
  298. return result;
  299. }
  300. public bool SaveAsRecipeByPath(string pathName, string recipeName, string recipeContent)
  301. {
  302. bool result = false;
  303. Invoke(svc => { result = svc.SaveAsRecipeByPath(pathName, recipeName, recipeContent); });
  304. return result;
  305. }
  306. public bool SaveRecipeByPath(string pathName, string recipeName, string recipeContent)
  307. {
  308. bool result = false;
  309. Invoke(svc => { result = svc.SaveRecipeByPath(pathName, recipeName, recipeContent); });
  310. return result;
  311. }
  312. public bool CreateFolderByPath(string pathName, string folderName)
  313. {
  314. bool result = false;
  315. Invoke(svc => { result = svc.CreateFolderByPath(pathName, folderName); });
  316. return result;
  317. }
  318. public bool RenameRecipeByPath(string pathName, string oldName, string newName)
  319. {
  320. bool result = false;
  321. Invoke(svc => { result = svc.RenameRecipeByPath(pathName, oldName, newName); });
  322. return result;
  323. }
  324. public bool RenameFolderByPath(string pathName, string oldName, string newName)
  325. {
  326. bool result = false;
  327. Invoke(svc => { result = svc.RenameFolderByPath(pathName, oldName, newName); });
  328. return result;
  329. }
  330. public string GetRecipeFormatXmlByPath(string pathName)
  331. {
  332. string result = null;
  333. Invoke(svc => { result = svc.GetRecipeFormatXmlByPath(pathName); });
  334. return result;
  335. }
  336. public string GetRecipeTemplateByPath(string pathName)
  337. {
  338. string result = string.Empty;
  339. Invoke(svc => { result = svc.GetRecipeTemplateByPath(pathName); });
  340. return result;
  341. }
  342. public string GetRecipeByBarcodeByPath(string pathName, string barcode)
  343. {
  344. string result = string.Empty;
  345. Invoke(svc => { result = svc.GetRecipeByBarcodeByPath(pathName, barcode); });
  346. return result;
  347. }
  348. public List<String> GetSequenceList(string recipeType, string sequenceType)
  349. {
  350. List<String> result = null;
  351. Invoke(svc => { result = svc.GetSequenceList(recipeType, sequenceType); });
  352. return result;
  353. }
  354. #endregion
  355. }
  356. }