Ejemplo n.º 1
0
        /// <summary>
        /// 添加设备信息
        /// </summary>
        /// <param name="dev"></param>
        /// <param name="devBll"></param>
        private static bool AddDevInfo(DevInfoBackup dev, DevInfoBll devBll)
        {
            try
            {
                DevInfo devInfo = GetDevInfo(dev);
                DevPos  devPos  = GetDevPos(dev);
                devInfo.SetPos(devPos);
                //if (string.IsNullOrEmpty(devInfo.Local_DevID))
                //{

                //}
                DevInfo infoTemp = devBll.Find(i => i.Local_DevID == devInfo.Local_DevID);
                if (infoTemp == null)
                {
                    return(devBll.Add(devInfo));//新设备,加入
                }
                else
                {
                    UpgradeDevInfo(infoTemp, devInfo);//已经存在的设备,更新
                    bool value = devBll.Edit(infoTemp);
                    if (!value)
                    {
                        Log.Info("Error: EditDevinfo Error");
                    }
                    return(value);
                }
            }
            catch (Exception e)
            {
                Log.Info("Error in DevInfoHelper.AddDevInfo:" + e.ToString());
                return(false);
            }
        }
 internal void Show(DevInfo tp)
 {
     _tp = tp;
     x   = tp.PosX;
     y   = tp.PosY;
     this.Show();
 }
Ejemplo n.º 3
0
 private void OnRefreshDev(DbDev dev)
 {
     if (RefreshDev != null)
     {
         var tDev = dev.ToTModel();
         tDev.DevDetail = _archor.ToTModel();
         RefreshDev(tDev);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 移除被删除的设备
        /// </summary>
        private static void RemoveDeleteDev(DevInfoBackup devTemp, DevInfoBll devBll)
        {
            DevInfo infoTemp = devBll.Find(i => i.Local_DevID == devTemp.DevId);

            if (infoTemp != null)
            {
                devBll.DeleteById(infoTemp.Id);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 添加摄像头信息
 /// </summary>
 /// <param name="cameraDev"></param>
 /// <param name="bll"></param>
 private static void AddCameraInfo(CameraInfoBackup cameraDev, Bll bll)
 {
     try
     {
         DevInfoBackup dev     = CameraToDevInfo(cameraDev);
         DevInfo       devInfo = GetDevInfo(dev);
         DevPos        devPos  = GetDevPos(dev);
         devInfo.SetPos(devPos);
         DevInfo infoTemp = bll.DevInfos.Find(i => i.Local_DevID == devInfo.Local_DevID);
         //Devinfo中,能通过Devid找到的就更新。找不到就新增
         if (infoTemp == null)
         {
             bll.DevInfos.Add(devInfo);
             Dev_CameraInfo cameraBackup = GetCameraInfo(cameraDev, devInfo);
             cameraBackup.RtspUrl = cameraDev.RtspURL;
             bll.Dev_CameraInfos.Add(cameraBackup);
         }
         else
         {
             UpgradeDevInfo(infoTemp, devInfo);
             bool value = bll.DevInfos.Edit(infoTemp);
             if (!value)
             {
                 Log.Info("Error: EditDevinfo Error");
             }
             Dev_CameraInfo cameraBackup = GetCameraInfo(cameraDev, infoTemp);
             if (!string.IsNullOrEmpty(cameraDev.RtspURL))
             {
                 cameraBackup.RtspUrl = cameraDev.RtspURL;
             }
             Dev_CameraInfo cameraDatabase = bll.Dev_CameraInfos.Find(cameraT => cameraT.Local_DevID == infoTemp.Local_DevID);
             if (cameraDatabase == null)
             {
                 bll.Dev_CameraInfos.Add(cameraBackup);
             }
             else
             {
                 UpgradeCameraInfo(cameraBackup, cameraDatabase);
                 bool valueT = bll.Dev_CameraInfos.Edit(cameraDatabase);
                 if (!valueT)
                 {
                     Log.Info("Error: EditDevinfo Error");
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Info("Error in DevInfoHelper.AddDevInfo:" + e.ToString());
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 添加设备信息
 /// </summary>
 /// <param name="dev"></param>
 /// <param name="devBll"></param>
 private static void AddDevInfo(DevInfoBackup dev, DevInfoBll devBll)
 {
     try
     {
         DevInfo devInfo = GetDevInfo(dev);
         DevPos  devPos  = GetDevPos(dev);
         devInfo.SetPos(devPos);
         devBll.Add(devInfo);
     }
     catch (Exception e)
     {
         Console.WriteLine("Error in DevInfoHelper.AddDevInfo:" + e.ToString());
     }
 }
        internal bool?Show(int areaId, Point point)
        {
            var area = bll.Areas.Find(areaId);

            if (area.Type == AreaTypes.楼层)
            {
                _floor = area;
                _room  = Bll.GetRoomByPos(_floor.Id, point.X, point.Y);
            }
            else if (area.Type == AreaTypes.机房)
            {
                _room  = area;
                _floor = _room.Parent;
            }
            else
            {
                return(false);
            }

            TbBuildingName.Text = _floor.Parent.Name;
            TbFloorName.Text    = _floor.Name;
            floorHeight         = _floor.InitBound.MinZ;
            //TbFloorHeight.Text = floorHeight.ToString("F2");
            if (_room != null)
            {
                TbRoomName.Text = _room.Name;
            }

            var devs = bll.DevInfos.Where(i => i.ParentId == _floor.Id && i.Local_TypeCode == TypeCodes.TrackPoint);

            _tp = new DevInfo();
            _tp.Local_TypeCode = TypeCodes.TrackPoint;
            _tp.PosX           = point.X;
            _tp.PosZ           = point.Y;
            if (_room != null)
            {
                _tp.Name = _room.Name + "_测点_" + (devs.Count + 1);
            }
            else
            {
                _tp.Name = _floor.Name + "_测点_" + (devs.Count + 1);
            }
            _tp.ParentId = _floor.Id;

            TbName.Text = _tp.Name;
            PcArchor.X  = _tp.PosX;
            PcArchor.Y  = _tp.PosZ;

            return(this.ShowDialog());
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 获取摄像头数据
        /// </summary>
        /// <param name="camDev"></param>
        /// <param name="dev"></param>
        /// <returns></returns>
        private static Dev_CameraInfo GetCameraInfo(CameraInfoBackup camDev, DevInfo dev)
        {
            Dev_CameraInfo info = new Dev_CameraInfo();

            info.Ip          = camDev.IP;
            info.UserName    = camDev.UserName;
            info.PassWord    = camDev.PassWord;
            info.CameraIndex = TryParseInt(camDev.CameraIndex);
            info.Port        = TryParseInt(camDev.Port);
            info.DevInfoId   = dev.Id;
            info.ParentId    = dev.ParentId;
            info.Local_DevID = dev.Local_DevID;
            return(info);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 添加设备信息
        /// </summary>
        /// <param name="dev"></param>
        /// <param name="devBll"></param>
        private static void AddFireFightDevInfo(FireFightDevInfoBackup dev, Bll bll)
        {
            try
            {
                int nAbutment_Type = Convert.ToInt32(dev.Abutment_Type);

                DevInfo devInfo = new DevInfo();
                devInfo.Id              = 0;
                devInfo.Name            = dev.Name;
                devInfo.ParentId        = Convert.ToInt32(dev.ParentId);
                devInfo.Code            = dev.Code;
                devInfo.KKS             = "";
                devInfo.Local_DevID     = "";
                devInfo.Local_CabinetID = "";
                devInfo.Local_TypeCode  = Convert.ToInt32(dev.Local_TypeCode);
                devInfo.Abutment_Id     = null;
                devInfo.Abutment_DevID  = "";
                devInfo.Abutment_Type   = (Abutment_DevTypes)nAbutment_Type;
                devInfo.Status          = 0;
                devInfo.RunStatus       = 0;
                devInfo.Placed          = null;
                devInfo.ModelName       = "";
                devInfo.CreateTime      = DateTime.Now;
                devInfo.CreateTimeStamp = Location.TModel.Tools.TimeConvert.ToStamp(devInfo.CreateTime);
                devInfo.ModifyTime      = DateTime.Now;
                devInfo.ModifyTimeStamp = Location.TModel.Tools.TimeConvert.ToStamp(devInfo.ModifyTime);
                devInfo.UserName        = "******";
                devInfo.IP              = "";
                devInfo.PosX            = 0;
                devInfo.PosY            = 0;
                devInfo.PosZ            = 0;
                devInfo.RotationX       = 0;
                devInfo.RotationY       = 0;
                devInfo.RotationZ       = 0;
                devInfo.ScaleX          = 0;
                devInfo.ScaleY          = 0;
                devInfo.ScaleZ          = 0;
                devInfo.Manufactor      = "";

                bll.DevInfos.Add(devInfo);
            }
            catch (Exception e)
            {
                Log.Info("Error in DevInfoHelper.AddFireFightDevInfo:" + e.ToString());
            }

            return;
        }
Ejemplo n.º 10
0
 /// <summary>
 /// 添加门禁信息
 /// </summary>
 /// <param name="cameraDev"></param>
 /// <param name="bll"></param>
 private static void AddDoorAccessInfo(DoorAccess doorAccess, Bll bll)
 {
     try
     {
         DevInfoBackup dev     = DoorAccessToDevInfo(doorAccess);
         DevInfo       devInfo = GetDevInfo(dev);
         DevPos        devPos  = GetDevPos(dev);
         devInfo.SetPos(devPos);
         bll.DevInfos.Add(devInfo);
         DbModel.Location.AreaAndDev.Dev_DoorAccess doorAccessDev = GetDoorAccessInfo(doorAccess, devInfo);
         bll.Dev_DoorAccess.Add(doorAccessDev);
     }
     catch (Exception e)
     {
         Console.WriteLine("Error in DevInfoHelper.AddDevInfo:" + e.ToString());
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// 获取设备信息
        /// </summary>
        /// <param name="dev"></param>
        /// <returns></returns>
        private static DevInfo GetDevInfo(DevInfoBackup dev)
        {
            DevInfo devInfo = new DevInfo
            {
                Name           = dev.Name,
                ParentId       = dev.ParentId,
                KKS            = dev.KKSCode,
                Local_DevID    = dev.DevId,
                Local_TypeCode = dev.TypeCode.ToInt(),
                Status         = Abutment_Status.正常,
                ModelName      = dev.ModelName,
                IP             = "",
                UserName       = "******"
            };

            return(devInfo);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// 添加摄像头信息
 /// </summary>
 /// <param name="cameraDev"></param>
 /// <param name="bll"></param>
 private static void AddCameraInfo(CameraInfoBackup cameraDev, Bll bll)
 {
     try
     {
         DevInfoBackup dev     = CameraToDevInfo(cameraDev);
         DevInfo       devInfo = GetDevInfo(dev);
         DevPos        devPos  = GetDevPos(dev);
         devInfo.SetPos(devPos);
         bll.DevInfos.Add(devInfo);
         Dev_CameraInfo camera = GetCameraInfo(cameraDev, devInfo);
         bll.Dev_CameraInfos.Add(camera);
     }
     catch (Exception e)
     {
         Console.WriteLine("Error in DevInfoHelper.AddDevInfo:" + e.ToString());
     }
 }
Ejemplo n.º 13
0
 /// <summary>
 /// 添加门禁信息
 /// </summary>
 /// <param name="cameraDev"></param>
 /// <param name="bll"></param>
 private static void AddDoorAccessInfo(DoorAccess doorAccess, Bll bll)
 {
     try
     {
         DevInfoBackup dev     = DoorAccessToDevInfo(doorAccess);
         DevInfo       devInfo = GetDevInfo(dev);
         DevPos        devPos  = GetDevPos(dev);
         devInfo.SetPos(devPos);
         DevInfo infoTemp = bll.DevInfos.Find(i => i.Local_DevID == devInfo.Local_DevID);
         if (infoTemp == null)
         {
             bll.DevInfos.Add(devInfo);
             DbModel.Location.AreaAndDev.Dev_DoorAccess doorAccessDev = GetDoorAccessInfo(doorAccess, devInfo);
             bll.Dev_DoorAccess.Add(doorAccessDev);
         }
         else
         {
             UpgradeDevInfo(infoTemp, devInfo);
             bool value = bll.DevInfos.Edit(infoTemp);
             if (!value)
             {
                 Log.Info("Error: EditDevinfo Error");
             }
             DbModel.Location.AreaAndDev.Dev_DoorAccess doorAccessBackup   = GetDoorAccessInfo(doorAccess, infoTemp);
             DbModel.Location.AreaAndDev.Dev_DoorAccess doorAccessDatabase = bll.Dev_DoorAccess.Find(door => door.Local_DevID == devInfo.Local_DevID);
             if (doorAccessDatabase == null)
             {
                 bll.Dev_DoorAccess.Add(doorAccessBackup);
             }
             else
             {
                 UpgradeDoorAccessInfo(doorAccessBackup, doorAccessDatabase);
                 bool valueT = bll.Dev_DoorAccess.Edit(doorAccessDatabase);
                 if (!valueT)
                 {
                     Log.Info("Error:Edit Dev_DoorAccess Error");
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Info("Error in DevInfoHelper.AddDevInfo:" + e.ToString());
     }
 }
Ejemplo n.º 14
0
 /// <summary>
 /// 添加基站设备
 /// </summary>
 /// <param name="devList">设备列表</param>
 /// <param name="devBlls">数据信息</param>
 /// <param name="areaId">设备所属区域ID</param>
 private static void AddLocationDev(List <LocationDevice> devList, ArchorBll archorBll, Area area)
 {
     for (int i = 0; i < devList.Count; i++)
     {
         var     locationDev = devList[i];
         DevInfo devInfo     = GetDevInfo(locationDev, area);
         DevPos  devPos      = GetDevPos(locationDev, devInfo.Local_DevID);
         Archor  archor      = GetAnchorInfo(locationDev, devInfo.Id);
         archor.ParentId = area.Id;
         if (string.IsNullOrEmpty(archor.Code) || archor.Code.Contains("Code"))
         {
             archor.Code = "Code_" + i;
         }
         devInfo.SetPos(devPos);
         archor.DevInfo = devInfo;
         archorBll.Add(archor);
         //devBlls.Add(devInfo);
     }
 }
Ejemplo n.º 15
0
        /// <summary>
        /// 获取设备信息
        /// </summary>
        /// <param name="locationDev"></param>
        /// <param name="areaId"></param>
        /// <returns></returns>
        private static DevInfo GetDevInfo(LocationDevice locationDev, Area area)
        {
            DevInfo dev = new DevInfo();

            dev.Local_DevID = Guid.NewGuid().ToString();
            dev.IP          = "";
            dev.KKS         = "";
            dev.Name        = locationDev.Name;
            dev.ModelName   = area.Name == DepNames.FactoryName?TypeNames.ArchorOutdoor:TypeNames.Archor;//室外基站||室内基站
            dev.Status      = 0;
            dev.ParentId    = area.Id;
            try
            {
                dev.Local_TypeCode = TypeCodes.Archor;
            }
            catch (Exception e)
            {
                dev.Local_TypeCode = 0;
            }
            dev.UserName = "******";
            return(dev);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 更新DevInfo信息
        /// </summary>
        /// <param name="dbInfo"></param>
        /// <param name="backupInfo"></param>
        private static void UpgradeDevInfo(DevInfo dbInfo, DevInfo backupInfo)
        {
            dbInfo.Name           = backupInfo.Name;
            dbInfo.ParentId       = backupInfo.ParentId;
            dbInfo.KKS            = backupInfo.KKS;
            dbInfo.Abutment_DevID = backupInfo.Abutment_DevID;
            dbInfo.Local_DevID    = backupInfo.Local_DevID;
            dbInfo.Local_TypeCode = backupInfo.Local_TypeCode;
            dbInfo.Status         = backupInfo.Status;
            dbInfo.ModelName      = backupInfo.ModelName;
            dbInfo.IP             = backupInfo.IP;
            dbInfo.UserName       = backupInfo.UserName;

            dbInfo.PosX      = backupInfo.PosX;
            dbInfo.PosY      = backupInfo.PosY;
            dbInfo.PosZ      = backupInfo.PosZ;
            dbInfo.RotationX = backupInfo.RotationX;
            dbInfo.RotationY = backupInfo.RotationY;
            dbInfo.RotationZ = backupInfo.RotationZ;
            dbInfo.ScaleX    = backupInfo.ScaleX;
            dbInfo.ScaleY    = backupInfo.ScaleY;
            dbInfo.ScaleZ    = backupInfo.ScaleZ;
        }
Ejemplo n.º 17
0
 /// <summary>
 /// 获取门禁信息
 /// </summary>
 /// <param name="camDev"></param>
 /// <param name="dev"></param>
 /// <returns></returns>
 private static DbModel.Location.AreaAndDev.Dev_DoorAccess GetDoorAccessInfo(DoorAccess doorAccessDev, DevInfo dev)
 {
     DbModel.Location.AreaAndDev.Dev_DoorAccess info = new DbModel.Location.AreaAndDev.Dev_DoorAccess();
     info.ParentId    = doorAccessDev.ParentId;
     info.DoorId      = doorAccessDev.DoorId;
     info.DevInfoId   = dev.Id;
     info.Local_DevID = dev.Local_DevID;
     return(info);
 }
Ejemplo n.º 18
0
        private void DealPatrolPoint(Bll bll, List <InspectionTrack> All, List <InspectionTrack> Delete, List <InspectionTrackHistory> HAdd, WebApiLib.Clients.BaseDataClient client)
        {
            List <PatrolPoint>        ppList  = bll.PatrolPoints.ToList();
            List <PatrolPointHistory> ppHList = bll.PatrolPointHistorys.ToList();
            List <DbModel.Location.AreaAndDev.DevInfo> devList = bll.DevInfos.ToList();

            if (ppList == null)
            {
                ppList = new List <PatrolPoint>();
            }

            if (ppHList == null)
            {
                ppHList = new List <PatrolPointHistory>();
            }

            if (devList == null)
            {
                devList = new List <DbModel.Location.AreaAndDev.DevInfo>();
            }

            List <PatrolPoint>        PAll    = new List <PatrolPoint>();
            List <PatrolPoint>        PAdd    = new List <PatrolPoint>();
            List <PatrolPoint>        PEdit   = new List <PatrolPoint>();
            List <PatrolPoint>        PDelete = new List <PatrolPoint>();
            List <PatrolPointHistory> PHAdd   = new List <PatrolPointHistory>();

            foreach (InspectionTrack item in All)
            {
                int Id       = item.Id;
                int patrolId = (int)item.Abutment_Id;
                CommunicationClass.SihuiThermalPowerPlant.Models.patrols recv = client.Getcheckpoints(patrolId);
                if (recv == null || recv.route.Count() <= 0)
                {
                    continue;
                }

                foreach (CommunicationClass.SihuiThermalPowerPlant.Models.checkpoints item2 in recv.route)
                {
                    DbModel.Location.AreaAndDev.DevInfo dev1 = devList.Find(p => p.KKS == item2.kksCode);
                    PatrolPoint now = ppList.Find(p => p.DeviceId == item2.deviceId && p.ParentId == Id);
                    if (now == null)
                    {
                        now = new PatrolPoint();

                        now.ParentId   = Id;
                        now.StaffCode  = item2.staffCode;
                        now.StaffName  = item2.staffName;
                        now.KksCode    = item2.kksCode;
                        now.DevName    = item2.deviceName;
                        now.DeviceCode = item2.deviceCode;
                        now.DeviceId   = item2.deviceId;
                        if (dev1 != null)
                        {
                            now.DevId = dev1.Id;
                        }

                        PAdd.Add(now);
                    }
                    else
                    {
                        now.ParentId   = Id;
                        now.StaffCode  = item2.staffCode;
                        now.StaffName  = item2.staffName;
                        now.KksCode    = item2.kksCode;
                        now.DevName    = item2.deviceName;
                        now.DeviceCode = item2.deviceCode;
                        now.DeviceId   = item2.deviceId;
                        if (dev1 != null)
                        {
                            now.DevId = dev1.Id;
                        }

                        PEdit.Add(now);
                    }
                }
            }

            foreach (InspectionTrack item in Delete)
            {
                int Id = item.Id;
                List <PatrolPoint> lstDelete = ppList.FindAll(p => p.ParentId == Id).ToList();
                if (lstDelete != null && lstDelete.Count() > 0)
                {
                    PDelete.AddRange(lstDelete);
                }
            }

            foreach (InspectionTrackHistory item in HAdd)
            {
                int Id       = item.Id;
                int patrolId = (int)item.Abutment_Id;
                CommunicationClass.SihuiThermalPowerPlant.Models.patrols recv = client.Getcheckpoints(patrolId);
                if (recv == null || recv.route.Count() <= 0)
                {
                    continue;
                }

                foreach (CommunicationClass.SihuiThermalPowerPlant.Models.checkpoints item2 in recv.route)
                {
                    DbModel.Location.AreaAndDev.DevInfo dev1 = devList.Find(p => p.KKS == item2.kksCode);
                    PatrolPointHistory history = ppHList.Find(p => p.DeviceId == item2.deviceId && p.ParentId == Id);
                    if (history == null)
                    {
                        history = new PatrolPointHistory();

                        history.ParentId   = Id;
                        history.StaffCode  = item2.staffCode;
                        history.StaffName  = item2.staffName;
                        history.KksCode    = item2.kksCode;
                        history.DevName    = item2.deviceName;
                        history.DeviceCode = item2.deviceCode;
                        history.DeviceId   = item2.deviceId;
                        if (dev1 != null)
                        {
                            history.DevId = dev1.Id;
                        }

                        PHAdd.Add(history);
                    }
                }
            }

            bll.PatrolPoints.AddRange(PAdd);
            bll.PatrolPoints.EditRange(PEdit);
            bll.PatrolPoints.RemoveList(PDelete);
            bll.PatrolPointHistorys.AddRange(PHAdd);

            PAll.AddRange(PAdd);
            PAll.AddRange(PEdit);
            DealPatrolPointItem(bll, All, HAdd, PAll, PDelete, PHAdd, client);

            return;
        }