Exemple #1
0
        private Brush GetDevRectFillColor(DevEntity dev)
        {
            if (dev.DevDetail is Archor)
            {
                if (GetSettingFunc != null)
                {
                    ArchorSetting setting = GetSettingFunc(dev);
                    if (setting != null)
                    {
                        if (setting.RelativeHeight == 2)
                        {
                            return(Brushes.LightGreen);
                        }
                        else
                        {
                            return(Brushes.Green);
                        }
                    }
                    else
                    {
                        return(Brushes.DeepSkyBlue);
                    }
                }
                else
                {
                    return(Brushes.DeepSkyBlue);
                }

                //Archor archor = dev.DevDetail as Archor;
                //if (!string.IsNullOrEmpty(archor.Code) && !archor.Code.StartsWith("Code"))
                //{
                //    return Brushes.Green;
                //}
                //else
                //{
                //    return Brushes.DeepSkyBlue;
                //}
            }
            else
            {
                return(Brushes.CadetBlue);
            }
        }
        private void MenuLoadOutArchorPoints_Click(object sender, RoutedEventArgs e)
        {
            Bll bll                = new Bll(false, false, false, false);
            var archors            = bll.Archors.ToList().Where(i => i.ParentId == 2).ToList();
            var devs               = bll.DevInfos.ToList().Where(i => i.ParentId == 2).ToList();
            var archorSettings     = bll.ArchorSettings.ToList();
            var newDevs            = new List <DevInfo>();
            var newArchors         = new List <Archor>();
            var newArchorSettings1 = new List <ArchorSetting>();
            var newArchorSettings2 = new List <ArchorSetting>();
            var notArchors         = new List <string>();
            var path               = AppDomain.CurrentDomain.BaseDirectory + "\\Data\\GPSPoints.txt";

            string[] lines = File.ReadAllLines(path);
            foreach (var item in lines)
            {
                string line = item.Trim();
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }
                string[] parts = line.Split(',');
                string   name  = parts[0].ToLower();
                double   x     = parts[2].ToDouble();
                double   y     = parts[3].ToDouble();
                double   z     = parts[4].ToDouble();


                var archor = archors.Find(i => i.Code.ToLower() == name || i.Name.ToLower() == name);
                if (archor != null)
                {
                    if (archor.Name == "4")
                    {
                        int j = 0;
                    }
                    newArchors.Add(archor);
                    archors.Remove(archor);
                    archor.X = x;
                    archor.Y = z;
                    archor.Z = y;
                    var dev = devs.Find(i => i.Id == archor.DevInfoId);
                    dev.PosX = (float)x;
                    dev.PosY = (float)z;
                    dev.PosZ = (float)y;
                    newDevs.Add(dev);

                    var archorSetting = archorSettings.Find(i => i.ArchorId == archor.Id || i.Code == archor.Code);
                    if (archorSetting != null)
                    {
                        newArchorSettings1.Add(archorSetting);
                    }
                    else
                    {
                        archorSetting = new ArchorSetting();
                        newArchorSettings2.Add(archorSetting);
                    }
                    archorSetting.ZeroX          = "0";
                    archorSetting.ZeroY          = "0";
                    archorSetting.AbsoluteX      = x.ToString("F3");
                    archorSetting.AbsoluteY      = y.ToString("F3");
                    archorSetting.RelativeX      = x.ToString("F3");
                    archorSetting.RelativeY      = y.ToString("F3");
                    archorSetting.AbsoluteHeight = z;
                    archorSetting.RelativeHeight = z;
                    archorSetting.RelativeMode   = RelativeMode.CAD坐标;
                    archorSetting.Name           = archor.Name;
                    archorSetting.Code           = archor.Code;
                    archorSetting.ArchorId       = archor.Id;
                }
                else
                {
                    notArchors.Add(line);
                }
            }
            bll.Archors.EditRange(newArchors);
            bll.DevInfos.EditRange(newDevs);
            //bll.Db.SaveChanges();
            bll.ArchorSettings.EditRange(newArchorSettings1);
            bll.ArchorSettings.AddRange(newArchorSettings2);
        }
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            if (AppContext.ParkName == "宝钢园区")
            {
                pow = 1;
            }

            List <DevInfo> devs = null;

            worker.ReportProgress(0);
            var bll = Bll.NewBllNoRelation();

            if (IsTrackPoint)
            {
                if (areaId == 0)
                {
                    devs = bll.DevInfos.Where(i => i.Local_TypeCode == TypeCodes.TrackPoint);
                }
                else
                {
                    devs = bll.DevInfos.Where(i => i.Local_TypeCode == TypeCodes.TrackPoint && i.ParentId == areaId);
                }
                archors = new List <Archor>();
                foreach (var item in devs)
                {
                    Archor anchor = new Archor(item);
                    archors.Add(anchor);
                }
            }
            else
            {
                if (areaId == 0)
                {
                    archors = bll.Archors.ToList();
                }
                else
                {
                    archors = bll.Archors.Where(i => i.ParentId == areaId);
                }
            }

            devs = bll.DevInfos.ToList();
            var areas = bll.Areas.GetWithBoundPoints(true);

            list = new List <ArchorSetting>();
            var list2 = bll.ArchorSettings.ToList();
            var list3 = new List <ArchorSetting>();

            for (int i = 0; i < archors.Count; i++)
            {
                try
                {
                    var           archor        = archors[i];
                    ArchorSetting archorSetting = bll.ArchorSettings.GetByArchor(archor);
                    if (archorSetting == null)
                    {
                        if (CalculateAll)
                        {
                            archorSetting = new ArchorSetting(archor.GetCode(), archor.Id);
                            listAdd.Add(archorSetting);
                            archorSetting.Name = archor.Name;
                            //var dev = archor.DevInfo;//大量循环获取sql数据的话采用按需加载的方式会慢很多
                            var dev = devs.Find(j => j.Id == archor.DevInfoId); //应该采用全部事先获取并从列表中搜索的方式,具体680多个,从35s变为1s
                                                                                //var area = dev.Parent;
                            var floor    = areas.Find(j => j.Id == dev.ParentId);
                            var building = areas.Find(j => j.Id == floor.ParentId);
                            if (building.Children == null)
                            {
                                building.Children = areas.FindAll(j => j.ParentId == building.Id);
                            }
                            var x = dev.PosX;
                            var y = dev.PosZ;
                            if (floor.IsPark()) //电厂
                            {
                                archorSetting.RelativeMode   = RelativeMode.相对园区;
                                archorSetting.RelativeHeight = archor.Y;
                                archorSetting.AbsoluteHeight = archor.Y;
                                var park       = floor;
                                var leftBottom = park.InitBound.GetLeftBottomPoint();
                                archorSetting.SetZero(leftBottom.X, leftBottom.Y);
                                archorSetting.SetRelative((x - leftBottom.X), (y - leftBottom.Y));
                                archorSetting.SetAbsolute(x, y);
                            }
                            else //机房
                            {
                                //var floor = area;
                                //var building = floor.Parent;
                                archorSetting.RelativeHeight = archor.Y;
                                archorSetting.AbsoluteHeight = (archor.Y + building.GetFloorHeight(floor.Id));

                                var minX = floor.InitBound.GetZeroX() + building.InitBound.GetZeroX();
                                var minY = floor.InitBound.GetZeroY() + building.InitBound.GetZeroY();

                                archorSetting.AbsoluteX = (x + minX).ToString("F3");
                                archorSetting.AbsoluteY = (y + minY).ToString("F3");

                                var room = Bll.GetDevRoom(floor, dev);
                                if (room != null)
                                {
                                    archorSetting.RelativeMode = RelativeMode.相对机房;
                                    var roomX = room.InitBound.GetZeroX();
                                    var roomY = room.InitBound.GetZeroY();
                                    archorSetting.SetPath(room, floor, building);
                                    archorSetting.SetZero(roomX, roomY);
                                    archorSetting.SetRelative((x - roomX), (y - roomY));
                                    archorSetting.SetAbsolute((minX + x), (minY + y));
                                }
                                else
                                {
                                    archorSetting.RelativeMode = RelativeMode.相对楼层;
                                    archorSetting.SetPath(null, floor, building);
                                    archorSetting.SetZero(0, 0);
                                    archorSetting.SetRelative(x, y);
                                    archorSetting.SetAbsolute((minX + x), (minY + y));
                                }
                            }
                        }
                    }
                    else
                    {
                        bool r = archorSetting.CalAbsolute();
                        if (r == false)
                        {
                            list3.Add(archorSetting);
                        }
                        listEdit.Add(archorSetting);
                    }
                    if (archorSetting != null)
                    {
                        archorSetting.SetExtensionInfo(LocationContext.OffsetX, LocationContext.OffsetY, pow);

                        if (ShowAll)
                        {
                            //if (archorSetting.RelativeHeight != 2)//过滤掉2m的基站 未测量位置坐标的
                            list.Add(archorSetting);
                        }
                        else
                        {
                            int defaultHeight = 2;
                            if (AppContext.ParkName == "宝钢园区")
                            {
                                defaultHeight = 200;
                            }
                            if (archorSetting.RelativeHeight != defaultHeight)//过滤掉2m的基站 未测量位置坐标的
                            {
                                list.Add(archorSetting);
                            }
                        }
                    }

                    double percent = i * 100f / archors.Count;
                    worker.ReportProgress((int)percent);
                }
                catch (Exception ex)
                {
                    worker.ReportProgress(0, ex);
                }
            }
        }
Exemple #4
0
        private Rectangle AddDevRect(DevEntity dev, double scale, double size, bool showDevName)
        {
            if (DevDict.ContainsKey(dev.Id))
            {
                DevDict[dev.Id].Remove();
            }

            AreaEntity parent = dev.Parent;

            double roomOffX = 0;
            double roomOffY = 0;

            if (DrawMode == 1)//大图模式
            {
                if (parent != null)
                {
                    if (parent.Type == AreaTypes.楼层 && parent.Parent != null)
                    {
                        roomOffX = parent.InitBound.MinX + parent.Parent.InitBound.MinX;
                        roomOffY = parent.InitBound.MinY + parent.Parent.InitBound.MinY;
                    }
                    else if (parent.Type == AreaTypes.机房 && parent.Parent != null)
                    {
                        roomOffX = parent.Parent.Parent.InitBound.MinX + parent.Parent.InitBound.MinX;
                        roomOffY = parent.Parent.Parent.InitBound.MinY + parent.Parent.InitBound.MinY;
                    }
                }
            }
            else //小图模式
            {
                if (parent != null)
                {
                    if (parent.Type == AreaTypes.楼层)
                    {
                        roomOffX = parent.InitBound.MinX;
                        roomOffY = parent.InitBound.MinY;
                    }
                    else if (parent.Type == AreaTypes.机房)
                    {
                        roomOffX = parent.Parent.InitBound.MinX;
                        roomOffY = parent.Parent.InitBound.MinY;
                    }
                }
            }

            double ax = dev.Pos.PosX + roomOffX;
            double ay = dev.Pos.PosZ + roomOffY;

            if (DrawMode == 1 && GetSettingFunc != null)//大图模式
            {
                ArchorSetting setting = GetSettingFunc(dev);
                if (setting != null)
                {
                    setting.CalAbsolute();//检测配置的数据是否正确
                    ax = setting.AbsoluteX.ToDouble();
                    ay = setting.AbsoluteY.ToDouble();
                }
            }


            double x = (ax - OffsetX) * scale - size * scale / 2;
            double y = (ay - OffsetY) * scale - size * scale / 2;

            DevShape devShape = new DevShape(Canvas1);

            if (showDevName)
            {
                if (udpArchorList == null)
                {
                    string path = AppDomain.CurrentDomain.BaseDirectory + "\\Data\\基站信息\\UDPArchorList.xml";
                    udpArchorList = XmlSerializeHelper.LoadFromFile <UDPArchorList>(path);
                }
                Label lb = new Label();
                lb.Content = GetDevName(dev);
                Canvas.SetLeft(lb, x + size * scale);
                Canvas.SetTop(lb, y);
                Canvas1.Children.Add(lb);
                lb.LayoutTransform = ScaleTransform1;

                var udpArchor = udpArchorList.Find(i => i.Id == GetArchorCode(dev));
                if (udpArchor != null)
                {
                    lb.Foreground = Brushes.Blue;
                }

                devShape.Label = lb;
            }


            //if (ViewMode == 0)
            //    y = Canvas1.Height - size * scale - y; //上下颠倒一下,不然就不是CAD上的上北下南的状况了
            Rectangle devRect = new Rectangle()
            {
                //Margin = new Thickness(x, y, 0, 0),
                Width           = size * scale,
                Height          = size * scale,
                Fill            = GetDevRectFillColor(dev),
                Stroke          = Brushes.Black,
                StrokeThickness = 1,
                Tag             = dev,
                ToolTip         = GetDevNameEx(dev)
            };

            devShape.Rect = devRect;
            devShape.Id   = dev.Id;

            devRect.ContextMenu = DevContextMenu;

            Canvas.SetLeft(devRect, x);
            Canvas.SetTop(devRect, y);

            DevDict[dev.Id]     = devShape;
            devRect.MouseDown  += DevRect_MouseDown;
            devRect.MouseEnter += DevRect_MouseEnter;
            devRect.MouseLeave += DevRect_MouseLeave;
            Canvas1.Children.Add(devRect);

            return(devRect);
        }
Exemple #5
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);
        }
Exemple #6
0
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            //LocationService service = new LocationService();
            //service.EditBusAnchor();
            if (string.IsNullOrEmpty(TbCode.Text))
            {
                MessageBox.Show("编号不能为空");
                return;
            }
            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    = TbHeight.Text.ToDouble();
            _archor.Name = TbName.Text;
            _archor.Code = TbCode.Text;
            _archor.Ip   = IPCode1.Text;

            archorNew.X    = PcAbsolute.X;
            archorNew.Z    = PcAbsolute.Y;
            archorNew.Y    = TbHeight.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)PcAbsolute.X;
            devNew.PosZ = (float)PcAbsolute.Y;
            devNew.PosY = TbHeight.Text.ToFloat();

            _dev.Name = TbName.Text;
            _dev.PosX = (float)PcAbsolute.X;
            _dev.PosZ = (float)PcAbsolute.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;
            }

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

            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.RelativeMode   = RelativeMode.相对园区;
            archorSetting.RelativeHeight = _archor.Y;
            archorSetting.AbsoluteHeight = _archor.Y;

            var x = _dev.PosX;
            var y = _dev.PosZ;

            //var leftBottom = park.InitBound.GetLeftBottomPoint();

            archorSetting.SetZero(PcZero.X, PcZero.Y);
            archorSetting.SetRelative(PcRelative.X, PcRelative.Y);
            archorSetting.SetAbsolute(PcAbsolute.X, PcAbsolute.Y);

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

            OnRefreshDev(devNew);

            MessageBox.Show("保存完成");
        }
        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("保存完成");
        }
Exemple #9
0
        public void ShowInfo(Archor archor)
        {
            this._archor = archor;
            dev          = archor.DevInfo;
            BLL.Bll bll = new BLL.Bll();


            PropertyGrid1.SelectedObject = archor;
            PropertyGrid2.SelectedObject = archor.DevInfo;

            archorSetting = bll.ArchorSettings.GetByArchor(archor);
            if (archorSetting == null)
            {
                //archorSetting = new ArchorSetting(archor);
                dev = archor.DevInfo;
                //var archor = archors[i];
                archorSetting      = new ArchorSetting(archor.Code, archor.Id);
                archorSetting.Name = archor.Name;
                var area = dev.Parent;
                var x    = dev.PosX;
                var y    = dev.PosZ;
                if (dev.ParentId == 2) //电厂
                {
                    archorSetting.RelativeMode   = RelativeMode.相对园区;
                    archorSetting.RelativeHeight = archor.Y;
                    archorSetting.AbsoluteHeight = archor.Y;

                    var park       = area;
                    var leftBottom = park.InitBound.GetLeftBottomPoint();

                    archorSetting.SetZero(leftBottom.X, leftBottom.Y);
                    archorSetting.SetRelative((x - leftBottom.X), (y - leftBottom.Y));
                    archorSetting.SetAbsolute(x, y);
                }
                else
                {
                    var floor    = area;
                    var building = floor.Parent;

                    archorSetting.RelativeHeight = archor.Y;
                    archorSetting.AbsoluteHeight = (archor.Y + building.GetFloorHeight(floor.Id));

                    var minX = floor.InitBound.GetZeroX() + building.InitBound.GetZeroX();
                    var minY = floor.InitBound.GetZeroY() + building.InitBound.GetZeroY();

                    var room = Bll.GetDevRoom(floor, dev);
                    if (room != null)
                    {
                        archorSetting.RelativeMode = RelativeMode.相对机房;
                        var roomX = room.InitBound.GetZeroX();
                        var roomY = room.InitBound.GetZeroY();
                        archorSetting.SetPath(room, floor, building);
                        archorSetting.SetZero(roomX, roomY);
                        archorSetting.SetRelative((x - roomX), (y - roomY));
                        archorSetting.SetAbsolute((minX + x), (minY + y));
                    }
                    else
                    {
                        archorSetting.RelativeMode = RelativeMode.相对楼层;
                        archorSetting.SetPath(null, floor, building);
                        archorSetting.SetZero(0, 0);
                        archorSetting.SetRelative(x, y);
                        archorSetting.SetAbsolute((minX + x), (minY + y));
                    }
                }
            }

            PropertyGrid3.SelectedObject = archorSetting;
        }