| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.Collections.ObjectModel;
 
- using System.Linq;
 
- using System.Windows;
 
- using System.Windows.Controls;
 
- using System.Xml;
 
- using Aitex.Core.RT.Log;
 
- using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;
 
- using RecipeEditorLib.DGExtension.CustomColumn;
 
- using RecipeEditorLib.RecipeModel.Params;
 
- namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
 
- {
 
-     public class RecipeFormatBuilder
 
-     {
 
-         public ObservableCollection<EditorDataGridTemplateColumnBase> Columns
 
-         {
 
-             get;
 
-             set;
 
-         }
 
-         public ObservableCollection<Param> Configs
 
-         {
 
-             get;
 
-             set;
 
-         }
 
-         public ObservableCollection<Param> OesConfig
 
-         {
 
-             get;
 
-             set;
 
-         }
 
-         public ObservableCollection<Param> VatConfig
 
-         {
 
-             get;
 
-             set;
 
-         }
 
-         public ObservableCollection<Param> BrandConfig
 
-         {
 
-             get;
 
-             set;
 
-         }
 
-         public ObservableCollection<Param> FineTuningConfig
 
-         {
 
-             get;
 
-             set;
 
-         }
 
-         public string RecipeChamberType
 
-         {
 
-             get;
 
-             set;
 
-         }
 
-         public string RecipeVersion
 
-         {
 
-             get;
 
-             set;
 
-         }
 
-         private RecipeProvider recipeProvider = new RecipeProvider();
 
-         public ObservableCollection<EditorDataGridTemplateColumnBase> Build(string path)
 
-         {
 
-             var str = recipeProvider.GetRecipeFormatXml(path);
 
-             string configstr = "";
 
-             if (path == "PM1")
 
-             {
 
-                 configstr = "Process";
 
-             }
 
-             else
 
-             {
 
-                 configstr = path;
 
-             }
 
-             XmlDocument doc = new XmlDocument();
 
-             try
 
-             {
 
-                 doc.LoadXml(str);
 
-                 XmlNode nodeRoot = doc.SelectSingleNode("TableRecipeFormat");
 
-                 RecipeChamberType = nodeRoot.Attributes["RecipeChamberType"].Value;
 
-                 RecipeVersion = nodeRoot.Attributes["RecipeVersion"].Value;
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 LOG.Write(ex);
 
-                 return null;
 
-             }
 
-             var columns = new ObservableCollection<EditorDataGridTemplateColumnBase>();
 
-             EditorDataGridTemplateColumnBase col = null;
 
-             XmlNodeList nodes = doc.SelectNodes("TableRecipeFormat/Catalog/Group");
 
-             foreach (XmlNode node in nodes)
 
-             {
 
-                 columns.Add(new ExpanderColumn()
 
-                 {
 
-                     DisplayName = node.Attributes["DisplayName"].Value,
 
-                     StringCellTemplate = "TemplateExpander",
 
-                     StringHeaderTemplate = "ParamExpander"
 
-                 });
 
-                 XmlNodeList childNodes = node.SelectNodes("Step");
 
-                 foreach (XmlNode step in childNodes)
 
-                 {
 
-                     //step number
 
-                     if (step.Attributes["ControlName"].Value == "StepNo")
 
-                     {
 
-                         col = new StepColumn()
 
-                         {
 
-                             DisplayName = "Step",
 
-                             ControlName = "StepNo",
 
-                             StringCellTemplate = "TemplateStep",
 
-                             StringHeaderTemplate = "ParamTemplate"
 
-                         };
 
-                         columns.Add(col);
 
-                         continue;
 
-                     }
 
-                     switch (step.Attributes["InputType"].Value)
 
-                     {
 
-                         case "TextInput":
 
-                             col = new TextBoxColumn()
 
-                             {
 
-                                 ModuleName = step.Attributes["ModuleName"].Value,
 
-                                 ControlName = step.Attributes["ControlName"].Value,
 
-                                 DisplayName = step.Attributes["DisplayName"].Value,
 
-                                 StringCellTemplate = "TemplateText",
 
-                                 StringHeaderTemplate = "ParamTemplate",
 
-                                 EnableConfig = step.Attributes["EnableConfig"] != null && Convert.ToBoolean(step.Attributes["EnableConfig"].Value),
 
-                                 EnableTolerance = step.Attributes["EnableTolerance"] != null && Convert.ToBoolean(step.Attributes["EnableTolerance"].Value),
 
-                             };
 
-                             columns.Add(col);
 
-                             break;
 
-                         case "ReadOnly":
 
-                             col = new TextBoxColumn()
 
-                             {
 
-                                 ModuleName = step.Attributes["ModuleName"].Value,
 
-                                 ControlName = step.Attributes["ControlName"].Value,
 
-                                 DisplayName = step.Attributes["DisplayName"].Value,
 
-                                 StringCellTemplate = "TemplateText",
 
-                                 StringHeaderTemplate = "ParamTemplate",
 
-                                 IsReadOnly = true,
 
-                                 EnableConfig = step.Attributes["EnableConfig"] != null && Convert.ToBoolean(step.Attributes["EnableConfig"].Value),
 
-                                 EnableTolerance = step.Attributes["EnableTolerance"] != null && Convert.ToBoolean(step.Attributes["EnableTolerance"].Value),
 
-                             };
 
-                             columns.Add(col);
 
-                             break;
 
-                         case "NumInput":
 
-                             col = new NumColumn()
 
-                             {
 
-                                 ModuleName = step.Attributes["ModuleName"].Value,
 
-                                 ControlName = step.Attributes["ControlName"].Value,
 
-                                 DisplayName = step.Attributes["DisplayName"].Value,
 
-                                 InputMode = step.Attributes["InputMode"].Value,
 
-                                 Minimun = double.Parse(step.Attributes["Min"].Value),
 
-                                 Maximun = double.Parse(step.Attributes["Max"].Value),
 
-                                 StringCellTemplate = "TemplateNumber",
 
-                                 StringHeaderTemplate = "ParamTemplate",
 
-                                 EnableConfig = step.Attributes["EnableConfig"] != null && Convert.ToBoolean(step.Attributes["EnableConfig"].Value),
 
-                                 EnableTolerance = step.Attributes["EnableTolerance"] != null && Convert.ToBoolean(step.Attributes["EnableTolerance"].Value),
 
-                             };
 
-                             columns.Add(col);
 
-                             break;
 
-                         case "DoubleInput":
 
-                             col = new DoubleColumn()
 
-                             {
 
-                                 ModuleName = step.Attributes["ModuleName"].Value,
 
-                                 ControlName = step.Attributes["ControlName"].Value,
 
-                                 DisplayName = step.Attributes["DisplayName"].Value,
 
-                                 InputMode = step.Attributes["InputMode"].Value,
 
-                                 Minimun = double.Parse(step.Attributes["Min"].Value),
 
-                                 Maximun = double.Parse(step.Attributes["Max"].Value),
 
-                                 StringCellTemplate = "TemplateNumber",
 
-                                 StringHeaderTemplate = "ParamTemplate",
 
-                                 EnableConfig = step.Attributes["EnableConfig"] != null && Convert.ToBoolean(step.Attributes["EnableConfig"].Value),
 
-                                 EnableTolerance = step.Attributes["EnableTolerance"] != null && Convert.ToBoolean(step.Attributes["EnableTolerance"].Value),
 
-                             };
 
-                             columns.Add(col);
 
-                             break;
 
-                         case "EditableSelection":
 
-                         case "ReadOnlySelection":
 
-                             col = new ComboxColumn()
 
-                             {
 
-                                 IsReadOnly = step.Attributes["InputType"].Value == "ReadOnlySelection",
 
-                                 ModuleName = step.Attributes["ModuleName"].Value,
 
-                                 Default = step.Attributes["Default"] != null ? step.Attributes["Default"].Value : "",
 
-                                 ControlName = step.Attributes["ControlName"].Value,
 
-                                 DisplayName = step.Attributes["DisplayName"].Value,
 
-                                 StringCellTemplate = "TemplateCombox",
 
-                                 StringHeaderTemplate = "ParamTemplate",
 
-                                 EnableConfig = step.Attributes["EnableConfig"] != null && Convert.ToBoolean(step.Attributes["EnableConfig"].Value),
 
-                                 EnableTolerance = step.Attributes["EnableTolerance"] != null && Convert.ToBoolean(step.Attributes["EnableTolerance"].Value),
 
-                             };
 
-                             XmlNodeList items = step.SelectNodes("Item");
 
-                             foreach (XmlNode item in items)
 
-                             {
 
-                                 ComboxColumn.Option opt = new ComboxColumn.Option();
 
-                                 opt.ControlName = item.Attributes["ControlName"].Value;
 
-                                 opt.DisplayName = item.Attributes["DisplayName"].Value;
 
-                                 ((ComboxColumn)col).Options.Add(opt);
 
-                             }
 
-                             columns.Add(col);
 
-                             break;
 
-                         case "LoopSelection":
 
-                             col = new LoopComboxColumn()
 
-                             {
 
-                                 IsReadOnly = false,
 
-                                 ModuleName = step.Attributes["ModuleName"].Value,
 
-                                 ControlName = step.Attributes["ControlName"].Value,
 
-                                 DisplayName = step.Attributes["DisplayName"].Value,
 
-                                 StringCellTemplate = "TemplateCombox",
 
-                                 StringHeaderTemplate = "ParamTemplate",
 
-                                 EnableConfig = step.Attributes["EnableConfig"] != null && Convert.ToBoolean(step.Attributes["EnableConfig"].Value),
 
-                                 EnableTolerance = step.Attributes["EnableTolerance"] != null && Convert.ToBoolean(step.Attributes["EnableTolerance"].Value),
 
-                             };
 
-                             XmlNodeList options = step.SelectNodes("Item");
 
-                             foreach (XmlNode item in options)
 
-                             {
 
-                                 LoopComboxColumn.Option opt = new LoopComboxColumn.Option();
 
-                                 opt.ControlName = item.Attributes["ControlName"].Value;
 
-                                 opt.DisplayName = item.Attributes["DisplayName"].Value;
 
-                                 ((LoopComboxColumn)col).Options.Add(opt);
 
-                             }
 
-                             columns.Add(col);
 
-                             break;
 
-                         case "PopSetting":
 
-                             col = new PopSettingColumn()
 
-                             {
 
-                                 ModuleName = step.Attributes["ModuleName"].Value,
 
-                                 ControlName = step.Attributes["ControlName"].Value,
 
-                                 DisplayName = step.Attributes["DisplayName"].Value,
 
-                                 StringCellTemplate = "TemplatePopSetting",
 
-                                 StringHeaderTemplate = "ParamTemplate",
 
-                                 EnableConfig = step.Attributes["EnableConfig"] != null && Convert.ToBoolean(step.Attributes["EnableConfig"].Value),
 
-                                 EnableTolerance = step.Attributes["EnableTolerance"] != null && Convert.ToBoolean(step.Attributes["EnableTolerance"].Value),
 
-                             };
 
-                             columns.Add(col);
 
-                             break;
 
-                     }
 
-                 }
 
-             }
 
-             Columns = columns;
 
-             var configs = new ObservableCollection<Param>();
 
-             nodes = doc.SelectNodes($"TableRecipeFormat/{configstr}Config/Configs");
 
-             foreach (XmlNode node in nodes)
 
-             {
 
-                 XmlNodeList childNodes = node.SelectNodes("Config");
 
-                 foreach (XmlNode configNode in childNodes)
 
-                 {
 
-                     switch (configNode.Attributes["InputType"].Value)
 
-                     {
 
-                         case "DoubleInput":
 
-                             var config = new DoubleParam()
 
-                             {
 
-                                 Name = configNode.Attributes["ControlName"].Value,
 
-                                 Value = configNode.Attributes["Default"].Value,
 
-                                 DisplayName = configNode.Attributes["DisplayName"].Value,
 
-                                 EnableConfig = configNode.Attributes["EnableConfig"] != null && Convert.ToBoolean(configNode.Attributes["EnableConfig"].Value),
 
-                                 EnableTolerance = configNode.Attributes["EnableTolerance"] != null && Convert.ToBoolean(configNode.Attributes["EnableTolerance"].Value),
 
-                             };
 
-                             if (double.TryParse(configNode.Attributes["Max"].Value, out double max))
 
-                             {
 
-                                 (config as DoubleParam).Maximun = max;
 
-                             }
 
-                             if (double.TryParse(configNode.Attributes["Min"].Value, out double min))
 
-                             {
 
-                                 (config as DoubleParam).Minimun = min;
 
-                             }
 
-                             configs.Add(config);
 
-                             break;
 
-                         case "NumInput":
 
-                             var numConfig = new NumParam()
 
-                             {
 
-                                 Name = configNode.Attributes["ControlName"].Value,
 
-                                 Value = int.Parse(configNode.Attributes["Default"].Value),
 
-                                 DisplayName = configNode.Attributes["DisplayName"].Value,
 
-                                 EnableConfig = configNode.Attributes["EnableConfig"] != null && Convert.ToBoolean(configNode.Attributes["EnableConfig"].Value),
 
-                                 EnableTolerance = configNode.Attributes["EnableTolerance"] != null && Convert.ToBoolean(configNode.Attributes["EnableTolerance"].Value),
 
-                             };
 
-                             if (double.TryParse(configNode.Attributes["Max"].Value, out  max))
 
-                             {
 
-                                 (numConfig as NumParam).Maximun = max;
 
-                             }
 
-                             if (double.TryParse(configNode.Attributes["Min"].Value, out  min))
 
-                             {
 
-                                 (numConfig as NumParam).Minimun = min;
 
-                             }
 
-                             configs.Add(numConfig);
 
-                             break;
 
-                         case "TextInput":
 
-                             var strConfig = new StringParam()
 
-                             {
 
-                                 Name = configNode.Attributes["ControlName"].Value,
 
-                                 Value = configNode.Attributes["Default"].Value,
 
-                                 DisplayName = configNode.Attributes["DisplayName"].Value,
 
-                                 EnableConfig = configNode.Attributes["EnableConfig"] != null && Convert.ToBoolean(configNode.Attributes["EnableConfig"].Value),
 
-                                 EnableTolerance = configNode.Attributes["EnableTolerance"] != null && Convert.ToBoolean(configNode.Attributes["EnableTolerance"].Value),
 
-                             };
 
-                             configs.Add(strConfig);
 
-                             break;
 
-                     }
 
-                 }
 
-             }
 
-             Configs = configs;
 
-             BrandConfig = GetConfig(doc.SelectNodes("TableRecipeFormat/BrandConfig/Configs"));
 
-             OesConfig = GetConfig(doc.SelectNodes("TableRecipeFormat/OesConfig/Configs"));
 
-             VatConfig = GetConfig(doc.SelectNodes("TableRecipeFormat/VatConfig/Configs"));
 
-             FineTuningConfig = GetConfig(doc.SelectNodes("TableRecipeFormat/FineTuningConfig/Configs"));
 
-             return Columns;
 
-         }
 
-         private ObservableCollection<Param> GetConfig(XmlNodeList nodes)
 
-         {
 
-             var configs = new ObservableCollection<Param>();
 
-             foreach (XmlNode node in nodes)
 
-             {
 
-                 XmlNodeList childNodes = node.SelectNodes("Config");
 
-                 foreach (XmlNode configNode in childNodes)
 
-                 {
 
-                     switch (configNode.Attributes["InputType"].Value)
 
-                     {
 
-                         case "TextInput":
 
-                             var text = new StringParam()
 
-                             {
 
-                                 Name = configNode.Attributes["ControlName"].Value,
 
-                                 Value = configNode.Attributes["Default"].Value,
 
-                                 DisplayName = configNode.Attributes["DisplayName"].Value,
 
-                             };
 
-                             configs.Add(text);
 
-                             break;
 
-                         case "DoubleInput":
 
-                             var config = new DoubleParam()
 
-                             {
 
-                                 Name = configNode.Attributes["ControlName"].Value,
 
-                                 Value = configNode.Attributes["Default"].Value,
 
-                                 DisplayName = configNode.Attributes["DisplayName"].Value,
 
-                             };
 
-                             if (double.TryParse(configNode.Attributes["Max"].Value, out double max))
 
-                             {
 
-                                 (config as DoubleParam).Maximun = max;
 
-                             }
 
-                             if (double.TryParse(configNode.Attributes["Min"].Value, out double min))
 
-                             {
 
-                                 (config as DoubleParam).Minimun = min;
 
-                             }
 
-                             configs.Add(config);
 
-                             break;
 
-                         case "ReadOnlySelection":
 
-                             var col = new ComboxParam()
 
-                             {
 
-                                 Name = configNode.Attributes["ControlName"].Value,
 
-                                 DisplayName = configNode.Attributes["DisplayName"].Value,
 
-                                 Value = configNode.Attributes["Default"] != null ? configNode.Attributes["Default"].Value : "",
 
-                                 Options = new ObservableCollection<ComboxColumn.Option>(),
 
-                                 IsEditable = configNode.Attributes["InputType"].Value == "ReadOnlySelection",
 
-                                 EnableTolerance = configNode.Attributes["EnableTolerance"] != null && Convert.ToBoolean(configNode.Attributes["EnableTolerance"].Value),
 
-                             };
 
-                             XmlNodeList items = configNode.SelectNodes("Item");
 
-                             foreach (XmlNode item in items)
 
-                             {
 
-                                 ComboxColumn.Option opt = new ComboxColumn.Option();
 
-                                 opt.ControlName = item.Attributes["ControlName"].Value;
 
-                                 opt.DisplayName = item.Attributes["DisplayName"].Value;
 
-                                 col.Options.Add(opt);
 
-                             }
 
-                             col.Value = !string.IsNullOrEmpty(col.Value) ? col.Value : (col.Options.Count > 0 ? col.Options[0].ControlName : "");
 
-                             configs.Add(col);
 
-                             break;
 
-                     }
 
-                 }
 
-             }
 
-             return configs;
 
-         }
 
-         public static void ApplyTemplate(UserControl uc, ObservableCollection<EditorDataGridTemplateColumnBase> columns)
 
-         {
 
-             columns.ToList().ForEach(col =>
 
-             {
 
-                 col.CellTemplate = (DataTemplate)uc.FindResource(col.StringCellTemplate);
 
-                 col.HeaderTemplate = (DataTemplate)uc.FindResource(col.StringHeaderTemplate);
 
-             });
 
-         }
 
-     }
 
- }
 
 
  |