/// <summary> /// 当分组信息发生变化的时候 增量式重新加载节点 /// </summary> public void UpdateSpecial() { var info = Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.GetRtuNotInAnyGroup(AreaId); if (info.Count == 0) { this.ChildTreeItems.Clear(); if (_father != null) { _father.ChildTreeItems.Remove(this); } return; } //node delete for (int i = this.ChildTreeItems.Count - 1; i >= 0; i--) { if (ChildTreeItems[i].NodeType != TypeOfTabTreeNode.IsTml) { this.ChildTreeItems.RemoveAt(i); continue; } if (info.Contains(ChildTreeItems[i].NodeId) == false || !Sr.EquipmentInfoHolding.Services.EquipmentDataInfoHold.InfoItems.ContainsKey( ChildTreeItems[i].NodeId)) { this.ChildTreeItems.RemoveAt(i); } } //tml add and update var exist = (from t in ChildTreeItems select t.NodeId).ToList(); foreach (var t in info) { if (exist.Contains(t)) { continue; } var para = Sr.EquipmentInfoHolding.Services.EquipmentDataInfoHold.GetInfoById(t); if (para == null || para.EquipmentType != WjParaBase.EquType.Rtu) { continue; } if (para.RtuFid != 0) { continue; } var vol = para as Wj3005Rtu; if (vol != null && vol.WjVoltage.RtuUsedType == 2) { ChildTreeItems.Add(new TreeNodeItemTmlViewModel(this, para)); } } //按给定顺序排序 var ntss = ServicesGrpSingleInfoHold.GetRtuOrGrpIndex(info); var idc = new Dictionary <int, TreeNodeBaseNode>(); foreach (var f in this.ChildTreeItems) { if (!ntss.Contains(f.NodeId)) { continue; } int index = ntss.IndexOf(f.NodeId); if (idc.ContainsKey(index) == false) { idc.Add(index, f); } } for (int i = 0; i < ChildTreeItems.Count; i++) { if (idc.ContainsKey(i) == false) { continue; } if (ChildTreeItems.Count < i) { continue; } if (ChildTreeItems[i].NodeId != idc[i].NodeId) { if (ChildTreeItems.Contains(idc[i])) { ChildTreeItems.Remove(idc[i]); } ChildTreeItems.Insert(i, idc[i]); } } }
/// <summary> /// 当分组信息发生变化的时候 增量式重新加载节点 /// </summary> public void UpdateArea(int areaId) { var info = Wlst.Sr.EquipmentInfoHolding.Services.AreaInfoHold.MySlef.GetAreaInfo(areaId); if (info == null) { this.ChildTreeItems.Clear(); return; } var gprlst = (from t in Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpMultiInfoHoldNew.ItemsMultiGrp where t.Key.Item1 == areaId select t.Key.Item2).ToList(); //node delete for (int i = this.ChildTreeItems.Count - 1; i >= 0; i--) { if (ChildTreeItems[i].NodeId == 0) { continue; } if (gprlst.Contains(ChildTreeItems[i].NodeId) == false) { ChildTreeItems.RemoveAt(i); } if (ChildTreeItems[i].NodeType != TypeOfTabTreeNode.IsGrp) { this.ChildTreeItems.RemoveAt(i); } } //tml add and update var exist = (from t in ChildTreeItems select t.NodeId).ToList(); var lstUp = new List <int>(); foreach (var t in gprlst) { if (exist.Contains(t)) { lstUp.Add(t); continue; } var para = Sr.EquipmentInfoHolding.Services.ServicesGrpMultiInfoHoldNew.GetGroupInfomation(areaId, t); if (para == null) { continue; } if (para.LstTml.Count == 0) { continue; } ChildTreeItems.Add(new TreeNodeItemMultiGroupViewModelNew(null, areaId, t, TypeOfTabTreeNode.IsGrp)); } foreach (var f in this.ChildTreeItems) { if (!lstUp.Contains(f.NodeId)) { continue; } f.ReUpdate(0); } //for (int i = this.ChildTreeItems.Count - 1; i >= 0; i--) //{ // if (this.ChildTreeItems[i].ChildTreeItems.Count == 0) this.ChildTreeItems.RemoveAt(i); //} for (int i = this.ChildTreeItems.Count - 1; i >= 0; i--) { if (this.ChildTreeItems[i].RtuCount == 0 || this.ChildTreeItems[i].ChildTreeItems.Count == 0) { this.ChildTreeItems.RemoveAt(i); } } }
/// <summary> /// 当分组信息发生变化的时候 增量式重新加载节点 updateArgu wuyong /// </summary> public override void ReUpdate(int updateArgu) { //添加分组到子节点中 if (!Sr.EquipmentInfoHolding.Services.ServicesGrpMulitInfoHold.ItemsMultGrp.ContainsKey(NodeId)) { this.ChildTreeItems.Clear(); if (_father != null) { _father.ChildTreeItems.Remove(this); } return; } var gprInfo = Sr.EquipmentInfoHolding.Services.ServicesGrpMulitInfoHold.ItemsMultGrp[NodeId]; this.NodeName = gprInfo.GroupName; //node delete for (int i = this.ChildTreeItems.Count - 1; i >= 0; i--) { if (ChildTreeItems[i].NodeType == TypeOfTabTreeNode.IsTml) { if (!gprInfo.LstTml.Contains(ChildTreeItems[i].NodeId) || Wlst.Sr.EquipmentInfoHolding.Services.EquipmentDataInfoHold.InfoItems.ContainsKey( ChildTreeItems[i].NodeId)) { this.ChildTreeItems.RemoveAt(i); } } else { this.ChildTreeItems.RemoveAt(i); } } var existnode = (from t in ChildTreeItems select t.NodeId).ToList(); //tml add and update foreach (var t in gprInfo.LstTml) { if (existnode.Contains(t)) { continue; } if (!Sr.EquipmentInfoHolding.Services.EquipmentDataInfoHold.InfoItems.ContainsKey(t)) { continue; } var f = Sr.EquipmentInfoHolding.Services.EquipmentDataInfoHold.InfoItems[t]; if (f.RtuFid != 0 || f.EquipmentType != WjParaBase.EquType.Rtu) { continue; } ChildTreeItems.Add(new TreeNodeItemTmlViewModel(this, f)); } foreach (var t in this.ChildTreeItems) { t.GetChildRtuCount(); } }
/// <summary> /// 当分组信息发生变化的时候 增量式重新加载节点 /// </summary> public void UpdateArea() { var info = Wlst.Sr.EquipmentInfoHolding.Services.AreaInfoHold.MySlef.GetAreaInfo(this.AreaId); //.Values.ToList(); if (info == null) { this.ChildTreeItems.Clear(); if (_father != null) { _father.ChildTreeItems.Remove(this); } return; } var nodename = ""; nodename = info.AreaName; if (this.AreaId == -1) { nodename = "全部区域"; } var gprlst = (from t in Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpMultiInfoHoldNew.ItemsMultiGrp where t.Key.Item1 == AreaId select t.Key.Item2).ToList(); //var spe = Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.GetRtuNotInAnyGroup(AreaId); //if(spe .Count >0) // gprlst.Add(0); //node delete for (int i = this.ChildTreeItems.Count - 1; i >= 0; i--) { if (ChildTreeItems[i].NodeId == 0) { continue; } if (gprlst.Contains(ChildTreeItems[i].NodeId) == false) { ChildTreeItems.RemoveAt(i); } if (ChildTreeItems[i].NodeType != TypeOfTabTreeNode.IsGrp) { this.ChildTreeItems.RemoveAt(i); } } //tml add and update var exist = (from t in ChildTreeItems select t.NodeId).ToList(); var lstUp = new List <int>(); foreach (var t in info.LstTml) { if (exist.Contains(t)) { lstUp.Add(t); continue; } var para = Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.GetGroupInfomation(AreaId, t); if (para == null) { continue; } if (para.LstTml.Count == 0) { continue; } ChildTreeItems.Add(new TreeNodeItemMultiGroupViewModelNew(this, AreaId, t, TypeOfTabTreeNode.IsGrp)); } foreach (var f in this.ChildTreeItems) { if (!lstUp.Contains(f.NodeId)) { continue; } f.ReUpdate(0); } this.NodeName = nodename; }
/// <summary> /// 当分组信息发生变化的时候 增量式重新加载节点 updateArgu wuyong /// </summary> public override void ReUpdate(int updateArgu) { //lvf 2018年4月17日14:37:13 默认区域id为0 var tu = new Tuple <int, int>(0, NodeId); //添加分组到子节点中 if (!ServicesGrpSingleInfoHold.InfoGroups.ContainsKey(tu)) { if (_father != null) { _father.ChildTreeItems.Remove(this); } return; } this.NodeName = ServicesGrpSingleInfoHold.InfoGroups[tu].GroupName; ////////////////node delete //////////////for (int i = this.ChildTreeItems.Count - 1; i >= 0; i--) //////////////{ ////////////// if (ChildTreeItems[i].NodeType == TypeOfTabTreeNode.IsGrp) ////////////// { ////////////// if ( ////////////// !ServicesGrpSingleInfoHold.InfoGroups[tu]. ////////////// LstGrp.Contains( ////////////// ChildTreeItems[i].NodeId)) ////////////// if (!Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.InfoGroups.ContainsKey(tu)) ////////////// { ////////////// this.ChildTreeItems.RemoveAt(i); ////////////// } ////////////// } ////////////// else if (ChildTreeItems[i].NodeType == TypeOfTabTreeNode.IsTml) ////////////// { ////////////// if ( ////////////// !ServicesGrpSingleInfoHold.InfoGroups[tu]. ////////////// LstTml.Contains( ////////////// ChildTreeItems[i].NodeId) || ////////////// !Wlst.Sr.EquipmentInfoHolding.Services.EquipmentDataInfoHold.InfoItems.ContainsKey(ChildTreeItems[i].NodeId)) ////////////// //!ServicesEquipemntInfoHold.EquipmentInfoDictionary.ContainsKey( ////////////// // ChildTreeItems[i].NodeId)) ////////////// { ////////////// this.ChildTreeItems.RemoveAt(i); ////////////// } ////////////// else ////////////// { ////////////// //if() ////////////// } ////////////// } //////////////} //////////////grp add and update ////////////foreach ( //////////// var t in //////////// ServicesGrpSingleInfoHold.InfoGroups[NodeId].LstGrp) ////////////{ //////////// bool bolfind = false; //////////// foreach (var ff in this.ChildTreeItems) //////////// { //////////// if (ff.NodeType == TypeOfTabTreeNode.IsGrp && ff.NodeId == t) //////////// { //////////// bolfind = true; //////////// ff.ReUpdate(0); //////////// break; //////////// } //////////// } //////////// if (!bolfind) //////////// { //////////// if ( //////////// !ServicesGrpSingleInfoHold.InfoGroups.ContainsKey(t)) //////////// continue; //////////// var addgrp = new TreeNodeItemSingleGroupViewModel(this, //////////// ServicesGrpSingleInfoHold. //////////// InfoGroups[t]); //////////// this.ChildTreeItems.Insert(0, addgrp); //////////// //addgrp.AddChild(); //////////// } ////////////} //tml add and update var tmpssssss = (from gt in ServicesGrpSingleInfoHold.InfoGroups[tu].LstTml orderby gt ascending select gt).ToList(); foreach (var t in tmpssssss) { bool bolfind = false; foreach (var ff in this.ChildTreeItems) { if (ff.NodeType == TypeOfTabTreeNode.IsTml && ff.NodeId == t) { bolfind = true; break; } } if (!bolfind) { //if (!Sr.EquipmentInfoHolding.Services.ServicesEquipemntInfoHold.EquipmentInfoDictionary .ContainsKey(t)) continue; //var ff = // Sr.EquipmentInfoHolding.Services.ServicesEquipemntInfoHold.EquipmentInfoDictionary // [t]; //ChildTreeItems.Add(new TreeNodeItemTmlViewModel(this, ff)); if (!BaseNodes.Nodess.ContainsKey(t)) { if ( !Wlst.Sr.EquipmentInfoHolding.Services.EquipmentDataInfoHold.InfoItems. ContainsKey( t)) { continue; } var f = Wlst.Sr.EquipmentInfoHolding.Services.EquipmentDataInfoHold.InfoItems [t]; if (f.RtuFid != 0) { continue; } new TreeNodeItemTmlViewModel(this, f); } if (!BaseNodes.Nodess.ContainsKey(t)) { continue; } ChildTreeItems.Add(BaseNodes.Nodess[t]); continue; } } var lst = new List <int>(); //var tu = new Tuple<int, int>(0, NodeId); lst.AddRange( ServicesGrpSingleInfoHold.InfoGroups[tu].LstTml); //lst.AddRange( // ServicesGrpSingleInfoHold.InfoGroups[tu].LstGrp); //var ntss = Wlst.Sr.EquipmentGroupInfoHolding.Services.ServicesGrpSingleInfoHold.GetRtuOrGrpIndex(lst); var ntss = Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.GetRtuOrGrpIndex(lst); var indexed = new List <TreeNodeBaseNode>(); var dir = new Dictionary <int, TreeNodeBaseNode>(); foreach (var g in this.ChildTreeItems) { if (!dir.ContainsKey(g.NodeId)) { dir.Add(g.NodeId, g); } } foreach (var t in ntss) { if (dir.ContainsKey(t)) { indexed.Add(dir[t]); } } for (int i = 0; i < indexed.Count; i++) { if (this.ChildTreeItems.Count > i) { if (this.ChildTreeItems[i].NodeId == indexed[i].NodeId && this.ChildTreeItems[i].NodeType == indexed[i].NodeType) { continue; } this.ChildTreeItems.RemoveAt(i); this.ChildTreeItems.Insert(i, indexed[i]); } else { this.ChildTreeItems.Add(indexed[i]); } } }
/// <summary> /// 加载节点,第一次使用 /// </summary> public override void AddChild() { ChildTreeItems.Clear(); if (NodeType != TypeOfTabTreeNode.IsGrp) { return; } //lvf 2018年4月17日14:37:13 默认区域id为0 var tu = new Tuple <int, int>(0, NodeId); //添加分组到子节点中 //if (!ServicesGrpSingleInfoHold.InfoGroups.ContainsKey(tu)) // return; //var tmps = // (from gt in // ServicesGrpSingleInfoHold.InfoGroups[tu].LstGrp // orderby gt ascending // select gt).ToList(); //var ntss = ServicesGrpSingleInfoHold.GetRtuOrGrpIndex(tmps); //foreach (var t in ntss) //{ // if (!ServicesGrpSingleInfoHold.InfoGroups.ContainsKey(t)) // continue; //ChildTreeItems.Add(new TreeNodeItemSingleGroupViewModel(this, // ServicesGrpSingleInfoHold.InfoGroups[ // tu])); ////} ////对分组子节点 进行数据加载 //foreach (var t1 in ChildTreeItems) //{ // t1.AddChild(); //} ///加载终端节点 var tmpssssss = (from gt in ServicesGrpSingleInfoHold.InfoGroups[tu].LstTml orderby gt ascending select gt).ToList(); var ntsss = ServicesGrpSingleInfoHold.GetRtuOrGrpIndex(tmpssssss); var LST = new List <TreeNodeBaseNode>(); foreach (var t in ntsss) { if (!BaseNodes.Nodess.ContainsKey(t)) { if ( !Wlst.Sr.EquipmentInfoHolding.Services.EquipmentDataInfoHold.InfoItems.ContainsKey( t)) { continue; } var f = Wlst.Sr.EquipmentInfoHolding.Services.EquipmentDataInfoHold.InfoItems [t]; new TreeNodeItemTmlViewModel(this, f); } if (!BaseNodes.Nodess.ContainsKey(t)) { continue; } // ChildTreeItems.Add(GrpComSingleMuliViewModel.BaseNodes.Nodess[t]); LST.Add(BaseNodes.Nodess[t]); continue; } // var lstord = (from t in LST orderby t.PhyId ascending select t).ToList(); foreach (var t in LST) { ChildTreeItems.Add(t); } }