| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using IwbZero.IwbBase;
- using IwbZero.ToolCommon.StringModel;
- namespace WeEngine
- {
- public class DefaultVariable
- {
- /// <summary>
- /// 运行编号
- /// </summary>
- 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();
- /// <summary>
- /// 节点路径
- /// </summary>
- [Description("节点路径")]
- public static string Path => _path.UAndT();
- private static readonly string _path = $"{IwbVariableType.Local}Path";
- /// <summary>
- /// 轮次总分
- /// </summary>
- [Description("轮次总分")]
- public static string FullRoundScore => _fullRoundScore.UAndT();
- private static readonly string _fullRoundScore = $"{IwbVariableType.Local}FullRoundScore";
- /// <summary>
- /// 节点总分
- /// </summary>
- [Description("节点总分")]
- public static string FullNodeScore => _fullNodeScore.UAndT();
- private static readonly string _fullNodeScore = $"{IwbVariableType.Local}FullNodeScore";
- /// <summary>
- /// 前一节点评分
- /// </summary>
- [Description("前一节点评分")]
- public static string PrevNodeScore => _prevNodeScore.UAndT();
- private static readonly string _prevNodeScore = $"{IwbVariableType.Local}PrevNodeScore";
- //public static string PrevRoundScore = $"{IwbVariableType.Local}PrevRoundScore";
- /// <summary>
- /// 轮次评分
- /// </summary>
- [Description("轮次评分")]
- public static string RoundScore => _roundScore.UAndT();
- private static readonly string _roundScore = $"{IwbVariableType.Local}RoundScore";
- /// <summary>
- /// 情景流总分
- /// </summary>
- [Description("情景流总分")]
- public static string FullFlowScore => _fullFlowScore.UAndT();
- private static readonly string _fullFlowScore = $"{IwbVariableType.Local}FullFlowScore";
- /// <summary>
- /// 情景流评分
- /// </summary>
- [Description("情景流评分")]
- public static string FlowScore => _flowScore;
- private static readonly string _flowScore = $"{IwbVariableType.Local}FlowScore";
- /// <summary>
- /// 情景流节点评分
- /// </summary>
- [Description("情景流节点评分")]
- public static string FlowNodeScore => _flowNodeScore.UAndT();
- private static readonly string _flowNodeScore = $"{IwbVariableType.Local}FlowNodeScore";
- /// <summary>
- /// 情景评分
- /// </summary>
- [Description("情景评分")]
- public static string SceneScore => _sceneScore.UAndT();
- private static readonly string _sceneScore = $"{IwbVariableType.Local}SceneScore";
- /// <summary>
- /// 事务节点验证条件结果
- /// </summary>
- [Description("事务节点验证条件结果")]
- public static string RunValidate => _runValidate.UAndT();
- private static readonly string _runValidate = $"{IwbVariableType.Local}RunValidate";
- /// <summary>
- /// 默认变量
- /// </summary>
- public static Hashtable Variables => GetVariables();
- public static List<string> 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<string> GetVariableNames()
- {
- var list = new List<string> { _runningId };
- foreach (DictionaryEntry dic in Variables)
- {
- list.Add(dic.Key.ToString());
- }
- return list;
- }
- public static List<VariableName> GetVariableNameList()
- {
- var list = new List<VariableName>();
- 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 += $"<option value=\"{FullRoundScore.Substring(1)}\">{GetName(FullRoundScore)}</option>";
- str += $"<option value=\"{FullFlowScore.Substring(1)}\">{GetName(FullFlowScore)}</option>";
- str += $"<option value=\"{FullNodeScore.Substring(1)}\">{GetName(FullNodeScore)}</option>";
- str += $"<option value=\"{PrevNodeScore.Substring(1)}\">{GetName(PrevNodeScore)}</option>";
- str += $"<option value=\"{RoundScore.Substring(1)}\">{GetName(RoundScore)}</option>";
- str += $"<option value=\"{FlowScore.Substring(1)}\">{GetName(FlowScore)}</option>";
- str += $"<option value=\"{FlowNodeScore.Substring(1)}\">{GetName(FlowNodeScore)}</option>";
- str += $"<option value=\"{SceneScore.Substring(1)}\">{GetName(SceneScore)}</option>";
- str += $"<option value=\"{Path.Substring(1)}\">{GetName(Path)}</option>";
- str += $"<option value=\"{RunValidate.Substring(1)}\">{GetName(RunValidate)}</option>";
- 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; }
- }
- }
- }
|