private void RecursionCameraGroup(List<Resource> customTree, List<string> pathList, Dictionary<string, CameraGroup> groupDic, Dictionary<string, NodeRelation> nodeRelationDic, List<NodeRelation> nodeRelationListT)
{
NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
if (customTree == null)
{
logEx.Error("RecursionCameraGroup failed.CustomTree is null.");
return;
}
if (pathList == null)
{
pathList = new List<string>();
}
if (groupDic == null)
{
groupDic = new Dictionary<string, CameraGroup>();
}
if (nodeRelationDic == null)
{
nodeRelationDic = new Dictionary<string, NodeRelation>();
}
if (nodeRelationListT == null)
{
nodeRelationListT = new List<NodeRelation>();
}
foreach (Resource custom in customTree)
{
//TypeId为5时,表示该节点为通道,对应一个摄像头
if (((int)NodeType.CAMERA).ToString().Equals(custom.TypeId))
{
//pathList.Add(custom.Id);
NodeRelation nodeRelation = new NodeRelation(custom.Id, new List<string>(pathList), CgwMonitorManage.Common.NodeType.CAMERA);
if (!nodeRelationDic.ContainsKey(custom.Id))
{
nodeRelationDic.Add(custom.Id, nodeRelation);
}
nodeRelationListT.Add(nodeRelation);
//获取完路径后,要返回上一级路径
//pathList.Remove(custom.Id);
}
//TypeId为1000时,表示该节点为分组
else if (((int)NodeType.GROUP).ToString().Equals(custom.TypeId))
{
//添加组信息
CameraGroup cameraGroup = new CameraGroup(custom.Id, custom.Caption);
groupDic.Add(custom.Id, cameraGroup);
NodeRelation nodeRelation = new NodeRelation(custom.Id, new List<string>(pathList), CgwMonitorManage.Common.NodeType.GROUP);
if (!nodeRelationDic.ContainsKey(custom.Id))
{
nodeRelationDic.Add(custom.Id, nodeRelation);
}
nodeRelationListT.Add(nodeRelation);
//添加分组关系
pathList.Add(custom.Id);
//如果是组,还需要递归处理,遍历子节点
RecursionCameraGroup(custom.items, pathList, groupDic, nodeRelationDic, nodeRelationListT);
//获取完路径后,要返回上一级路径
pathList.Remove(custom.Id);
}
else
{
//其他类型节点不做处理
}
}
}