| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540 | 
							- using System.Collections.Generic;
 
- using System.Collections.ObjectModel;
 
- using System.Linq;
 
- using System.Runtime.Serialization;
 
- using System.Windows;
 
- using System.Windows.Controls;
 
- using System.Xml;
 
- using Aitex.Core.UI.View.Common;
 
- using Caliburn.Micro.Core;
 
- using MECF.Framework.Common.CommonData;
 
- using MECF.Framework.Common.DataCenter;
 
- using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
 
- namespace MECF.Framework.UI.Client.CenterViews.Editors.Sequence
 
- {
 
-     public class FileNode : PropertyChangedBase
 
-     {
 
-         public FileNode()
 
-         {
 
-             this.Files = new ObservableCollection<FileNode>();
 
-             this.IsFile = false;
 
-         }
 
-         public FileNode(FileNodeItem fileNodeItem)
 
-         {
 
-             IsFile = true;
 
-             FullPath = fileNodeItem.FullPath;
 
-             AllParentPath = fileNodeItem.AllParentPath;
 
-             Name = fileNodeItem.Name;
 
-             this.Files = new ObservableCollection<FileNode>();
 
-             PrefixPath = fileNodeItem.PrefixPath;
 
-             Creator = fileNodeItem.Creator;
 
-             Revisor = fileNodeItem.Revisor;
 
-             Description = fileNodeItem.Description;
 
-             CreatTime = fileNodeItem.CreatTime;
 
-             ReviseTime = fileNodeItem.ReviseTime;
 
-             Permission = fileNodeItem.Permission;
 
-             Level = fileNodeItem.Level;
 
-             if (fileNodeItem.Parent != null)
 
-                 Parent = new FileNode(fileNodeItem.Parent);
 
-         }
 
-         private string name = string.Empty;
 
-         public string Name
 
-         {
 
-             get { return name; }
 
-             set { name = value; NotifyOfPropertyChange("Name"); }
 
-         }
 
-         public string FullPath { get; set; }
 
-         public string AllParentPath { get; set; }
 
-         public FileNode Parent { get; set; }
 
-         public ObservableCollection<FileNode> Files { get; set; }
 
-         public bool IsFile { get; set; }
 
-         public string PrefixPath { get; set; }
 
-         private string creator = string.Empty;
 
-         public string Creator
 
-         {
 
-             get { return creator; }
 
-             set { creator = value; NotifyOfPropertyChange("Creator"); }
 
-         }
 
-         private string revisor = string.Empty;
 
-         public string Revisor
 
-         {
 
-             get { return revisor; }
 
-             set { revisor = value; NotifyOfPropertyChange("Revisor"); }
 
-         }
 
-         private string description = string.Empty;
 
-         public string Description
 
-         {
 
-             get { return description; }
 
-             set { description = value; NotifyOfPropertyChange("Description"); }
 
-         }
 
-         private string creatTime = string.Empty;
 
-         public string CreatTime
 
-         {
 
-             get { return creatTime; }
 
-             set { creatTime = value; NotifyOfPropertyChange("CreatTime"); }
 
-         }
 
-         private string reviseTime = string.Empty;
 
-         public string ReviseTime
 
-         {
 
-             get { return reviseTime; }
 
-             set { reviseTime = value; NotifyOfPropertyChange("ReviseTime"); }
 
-         }
 
-         private string permission = string.Empty;
 
-         public string Permission
 
-         {
 
-             get { return permission; }
 
-             set { permission = value; NotifyOfPropertyChange("Permission"); }
 
-         }
 
-         private string level = string.Empty;
 
-         public string Level
 
-         {
 
-             get { return level; }
 
-             set { level = value; NotifyOfPropertyChange("Level"); }
 
-         }
 
-         private bool _IsSelected;
 
-         public bool IsSelected
 
-         {
 
-             get { return _IsSelected; }
 
-             set { _IsSelected = value; NotifyOfPropertyChange("IsSelected"); }
 
-         }
 
-         private bool _isExpanded;
 
-         public bool IsExpanded
 
-         {
 
-             get => _isExpanded;
 
-             set
 
-             {
 
-                 if (_isExpanded != value) {
 
-                     _isExpanded = value;
 
-                     NotifyOfPropertyChange("IsExpanded");
 
-                 };
 
-             }
 
-         }
 
-         private Visibility _IsVisiable;
 
-         public Visibility IsVisiable
 
-         {
 
-             get { return _IsVisiable; }
 
-             set { _IsVisiable = value; NotifyOfPropertyChange("IsVisiable"); }
 
-         }
 
-         private bool _IsChecked;
 
-         public bool IsChecked
 
-         {
 
-             get { return _IsChecked; }
 
-             set { _IsChecked = value; NotifyOfPropertyChange("IsChecked"); }
 
-         }
 
-         private bool _IsBackupSelected;
 
-         public bool IsBackupSelected
 
-         {
 
-             get { return _IsBackupSelected; }
 
-             set
 
-             {
 
-                 _IsBackupSelected = value;
 
-                 if (!IsFile)
 
-                 {
 
-                     foreach (var item in Files)
 
-                     {
 
-                         SetAllChild(item, value);
 
-                     }
 
-                 }
 
-                 NotifyOfPropertyChange("IsBackupSelected");
 
-             }
 
-         }
 
-         private void SetAllChild(FileNode fileNode, bool value)
 
-         {
 
-             if (!fileNode.IsFile)
 
-             {
 
-                 SetAllChild(fileNode, value);
 
-             }
 
-             else
 
-             {
 
-                 fileNode.IsBackupSelected = value;
 
-             }
 
-         }
 
-         private bool _IsEnable;
 
-         public bool IsEnable
 
-         {
 
-             get { return _IsEnable; }
 
-             set { _IsEnable = value; NotifyOfPropertyChange("IsEnable"); }
 
-         }
 
-     }
 
-     public class RecipeSequenceTreeBuilder
 
-     {
 
-         public static List<FileNode> GetFiles(string prefixPath, List<string> filenames)
 
-         {
 
-             List<FileNode> folders = new List<FileNode>();
 
-             FileNode root = new FileNode() { Name = "Files", IsFile = false, FullPath = "", PrefixPath = prefixPath };
 
-             folders.Add(root);
 
-             foreach (string filename in filenames)
 
-             {
 
-                 string[] filesplits = filename.Split('\\');
 
-                 FileNode parent = root;
 
-                 if (filesplits.Length > 1)
 
-                 {
 
-                     for (var index = 0; index < filesplits.Length - 1; index++)
 
-                     {
 
-                         bool found = false;
 
-                         for (var j = 0; j < parent.Files.Count; j++)
 
-                         {
 
-                             if (parent.Files[j].Name == filesplits[index] && !parent.Files[j].IsFile)
 
-                             {
 
-                                 found = true;
 
-                                 parent = parent.Files[j];
 
-                                 break;
 
-                             }
 
-                         }
 
-                         if (!found)
 
-                         {
 
-                             FileNode folder = new FileNode() { Name = filesplits[index], IsFile = false, PrefixPath = prefixPath };
 
-                             folder.FullPath = (parent.FullPath == string.Empty ? filesplits[index] : parent.FullPath + "\\" + filesplits[index]);
 
-                             folder.Parent = parent;
 
-                             parent.Files.Add(folder);
 
-                             parent = folder;
 
-                         }
 
-                     }
 
-                 }
 
-                 FileNode file = new FileNode() { Name = filesplits[filesplits.Length - 1], IsFile = true, PrefixPath = prefixPath };
 
-                 file.FullPath = (parent.FullPath == string.Empty ? filesplits[filesplits.Length - 1] : parent.FullPath + "\\" + filesplits[filesplits.Length - 1]);
 
-                 file.Parent = parent;
 
-                 parent.Files.Add(file);
 
-             }
 
-             return folders;
 
-         }
 
-         static string GetAttributeValueByXmlDoc(XmlDocument _doc, string attributeName)
 
-         {
 
-             XmlElement nodeData = _doc.SelectSingleNode($"Aitex/TableRecipeData") as XmlElement;
 
-             return nodeData.GetAttribute(attributeName);
 
-         }
 
-         static string GetAttributeValue(string prefixPath, string recipeName, string attributeName)
 
-         {
 
-             RecipeProvider _recipeProvider = new RecipeProvider();
 
-             string content = _recipeProvider.LoadRecipe(prefixPath, recipeName);
 
-             XmlDocument _doc = new XmlDocument();
 
-             _doc.LoadXml(content);
 
-             XmlElement nodeData = _doc.SelectSingleNode($"Aitex/TableRecipeData") as XmlElement;
 
-             return nodeData.GetAttribute(attributeName);
 
-         }
 
-         public static void CreateTreeViewItems(XmlElement curElementNode, FileNode parent, string prefixPath, string selectionName, bool selectionIsFolder)
 
-         {
 
-             string currentMode = QueryDataClient.Instance.Service.GetConfig("System.Engineeringmode")?.ToString();
 
-             selectionIsFolder = false;
 
-             foreach (XmlElement ele in curElementNode.ChildNodes)
 
-             {
 
-                 if (ele.Name == "File")
 
-                 {
 
-                     string fileName = ele.Attributes["Name"].Value;
 
-                     fileName = fileName.Substring(fileName.LastIndexOf('\\') + 1);
 
-                     string fullPath = string.IsNullOrEmpty(parent.FullPath)
 
-                         ? fileName
 
-                         : parent.FullPath + "\\" + fileName;
 
-                     RecipeProvider _recipeProvider = new RecipeProvider();
 
-                     string content = _recipeProvider.LoadRecipe(prefixPath, fullPath);
 
-                     XmlDocument _doc = new XmlDocument();
 
-                     _doc.LoadXml(content);
 
-                     if ((content == null) || (content == ""))
 
-                     {
 
-                         continue;
 
-                     }
 
-                     FileNode file = new FileNode()
 
-                     {
 
-                         Name = fileName,
 
-                         IsFile = true,
 
-                         PrefixPath = prefixPath,
 
-                         Parent = parent,
 
-                         FullPath = fullPath,
 
-                         Creator = GetAttributeValueByXmlDoc(_doc, "CreatedBy"),
 
-                         Description = GetAttributeValueByXmlDoc(_doc, "Description"),
 
-                         CreatTime = GetAttributeValueByXmlDoc(_doc, "CreationTime"),
 
-                         ReviseTime = GetAttributeValueByXmlDoc(_doc, "LastRevisionTime"),
 
-                         Revisor = GetAttributeValueByXmlDoc(_doc, "LastRevisedBy"),
 
-                         Permission = GetAttributeValueByXmlDoc(_doc, "RecipePermission"),
 
-                         Level = GetAttributeValueByXmlDoc(_doc, "RecipeLevel"),
 
-                         IsChecked = GetAttributeValueByXmlDoc(_doc, "CheckResult") == "Correct",
 
-                     };
 
-                     string fileMode = string.Empty;
 
-                     if (!string.IsNullOrEmpty(currentMode) && currentMode.Equals("Normal"))
 
-                         file.IsEnable = GetAttributeValueByXmlDoc(_doc, "NormalMode") != "Notuseable";
 
-                     else
 
-                         file.IsEnable = GetAttributeValueByXmlDoc(_doc, "EngineeringMode") != "Notuseable";
 
-                     if (!selectionIsFolder)
 
-                     {
 
-                         if (selectionName == file.FullPath)
 
-                             file.IsSelected = true;
 
-                         else
 
-                             file.IsSelected = false;
 
-                         FileNode node = file.Parent;
 
-                         while (node.FullPath.Contains("\\"))
 
-                         {
 
-                             node.IsExpanded = true;
 
-                             node = node.Parent;
 
-                         }
 
-                         parent.Files.Add(file);
 
-                     }
 
-                 }
 
-                 else if (ele.Name == "Folder")
 
-                 {
 
-                     string folderName = ele.Attributes["Name"].Value;
 
-                     folderName = folderName.Substring(folderName.LastIndexOf('\\') + 1);
 
-                     string fullPath = string.IsNullOrEmpty(parent.FullPath)
 
-                         ? folderName
 
-                         : parent.FullPath + "\\" + folderName;
 
-                     FileNode folder = new FileNode()
 
-                     {
 
-                         Name = folderName,
 
-                         IsFile = false,
 
-                         PrefixPath = prefixPath,
 
-                         Parent = parent,
 
-                         FullPath = fullPath,
 
-                         IsExpanded = !fullPath.Contains("\\"),
 
-                         IsChecked = true,
 
-                         IsEnable = true
 
-                     };
 
-                     parent.Files.Add(folder);
 
-                     if (selectionIsFolder && selectionName == folder.FullPath)
 
-                     {
 
-                         folder.IsSelected = true;
 
-                         FileNode node = folder;
 
-                         while (node.FullPath.Contains("\\"))
 
-                         {
 
-                             node.IsExpanded = true;
 
-                             node = node.Parent;
 
-                         }
 
-                     }
 
-                     CreateTreeViewItems(ele, folder, prefixPath, selectionName, selectionIsFolder);
 
-                 }
 
-             }
 
-         }
 
-         static string GetRestoreAttributeValue(string prefixPath, string recipeName, string attributeName)
 
-         {
 
-             RecipeProvider _recipeProvider = new RecipeProvider();
 
-             string content = _recipeProvider.LoadRestoreRecipe(prefixPath, recipeName);
 
-             XmlDocument _doc = new XmlDocument();
 
-             _doc.LoadXml(content);
 
-             XmlElement nodeData = _doc.SelectSingleNode($"Aitex/TableRecipeData") as XmlElement;
 
-             return nodeData.GetAttribute(attributeName);
 
-         }
 
-         public static void CreateRestoreTreeViewItems(XmlElement curElementNode, FileNode parent, string prefixPath, string selectionName, bool selectionIsFolder)
 
-         {
 
-             selectionIsFolder = false;
 
-             foreach (XmlElement ele in curElementNode.ChildNodes)
 
-             {
 
-                 if (ele.Name == "File")
 
-                 {
 
-                     string fileName = ele.Attributes["Name"].Value;
 
-                     fileName = fileName.Substring(fileName.LastIndexOf('\\') + 1);
 
-                     string fullPath = string.IsNullOrEmpty(parent.FullPath)
 
-                         ? fileName
 
-                         : parent.FullPath + "\\" + fileName;
 
-                     FileNode file = new FileNode()
 
-                     {
 
-                         Name = fileName,
 
-                         IsFile = true,
 
-                         PrefixPath = prefixPath,
 
-                         Parent = parent,
 
-                         FullPath = fullPath,
 
-                         Creator = GetRestoreAttributeValue(prefixPath, fullPath, "CreatedBy"),
 
-                         Description = GetRestoreAttributeValue(prefixPath, fullPath, "Description"),
 
-                         CreatTime = GetRestoreAttributeValue(prefixPath, fullPath, "CreationTime"),
 
-                         ReviseTime = GetRestoreAttributeValue(prefixPath, fullPath, "LastRevisionTime"),
 
-                         Revisor = GetRestoreAttributeValue(prefixPath, fullPath, "LastRevisedBy"),
 
-                         Permission = GetRestoreAttributeValue(prefixPath, fullPath, "RecipePermission"),
 
-                         Level = GetRestoreAttributeValue(prefixPath, fullPath, "RecipeLevel"),
 
-                     };
 
-                     if (!selectionIsFolder)
 
-                     {
 
-                         file.IsSelected = true;
 
-                         FileNode node = file.Parent;
 
-                         while (node.FullPath.Contains("\\"))
 
-                         {
 
-                             node.IsExpanded = true;
 
-                             node = node.Parent;
 
-                         }
 
-                         parent.Files.Add(file);
 
-                     }
 
-                 }
 
-                 else if (ele.Name == "Folder")
 
-                 {
 
-                     string folderName = ele.Attributes["Name"].Value;
 
-                     folderName = folderName.Substring(folderName.LastIndexOf('\\') + 1);
 
-                     string fullPath = string.IsNullOrEmpty(parent.FullPath)
 
-                         ? folderName
 
-                         : parent.FullPath + "\\" + folderName;
 
-                     FileNode folder = new FileNode()
 
-                     {
 
-                         Name = folderName,
 
-                         IsFile = false,
 
-                         PrefixPath = prefixPath,
 
-                         Parent = parent,
 
-                         FullPath = fullPath,
 
-                         IsExpanded = !fullPath.Contains("\\"),
 
-                     };
 
-                     parent.Files.Add(folder);
 
-                     if (selectionIsFolder && selectionName == folder.FullPath)
 
-                     {
 
-                         folder.IsSelected = true;
 
-                         FileNode node = folder;
 
-                         while (node.FullPath.Contains("\\"))
 
-                         {
 
-                             node.IsExpanded = true;
 
-                             node = node.Parent;
 
-                         }
 
-                     }
 
-                     CreateRestoreTreeViewItems(ele, folder, prefixPath, selectionName, selectionIsFolder);
 
-                 }
 
-             }
 
-         }
 
-         public static List<FileNode> BuildFileNode(string prefixPath, string selectionName, bool selectionIsFolder, string fileListInXml)
 
-         {
 
-             List<FileNode> folders = new List<FileNode>();
 
-             FileNode root = new FileNode() { Name = "Files", IsFile = false, FullPath = "", PrefixPath = prefixPath };
 
-             folders.Add(root);
 
-             XmlDocument doc = new XmlDocument();
 
-             doc.LoadXml(fileListInXml);
 
-             CreateTreeViewItems(doc.DocumentElement, root, prefixPath, selectionName, selectionIsFolder);
 
-             return folders;
 
-         }
 
-         public static List<FileNode> BuildRestoreFileNode(string prefixPath, string selectionName, bool selectionIsFolder, string fileListInXml)
 
-         {
 
-             List<FileNode> folders = new List<FileNode>();
 
-             FileNode root = new FileNode() { Name = "Files", IsFile = false, FullPath = "", PrefixPath = prefixPath };
 
-             folders.Add(root);
 
-             XmlDocument doc = new XmlDocument();
 
-             doc.LoadXml(fileListInXml);
 
-             CreateRestoreTreeViewItems(doc.DocumentElement, root, prefixPath, selectionName, selectionIsFolder);
 
-             return folders;
 
-         }
 
-         public static ObservableCollection<FileNode> GetFileNodeParameterList(string prefixPath)
 
-         {
 
-             RecipeProvider _recipeProvider = new RecipeProvider();
 
-             ObservableCollection<FileNode> fileList = new ObservableCollection<FileNode>();
 
-             var tempfiles = _recipeProvider.GetFileNodeParameterList(prefixPath);
 
-             FileNodeItemToFileNode(fileList, tempfiles);
 
-             FileNodeParent(fileList);
 
-             FileNodeAllParentPath(fileList);
 
-             return fileList;
 
-         }
 
-         private static void FileNodeAllParentPath(ObservableCollection<FileNode> fileList)
 
-         {
 
-             foreach (var item in fileList)
 
-             {
 
-                 if (item.Files != null && item.Files.Count > 0)
 
-                 {
 
-                     FileNodeAllParentPath(item.Files);
 
-                 }
 
-                 if (item.Parent != null)
 
-                 {
 
-                     List<string> allParentName = new List<string>();
 
-                     SetFileNodeAllParentPath(item, allParentName);
 
-                     if (allParentName != null && allParentName.Count > 0)
 
-                     {
 
-                         allParentName.RemoveAt(0);
 
-                         allParentName.Reverse();
 
-                         item.AllParentPath = string.Join("\\", allParentName);
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         private static void SetFileNodeAllParentPath(FileNode fileNode, List<string> allParentName)
 
-         {
 
-             allParentName.Add(fileNode.Name);
 
-             if (fileNode.Parent == null)
 
-             {
 
-                 return;
 
-             }
 
-             SetFileNodeAllParentPath(fileNode.Parent, allParentName);
 
-         }
 
-         private static void FileNodeParent(ObservableCollection<FileNode> fileList)
 
-         {
 
-             foreach (var item in fileList)
 
-             {
 
-                 if (item.Files == null || item.Files.Count == 0)
 
-                 {
 
-                     continue;
 
-                 }
 
-                 SetFileNodeParent(item);
 
-             }
 
-         }
 
-         private static void SetFileNodeParent(FileNode fileNode)
 
-         {
 
-             if (fileNode.Files == null || fileNode.Files.Count == 0)
 
-             {
 
-                 return;
 
-             }
 
-             foreach (var item in fileNode.Files)
 
-             {
 
-                 item.Parent = fileNode;
 
-                 SetFileNodeParent(item);
 
-             }
 
-         }
 
-         private static void FileNodeItemToFileNode(ObservableCollection<FileNode> fileList, List<FileNodeItem> fileNodeItems)
 
-         {
 
-             foreach (var item in fileNodeItems)
 
-             {
 
-                 if (item.IsFile)
 
-                 {
 
-                     fileList.Add(new FileNode(item));
 
-                 }
 
-                 else
 
-                 {
 
-                     GetSubFiles(item).ForEach(x => fileList.Add(x));
 
-                 }
 
-             }
 
-         }
 
-         private static List<FileNode> GetSubFiles(FileNodeItem fileNodeItem)
 
-         {
 
-             List<FileNode> fileNodeList = new List<FileNode>();
 
-             foreach (var item in fileNodeItem.Files)
 
-             {
 
-                 if (item.IsFile)
 
-                 {
 
-                     fileNodeList.Add(new FileNode(item));
 
-                 }
 
-                 else
 
-                 {
 
-                     FileNode fileNode = new FileNode();
 
-                     fileNode.Name = item.Name;
 
-                     fileNode.FullPath = item.FullPath;
 
-                     fileNode.PrefixPath = item.PrefixPath;
 
-                     fileNode.IsFile = false;
 
-                     GetSubFiles(item).ForEach(x => fileNode.Files.Add(x));
 
-                     fileNodeList.Add(fileNode);
 
-                 }
 
-             }
 
-             return fileNodeList;
 
-         }
 
-     }
 
- }
 
 
  |