2023-04-13 11:51:03 +08:00
|
|
|
|
using System;
|
2023-05-10 16:21:45 +08:00
|
|
|
|
using System.Collections.Generic;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Xml;
|
|
|
|
|
using Aitex.Core.RT.Log;
|
|
|
|
|
using MECF.Framework.UI.Client.CenterViews.Configs.Roles;
|
|
|
|
|
using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;
|
|
|
|
|
using MECF.Framework.UI.Client.ClientBase;
|
2023-05-10 16:21:45 +08:00
|
|
|
|
using MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn;
|
|
|
|
|
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
using Sicentury.Core;
|
|
|
|
|
|
2023-05-10 16:21:45 +08:00
|
|
|
|
namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
|
|
|
|
public class RecipeFormatBuilder
|
|
|
|
|
{
|
2023-06-15 19:19:41 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 步骤起始编号。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const int STEP_INDEX_BASE = 1;
|
|
|
|
|
|
2023-06-13 16:10:57 +08:00
|
|
|
|
public const string SPEC_COL_STEPNO = "StepNo";
|
|
|
|
|
public const string SPEC_COL_STEPUID = "StepUid";
|
|
|
|
|
|
2023-06-16 09:51:51 +08:00
|
|
|
|
#region RecipeFormat.xml模板文件中使用的Node、Attribute名称
|
|
|
|
|
|
|
|
|
|
private const string NAME_NODE_TABLE_RECIPE_FORMAT = "TableRecipeFormat";
|
|
|
|
|
private const string NAME_NODE_CATALOG = "Catalog";
|
|
|
|
|
private const string NAME_NODE_GROUP = "Group";
|
|
|
|
|
private const string NAME_NODE_STEP = "Step";
|
|
|
|
|
private const string NAME_ATTR_CHAMBER_TYPE = "RecipeChamberType";
|
|
|
|
|
private const string NAME_ATTR_VERSION = "RecipeVersion";
|
|
|
|
|
private const string NAME_ATTR_MODULE_NAME = "ModuleName";
|
|
|
|
|
private const string NAME_ATTR_CONTROL_NAME = "ControlName";
|
|
|
|
|
private const string NAME_ATTR_DISPLAY_NAME = "DisplayName";
|
|
|
|
|
private const string NAME_ATTR_UNIT_NAME = "UnitName";
|
|
|
|
|
|
|
|
|
|
private const string PATH_GROUP = $"{NAME_NODE_TABLE_RECIPE_FORMAT}/{NAME_NODE_CATALOG}/{NAME_NODE_GROUP}";
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Variables
|
|
|
|
|
|
|
|
|
|
private readonly RecipeProvider _recipeProvider = new();
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Properties
|
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public ObservableCollection<RecipeInfo> RecipeInfos
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ObservableCollection<StepInfo> StepInfos
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ObservableCollection<ContentInfo> ContentInfos
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RecipeStep Configs
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RecipeStep OesConfig
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RecipeStep VatConfig
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
2023-06-16 09:51:51 +08:00
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public RecipeStep BrandConfig
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RecipeStep FineTuningConfig
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string RecipeChamberType
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string RecipeVersion
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
2023-06-16 09:51:51 +08:00
|
|
|
|
|
|
|
|
|
public List<EditorDataGridTemplateColumnBase> Columns
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Methods
|
|
|
|
|
|
|
|
|
|
private RecipeStep GetConfig(XmlNodeList nodes)
|
|
|
|
|
{
|
|
|
|
|
var configs = new RecipeStep(null);
|
|
|
|
|
foreach (XmlNode node in nodes)
|
|
|
|
|
{
|
|
|
|
|
var childNodes = node.SelectNodes("Config");
|
|
|
|
|
foreach (XmlNode configNode in childNodes)
|
|
|
|
|
{
|
|
|
|
|
switch (configNode.Attributes["InputType"].Value)
|
|
|
|
|
{
|
|
|
|
|
case "TextInput":
|
|
|
|
|
var text = new StringParam(configNode.Attributes["Default"].Value)
|
|
|
|
|
{
|
|
|
|
|
Name = configNode.Attributes[NAME_ATTR_CONTROL_NAME].Value,
|
|
|
|
|
DisplayName = configNode.Attributes[NAME_ATTR_DISPLAY_NAME].Value,
|
|
|
|
|
};
|
|
|
|
|
configs.Add(text);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "Set3RatioInput":
|
|
|
|
|
var param = new Sets3RatioParam()
|
|
|
|
|
{
|
|
|
|
|
Name = configNode.Attributes[NAME_ATTR_CONTROL_NAME].Value,
|
|
|
|
|
DisplayName = configNode.Attributes[NAME_ATTR_DISPLAY_NAME].Value
|
|
|
|
|
};
|
|
|
|
|
configs.Add(param);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "DoubleInput":
|
|
|
|
|
var config = new DoubleParam(GlobalDefs.TryParseToDouble(configNode.Attributes["Default"].Value))
|
|
|
|
|
{
|
|
|
|
|
Name = configNode.Attributes[NAME_ATTR_CONTROL_NAME].Value,
|
|
|
|
|
DisplayName = configNode.Attributes[NAME_ATTR_DISPLAY_NAME].Value,
|
|
|
|
|
};
|
|
|
|
|
if (double.TryParse(configNode.Attributes["Max"].Value, out var max))
|
|
|
|
|
{
|
|
|
|
|
(config as DoubleParam).Maximun = max;
|
|
|
|
|
}
|
|
|
|
|
if (double.TryParse(configNode.Attributes["Min"].Value, out var min))
|
|
|
|
|
{
|
|
|
|
|
(config as DoubleParam).Minimun = min;
|
|
|
|
|
}
|
|
|
|
|
configs.Add(config);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "ReadOnlySelection":
|
|
|
|
|
|
|
|
|
|
var col = new ComboxParam()
|
|
|
|
|
{
|
|
|
|
|
Name = configNode.Attributes[NAME_ATTR_CONTROL_NAME].Value,
|
|
|
|
|
DisplayName = configNode.Attributes[NAME_ATTR_DISPLAY_NAME].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),
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
var items = configNode.SelectNodes("Item");
|
|
|
|
|
foreach (XmlNode item in items)
|
|
|
|
|
{
|
|
|
|
|
var opt = new ComboxColumn.Option
|
|
|
|
|
{
|
|
|
|
|
ControlName = item.Attributes[NAME_ATTR_CONTROL_NAME].Value,
|
|
|
|
|
DisplayName = item.Attributes[NAME_ATTR_DISPLAY_NAME].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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 去除小数点、箭头、括号(含括号里的内容)、横杠
|
|
|
|
|
/// </summary>
|
2023-06-16 09:51:51 +08:00
|
|
|
|
/// <param name="displayName"></param>
|
|
|
|
|
/// <param name="bracket">新增参数,括号及其内容可以不去除</param>
|
2023-04-13 11:51:03 +08:00
|
|
|
|
/// <returns></returns>
|
2023-06-16 09:51:51 +08:00
|
|
|
|
private string strAbc(string displayName, bool bracket = true)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
if (Regex.IsMatch(displayName.Substring(0, 1), @"^[+-]?\d*[.]?\d*$"))
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
displayName = displayName.Remove(0, displayName.IndexOf(".") + 1); //去除序号
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
2023-06-16 09:51:51 +08:00
|
|
|
|
|
|
|
|
|
displayName = displayName.Trim().Replace(" ", "").Replace(".", "").Replace("->", "_").Replace("-", "");
|
|
|
|
|
if (bracket)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
if (displayName.Contains("(") && displayName.Contains(")"))
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
displayName = displayName.Remove(displayName.IndexOf("("),
|
|
|
|
|
displayName.IndexOf(")") - displayName.IndexOf("(") + 1);
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-16 09:51:51 +08:00
|
|
|
|
|
|
|
|
|
return displayName;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
2023-06-16 09:51:51 +08:00
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public double GetDoubleValueByName(string module, string name)
|
|
|
|
|
{
|
|
|
|
|
var value = SystemConfigProvider.Instance.GetValueByName(module, name);
|
|
|
|
|
double returnValue = 0;
|
2023-06-16 09:51:51 +08:00
|
|
|
|
if (string.IsNullOrEmpty(value))
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
|
|
|
|
if (name.EndsWith(".Default"))
|
|
|
|
|
{
|
|
|
|
|
returnValue = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (name.EndsWith(".Min"))
|
|
|
|
|
{
|
|
|
|
|
returnValue = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (name.EndsWith(".Max"))
|
|
|
|
|
{
|
|
|
|
|
returnValue = 10000;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
returnValue = double.Parse(value);
|
|
|
|
|
}
|
|
|
|
|
return returnValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetStringValueByName(string module, string name)
|
|
|
|
|
{
|
|
|
|
|
return SystemConfigProvider.Instance.GetValueByName(module, name);
|
|
|
|
|
}
|
2023-06-16 09:51:51 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取RecipInfo的Name信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="path"></param>
|
|
|
|
|
/// <param name="module"></param>
|
|
|
|
|
/// <param name="defaultCellEnable"></param>
|
|
|
|
|
/// <returns></returns>
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public ObservableCollection<RecipeInfo> GetRecipeColumnName(string path, string module = "PM1", bool defaultCellEnable = true)
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
var str = _recipeProvider.GetRecipeFormatXml(path);
|
2023-04-13 11:51:03 +08:00
|
|
|
|
var doc = new XmlDocument();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
doc.LoadXml(str);
|
|
|
|
|
|
2023-06-16 09:51:51 +08:00
|
|
|
|
var nodeRoot = doc.SelectSingleNode(NAME_NODE_TABLE_RECIPE_FORMAT);
|
|
|
|
|
RecipeChamberType = nodeRoot.Attributes[NAME_ATTR_CHAMBER_TYPE].Value;
|
|
|
|
|
RecipeVersion = nodeRoot.Attributes[NAME_ATTR_VERSION].Value;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LOG.Write(ex);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RecipeInfos = new ObservableCollection<RecipeInfo>();
|
|
|
|
|
|
2023-06-16 09:51:51 +08:00
|
|
|
|
var nodes = doc.SelectNodes(PATH_GROUP);
|
2023-04-13 11:51:03 +08:00
|
|
|
|
foreach (XmlNode node in nodes)
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
var childNodes = node.SelectNodes(NAME_NODE_STEP);
|
2023-04-13 11:51:03 +08:00
|
|
|
|
foreach (XmlNode step in childNodes)
|
|
|
|
|
{
|
|
|
|
|
RecipeInfos.Add(new RecipeInfo()
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
ID = step.Attributes[NAME_ATTR_CONTROL_NAME].Value,
|
|
|
|
|
Name = step.Attributes[NAME_ATTR_DISPLAY_NAME].Value
|
2023-04-13 11:51:03 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return RecipeInfos;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-16 09:51:51 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取StepInfo的No信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public ObservableCollection<StepInfo> GetRecipeStepNo()
|
|
|
|
|
{
|
|
|
|
|
StepInfos = new ObservableCollection<StepInfo>();
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < 50; i++)
|
|
|
|
|
{
|
|
|
|
|
StepInfos.Add(new StepInfo()
|
|
|
|
|
{
|
|
|
|
|
ID = (i + 1).ToString(),
|
|
|
|
|
Name = "Step" + (i + 1).ToString()
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return StepInfos;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-16 09:51:51 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取ContentInfo的Name信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="path"></param>
|
|
|
|
|
/// <param name="module"></param>
|
|
|
|
|
/// <param name="defaultCellEnable"></param>
|
|
|
|
|
/// <returns></returns>
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public ObservableCollection<ContentInfo> GetContentName(string path, string module = "PM1", bool defaultCellEnable = true)
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
var str = _recipeProvider.GetRecipeFormatXml(path);
|
2023-04-13 11:51:03 +08:00
|
|
|
|
var doc = new XmlDocument();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
doc.LoadXml(str);
|
|
|
|
|
|
2023-06-16 09:51:51 +08:00
|
|
|
|
var nodeRoot = doc.SelectSingleNode(NAME_NODE_TABLE_RECIPE_FORMAT);
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
2023-06-16 09:51:51 +08:00
|
|
|
|
RecipeChamberType = nodeRoot.Attributes[NAME_ATTR_CHAMBER_TYPE].Value;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
2023-06-16 09:51:51 +08:00
|
|
|
|
RecipeVersion = nodeRoot.Attributes[NAME_ATTR_VERSION].Value;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LOG.Write(ex);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ContentInfos = new ObservableCollection<ContentInfo>();
|
|
|
|
|
|
|
|
|
|
var nodesCatalog = doc.SelectNodes("TableRecipeFormat/Catalog");
|
|
|
|
|
foreach (XmlNode catalog in nodesCatalog)
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
var catalogName = catalog.Attributes[NAME_ATTR_DISPLAY_NAME].Value;
|
|
|
|
|
var nodeGroups = catalog.SelectNodes(NAME_NODE_GROUP);
|
2023-04-13 11:51:03 +08:00
|
|
|
|
foreach (XmlNode group in nodeGroups)
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
var groupName = group.Attributes[NAME_ATTR_DISPLAY_NAME].Value;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
var nodeContents = group.SelectNodes("Content");
|
|
|
|
|
foreach (XmlNode content in nodeContents)
|
|
|
|
|
{
|
|
|
|
|
ContentInfos.Add(new ContentInfo()
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
Name = catalogName + "." + groupName + "." + content.Attributes[NAME_ATTR_DISPLAY_NAME].Value
|
2023-04-13 11:51:03 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ContentInfos;
|
|
|
|
|
}
|
2023-05-10 16:21:45 +08:00
|
|
|
|
|
2023-06-15 19:19:41 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 从指定的RecipeFormat.xml文件创建Recipe格式。
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="path"></param>
|
|
|
|
|
/// <param name="module"></param>
|
|
|
|
|
/// <param name="defaultCellEnable"></param>
|
|
|
|
|
/// <param name="roleName"></param>
|
|
|
|
|
/// <returns></returns>
|
2023-05-10 16:21:45 +08:00
|
|
|
|
public List<EditorDataGridTemplateColumnBase> Build(string path, string module = "PM1", bool defaultCellEnable = true, string roleName = "管理员")
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
2023-05-10 16:21:45 +08:00
|
|
|
|
//XML文档读取格式由 $"PM.{module}.RecipeConfig 改为 $"RecipeConfig ,RecipeConfig参数放在Sic层级下,和PM同级别
|
2023-06-16 09:51:51 +08:00
|
|
|
|
var str = _recipeProvider.GetRecipeFormatXml(path);
|
2023-04-13 11:51:03 +08:00
|
|
|
|
var doc = new XmlDocument();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
doc.LoadXml(str);
|
|
|
|
|
|
2023-06-16 09:51:51 +08:00
|
|
|
|
var nodeRoot = doc.SelectSingleNode(NAME_NODE_TABLE_RECIPE_FORMAT);
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
2023-06-16 09:51:51 +08:00
|
|
|
|
RecipeChamberType = nodeRoot.Attributes[NAME_ATTR_CHAMBER_TYPE].Value;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
2023-06-16 09:51:51 +08:00
|
|
|
|
RecipeVersion = nodeRoot.Attributes[NAME_ATTR_VERSION].Value;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LOG.Write(ex);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//初始化RoleManager
|
|
|
|
|
var roleManager = new RoleManager();
|
|
|
|
|
roleManager.Initialize();
|
|
|
|
|
|
|
|
|
|
//得到当前登录的RoleItem
|
|
|
|
|
var roleItem = roleManager.GetRoleByName(roleName);
|
|
|
|
|
|
|
|
|
|
var menuPermission = new MenuPermission();
|
|
|
|
|
menuPermission.ParsePermission(roleItem.Role.MenuPermission);
|
|
|
|
|
|
2023-05-10 16:21:45 +08:00
|
|
|
|
var columns = new List<EditorDataGridTemplateColumnBase>();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
|
|
|
|
EditorDataGridTemplateColumnBase col = null;
|
2023-06-16 09:51:51 +08:00
|
|
|
|
var nodes = doc.SelectNodes(PATH_GROUP);
|
2023-04-13 11:51:03 +08:00
|
|
|
|
foreach (XmlNode node in nodes)
|
|
|
|
|
{
|
|
|
|
|
var colExpander = new ExpanderColumn()
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
DisplayName = node.Attributes[NAME_ATTR_DISPLAY_NAME].Value,
|
|
|
|
|
StringCellTemplate = "CellTemplateExpander",
|
|
|
|
|
StringHeaderTemplate = "ColumnHeaderTemplateExpander"
|
2023-04-13 11:51:03 +08:00
|
|
|
|
};
|
2023-06-16 11:44:52 +08:00
|
|
|
|
colExpander.Header = colExpander;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
columns.Add(colExpander);
|
|
|
|
|
|
2023-06-16 09:51:51 +08:00
|
|
|
|
var childNodes = node.SelectNodes(NAME_NODE_STEP);
|
2023-04-13 11:51:03 +08:00
|
|
|
|
foreach (XmlNode step in childNodes)
|
|
|
|
|
{
|
|
|
|
|
//step number
|
2023-06-16 09:51:51 +08:00
|
|
|
|
if (step.Attributes[NAME_ATTR_CONTROL_NAME].Value == SPEC_COL_STEPNO)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
|
|
|
|
col = new StepColumn()
|
|
|
|
|
{
|
|
|
|
|
DisplayName = "Step",
|
|
|
|
|
UnitName = "",
|
|
|
|
|
ControlName = "StepNo",
|
2023-06-16 09:51:51 +08:00
|
|
|
|
StringCellTemplate = "CellTemplateStepNo",
|
2023-06-13 16:10:57 +08:00
|
|
|
|
StringHeaderTemplate = "ColumnHeaderTemplateStepNo",
|
2023-04-13 11:51:03 +08:00
|
|
|
|
IsEnable = defaultCellEnable,
|
|
|
|
|
IsReadOnly = true
|
|
|
|
|
};
|
|
|
|
|
}
|
2023-06-16 09:51:51 +08:00
|
|
|
|
else if (step.Attributes[NAME_ATTR_CONTROL_NAME].Value == SPEC_COL_STEPUID)
|
2023-05-10 16:21:45 +08:00
|
|
|
|
{
|
|
|
|
|
col = new TextBoxColumn()
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
ModuleName = step.Attributes[NAME_ATTR_MODULE_NAME].Value,
|
|
|
|
|
ControlName = step.Attributes[NAME_ATTR_CONTROL_NAME].Value,
|
|
|
|
|
DisplayName = step.Attributes[NAME_ATTR_DISPLAY_NAME].Value,
|
|
|
|
|
UnitName = step.Attributes[NAME_ATTR_UNIT_NAME].Value,
|
|
|
|
|
StringCellTemplate = "CellTemplateDisplay",
|
2023-06-13 16:10:57 +08:00
|
|
|
|
StringHeaderTemplate = "ColumnHeaderTemplateCommon",
|
2023-05-10 16:21:45 +08:00
|
|
|
|
IsReadOnly = true,
|
|
|
|
|
IsEnable = defaultCellEnable,
|
2023-05-30 17:05:19 +08:00
|
|
|
|
Visibility = Visibility.Collapsed
|
2023-05-10 16:21:45 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
2023-04-13 11:51:03 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch (step.Attributes["InputType"].Value)
|
|
|
|
|
{
|
2023-05-10 16:21:45 +08:00
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
case "Set3RatioInput":
|
|
|
|
|
col = new RatioColumn()
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
ModuleName = step.Attributes[NAME_ATTR_MODULE_NAME].Value,
|
|
|
|
|
ControlName = step.Attributes[NAME_ATTR_CONTROL_NAME].Value,
|
|
|
|
|
DisplayName = step.Attributes[NAME_ATTR_DISPLAY_NAME].Value,
|
|
|
|
|
UnitName = step.Attributes[NAME_ATTR_UNIT_NAME].Value,
|
2023-04-13 11:51:03 +08:00
|
|
|
|
Default = GetStringValueByName("PM",
|
2023-06-16 09:51:51 +08:00
|
|
|
|
$"PM.RecipeConfig.{strAbc(node.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.{strAbc(step.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.Default"),
|
|
|
|
|
StringCellTemplate = "CellTemplateDisplay",
|
|
|
|
|
StringCellEditingTemplate = "CellTemplateSets3Ratio",
|
2023-06-13 16:10:57 +08:00
|
|
|
|
StringHeaderTemplate = "ColumnHeaderTemplateCommon",
|
2023-04-13 11:51:03 +08:00
|
|
|
|
EnableConfig = step.Attributes["EnableConfig"] != null &&
|
|
|
|
|
Convert.ToBoolean(step.Attributes["EnableConfig"].Value),
|
|
|
|
|
EnableTolerance = step.Attributes["EnableTolerance"] != null &&
|
|
|
|
|
Convert.ToBoolean(step.Attributes["EnableTolerance"].Value),
|
|
|
|
|
IsEnable = defaultCellEnable,
|
|
|
|
|
MaxSets = 3
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "TextInput":
|
|
|
|
|
col = new TextBoxColumn()
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
ModuleName = step.Attributes[NAME_ATTR_MODULE_NAME].Value,
|
|
|
|
|
ControlName = step.Attributes[NAME_ATTR_CONTROL_NAME].Value,
|
|
|
|
|
DisplayName = step.Attributes[NAME_ATTR_DISPLAY_NAME].Value,
|
|
|
|
|
UnitName = step.Attributes[NAME_ATTR_UNIT_NAME].Value,
|
2023-04-13 11:51:03 +08:00
|
|
|
|
Default = GetStringValueByName("PM",
|
2023-06-16 09:51:51 +08:00
|
|
|
|
$"PM.RecipeConfig.{strAbc(node.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.{strAbc(step.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.Default"),
|
|
|
|
|
StringCellTemplate = "CellTemplateDisplay",
|
|
|
|
|
StringCellEditingTemplate = "CellTemplateText",
|
2023-06-13 16:10:57 +08:00
|
|
|
|
StringHeaderTemplate = "ColumnHeaderTemplateCommon",
|
2023-04-13 11:51:03 +08:00
|
|
|
|
EnableConfig = step.Attributes["EnableConfig"] != null &&
|
|
|
|
|
Convert.ToBoolean(step.Attributes["EnableConfig"].Value),
|
|
|
|
|
EnableTolerance = step.Attributes["EnableTolerance"] != null &&
|
|
|
|
|
Convert.ToBoolean(step.Attributes["EnableTolerance"].Value),
|
|
|
|
|
IsEnable = defaultCellEnable,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "ReadOnly":
|
|
|
|
|
col = new TextBoxColumn()
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
ModuleName = step.Attributes[NAME_ATTR_MODULE_NAME].Value,
|
|
|
|
|
ControlName = step.Attributes[NAME_ATTR_CONTROL_NAME].Value,
|
|
|
|
|
DisplayName = step.Attributes[NAME_ATTR_DISPLAY_NAME].Value,
|
|
|
|
|
UnitName = step.Attributes[NAME_ATTR_UNIT_NAME].Value,
|
|
|
|
|
StringCellTemplate = "CellTemplateDisplay",
|
|
|
|
|
StringCellEditingTemplate = "CellTemplateText",
|
2023-06-13 16:10:57 +08:00
|
|
|
|
StringHeaderTemplate = "ColumnHeaderTemplateCommon",
|
2023-04-13 11:51:03 +08:00
|
|
|
|
IsReadOnly = true,
|
|
|
|
|
EnableConfig = step.Attributes["EnableConfig"] != null &&
|
|
|
|
|
Convert.ToBoolean(step.Attributes["EnableConfig"].Value),
|
|
|
|
|
EnableTolerance = step.Attributes["EnableTolerance"] != null &&
|
|
|
|
|
Convert.ToBoolean(step.Attributes["EnableTolerance"].Value),
|
|
|
|
|
IsEnable = defaultCellEnable,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "NumInput":
|
|
|
|
|
col = new NumColumn()
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
ModuleName = step.Attributes[NAME_ATTR_MODULE_NAME].Value,
|
|
|
|
|
ControlName = step.Attributes[NAME_ATTR_CONTROL_NAME].Value,
|
|
|
|
|
DisplayName = step.Attributes[NAME_ATTR_DISPLAY_NAME].Value,
|
|
|
|
|
UnitName = step.Attributes[NAME_ATTR_UNIT_NAME].Value,
|
2023-04-13 11:51:03 +08:00
|
|
|
|
InputMode = step.Attributes["InputMode"].Value,
|
|
|
|
|
//Minimun = double.Parse(step.Attributes["Min"].Value),
|
|
|
|
|
Minimun = GetDoubleValueByName("PM",
|
2023-06-16 09:51:51 +08:00
|
|
|
|
$"PM.RecipeConfig.{strAbc(node.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.{strAbc(step.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.Min"),
|
2023-04-13 11:51:03 +08:00
|
|
|
|
//Maximun = double.Parse(step.Attributes["Max"].Value),
|
|
|
|
|
Maximun = GetDoubleValueByName("PM",
|
2023-06-16 09:51:51 +08:00
|
|
|
|
$"PM.RecipeConfig.{strAbc(node.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.{strAbc(step.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.Max"),
|
|
|
|
|
StringCellTemplate = "CellTemplateDisplay",
|
|
|
|
|
StringCellEditingTemplate = "CellTemplateNumber",
|
2023-06-13 16:10:57 +08:00
|
|
|
|
StringHeaderTemplate = "ColumnHeaderTemplateCommon",
|
2023-04-13 11:51:03 +08:00
|
|
|
|
EnableConfig = step.Attributes["EnableConfig"] != null &&
|
|
|
|
|
Convert.ToBoolean(step.Attributes["EnableConfig"].Value),
|
|
|
|
|
EnableTolerance = step.Attributes["EnableTolerance"] != null &&
|
|
|
|
|
Convert.ToBoolean(step.Attributes["EnableTolerance"].Value),
|
|
|
|
|
IsEnable = defaultCellEnable,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "DoubleInput":
|
|
|
|
|
//MFC和PC的最大值读取MFC的设定
|
2023-06-16 09:51:51 +08:00
|
|
|
|
var displayText = new Regex(@"\(M\d+\)").Match(step.Attributes[NAME_ATTR_DISPLAY_NAME].Value)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
.Value;
|
|
|
|
|
var maxConfig =
|
2023-06-16 09:51:51 +08:00
|
|
|
|
$"PM.RecipeConfig.{strAbc(node.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.{strAbc(step.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.Max";
|
2023-04-13 11:51:03 +08:00
|
|
|
|
var minConfig =
|
2023-06-16 09:51:51 +08:00
|
|
|
|
$"PM.RecipeConfig.{strAbc(node.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.{strAbc(step.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.Min";
|
2023-04-13 11:51:03 +08:00
|
|
|
|
if (displayText.Contains("M"))
|
|
|
|
|
{
|
|
|
|
|
maxConfig =
|
|
|
|
|
$"PM.{module}.MFC.Mfc{displayText.Replace("(M", "").Replace(")", "")}.N2Scale";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
displayText = new Regex(@"\(PC\d+\)").Match(step.Attributes[NAME_ATTR_DISPLAY_NAME].Value)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
.Value;
|
|
|
|
|
if (displayText.Contains("PC"))
|
|
|
|
|
{
|
|
|
|
|
maxConfig =
|
|
|
|
|
$"PM.{module}.PC.PC{displayText.Replace("(PC", "").Replace(")", "")}.Scale";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
col = new DoubleColumn()
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
ModuleName = step.Attributes[NAME_ATTR_MODULE_NAME].Value,
|
|
|
|
|
ControlName = step.Attributes[NAME_ATTR_CONTROL_NAME].Value,
|
|
|
|
|
DisplayName = step.Attributes[NAME_ATTR_DISPLAY_NAME].Value,
|
|
|
|
|
UnitName = step.Attributes[NAME_ATTR_UNIT_NAME].Value,
|
2023-04-13 11:51:03 +08:00
|
|
|
|
InputMode = step.Attributes["InputMode"].Value,
|
|
|
|
|
Maximun = GetDoubleValueByName("PM", maxConfig),
|
|
|
|
|
Minimun = GetDoubleValueByName("PM", minConfig),
|
|
|
|
|
Default = GetStringValueByName("PM",
|
2023-06-16 09:51:51 +08:00
|
|
|
|
$"PM.RecipeConfig.{strAbc(node.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.{strAbc(step.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.Default"),
|
|
|
|
|
StringCellTemplate = "CellTemplateDisplay",
|
|
|
|
|
StringCellEditingTemplate = "CellTemplateNumber",
|
2023-06-13 16:10:57 +08:00
|
|
|
|
StringHeaderTemplate = "ColumnHeaderTemplateCommon",
|
2023-04-13 11:51:03 +08:00
|
|
|
|
EnableConfig = step.Attributes["EnableConfig"] != null &&
|
|
|
|
|
Convert.ToBoolean(step.Attributes["EnableConfig"].Value),
|
|
|
|
|
EnableTolerance = step.Attributes["EnableTolerance"] != null &&
|
|
|
|
|
Convert.ToBoolean(step.Attributes["EnableTolerance"].Value),
|
|
|
|
|
IsEnable = defaultCellEnable,
|
|
|
|
|
};
|
2023-05-10 16:21:45 +08:00
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
//strAbc此函数去除了括号及括号中的内容,所以在此处重新赋值,保留括号及其内容*********************
|
2023-05-10 16:21:45 +08:00
|
|
|
|
if (displayText.Contains("M")|| displayText.Contains("PC"))
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
|
|
|
|
col.Default = GetStringValueByName("PM",
|
2023-06-16 09:51:51 +08:00
|
|
|
|
$"PM.RecipeConfig.{strAbc(node.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.{strAbc(step.Attributes[NAME_ATTR_DISPLAY_NAME].Value, false)}.Default");
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
//******************************************************************************************
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (displayText.Contains("M"))
|
|
|
|
|
{
|
2023-05-10 16:21:45 +08:00
|
|
|
|
((DoubleColumn)col).Minimun = ((DoubleColumn)col).Maximun *GetDoubleValueByName("PM", $"PM.{module}.MFC.MinScale") / 100.0;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "DoubleTextInput":
|
|
|
|
|
//MFC和 PC 的最大值读取MFC的设定
|
2023-06-16 09:51:51 +08:00
|
|
|
|
displayText = new Regex(@"\(M\d+\)").Match(step.Attributes[NAME_ATTR_DISPLAY_NAME].Value).Value;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
maxConfig =
|
2023-06-16 09:51:51 +08:00
|
|
|
|
$"PM.RecipeConfig.{strAbc(node.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.{strAbc(step.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.Max";
|
2023-04-13 11:51:03 +08:00
|
|
|
|
minConfig =
|
2023-06-16 09:51:51 +08:00
|
|
|
|
$"PM.RecipeConfig.{strAbc(node.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.{strAbc(step.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.Min";
|
2023-04-13 11:51:03 +08:00
|
|
|
|
if (displayText.Contains("M"))
|
|
|
|
|
{
|
|
|
|
|
maxConfig =
|
|
|
|
|
$"PM.{module}.MFC.Mfc{displayText.Replace("(M", "").Replace(")", "")}.N2Scale";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
displayText = new Regex(@"\(PC\d+\)").Match(step.Attributes[NAME_ATTR_DISPLAY_NAME].Value)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
.Value;
|
|
|
|
|
if (displayText.Contains("PC"))
|
|
|
|
|
{
|
|
|
|
|
maxConfig =
|
|
|
|
|
$"PM.{module}.PC.PC{displayText.Replace("(PC", "").Replace(")", "")}.Scale";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
col = new DoubleColumn()
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
ModuleName = step.Attributes[NAME_ATTR_MODULE_NAME].Value,
|
|
|
|
|
ControlName = step.Attributes[NAME_ATTR_CONTROL_NAME].Value,
|
|
|
|
|
DisplayName = step.Attributes[NAME_ATTR_DISPLAY_NAME].Value,
|
|
|
|
|
UnitName = step.Attributes[NAME_ATTR_UNIT_NAME].Value,
|
2023-04-13 11:51:03 +08:00
|
|
|
|
InputMode = step.Attributes["InputMode"].Value,
|
|
|
|
|
Minimun = GetDoubleValueByName("PM", minConfig),
|
|
|
|
|
Maximun = GetDoubleValueByName("PM", maxConfig),
|
|
|
|
|
Default = "Hold",
|
2023-06-16 09:51:51 +08:00
|
|
|
|
StringCellTemplate = "CellTemplateDisplay",
|
|
|
|
|
StringCellEditingTemplate = "CellTemplateNumberText",
|
2023-06-13 16:10:57 +08:00
|
|
|
|
StringHeaderTemplate = "ColumnHeaderTemplateCommon",
|
2023-04-13 11:51:03 +08:00
|
|
|
|
EnableConfig = step.Attributes["EnableConfig"] != null &&
|
|
|
|
|
Convert.ToBoolean(step.Attributes["EnableConfig"].Value),
|
|
|
|
|
EnableTolerance = step.Attributes["EnableTolerance"] != null &&
|
|
|
|
|
Convert.ToBoolean(step.Attributes["EnableTolerance"].Value),
|
|
|
|
|
IsEnable = defaultCellEnable,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "EditableSelection":
|
|
|
|
|
case "ReadOnlySelection":
|
|
|
|
|
col = new ComboxColumn()
|
|
|
|
|
{
|
|
|
|
|
//IsReadOnly = step.Attributes["InputType"].Value == "ReadOnlySelection",
|
|
|
|
|
IsEditable = step.Attributes["InputType"].Value != "ReadOnlySelection",
|
2023-06-16 09:51:51 +08:00
|
|
|
|
ModuleName = step.Attributes[NAME_ATTR_MODULE_NAME].Value,
|
2023-04-13 11:51:03 +08:00
|
|
|
|
//Default = step.Attributes["Default"] != null ? step.Attributes["Default"].Value : "",
|
|
|
|
|
Default = GetStringValueByName("PM",
|
2023-06-16 09:51:51 +08:00
|
|
|
|
$"PM.RecipeConfig.{strAbc(node.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.{strAbc(step.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.Default"),
|
|
|
|
|
ControlName = step.Attributes[NAME_ATTR_CONTROL_NAME].Value,
|
|
|
|
|
DisplayName = step.Attributes[NAME_ATTR_DISPLAY_NAME].Value,
|
|
|
|
|
UnitName = step.Attributes[NAME_ATTR_UNIT_NAME].Value,
|
|
|
|
|
StringCellTemplate = "CellTemplateDisplay",
|
|
|
|
|
StringCellEditingTemplate = "CellTemplateComboBoxEx",
|
2023-06-13 16:10:57 +08:00
|
|
|
|
StringHeaderTemplate = "ColumnHeaderTemplateCommon",
|
2023-04-13 11:51:03 +08:00
|
|
|
|
EnableConfig = step.Attributes["EnableConfig"] != null &&
|
|
|
|
|
Convert.ToBoolean(step.Attributes["EnableConfig"].Value),
|
|
|
|
|
EnableTolerance = step.Attributes["EnableTolerance"] != null &&
|
|
|
|
|
Convert.ToBoolean(step.Attributes["EnableTolerance"].Value),
|
|
|
|
|
IsEnable = defaultCellEnable,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
var items = step.SelectNodes("Item");
|
|
|
|
|
foreach (XmlNode item in items)
|
|
|
|
|
{
|
|
|
|
|
var opt = new ComboxColumn.Option();
|
2023-06-16 09:51:51 +08:00
|
|
|
|
opt.ControlName = item.Attributes[NAME_ATTR_CONTROL_NAME].Value;
|
|
|
|
|
opt.DisplayName = item.Attributes[NAME_ATTR_DISPLAY_NAME].Value;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
((ComboxColumn)col).Options.Add(opt);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "FlowModeSelection":
|
|
|
|
|
col = new FlowModeColumn()
|
|
|
|
|
{
|
|
|
|
|
//IsReadOnly = step.Attributes["InputType"].Value == "ReadOnlySelection",
|
|
|
|
|
IsEditable = false,
|
2023-06-16 09:51:51 +08:00
|
|
|
|
ModuleName = step.Attributes[NAME_ATTR_MODULE_NAME].Value,
|
2023-04-13 11:51:03 +08:00
|
|
|
|
//Default = step.Attributes["Default"] != null ? step.Attributes["Default"].Value : "",
|
|
|
|
|
Default = GetStringValueByName("PM",
|
2023-06-16 09:51:51 +08:00
|
|
|
|
$"PM.RecipeConfig.{strAbc(node.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.{strAbc(step.Attributes[NAME_ATTR_DISPLAY_NAME].Value)}.Default"),
|
|
|
|
|
ControlName = step.Attributes[NAME_ATTR_CONTROL_NAME].Value,
|
|
|
|
|
DisplayName = step.Attributes[NAME_ATTR_DISPLAY_NAME].Value,
|
|
|
|
|
UnitName = step.Attributes[NAME_ATTR_UNIT_NAME].Value,
|
|
|
|
|
StringCellTemplate = "CellTemplateDisplay",
|
|
|
|
|
StringCellEditingTemplate = "CellTemplateComboBoxEx",
|
2023-06-13 16:10:57 +08:00
|
|
|
|
StringHeaderTemplate = "ColumnHeaderTemplateCommon",
|
2023-04-13 11:51:03 +08:00
|
|
|
|
EnableConfig = step.Attributes["EnableConfig"] != null &&
|
|
|
|
|
Convert.ToBoolean(step.Attributes["EnableConfig"].Value),
|
|
|
|
|
EnableTolerance = step.Attributes["EnableTolerance"] != null &&
|
|
|
|
|
Convert.ToBoolean(step.Attributes["EnableTolerance"].Value),
|
|
|
|
|
IsEnable = defaultCellEnable,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
var flowMode = step.SelectNodes("Item");
|
|
|
|
|
foreach (XmlNode item in flowMode)
|
|
|
|
|
{
|
|
|
|
|
var opt = new ComboxColumn.Option
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
ControlName = item.Attributes[NAME_ATTR_CONTROL_NAME].Value,
|
|
|
|
|
DisplayName = item.Attributes[NAME_ATTR_DISPLAY_NAME].Value
|
2023-04-13 11:51:03 +08:00
|
|
|
|
};
|
|
|
|
|
((ComboxColumn)col).Options.Add(opt);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "LoopSelection":
|
|
|
|
|
col = new LoopComboxColumn()
|
|
|
|
|
{
|
|
|
|
|
IsReadOnly = false,
|
2023-06-16 09:51:51 +08:00
|
|
|
|
ModuleName = step.Attributes[NAME_ATTR_MODULE_NAME].Value,
|
|
|
|
|
ControlName = step.Attributes[NAME_ATTR_CONTROL_NAME].Value,
|
|
|
|
|
DisplayName = step.Attributes[NAME_ATTR_DISPLAY_NAME].Value,
|
|
|
|
|
StringCellTemplate = "CellTemplateDisplay",
|
|
|
|
|
StringCellEditingTemplate = "CellTemplateComboBoxEx",
|
2023-06-13 16:10:57 +08:00
|
|
|
|
StringHeaderTemplate = "ColumnHeaderTemplateCommon",
|
2023-04-13 11:51:03 +08:00
|
|
|
|
EnableTolerance = step.Attributes["EnableTolerance"] != null &&
|
|
|
|
|
Convert.ToBoolean(step.Attributes["EnableTolerance"].Value),
|
|
|
|
|
IsEnable = defaultCellEnable,
|
|
|
|
|
};
|
|
|
|
|
var options = step.SelectNodes("Item");
|
|
|
|
|
foreach (XmlNode item in options)
|
|
|
|
|
{
|
|
|
|
|
var opt = new LoopComboxColumn.Option();
|
2023-06-16 09:51:51 +08:00
|
|
|
|
opt.ControlName = item.Attributes[NAME_ATTR_CONTROL_NAME].Value;
|
|
|
|
|
opt.DisplayName = item.Attributes[NAME_ATTR_DISPLAY_NAME].Value;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
((LoopComboxColumn)col).Options.Add(opt);
|
|
|
|
|
}
|
2023-05-10 16:21:45 +08:00
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "PopSetting":
|
|
|
|
|
col = new PopSettingColumn()
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
ModuleName = step.Attributes[NAME_ATTR_MODULE_NAME].Value,
|
|
|
|
|
ControlName = step.Attributes[NAME_ATTR_CONTROL_NAME].Value,
|
|
|
|
|
DisplayName = step.Attributes[NAME_ATTR_DISPLAY_NAME].Value,
|
|
|
|
|
UnitName = step.Attributes[NAME_ATTR_UNIT_NAME].Value,
|
|
|
|
|
StringCellTemplate = "CellTemplateDisplay",
|
|
|
|
|
StringCellEditingTemplate = "CellTemplatePopSetting",
|
|
|
|
|
StringHeaderTemplate = "ColumnHeaderTemplateCommon",
|
2023-04-13 11:51:03 +08:00
|
|
|
|
EnableConfig = step.Attributes["EnableConfig"] != null &&
|
|
|
|
|
Convert.ToBoolean(step.Attributes["EnableConfig"].Value),
|
|
|
|
|
EnableTolerance = step.Attributes["EnableTolerance"] != null &&
|
|
|
|
|
Convert.ToBoolean(step.Attributes["EnableTolerance"].Value),
|
|
|
|
|
IsEnable = defaultCellEnable,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-15 19:19:41 +08:00
|
|
|
|
// Header属性指向列对象,使用HeaderTemplate模板渲染Header
|
|
|
|
|
col.Header = col;
|
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
// 单元格是否可编辑?
|
|
|
|
|
var isCellEditable = step.Attributes["IsColumnEditable"]?.Value;
|
|
|
|
|
if (string.IsNullOrEmpty(isCellEditable) == false && isCellEditable.ToLower() == "false")
|
2023-05-30 17:05:19 +08:00
|
|
|
|
{
|
|
|
|
|
col.IsEditable = false;
|
2023-06-13 16:10:57 +08:00
|
|
|
|
col.IsReadOnly = true;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
col.StringCellEditingTemplate = "";
|
2023-05-30 17:05:19 +08:00
|
|
|
|
}
|
2023-06-15 19:19:41 +08:00
|
|
|
|
|
2023-06-16 11:44:52 +08:00
|
|
|
|
// 设置列访问权限
|
|
|
|
|
SetPermission(col, menuPermission);
|
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
colExpander.ChildColumns.Add(col); // 将本列追加到Expander中
|
|
|
|
|
columns.Add(col);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Columns = columns;
|
|
|
|
|
|
|
|
|
|
var configs = new RecipeStep(null);
|
2023-05-10 16:21:45 +08:00
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
nodes = doc.SelectNodes("TableRecipeFormat/ProcessConfig/Configs");
|
|
|
|
|
foreach (XmlNode node in nodes)
|
|
|
|
|
{
|
|
|
|
|
var childNodes = node.SelectNodes("Config");
|
|
|
|
|
foreach (XmlNode configNode in childNodes)
|
|
|
|
|
{
|
2023-05-10 16:21:45 +08:00
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
switch (configNode.Attributes["InputType"].Value)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
case "DoubleInput":
|
|
|
|
|
var config = new DoubleParam(GlobalDefs.TryParseToDouble(configNode.Attributes["Default"].Value))
|
|
|
|
|
{
|
2023-06-16 09:51:51 +08:00
|
|
|
|
Name = configNode.Attributes[NAME_ATTR_CONTROL_NAME].Value,
|
|
|
|
|
DisplayName = configNode.Attributes[NAME_ATTR_DISPLAY_NAME].Value,
|
2023-04-13 11:51:03 +08:00
|
|
|
|
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 var max))
|
|
|
|
|
{
|
|
|
|
|
(config as DoubleParam).Maximun = max;
|
|
|
|
|
}
|
|
|
|
|
if (double.TryParse(configNode.Attributes["Min"].Value, out var min))
|
|
|
|
|
{
|
|
|
|
|
(config as DoubleParam).Minimun = min;
|
|
|
|
|
}
|
|
|
|
|
configs.Add(config);
|
|
|
|
|
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;
|
|
|
|
|
}
|
2023-06-16 09:51:51 +08:00
|
|
|
|
|
2023-06-16 11:44:52 +08:00
|
|
|
|
/// <summary>
|
2023-06-16 15:48:27 +08:00
|
|
|
|
/// 重新加载指定角色的列访问权限。
|
2023-06-16 11:44:52 +08:00
|
|
|
|
/// </summary>
|
2023-06-16 15:48:27 +08:00
|
|
|
|
/// <param name="role">指定的角色。</param>
|
|
|
|
|
public void ReloadColumnsPermission(RoleItem role)
|
2023-06-16 11:44:52 +08:00
|
|
|
|
{
|
|
|
|
|
var perm = new MenuPermission();
|
|
|
|
|
perm.ParsePermission(role.Role.MenuPermission);
|
|
|
|
|
|
|
|
|
|
foreach (var col in Columns)
|
|
|
|
|
{
|
|
|
|
|
SetPermission(col, perm);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设置列权限。
|
|
|
|
|
/// </summary>
|
2023-06-16 11:44:52 +08:00
|
|
|
|
/// <remarks>
|
|
|
|
|
/// 以下时机对列访问权限进行设置:
|
|
|
|
|
/// <br/>
|
|
|
|
|
/// 调用<see cref="RecipeFormatBuilder.Build"/>方法构建配方编辑器表格格式时;
|
|
|
|
|
/// <br/>
|
|
|
|
|
/// 当配方编辑器视图被激活时,可能列权限发生了变更,调用<see cref="UpdatePermission"/>方法更新列权限。
|
|
|
|
|
/// </remarks>
|
2023-04-13 11:51:03 +08:00
|
|
|
|
/// <param name="column"></param>
|
|
|
|
|
/// <param name="permission"></param>
|
|
|
|
|
/// <returns></returns>
|
2023-06-16 11:44:52 +08:00
|
|
|
|
private static void SetPermission(EditorDataGridTemplateColumnBase column, MenuPermission permission)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
|
|
|
|
if (column == null)
|
|
|
|
|
throw new ArgumentNullException(nameof(column));
|
|
|
|
|
|
|
|
|
|
if (permission == null)
|
|
|
|
|
throw new ArgumentNullException(nameof(permission));
|
|
|
|
|
|
2023-06-16 11:44:52 +08:00
|
|
|
|
// StepNo列和StepUid列不受权限控制
|
|
|
|
|
if (column.ControlName == SPEC_COL_STEPUID)
|
|
|
|
|
{
|
|
|
|
|
column.Permission = MenuPermissionEnum.MP_NONE;
|
|
|
|
|
}
|
|
|
|
|
else if (column.ControlName == SPEC_COL_STEPNO)
|
|
|
|
|
{
|
|
|
|
|
column.Permission = MenuPermissionEnum.MP_READ;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var mpKey = column.DisplayName.Replace(" ", "");
|
|
|
|
|
column.Permission = permission.MenuPermissionDictionary.TryGetValue(mpKey, out var perm)
|
|
|
|
|
? perm
|
|
|
|
|
: MenuPermissionEnum.MP_NONE;
|
|
|
|
|
}
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
2023-06-16 09:51:51 +08:00
|
|
|
|
|
|
|
|
|
#endregion
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|