123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.IO;
- using System.Linq;
- using System.Xml;
- using Aitex.Common.Util;
- using Aitex.Core.RT.Event;
- using MECF.Framework.Common.DataCenter;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.Jobs;
- using MECF.Framework.Common.RecipeCenter;
- using MECF.Framework.UI.Client.ClientBase;
- using OpenSEMI.ClientBase;
- using OpenSEMI.ClientBase.ServiceProvider;
- using RecipeEditorLib.DGExtension.CustomColumn;
- namespace MECF.Framework.UI.Client.CenterViews.Editors.Sequence
- {
- public class SequenceDataProvider : IProvider
- {
- private static SequenceDataProvider _Instance = null;
- public static SequenceDataProvider Instance
- {
- get
- {
- if (_Instance == null)
- _Instance = new SequenceDataProvider();
- return _Instance;
- }
- }
- public void Create()
- {
- }
- public bool CreateSequenceFolder(string foldername)
- {
- return RecipeClient.Instance.Service.CreateSequenceFolder(foldername);
- }
- public bool DeleteSequenceFolder(string foldername)
- {
- return RecipeClient.Instance.Service.DeleteSequenceFolder(foldername);
- }
- public bool Save(SequenceData seq)
- {
- //if ((bool)QueryDataClient.Instance.Service.GetData("System.IsAutoMode"))
- //{
- // DialogBox.ShowDialog(DialogButton.OK, 0, "Auto状态下不能对recipe做出修改");
- // return false;
- //}
- var path = GenerateSequenceFilePath("Sequence", seq.Name);
- if (CheckSequenceUsedInJob(path))
- {
- DialogBox.ShowDialog(DialogButton.OK, 0, "Sequence is used in auto running jobs, can not be modified");
- return false;
- }
- return RecipeClient.Instance.Service.SaveSequence(seq.Name, seq.ToXml());
- }
- public List<string> GetSequences()
- {
- return RecipeClient.Instance.Service.GetSequenceNameList();
- }
- public List<string> GetRecipes(ModuleName modulename)
- {
- return RecipeClient.Instance.Service.GetRecipes(modulename, true).ToList();
- }
- public SequenceData GetSequenceByName(ObservableCollection<EditorDataGridTemplateColumnBase> _columns, string name)
- {
- string content = RecipeClient.Instance.Service.GetSequence(name);
- SequenceData seq = new SequenceData();
- XmlDocument doc = new XmlDocument();
- doc.LoadXml(content);
- seq.Name = name;
- seq.Load(_columns, doc);
- return seq;
- }
- public bool Rename(string beforename, string currentname)
- {
- //if ((bool)QueryDataClient.Instance.Service.GetData("System.IsAutoMode"))
- //{
- // DialogBox.ShowDialog(DialogButton.OK, 0, "Auto状态下不能对Sequence做出修改");
- // return false;
- //}
- var path = GenerateSequenceFilePath("Sequence", currentname);
- if (CheckSequenceUsedInJob(path))
- {
- DialogBox.ShowDialog(DialogButton.OK, 0, "Sequence is used in auto running jobs, can not be modified");
- return false;
- }
- return RecipeClient.Instance.Service.RenameSequence(beforename, currentname);
- }
- public bool Delete(string name)
- {
- //if ((bool)QueryDataClient.Instance.Service.GetData("System.IsAutoMode"))
- //{
- // DialogBox.ShowDialog(DialogButton.OK, 0, "Auto状态下不能对Sequence做出修改");
- // return false;
- //}
- var path = GenerateSequenceFilePath("Sequence", name);
- if (CheckSequenceUsedInJob(path))
- {
- DialogBox.ShowDialog(DialogButton.OK, 0, "Sequence is used in auto running jobs, can not be modified");
- return false;
- }
- return RecipeClient.Instance.Service.DeleteSequence(name);
- }
- public bool SaveAs(string name, SequenceData seq)
- {
- //if ((bool)QueryDataClient.Instance.Service.GetData("System.IsAutoMode"))
- //{
- // DialogBox.ShowDialog(DialogButton.OK, 0, "Auto状态下不能对Sequence做出修改");
- // return false;
- //}
- var path = GenerateSequenceFilePath("Sequence", name);
- if (CheckSequenceUsedInJob(path))
- {
- DialogBox.ShowDialog(DialogButton.OK, 0, "Sequence is used in auto running jobs, can not be modified");
- return false;
- }
- return RecipeClient.Instance.Service.SaveAsSequence(name, seq.ToXml());
- }
- public string GetSequenceFromXml()
- {
- string template = RecipeClient.Instance.Service.GetSequenceFormatXml();
- return template;
- }
- private string GenerateSequenceFilePath(string chamId, string recipeName)
- {
- return getRecipeDirPath(chamId) + recipeName + ".seq";
- }
-
- private string getRecipeDirPath(string chamId)
- {
- var dir = string.Format("{0}{1}\\", PathManager.GetRecipeDir(), chamId);
- DirectoryInfo di = new DirectoryInfo(dir);
- if (!di.Exists) di.Create();
- return dir;
- }
-
- public bool CheckSequenceUsedInJob(string pathName)
- {
- List<ProcessJobInfo> ProcessList = (List<ProcessJobInfo>)QueryDataClient.Instance.Service.GetData("Scheduler.CurrentRecipeList");
- if (ProcessList != null)
- {
- foreach (var pj in ProcessList)
- {
- if (pathName.EndsWith(@"\" + pj.Sequence.Name + ".seq", System.StringComparison.OrdinalIgnoreCase))
- return true;
- }
- }
- return false;
- }
- }
- }
|