Ejemplo n.º 1
0
        internal void LoadList(ArchorDevList archors)
        {
            this.archors = archors;
            resultList   = new CommandResultManager();
            if (archors.ArchorList != null)
            {
                foreach (var item in archors.ArchorList)
                {
                    var group = resultList.Add(item);
                    //group.Archor.Ip = item.ArchorIp;
                    group.Archor.Area = item.InstallArea;
                }
            }

            UDPArchorList list = new UDPArchorList();

            foreach (var item in resultList.Groups)
            {
                list.Add(item.Archor);
                item.Archor.Num = list.Count;
            }

            archorList = list;
            if (ArchorListChanged != null)
            {
                ArchorListChanged(list, null);
            }
        }
Ejemplo n.º 2
0
        public static ArchorDevList LoadArchoDevInfo()
        {
            string basePath = AppDomain.CurrentDomain.BaseDirectory;
            string filePath = basePath + "Data\\基站信息\\ArchorFiles.xml";
            var    initInfo = XmlSerializeHelper.LoadFromFile <ArchorDevList>(filePath);

            if (initInfo != null)
            {
                ArchorList = initInfo;
            }
            return(initInfo);
        }
Ejemplo n.º 3
0
        private void LoadList()
        {
            //3.加载清单代码
            var list = ArchorHelper.LoadArchoDevInfo();

            ArchorDevList list2 = new ArchorDevList();

            list2.ArchorList = new List <ArchorDev>();
            foreach (var item in list.ArchorList)
            {
                var a = DbArchorList.Find(i => i.Code == item.ArchorID);
                if (a != null)
                {
                    list2.ArchorList.Add(item);
                    item.Archor = a;
                }
            }
            archorManager.LoadList(list2);
        }
        private void TbCode_KeyUp(object sender, KeyEventArgs e)
        {
            ArchorDevList archorList = ArchorHelper.ArchorList;

            if (archorList != null && archorList.ArchorList != null)
            {
                var code = (TbCode.Text).ToLower();
                var devs = archorList.ArchorList.Where(i => (i.ArchorID).ToLower().Contains(code)).ToList();
                if (devs != null && devs.Count() > 0)
                {
                    TbCode.ItemsSource    = devs;
                    IPCode1.ItemsSource   = devs;
                    TbCode.IsDropDownOpen = true;

                    if (devs.Count() == 1)
                    {
                        TbCode.SelectedItem = devs[0];
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void LoadList()
        {
            var list = ArchorHelper.LoadArchoDevInfo();

            Bll bll     = Bll.NewBllNoRelation();
            var anchors = bll.Archors.ToList();

            ArchorDevList list2 = new ArchorDevList();

            list2.ArchorList = new List <ArchorDev>();
            foreach (var item in list.ArchorList)
            {
                var a = anchors.Find(i => i.Code == item.ArchorID);
                if (a != null)
                {
                    list2.ArchorList.Add(item);
                }
            }

            archorManager.LoadList(list2);
            CbList.IsChecked = true;
        }
Ejemplo n.º 6
0
        public bool ShowInfo(Rectangle rect, int devId)
        {
            ArchorDevList archorList = ArchorHelper.ArchorList;

            TbCode.ItemsSource       = archorList.ArchorList;
            TbCode.DisplayMemberPath = "ArchorID";

            IPCode1.ItemsSource       = archorList.ArchorList;
            IPCode1.DisplayMemberPath = "ArchorIp";

            Bll bll = new Bll();

            this._dev  = bll.DevInfos.Find(devId);
            this._rect = rect;
            _archor    = bll.Archors.Find(i => i.DevInfoId == _dev.Id);
            if (_archor == null)
            {
                return(false);//不是基站的设备
            }
            _item      = new ArchorSetting(_archor.GetCode(), _archor.Id);
            _code      = _archor.Code;
            _item.Name = _archor.Name;

            var area = bll.GetAreaTree(false, _dev.ParentId);

            _item.RelativeMode = RelativeMode.相对楼层;

            x = _dev.PosX;
            z = _dev.PosZ;

            _item.SetRelative(x, z);
            _item.RelativeHeight = _dev.PosY;

            park = area;

            var minX = park.InitBound.MinX;
            var minY = park.InitBound.MinY;

            _item.SetAbsolute(x + minX, z + minY);

            LbId.Text     = _archor.Id + "";
            TbName.Text   = _archor.Name;
            TbCode.Text   = _archor.GetCode();
            IPCode1.Text  = _archor.Ip;
            TbHeight.Text = _item.RelativeHeight.ToString("F3");

            PcArchor.X = x;
            PcArchor.Y = z;


            PcArchor.IsEnabled = true;

            var setting = bll.ArchorSettings.GetByCode(_code, _archor.Id);

            if (setting != null)
            {
                //PcZero.X = setting.ZeroX.ToDouble();
                //PcZero.Y = setting.ZeroY.ToDouble();

                SetZeroPoint(setting.ZeroX.ToDouble(), setting.ZeroY.ToDouble());
                Title += " [已配置]";
            }
            else
            {
                SetZeroPoint(ArchorSettingContext.ZeroX, ArchorSettingContext.ZeroY);
                //PcZero.X = ArchorSettingContext.ZeroX;
                //PcZero.Y = ArchorSettingContext.ZeroY;
                //PcRelative.X = x - ArchorSettingContext.ZeroX;
                //PcRelative.Y = z - ArchorSettingContext.ZeroY;
            }

            PcAbsolute.X = PcZero.X + PcRelative.X;
            PcAbsolute.Y = PcZero.Y + PcRelative.Y;

            PcZero.ValueChanged     += PcZero_OnValueChanged;
            PcRelative.ValueChanged += PcRelative_OnValueChanged;

            return(true);
        }
        public bool ShowInfo(Rectangle rect, int devId)
        {
            PcZero.ValueChanged     -= PcZero_ValueChanged;
            PcRelative.ValueChanged -= PcRelative_ValueChanged;
            PcArchor.ValueChanged   -= PcArchor_ValueChanged;

            ArchorDevList archorList = ArchorHelper.ArchorList;

            TbCode.ItemsSource       = archorList.ArchorList;
            TbCode.DisplayMemberPath = "ArchorID";

            IPCode1.ItemsSource       = archorList.ArchorList;
            IPCode1.DisplayMemberPath = "ArchorIp";

            Bll bll = new Bll();

            this._dev  = bll.DevInfos.Find(devId);
            this._rect = rect;
            _archor    = bll.Archors.Find(i => i.DevInfoId == _dev.Id);
            if (_archor == null)
            {
                return(false);
            }
            _code = _archor.GetCode();

            _item      = new ArchorSetting(_code, _archor.Id);
            _item.Name = _archor.Name;
            var area = _dev.Parent;

            x = _dev.PosX;
            z = _dev.PosZ;

            _item.SetRelative(x, z);
            _item.RelativeHeight = _dev.PosY;

            _floor = area;

            _building = _floor.Parent;

            if (_building.Children == null)
            {
                _building.Children = bll.Areas.Where(i => i.ParentId == _building.Id);
            }
            floorHeight        = _floor.InitBound.MinZ;
            TbFloorHeight.Text = floorHeight.ToString("F3");

            //var building = areas.Find(j => j.Id == floor.ParentId);
            //_floor.InitBound.SetInitBound();
            var floorBound = _floor.InitBound;

            if (floorBound.Points == null)
            {
                floorBound.Points = bll.Points.FindAll(i => i.BoundId == floorBound.Id);
            }
            if (floorBound.MaxX == 0)
            {
                floorBound.SetMinMaxXY();
                bll.Bounds.Edit(floorBound);
            }
            var minX = floorBound.MinX + _building.InitBound.MinX;
            var minY = floorBound.MinY + _building.InitBound.MinY;

            _item.AbsoluteX = (x + minX).ToString("F3");
            _item.AbsoluteY = (z + minY).ToString("F3");

            //var rooms = areas.FindAll(j => j.ParentId == floor.Id);
            _room = Bll.GetDevRoom(_floor, _dev);
            //PropertyGrid3.SelectedObject = item;

            LbId.Text    = _archor.Id + "";
            TbName.Text  = _archor.Name;
            TbCode.Text  = _archor.GetCode();
            IPCode1.Text = _archor.Ip;
            double height = _item.RelativeHeight;

            //if (height == 2)
            //{
            //    height = 2.6;//现场实际一般高度是2.6左右
            //}
            TbHeight.Text       = height.ToString("F3");
            TbHeight2.Text      = (floorHeight + height).ToString("F3");
            PcArchor.X          = x;
            PcArchor.Y          = z;
            TbBuildingName.Text = _building.Name;
            TbFloorName.Text    = _floor.Name;

            PcAbsolute.X = _building.InitBound.MinX + _floor.InitBound.MinX + x;
            PcAbsolute.Y = _building.InitBound.MinY + _floor.InitBound.MinY + z;

            if (_room != null)
            {
                TbRoomName.Text    = _room.Name;
                PcArchor.IsEnabled = false;
                var setting = bll.ArchorSettings.GetByCode(_code, _archor.Id);
                if (setting != null)
                {
                    SetZeroPoint(setting.ZeroX.ToFloat(), setting.ZeroY.ToFloat());
                    Title += " [已配置]";
                }
                else
                {
                    if (ArchorSettingContext.ZeroX != 0)
                    {
                        SetZeroPoint(ArchorSettingContext.ZeroX, ArchorSettingContext.ZeroY);
                    }
                    else
                    {
                        SetZeroPoint(_room.InitBound.MinX, _room.InitBound.MinY);
                    }
                }
            }
            else
            {
                var setting = bll.ArchorSettings.GetByCode(_code, _archor.Id);
                if (setting != null)
                {
                    SetZeroPoint(setting.ZeroX.ToFloat(), setting.ZeroY.ToFloat());
                    Title += " [已配置]";
                }
                else
                {
                    PcArchor.IsEnabled = true;
                    PcRelative.X       = PcArchor.X;
                    PcRelative.Y       = PcArchor.Y;

                    if (ArchorSettingContext.ZeroX != 0)
                    {
                        SetZeroPoint(ArchorSettingContext.ZeroX, ArchorSettingContext.ZeroY);
                    }
                }
            }

            PcZero.ValueChanged     += PcZero_ValueChanged;
            PcRelative.ValueChanged += PcRelative_ValueChanged;
            PcArchor.ValueChanged   += PcArchor_ValueChanged;

            //OnShowPoint();
            return(true);
        }
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            //LocationService service = new LocationService();
            //service.EditBusAnchor();
            if (string.IsNullOrEmpty(TbCode.Text))
            {
                MessageBox.Show("编号不能为空");
                return;
            }

            ArchorDevList archorList = ArchorHelper.ArchorList;

            TbCode.ItemsSource       = archorList.ArchorList;
            TbCode.DisplayMemberPath = "ArchorID";

            IPCode1.ItemsSource       = archorList.ArchorList;
            IPCode1.DisplayMemberPath = "ArchorIp";

            Bll bll = new Bll();

            var archorNew = bll.Archors.Find(_archor.Id);

            string code = _archor.Code;

            _archor.X    = PcAbsolute.X;
            _archor.Z    = PcAbsolute.Y;
            _archor.Y    = TbHeight2.Text.ToDouble();
            _archor.Name = TbName.Text;
            _archor.Code = TbCode.Text;
            _archor.Ip   = IPCode1.Text;

            archorNew.X    = PcAbsolute.X;
            archorNew.Z    = PcAbsolute.Y;
            archorNew.Y    = TbHeight2.Text.ToDouble();
            archorNew.Name = TbName.Text;
            archorNew.Code = TbCode.Text;
            archorNew.Ip   = IPCode1.Text;

            var devNew = bll.DevInfos.Find(_dev.Id);

            devNew.Name = TbName.Text;
            devNew.PosX = (float)PcArchor.X;
            devNew.PosZ = (float)PcArchor.Y;
            devNew.PosY = TbHeight.Text.ToFloat();

            _dev.Name = TbName.Text;
            _dev.PosX = (float)PcArchor.X;
            _dev.PosZ = (float)PcArchor.Y;
            _dev.PosY = TbHeight.Text.ToFloat();


            //if (bll.bus_anchors.Update(code, _archor) == false)
            //{
            //    MessageBox.Show("保存失败1");
            //    return;
            //}

            if (bll.Archors.Edit(archorNew) == false)
            {
                MessageBox.Show("保存失败2");
                return;
            }
            if (bll.DevInfos.Edit(devNew) == false)
            {
                MessageBox.Show("保存失败3");
                return;
            }


            ArchorSetting archorSetting = bll.ArchorSettings.GetByCode(_code, _archor.Id);
            bool          isAdd         = false;

            if (archorSetting == null)
            {
                archorSetting = new ArchorSetting(_code, _archor.Id);
                isAdd         = true;
            }
            archorSetting.Code           = _archor.Code;
            archorSetting.Name           = _archor.Name;
            archorSetting.RelativeHeight = TbHeight.Text.ToDouble();
            archorSetting.AbsoluteHeight = TbHeight2.Text.ToDouble();

            GetDevRoom();
            if (_room != null)
            {
                archorSetting.RelativeMode = RelativeMode.相对机房;
                archorSetting.SetPath(_room, _floor, _building);
                archorSetting.SetZero(PcZero.X, PcZero.Y);
                archorSetting.SetRelative(PcRelative.X, PcRelative.Y);
                archorSetting.SetAbsolute(PcAbsolute.X, PcAbsolute.Y);
            }
            else
            {
                archorSetting.RelativeMode = RelativeMode.相对楼层;
                archorSetting.SetPath(null, _floor, _building);
                archorSetting.SetZero(PcZero.X, PcZero.Y);
                //archorSetting.SetRelative(PcArchor.X, PcArchor.Y);
                archorSetting.SetRelative(PcRelative.X, PcRelative.Y);
                archorSetting.SetAbsolute(PcAbsolute.X, PcAbsolute.Y);
            }

            if (archorSetting.CalAbsolute() == false)//75个里面有43个录入的绝对坐标有问题
            {
                MessageBox.Show("有bug,请检查代码!");
            }

            if (isAdd)
            {
                if (bll.ArchorSettings.Add(archorSetting) == false)
                {
                    MessageBox.Show("保存失败4");
                    return;
                }
            }
            else
            {
                if (bll.ArchorSettings.Edit(archorSetting) == false)
                {
                    MessageBox.Show("保存失败5");
                    return;
                }
            }

            OnRefreshDev();

            MessageBox.Show("保存完成");
        }