using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; using System.ServiceModel; using Aitex.Core.RT.RecipeCenter; using Aitex.Core.Util; using Aitex.Core.WCF; using MECF.Framework.Common.Equipment; using CyberX8_Core; namespace MECF.Framework.Common.RecipeCenter { public class RecipeClient : Singleton { public bool InProcess { get; set; } private IRecipeService _service; public IRecipeService Service { get { if (_service == null) { if (InProcess) _service = new RecipeService(); else _service = new RecipeServiceClient(); } return _service; } } } public class RecipeServiceClient : ServiceClientWrapper, IRecipeService { public RecipeServiceClient() : base("Client_IRecipeService", "RecipeService") { } public string LoadRecipe(ModuleName chamId, string recipeName) { string result = null; Invoke(svc => { result = svc.LoadRecipe(chamId, recipeName); }); return result; } public bool DeleteRecipeByFullPath(string fullPath) { bool result = true; Invoke(svc => { result = svc.DeleteRecipeByFullPath(fullPath); }); return result; } public bool PromoteRecipe(List FilePaths) { bool result = true; Invoke(svc => { result = svc.PromoteRecipe(FilePaths); }); return result; } public Tuple LoadRunTimeRecipeInfo(ModuleName chamId) { Tuple result = null; Invoke(svc => { result = svc.LoadRunTimeRecipeInfo(chamId); }); return result; } public IEnumerable GetRecipes(ModuleName chamId, bool includeUsedRecipe) { IEnumerable result = null; Invoke(svc => { result = svc.GetRecipes(chamId, includeUsedRecipe); }); return result; } public IEnumerable GetAllRecipes(string chamId) { IEnumerable result = null; Invoke(svc => { result = svc.GetAllRecipes(chamId); }); return result; } public ObservableCollection GetRecipesByType(string recipeType) { ObservableCollection result = null; Invoke(svc => { result = svc.GetRecipesByType(recipeType); }); return result; } public ObservableCollection GetEngineeringRecipesByType(string recipeType) { ObservableCollection result = null; Invoke(svc => { result=svc.GetEngineeringRecipesByType(recipeType);} ); return result; } /// /// 获取目录集合节点 /// /// /// public ObservableCollection GetRecipeByDirectoryList(List directories) { ObservableCollection result = null; Invoke(svc => { result = svc.GetRecipeByDirectoryList(directories); }); return result; } /// /// 加载 Recipe /// /// /// [OperationContract] public string LoadGenericityRecipe(string type, string recipeFullName) { string result = null; Invoke(svc => { result = svc.LoadGenericityRecipe(type,recipeFullName); }); return result; } /// /// 保存 Recipe /// /// /// [OperationContract] public void SaveRecipeTypeRecipe(string root, string recipeName,string recipeType, string recipe, string dataType) { Invoke(svc => svc.SaveRecipeTypeRecipe(root, recipeName,recipeType, recipe,dataType)); } public string GetXmlRecipeList(ModuleName chamId, bool includeUsedRecipe) { string result = null; Invoke(svc => { result = svc.GetXmlRecipeList(chamId, includeUsedRecipe); }); return result; } public bool DeleteRecipe(ModuleName chamId, string recipeName) { bool result = false; Invoke(svc => { result = svc.DeleteRecipe(chamId, recipeName); }); return result; } public bool DeleteFolder(ModuleName chamId, string folderName) { bool result = false; Invoke(svc => { result = svc.DeleteFolder(chamId, folderName); }); return result; } public bool SaveAsRecipe(ModuleName chamId, string recipeName, string recipeContent) { bool result = false; Invoke(svc => { result = svc.SaveAsRecipe(chamId, recipeName, recipeContent); }); return result; } public bool SaveAsRecipe2(ModuleName chamId,string type, string recipeName, string recipeContent) { bool result = false; Invoke(svc => { result = svc.SaveAsRecipe2(chamId,type, recipeName, recipeContent); }); return result; } public bool SaveRecipe(ModuleName chamId, string recipeName, string recipeContent) { bool result = false; Invoke(svc => { result = svc.SaveRecipe(chamId, recipeName, recipeContent); }); return result; } public bool CreateFolder(ModuleName chamId, string folderName) { bool result = false; Invoke(svc => { result = svc.CreateFolder(chamId, folderName); }); return result; } public bool MoveRecipeFile(ModuleName chamId, string folderName, string tragetFolderName) { bool result = false; Invoke(svc => { result = svc.MoveRecipeFile(chamId, folderName, tragetFolderName); }); return result; } public bool RenameRecipe(ModuleName chamId, string oldName, string newName) { bool result = false; Invoke(svc => { result = svc.RenameRecipe(chamId, oldName, newName); }); return result; } public bool RenameFolder(ModuleName chamId, string oldName, string newName) { bool result = false; Invoke(svc => { result = svc.RenameFolder(chamId, oldName, newName); }); return result; } public string GetRecipeFormatXml(ModuleName chamId) { string result = null; Invoke(svc => { result = svc.GetRecipeFormatXml(chamId); }); return result; } public string GetRecipeTemplate(ModuleName chamId) { string result = string.Empty; Invoke(svc => { result = svc.GetRecipeTemplate(chamId); }); return result; } public string GetRecipeByBarcode(ModuleName chamId, string barcode) { string result = string.Empty; Invoke(svc => { result = svc.GetRecipeByBarcode(chamId, barcode); }); return result; } public string GetXmlSequenceList(ModuleName chamId) { string result = null; Invoke(svc => { result = svc.GetXmlSequenceList(chamId); }); return result; } public string GetSequence(string sequenceName) { string result = string.Empty; Invoke(svc => { result = svc.GetSequence(sequenceName); }); return result; } public List GetSequenceNameList() { List result = null; Invoke(svc => { result = svc.GetSequenceNameList(); }); return result; } public bool DeleteSequence(string sequenceName) { bool result = false; Invoke(svc => { result = svc.DeleteSequence(sequenceName); }); return result; } public bool SaveSequence(string sequenceName, string sequenceContent) { bool result = false; Invoke(svc => { result = svc.SaveSequence(sequenceName, sequenceContent); }); return result; } public bool SaveAsSequence(string sequenceName, string sequenceContent) { bool result = false; Invoke(svc => { result = svc.SaveAsSequence(sequenceName, sequenceContent); }); return result; } public bool RenameSequence(string oldName, string newName) { bool result = false; Invoke(svc => { result = svc.RenameSequence(oldName, newName); }); return result; } public string GetSequenceFormatXml() { string result = string.Empty; Invoke(svc => { result = svc.GetSequenceFormatXml(); }); return result; } public bool RenameSequenceFolder(string oldName, string newName) { bool result = false; Invoke(svc => { result = svc.RenameSequenceFolder(oldName, newName); }); return result; } public bool CreateSequenceFolder(string folderName) { bool result = false; Invoke(svc => { result = svc.CreateSequenceFolder(folderName); }); return result; } public bool DeleteSequenceFolder(string folderName) { bool result = false; Invoke(svc => { result = svc.DeleteSequenceFolder(folderName); }); return result; } #region extended recipe interface public string LoadRecipeByPath(string path) { string result = null; Invoke(svc => { result = svc.LoadRecipeByPath(path); }); return result; } public Tuple LoadRunTimeRecipeInfoByPath(string pathName) { Tuple result = null; Invoke(svc => { result = svc.LoadRunTimeRecipeInfoByPath(pathName); }); return result; } public IEnumerable GetRecipesByPath(string pathName, bool includeUsedRecipe) { IEnumerable result = null; Invoke(svc => { result = svc.GetRecipesByPath(pathName, includeUsedRecipe); }); return result; } public string GetXmlRecipeListByPath(string pathName, bool includeUsedRecipe) { string result = null; Invoke(svc => { result = svc.GetXmlRecipeListByPath(pathName, includeUsedRecipe); }); return result; } public bool DeleteRecipeByPath(string pathName, string recipeName) { bool result = false; Invoke(svc => { result = svc.DeleteRecipeByPath(pathName, recipeName); }); return result; } public bool DeleteFolderByPath(string pathName, string folderName) { bool result = false; Invoke(svc => { result = svc.DeleteFolderByPath(pathName, folderName); }); return result; } public bool SaveAsRecipeByPath(string pathName, string recipeName, string recipeContent) { bool result = false; Invoke(svc => { result = svc.SaveAsRecipeByPath(pathName, recipeName, recipeContent); }); return result; } public bool SaveRecipeByPath(string pathName, string recipeName, string recipeContent) { bool result = false; Invoke(svc => { result = svc.SaveRecipeByPath(pathName, recipeName, recipeContent); }); return result; } public bool CreateFolderByPath(string pathName, string folderName) { bool result = false; Invoke(svc => { result = svc.CreateFolderByPath(pathName, folderName); }); return result; } public bool RenameRecipeByPath(string pathName, string oldName, string newName) { bool result = false; Invoke(svc => { result = svc.RenameRecipeByPath(pathName, oldName, newName); }); return result; } public bool RenameFolderByPath(string pathName, string oldName, string newName) { bool result = false; Invoke(svc => { result = svc.RenameFolderByPath(pathName, oldName, newName); }); return result; } public string GetRecipeFormatXmlByPath(string pathName) { string result = null; Invoke(svc => { result = svc.GetRecipeFormatXmlByPath(pathName); }); return result; } public string GetRecipeTemplateByPath(string pathName) { string result = string.Empty; Invoke(svc => { result = svc.GetRecipeTemplateByPath(pathName); }); return result; } public string GetRecipeByBarcodeByPath(string pathName, string barcode) { string result = string.Empty; Invoke(svc => { result = svc.GetRecipeByBarcodeByPath(pathName, barcode); }); return result; } public List GetSequenceList(string recipeType, string sequenceType) { List result = null; Invoke(svc => { result = svc.GetSequenceList(recipeType, sequenceType); }); return result; } #endregion } }