using System.Collections; using System.Collections.Generic; using System.ComponentModel; using IwbZero.IwbBase; using IwbZero.ToolCommon.StringModel; namespace WeEngine { public class DefaultVariable { /// /// 运行编号 /// private static readonly string _runningId = $"{IwbVariableType.Local}RunningId"; [Description("运行编号")] public static string RunningId => _runningId.UAndT(); private static readonly string _id = $"{IwbVariableType.Local}Id"; [Description("编号")] public static string Id => _id.UAndT(); /// /// 节点路径 /// [Description("节点路径")] public static string Path => _path.UAndT(); private static readonly string _path = $"{IwbVariableType.Local}Path"; /// /// 轮次总分 /// [Description("轮次总分")] public static string FullRoundScore => _fullRoundScore.UAndT(); private static readonly string _fullRoundScore = $"{IwbVariableType.Local}FullRoundScore"; /// /// 节点总分 /// [Description("节点总分")] public static string FullNodeScore => _fullNodeScore.UAndT(); private static readonly string _fullNodeScore = $"{IwbVariableType.Local}FullNodeScore"; /// /// 前一节点评分 /// [Description("前一节点评分")] public static string PrevNodeScore => _prevNodeScore.UAndT(); private static readonly string _prevNodeScore = $"{IwbVariableType.Local}PrevNodeScore"; //public static string PrevRoundScore = $"{IwbVariableType.Local}PrevRoundScore"; /// /// 轮次评分 /// [Description("轮次评分")] public static string RoundScore => _roundScore.UAndT(); private static readonly string _roundScore = $"{IwbVariableType.Local}RoundScore"; /// /// 情景流总分 /// [Description("情景流总分")] public static string FullFlowScore => _fullFlowScore.UAndT(); private static readonly string _fullFlowScore = $"{IwbVariableType.Local}FullFlowScore"; /// /// 情景流评分 /// [Description("情景流评分")] public static string FlowScore => _flowScore; private static readonly string _flowScore = $"{IwbVariableType.Local}FlowScore"; /// /// 情景流节点评分 /// [Description("情景流节点评分")] public static string FlowNodeScore => _flowNodeScore.UAndT(); private static readonly string _flowNodeScore = $"{IwbVariableType.Local}FlowNodeScore"; /// /// 情景评分 /// [Description("情景评分")] public static string SceneScore => _sceneScore.UAndT(); private static readonly string _sceneScore = $"{IwbVariableType.Local}SceneScore"; /// /// 事务节点验证条件结果 /// [Description("事务节点验证条件结果")] public static string RunValidate => _runValidate.UAndT(); private static readonly string _runValidate = $"{IwbVariableType.Local}RunValidate"; /// /// 默认变量 /// public static Hashtable Variables => GetVariables(); public static List VariableNames => GetVariableNames(); private static Hashtable GetVariables(bool u = true) { var variables = new Hashtable { {u ? Path : _path, new IwbRtVariable(Path)}, {u ? FullRoundScore : _fullRoundScore, new IwbRtVariable(FullFlowScore, "Numeric")}, {u ? FullNodeScore : _fullNodeScore, new IwbRtVariable(FullNodeScore, "Numeric")}, {u ? PrevNodeScore : _prevNodeScore, new IwbRtVariable(PrevNodeScore, "Numeric")}, {u ? RoundScore : _roundScore, new IwbRtVariable(RoundScore, "Numeric")}, {u ? FullFlowScore : _fullFlowScore, new IwbRtVariable(FullFlowScore, "Numeric")}, {u ? FlowScore : _flowScore, new IwbRtVariable(FlowScore, "Numeric")}, {u ? FlowNodeScore : _flowNodeScore, new IwbRtVariable(FlowNodeScore, "Numeric")}, {u ? SceneScore : _sceneScore, new IwbRtVariable(SceneScore, "Numeric")}, {u ? RunValidate : _runValidate, new IwbRtVariable(RunValidate)} }; return variables; } public static List GetVariableNames() { var list = new List { _runningId }; foreach (DictionaryEntry dic in Variables) { list.Add(dic.Key.ToString()); } return list; } public static List GetVariableNameList() { var list = new List(); var variables = GetVariables(false); foreach (DictionaryEntry dic in variables) { var key = dic.Key.ToString(); var name = GetName(key); list.Add(new VariableName($"{name}({key})", key)); } return list; } public static string GetVariableSelects() { string str = ""; str += $""; str += $""; str += $""; str += $""; str += $""; str += $""; str += $""; str += $""; str += $""; str += $""; return str; } private static string GetName(string key) { key = key.StartsWith("@") ? key.Substring(1) : key; var p = typeof(DefaultVariable).GetProperty(key); var obj = p?.GetCustomAttributes(typeof(DescriptionAttribute), true)[0]; var str = obj != null ? ((DescriptionAttribute)obj).Description : ""; return str; } public class VariableName { public VariableName() { } public VariableName(string name, string value) { Name = name; Value = value; } public string Name { get; set; } public string Value { get; set; } } } }