123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- /*-------------------------------------------------------------------------
- * 功能描述:DataNodeUtil
- * 作者:xulisong
- * 创建时间: 2018/12/10 14:51:29
- * 版本号:v1.0
- * -------------------------------------------------------------------------*/
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using SAGA.Models;
- namespace SAGA.GplotRelationComputerManage
- {
- public class DataNodeUtil
- {
- public static void BuildNode(DataNode node, List<DataNode> sourceNodes)
- {
- //从上往下遍历可以控制父节点的范围
- var isHandled = node.GetData<bool>();
- node.SetData(true);
- #region 结束条件
- if (string.IsNullOrWhiteSpace(node.Sno))
- {
- return;
- }
- if (node.Childrens.Count != 0 ||isHandled)
- {
- return;
- }
- #endregion
- #region 父子关系整理
- var baseNo = node.Sno;
- List<DataNode> mainNodes = new List<DataNode>();
- List<DataNode> standbyNodes = new List<DataNode>();
- foreach (var sourceNode in sourceNodes)
- {
- if (sourceNode.Sno == baseNo)
- {
- continue;
- }
- if (sourceNode.InLineNo == baseNo)
- {
- sourceNode.Parent = node;
- mainNodes.Add(sourceNode);
- }
- else if(sourceNode.InLineNo1 == baseNo)
- {
- sourceNode.Parent = node;
- standbyNodes.Add(sourceNode);
- }
- }
- node.Childrens.AddRange(mainNodes);
- node.Childrens.AddRange(standbyNodes);
- #endregion
- #region 递归调用
- foreach (var nodeChildren in node.Childrens)
- {
- BuildNode(nodeChildren, sourceNodes);
- }
- #endregion
- }
- }
- }
|