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); } } }
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; }