/// <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]);
                }
            }
        }
Beispiel #2
0
        public void LoadNode()
        {
            if (ServicesGrpSingleInfoHold.InfoGroups.Count == 0 &&
                Sr.EquipmentInfoHolding.Services.AreaInfoHold.MySlef.AreaInfo.Count == 0)
            {
                return;
            }
            ChildTreeItems.Clear();
            var        userProperty = UserInfo.UserLoginInfo;
            List <int> areaLst      = new List <int>();

            areaLst.AddRange(userProperty.AreaX);
            foreach (var t in userProperty.AreaW)
            {
                if (!areaLst.Contains(t))
                {
                    areaLst.Add(t);
                }
            }
            foreach (var f in userProperty.AreaR)
            {
                if (!areaLst.Contains(f))
                {
                    areaLst.Add(f);
                }
            }
            IsLoadOnlyOneArea = areaLst.Count < 2;

            if (userProperty.D == true)
            {
                if (Wj9001ManageSetting.ViewModel.Wj9001LoadSet.Myself.IsShowArea)
                {
                    foreach (var f in Wlst.Sr.EquipmentInfoHolding.Services.AreaInfoHold.MySlef.AreaInfo.Keys)
                    {
                        var lstInArea = Wlst.Sr.EquipmentInfoHolding.Services.AreaInfoHold.MySlef.GetRtuInArea(f);
                        var rtuLst    = new List <int>();
                        foreach (var a in lstInArea)
                        {
                            var pb = Wlst.Sr.EquipmentInfoHolding.Services.EquipmentDataInfoHold.GetInfoById(a);
                            if (pb == null)
                            {
                                continue;
                            }
                            if (pb.EquipmentType == WjParaBase.EquType.Leak && pb.RtuFid == 0)  //线路为主设备
                            {
                                rtuLst.Add(pb.RtuId);
                                //if (IsLoadOnlyOneArea)
                                //{
                                //    int AreaId = areaLst[0];
                                //    ShowGrpInArea(AreaId);
                                //}
                                //else
                                //{
                                //    this.ChildTreeItems.Add(new TreeNodeAreaViewModel(null, f, 0, TypeOfTabTreeNode.IsArea));
                                //}

                                //break;
                            }
                            else if (pb.EquipmentType == WjParaBase.EquType.Rtu &&
                                     pb.EquipmentsThatAttachToThisRtu.Count > 0) //haha 特殊终端下有线路
                            {
                                foreach (var g in pb.EquipmentsThatAttachToThisRtu)
                                {
                                    var pa = Wlst.Sr.EquipmentInfoHolding.Services.EquipmentDataInfoHold.GetInfoById(g);
                                    if (pa == null)
                                    {
                                        continue;
                                    }
                                    if (pa.EquipmentType == WjParaBase.EquType.Leak && pa.RtuFid > 0)
                                    {
                                        rtuLst.Add(g);
                                        //if (IsLoadOnlyOneArea)
                                        //{
                                        //    int AreaId = areaLst[0];
                                        //    ShowGrpInArea(AreaId);
                                        //}
                                        //else
                                        //{
                                        //     this.ChildTreeItems.Add(new TreeNodeAreaViewModel(null, f, 0, TypeOfTabTreeNode.IsArea));
                                        //}

                                        //break;
                                    }
                                }
                            }
                        }
                        if (rtuLst.Count > 0)
                        {
                            if (IsLoadOnlyOneArea)
                            {
                                int AreaId = areaLst[0];
                                ShowGrpInArea(AreaId);
                            }
                            else
                            {
                                this.ChildTreeItems.Add(new TreeNodeAreaViewModel(null, f, 0,
                                                                                  TypeOfTabTreeNode.IsArea));
                            }
                        }
                    }
                }
                else
                {
                    foreach (var f in Wlst.Sr.EquipmentInfoHolding.Services.AreaInfoHold.MySlef.AreaInfo.Keys)
                    {
                        ShowGrpInArea(f);
                    }
                }
            }
            else
            {
                if (IsLoadOnlyOneArea)
                {
                    int AreaId = areaLst[0];
                    ShowGrpInArea(AreaId);
                }
                else
                {
                    foreach (var f in areaLst)
                    {
                        var lstInArea = Wlst.Sr.EquipmentInfoHolding.Services.AreaInfoHold.MySlef.GetRtuInArea(f);
                        var rtuLst    = new List <int>();
                        foreach (var a in lstInArea)
                        {
                            var pb = Wlst.Sr.EquipmentInfoHolding.Services.EquipmentDataInfoHold.GetInfoById(a);
                            if (pb == null)
                            {
                                continue;
                            }
                            if (pb.EquipmentType == WjParaBase.EquType.Leak && pb.RtuFid == 0)  //线路为主设备
                            {
                                rtuLst.Add(pb.RtuId);
                                //this.ChildTreeItems.Add(new TreeNodeAreaViewModel(null, f, 0, TypeOfTabTreeNode.IsArea));
                                //break; ;
                            }
                            else if (pb.EquipmentType == WjParaBase.EquType.Rtu &&
                                     pb.EquipmentsThatAttachToThisRtu.Count > 0) //haha 特殊终端下有线路
                            {
                                foreach (var g in pb.EquipmentsThatAttachToThisRtu)
                                {
                                    var pa = Wlst.Sr.EquipmentInfoHolding.Services.EquipmentDataInfoHold.GetInfoById(g);
                                    if (pa == null)
                                    {
                                        continue;
                                    }
                                    if (pa.EquipmentType == WjParaBase.EquType.Leak && pa.RtuFid > 0)
                                    {
                                        rtuLst.Add(g);
                                        //this.ChildTreeItems.Add(new TreeNodeAreaViewModel(null, f, 0, TypeOfTabTreeNode.IsArea));
                                        //break;
                                    }
                                }
                            }
                        }
                        if (rtuLst.Count > 0)
                        {
                            if (IsLoadOnlyOneArea)
                            {
                                int AreaId = areaLst[0];
                                ShowGrpInArea(AreaId);
                            }
                            else
                            {
                                this.ChildTreeItems.Add(new TreeNodeAreaViewModel(null, f, 0,
                                                                                  TypeOfTabTreeNode.IsArea));
                            }
                        }
                    }
                }
            }
            for (int i = this.ChildTreeItems.Count - 1; i > 0; i--)
            {
                var t = this.ChildTreeItems[i];
                if (t.NodeType == TypeOfTabTreeNode.IsTml)
                {
                    continue;
                }
                t.GetChildRtuCount();
                if (t.RtuCount == 0)
                {
                    ChildTreeItems.Remove(t);
                }
            }
            foreach (var t in this.ChildTreeItems)
            {
                t.GetChildRtuCount();
            }
        }