public void CleanChildren()
 {
     for (int i = ChildTreeItems.Count - 1; i > -1; i--)
     {
         ChildTreeItems.RemoveAt(i);
     }
 }
Beispiel #2
0
        /// <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>
        /// 当分组信息发生变化的时候  增量式重新加载节点
        /// </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;
            }

            this.NodeName = info.AreaName;

            var arealst = (from t in info.LstTml select t).ToList();

            var gprlst = (from t in Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.InfoGroups
                          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.IsGrpSpecial &&
                    ChildTreeItems[i].NodeType != TypeOfTabTreeNode.IsGrp &&
                    ChildTreeItems[i].NodeType != TypeOfTabTreeNode.IsAll)
                {
                    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 TreeNodeItemSingleGroupViewModel(this, AreaId, t, TypeOfTabTreeNode.IsGrp));
            }

            foreach (var f in this.ChildTreeItems)
            {
                if (!lstUp.Contains(f.NodeId))
                {
                    continue;
                }
                f.ReUpdate(0);
            }

            TreeNodeBaseNode spe = null;
            var spelst           = Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.GetRtuNotInAnyGroup(AreaId);

            foreach (var f in this.ChildTreeItems)
            {
                if (f.NodeType == TypeOfTabTreeNode.IsAll)
                {
                    f.ReUpdate(0);
                }
                if (f.NodeType == TypeOfTabTreeNode.IsGrpSpecial)
                {
                    if (spelst.Count == 0)
                    {
                        this.ChildTreeItems.Remove(f);
                        break;
                    }
                    f.ReUpdate(0);
                    spe = f;
                }
            }

            if (spe == null && spelst.Count > 0)
            {
                this.ChildTreeItems.Add(new TreeNodeItemSingleGroupViewModel(this, AreaId, 0,
                                                                             TypeOfTabTreeNode.IsGrpSpecial));
            }
        }