/// <summary> /// 加载节点,第一次使用 /// </summary> private void AddChild() { ChildItems.Clear(); var grp = (from t in Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.InfoGroups where t.Key.Item1 == AreaId orderby t.Value.Index select t.Value).ToList(); this.ChildItems.Add(new RtuGrpItem(AreaId, 0, 3)); foreach (var f in grp) { this.ChildItems.Add(new RtuGrpItem(AreaId, f.GroupId, 2)); } //this.ChildItems.Add(new RtuGrpItem(AreaId, 0, 4)); for (int i = ChildItems.Count - 1; i >= 0; i--) { if (ChildItems[i].ChildItems.Count == 0) { ChildItems.RemoveAt(i); } } }
private void UpdateChildPara() { var allgrp = this.ChildItems[0]; allgrp.SortIndex = 0; //allgrp.UpdateShowInfo(); var spegrp = this.ChildItems[ChildItems.Count - 1]; spegrp.SortIndex = 99999; //spegrp.UpdateShowInfo(); var grpLst = (from t in Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.InfoGroups where t.Key.Item1 == AreaId orderby t.Value.Index select t.Value.GroupId).ToList(); //var tmlLst = // (from t in Wlst.Sr.SlusglInfoHold.Services.SluSglFieldHold.MySlef.Info // where t.Value.AreaId == AreaId && lstneworder.Contains(t.Key) // select t.Key).ToList(); //delete var dlt = (from t in ChildItems where t.NodeId != 0 && grpLst.Contains(t.NodeId) == false select t).ToList(); foreach (var f in dlt) { if (ChildItems.Contains(f)) { ChildItems.Remove(f); } } //update setinfo foreach (var f in ChildItems) { f.UpdateShowInfo(); } //newadd var ex = (from t in ChildItems select t.NodeId).ToList(); var newadd = (from t in grpLst where ex.Contains(t) == false select t).ToList(); foreach (var f in newadd) { ChildItems.Add(new RtuGrpItem(AreaId, f, 2)); } grpLst.Insert(0, 0); grpLst.Add(99999); this.Sort(grpLst); ////sort //var dic = new Dictionary<int, int>(); //for (int i = 0; i <= grpLst.Count; i++) //{ // if (dic.ContainsKey(grpLst[i]) == false) dic.Add(grpLst[i], i + 3); //} //foreach (var f in ChildItems) //{ // if (dic.ContainsKey(f.NodeId)) f.SortIndex = dic[f.NodeId]; //} //this.ChildItems = (from t in ChildItems orderby t.SortIndex ascending select t).ToList(); for (int i = ChildItems.Count - 1; i >= 0; i--) { if (ChildItems[i].ChildItems.Count == 0) { ChildItems.RemoveAt(i); } } }
//1、区域,2、分组,3、全部设备,4、特殊设备 private void UpdateChildPara() { var lstneworder = new List <int>(); if (NodeType == 2) //grp { var grp = Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.GetGroupInfomation(AreaId, NodeId); if (grp != null) { lstneworder = Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.GetRtuOrGrpIndex(grp.LstTml); } } if (NodeType == 3) //all { var grp = Wlst.Sr.EquipmentInfoHolding.Services.AreaInfoHold.MySlef.GetAreaInfo(AreaId); if (grp != null) { var gprs = Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.GetRtuOrGrpIndex(grp.LstTml, AreaId, true); foreach (var f in gprs.Item1) { lstneworder.AddRange(gprs.Item1); } lstneworder.AddRange( Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.GetRtuOrGrpIndex(gprs.Item2)); } } if (NodeType == 4) //spe { var grp = Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.GetRtuNotInAnyGroup(AreaId); if (grp.Count == 0) { return; } lstneworder.AddRange( Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.GetRtuOrGrpIndex(grp)); } if (NodeType >= 2 && NodeType <= 4) { var tmlLst = (from t in Wlst.Sr.SlusglInfoHold.Services.SluSglInfoHold.MySlef.Info where t.Value.AreaId == AreaId && lstneworder.Contains(t.Key) select t.Key).ToList(); //delete var dlt = (from t in ChildItems where tmlLst.Contains(t.NodeId) == false select t).ToList(); foreach (var f in dlt) { if (ChildItems.Contains(f)) { ChildItems.Remove(f); } } var dic = new List <int>(); //update setinfo foreach (var f in ChildItems) { f.UpdateShowInfo(); dic.Add(f.NodeId); } //newadd foreach (var f in tmlLst) { if (dic.Contains(f)) { continue; } ChildItems.Add(new FieldNodeItem(f)); } this.Sort(tmlLst); ////add and sort //for (int i = 0; i < tmlLst.Count; i++) //{ // int cur = tmlLst[i]; // if (ChildItems.Count < i + 1) ChildItems.Add(dic[cur]); // else if (ChildItems[i].NodeId != cur) ChildItems.Insert(i, dic[cur]); //} } for (int i = ChildItems.Count - 1; i >= 0; i--) { if (ChildItems[i].ChildItems.Count == 0) { ChildItems.RemoveAt(i); } } }