| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474 |
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using IwbZero.IwbBase;
- using IwbZero.ToolCommon.StringModel;
- using Newtonsoft.Json;
- using WeEngine.Enum;
- using WeEngine.Packages;
- namespace WeEngine.CommonDto
- {
- public class RunningBase
- {
- public RunningBase()
- {
- }
- public RunningBase(NodeBase node)
- {
- Id = node.Id;
- No = node.InternalNo;
- Name = node.Name;
- CorrectionScore = node.CorrectionScore;
- SystemScore = node.ActualScore;
- FullScore = node.NodeFullScore;
- WaitPath = node.WaitPath;
- Variables = "";
- if (node.Variables != null && node.Variables.Count > 0)
- {
- foreach (DictionaryEntry entry in node.Variables)
- {
- if (!DefaultVariable.VariableNames.Contains(entry.Key))
- {
- var v = (IwbRtVariable)entry.Value;
- Variables += (Variables == "" ? "" : ",") + $"[{v.VarName}:{v.DataType.TypeString}:{v.GetStringValue()}]";
- }
- }
- }
- IsStart = node.NodeState == NodeState.Running || node.NodeState == NodeState.RunEnd ||
- node.NodeState == NodeState.Complete;
- IsEnd = node.NodeState == NodeState.RunEnd || node.NodeState == NodeState.Complete;
- }
- [JsonIgnore]
- public RunningBase Parent { get; set; }
- public string Id { get; set; }
- public string No { get; set; }
- public string Name { get; set; }
- [JsonIgnore]
- public string ParentPath => Parent?.Path ?? "";
- public string Path => GetNodePath();
- public string Variables{ get; set; }
- public decimal FullScore { get; set; }
- public decimal CorrectionScore { get; set; }
- public decimal SystemScore { get; set; }
- public bool IsStart { get; set; }
- public bool IsEnd { get; set; }
- public List<string> WaitPath { get; set; }
- protected virtual string GetNodePath()
- {
- return Parent != null ? $"{ParentPath}_{No}" : No;
- }
- [JsonIgnore]
- public Hashtable VariableTable => GetVariableTable();
- private Hashtable GetVariableTable()
- {
- var vTable= new Hashtable();
- if (Variables.IsNotEmpty())
- {
- var varArr = Variables.StrToArray();
- foreach (var v in varArr)
- {
- var arr = v.StrToArray(":");
- string id = "";
- if (arr.Length > 0)
- {
- id = arr[0].UAndT();
- }
- if (id.IsNotEmpty())
- {
- vTable[id] = IwbRtVariable.Str2Variable(v);
- }
- }
-
- }
- return vTable;
- }
- public Hashtable GetVariables()
- {
- var variables = new Hashtable().MergeHashtable(VariableTable);
- if (Parent != null)
- {
- variables = Parent.GetVariables().MergeHashtable(variables);
- }
- return variables;
- }
- public List<RoundRunningInfo> GetRunRoundInfo(List<RoundRunningInfo> roundInfo)
- {
- return roundInfo?.Where(a => a.IsStart).ToList() ?? new List<RoundRunningInfo>();
- }
- public List<BlockRunningInfo> GetRunBlockInfo(List<RoundRunningInfo> roundInfo)
- {
- var list = new List<BlockRunningInfo>();
- foreach (var info in roundInfo)
- {
- var temp = info.BlockInfo?.Where(a => a.IsStart);
- if (temp != null)
- {
- list.AddRange(temp);
- }
- }
- return list;
- }
- public List<FlowRunningInfo> GetRunFlowInfo(List<BlockRunningInfo> blockInfo)
- {
- var list = new List<FlowRunningInfo>();
- foreach (var info in blockInfo)
- {
- var temp = info.FlowInfo?.Where(a => a.IsStart);
- if (temp != null)
- {
- list.AddRange(temp);
- }
- }
- return list;
- }
- public List<FlowNodeRunningInfo> GetRunNodeInfo(List<FlowRunningInfo> flowInfo)
- {
- var list = new List<FlowNodeRunningInfo>();
- foreach (var info in flowInfo)
- {
- var temp = info.NodeInfo?.FirstOrDefault(a => a.IsStart);
- if (temp != null)
- {
- list.Add(temp);
- list = GetRunChildNodeInfo(list, temp.NodeInfo);
- }
- }
- return list;
- }
- private List<FlowNodeRunningInfo> GetRunChildNodeInfo(List<FlowNodeRunningInfo> list, List<FlowNodeRunningInfo> childNodes)
- {
- var temp = childNodes?.FirstOrDefault(a => a.IsStart);
- if (temp != null)
- {
- list.Add(temp);
- if (temp.NodeInfo != null && temp.NodeInfo.Any())
- {
- list = GetRunChildNodeInfo(list, temp.NodeInfo);
- }
- }
- return list;
- }
- public List<SceneRunningInfo> GetRunSceneInfo(List<FlowNodeRunningInfo> nodeInfo)
- {
- var list = new List<SceneRunningInfo>();
- foreach (var info in nodeInfo)
- {
- var temp = info.SceneInfo?.Where(a => a.IsStart);
- if (temp != null)
- {
- list.AddRange(temp);
- }
- }
- return list;
- }
- public List<BehaviorRunningInfo> GetRunBehaviorInfo(List<SceneRunningInfo> sceneInfo)
- {
- var list = new List<BehaviorRunningInfo>();
- foreach (var info in sceneInfo)
- {
- var temp = info.BehaviorInfo?.Where(a => a.IsStart);
- if (temp != null)
- {
- list.AddRange(temp);
- }
- }
- return list;
- }
- }
- public class RunningInfo : RunningBase
- {
- public RunningInfo()
- {
- Parent = null;
- }
- public RunningInfo(NodeBase node) : base(node)
- {
- }
-
- public string PackageNo { get; set; }
- public int CurrentRoundIndex { get; set; }
- /// <summary>
- /// 考核角色
- /// </summary>
- public List<string> AssessRoles { get; set; }
- /// <summary>
- /// 未考核分数自动运行(满分)
- /// </summary>
- public bool AssessAuto { get; set; }
- /// <summary>
- /// 自动下一轮
- /// </summary>
- public bool AutoNextRound { get; set; }
- /// <summary>
- /// 每轮总分
- /// </summary>
- public decimal RoundScore { get; set; }
- [JsonIgnore]
- private List<RoundRunningInfo> _infos;
- public List<RoundRunningInfo> RoundInfo {
- get
- {
- if (_infos != null && _infos.Any())
- {
- foreach (var info in _infos)
- {
- info.Parent = this;
- }
- }
- return _infos;
- }
- set => _infos = value;
- }
- #region Current-RUN
- [JsonIgnore]
- public List<RoundRunningInfo> RunRoundInfo => GetRunRoundInfo(RoundInfo);
- [JsonIgnore]
- public List<BlockRunningInfo> RunBlockInfo => GetRunBlockInfo(RunRoundInfo);
- [JsonIgnore]
- public List<FlowRunningInfo> RunFlowInfo => GetRunFlowInfo(RunBlockInfo);
- [JsonIgnore]
- public List<FlowNodeRunningInfo> RunNodeInfo => GetRunNodeInfo(RunFlowInfo);
- [JsonIgnore]
- public List<SceneRunningInfo> RunSceneInfo => GetRunSceneInfo(RunNodeInfo);
- [JsonIgnore]
- public List<BehaviorRunningInfo> RunBehaviorInfo => GetRunBehaviorInfo(RunSceneInfo);
- #endregion
- }
- public class RoundRunningInfo: RunningBase
- {
- public RoundRunningInfo()
- {
- }
- public RoundRunningInfo(NodeBase node) : base(node)
- {
- RoundIndex = ((SceneRoundNode) node).RoundIndex;
- }
- public int RoundIndex { get; set; }
- [JsonIgnore]
- private List<BlockRunningInfo> _infos;
- public List<BlockRunningInfo> BlockInfo
- {
- get
- {
- if (_infos != null && _infos.Any())
- {
- foreach (var info in _infos)
- {
- info.Parent = this;
- }
- }
- return _infos;
- }
- set => _infos = value;
- }
- [JsonIgnore]
- public List<BlockRunningInfo> RunBlockInfos => BlockInfo.Where(a=>a.IsStart).ToList();
- [JsonIgnore]
- public List<FlowRunningInfo> RunFlowInfos => GetRunFlowInfo(RunBlockInfos);
- [JsonIgnore]
- public List<FlowNodeRunningInfo> RunNodeInfos => GetRunNodeInfo(RunFlowInfos);
- [JsonIgnore]
- public List<SceneRunningInfo> RunSceneInfos => GetRunSceneInfo(RunNodeInfos);
- [JsonIgnore]
- public List<BehaviorRunningInfo> RunBehaviorInfos => GetRunBehaviorInfo(RunSceneInfos);
- [JsonIgnore]
- public List<FlowRunningInfo> FlowInfos => GetRunFlowInfo(BlockInfo);
- [JsonIgnore]
- public List<FlowNodeRunningInfo> NodeInfos => GetRunNodeInfo(FlowInfos);
- [JsonIgnore]
- public List<SceneRunningInfo> SceneInfos => GetRunSceneInfo(NodeInfos);
- [JsonIgnore]
- public List<BehaviorRunningInfo> BehaviorInfos => GetRunBehaviorInfo(SceneInfos);
- }
- public class BlockRunningInfo: RunningBase
- {
- public BlockRunningInfo()
- {
- }
- public BlockRunningInfo(NodeBase node) : base(node)
- {
- BlockType = ((SceneFlowBlockNode) node).BlockType;
- }
- public SceneFlowBlockType BlockType { get; set; }
- [JsonIgnore]
- private List<FlowRunningInfo> _infos;
- public List<FlowRunningInfo> FlowInfo
- {
- get
- {
- if (_infos != null && _infos.Any())
- {
- foreach (var info in _infos)
- {
- info.Parent = this;
- }
- }
- return _infos;
- }
- set => _infos = value;
- }
- }
- public class FlowRunningInfo: RunningBase
- {
- public FlowRunningInfo()
- {
- }
- public FlowRunningInfo(NodeBase node) : base(node)
- {
- }
- [JsonIgnore]
- private List<FlowNodeRunningInfo> _infos;
- public List<FlowNodeRunningInfo> NodeInfo
- {
- get
- {
- if (_infos != null && _infos.Any())
- {
- foreach (var info in _infos)
- {
- info.Parent = this;
- }
- }
- return _infos;
- }
- set => _infos = value;
- }
- }
- public class FlowNodeRunningInfo: RunningBase
- {
- public FlowNodeRunningInfo()
- {
- }
- public FlowNodeRunningInfo(NodeBase node) : base(node)
- {
- }
- [JsonIgnore]
- private List<SceneRunningInfo> _sInfos;
- public List<SceneRunningInfo> SceneInfo
- {
- get
- {
- if (_sInfos != null && _sInfos.Any())
- {
- foreach (var info in _sInfos)
- {
- info.Parent = this;
- }
- }
- return _sInfos;
- }
- set => _sInfos = value;
- }
- [JsonIgnore]
- private List<FlowNodeRunningInfo> _infos;
- public List<FlowNodeRunningInfo> NodeInfo
- {
- get
- {
- if (_infos != null && _infos.Any())
- {
- foreach (var info in _infos)
- {
- info.Parent = this;
- }
- }
- return _infos;
- }
- set => _infos = value;
- }
- }
- public class SceneRunningInfo: RunningBase
- {
- public SceneRunningInfo()
- {
- }
- public SceneRunningInfo(NodeBase node) : base(node)
- {
- //var variables = node.GetSelfVariables();
- //if (variables != null && variables.Count > 0)
- //{
- // foreach (DictionaryEntry entry in variables)
- // {
- // var v = (IwbRtVariable)entry.Value;
- // Variables += (Variables == "" ? "" : ",") + $"[{v.VarName}:{v.DataType.TypeString}:{v.GetStringValue()}]";
- // }
- //}
- }
- [JsonIgnore]
- private List<BehaviorRunningInfo> _infos;
- public List<BehaviorRunningInfo> BehaviorInfo
- {
- get
- {
- if (_infos != null && _infos.Any())
- {
- foreach (var info in _infos)
- {
- info.Parent = this;
- }
- }
- return _infos;
- }
- set => _infos = value;
- }
- }
- public class BehaviorRunningInfo: RunningBase
- {
- public BehaviorRunningInfo()
- {
- }
- public string KeyWords { get; set; }
- public BehaviorRunningInfo(NodeBase node) : base(node)
- {
- }
- }
- }
|