public void Can_Start_VideoAnalytics() { DeviceDto cameraDevice = __controllerService.GetCameraDeviceByGuid(Guid.Parse("{ff0e79c3-9a33-47f5-9552-223a69a22bbe}")); NvrCameraDto nvrCameraDto = cameraDevice as NvrCameraDto; AnalyticsEventTemplateDto analyticsEventTemplateDto = _systemService.GetAnalyticsEventTemplate(nvrCameraDto.AnalyticsEventTemplateId.Value); }
public IEnumerable <DeviceDto> GetCameras(NvrDto nvrDto) { try { // Requesting the cameras list from the server. /*var server = InitializeServer(nvrDto); * this.camerasManager.GetCamerasAsObservable(server.ServerUniqueId).Subscribe( * cameras => * { * // Looking for a camera with name specified in configuration * var camerasResult = cameras.Cameras.Select(camera => * { * var device = new NvrCameraDto() * { * CameraGUID = camera.Id.ToString(), * Description = camera.Name, * IPAddress = camera.Address, * Lat = camera.LocationLatitude, * Long = camera.LocationLongitude, * Type = "NVRCamera", * LocationDescription = string.Empty, * Metadata = * string.Format("<metadata><camera-id>{0}</camera-id></metadata>", camera.Id), * Width = camera.Width, * Height = camera.Height, * FPS = (int)camera.RecordingFrameRate, * ZoneColumns = camera.Width, * ZoneRows = camera.Height, * UpdateRate = (decimal?)0.0001 * * }; * return device; * }).ToList(); * var camera = cameras.Cameras.FirstOrDefault(c => c.Name == this.cameraName); * if (camera != null) * { * var source = new Source(this.server.Id, camera.Id, false) { Framerate = 25 }; * //If playing video and loading thumbnails are requested during handling a response to a cameras request from the CamerasManager * // - it has to be done in separate thread in order to avoid problems with deadlock of CamerasManager. * ThreadPool.QueueUserWorkItem(_ => * { * // Setting the source to player in order to start playing the video * this.player.Source = source; * this.player.Play(); * * // Setting the source to ThumbnailsSlider in order to load thumbnails for this specific camera * this.slider.Source = source; * }); * } * else * { * // Such camera not found * } * }, * error => * { * // An error occurred when receiving the cameras list * exception => _logger.Error("Failed to get cameras for server. Error information:\r\n{0}", exception)); * return cameras.EmptyIfNull(); * });*/ var camerasInfoRequestMessage = new AdditionalCameraInfoRequest(); var cameras = ExecuteRequest <AdditionalCameraInfoResponse, IEnumerable <DeviceDto> >(nvrDto, camerasInfoRequestMessage, result => { var camerasResult = result.CamerasInfoCollection.Select(camera => { var device = new NvrCameraDto() { CameraGUID = camera.Id.ToString(), Description = camera.Name, IPAddress = camera.Address, Lat = camera.LocationLatitude, Long = camera.LocationLongitude, Type = "NVRCamera", IsPtz = false, IsMovable = false, LocationDescription = string.Empty, Metadata = string.Format("<metadata><camera-id>{0}</camera-id></metadata>", camera.Id), Width = camera.Width, Height = camera.Height, FPS = (int)camera.RecordingFrameRate, ZoneColumns = camera.Width, ZoneRows = camera.Height, UpdateRate = (decimal?)0.0001 }; return(device); }).ToList(); return(camerasResult); }, exception => _logger.Error("Failed to get cameras for server. Error information:\r\n{0}", exception)); return(cameras.EmptyIfNull()); } catch (Exception ex) { _logger.Info("NvrService GetCameras() Exception:" + ex.Message); string Message = "NvrService-GetCameras -- Exception = " + ex.Message; //InsertBrokerOperationLog.AddProcessLog(Message); InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin } finally { ClearMemory(); } return(null); }
public void UpdateCameraStatus() { try { _logger.Info("CameraStatus: GetNVRCameraCollection"); string[] fileEntries = Directory.GetFiles(Storage.DeviceListPath); int FileCOunt = fileEntries.Count(); if (FileCOunt > 0) { var _timerInterval = FileCOunt / 3.33; int _timerTime = Convert.ToInt32(_timerInterval); if (Storage.CameraStatusTimeSec < _timerTime) { _timer.Interval = (_timerTime + 10) * 1000; //return; } } if (IsFirstTimeCameraStatus == true) { IsFirstTimeCameraStatus = false; return; } foreach (var Filename in fileEntries) { NvrCameraDto deviceDto = null; XmlSerializer ser = new XmlSerializer(typeof(NvrCameraDto)); using (XmlReader reader = XmlReader.Create(Filename)) { deviceDto = (NvrCameraDto)ser.Deserialize(reader); } if (deviceDto is NvrCameraDto) { try { //create rtsp url var nvrCamera = deviceDto as NvrCameraDto; if (nvrCamera.CameraIp != null && nvrCamera.CameraIp != "") { int nPort = 554; if (nvrCamera.CameraPort != null || nvrCamera.CameraPort != "") { nPort = int.Parse(nvrCamera.CameraPort); } Task.Run(() => UpdateStatus(deviceDto, nPort)); } } catch (Exception ex) { _logger.Info("CameraStatusService UpdateCameraStatus() Exception" + ex.Message); } } } } catch (Exception ex) { _logger.Info("CameraStatusService UpdateCameraStatus() Exception" + ex.Message); } }
private IEnumerable <DeviceDto> GetDevicesCollection() { InsertBrokerOperationLog.AddProcessLog("Camera status service GetDevicesCollection(): Start"); try { using (var context = new CentralDBEntities()) { IList <DeviceDto> result = new List <DeviceDto>(); var resultsCollection = context.Device; var result2 = resultsCollection.Select(x => x).ToList(); foreach (var _entity in result2) { if (_entity is AMS.Broker.DataStore.NvrCamera) { try { var _entity1 = _entity as AMS.Broker.DataStore.NvrCamera; var _deviceDto = new NvrCameraDto() { DeviceId = _entity1.DeviceId, ExternalId = _entity1.ExternalId, Description = _entity1.Description, Metadata = _entity1.Metadata, Type = _entity1.Type, Lat = _entity1.Lat, Long = _entity1.Long, Altitude = _entity1.Altitude, LocationDescription = _entity1.LocationDescription, CameraGUID = _entity1.CameraGuid, NvrId = _entity1.NvrId, SiteId = _entity1.SiteId.HasValue ? _entity1.SiteId.Value : 0, ActiveAlert = _entity1.ActiveAlert, InterfaceId = _entity1.InterfaceId.HasValue ? _entity1.InterfaceId.Value : 0, IsMovable = _entity1.IsMovable, Name = _entity1.Name, AnalyticAlgorithmTypeId = _entity1.AnalyticAlgorithmTypeId, //None FPS = _entity1.FPS, Version = _entity1.Version, MaxBlobSize = _entity1.MaxBlobSize, MinBlobSize = _entity1.MinBlobSize, AlarmDelay = _entity1.AlarmDelay, UpdateRate = _entity1.UpdateRate, Width = _entity1.Width, Height = _entity1.Height, ZoneRows = _entity1.ZoneRows, ZoneColumns = _entity1.ZoneColumns, ZoneData = null, AnalyticsEventTemplateId = _entity1.AnalyticsEventTemplateId, IsPtz = _entity1.IsPtz, CameraIp = _entity1.CameraIp, LineStart = _entity1.LineStart, LineEnd = _entity1.LineEnd, DirectionFlag = _entity1.DirectionFlag, CameraUrl = _entity1.CameraUrl, CamUser = _entity1.CamUser, CamPassword = _entity1.CamPassword, CameraPort = _entity1.CameraPort, CameraType = _entity1.CameraType, MaxBlobHeight = _entity1.MaxBlobHeight, MaxBlobWidth = _entity1.MaxBlobWidth, MinBlobHeight = _entity1.MinBlobHeight, MinBlobWidth = _entity1.MinBlobWidth, AnalyticsServerIp = _entity1.AnalyticsServerIp, Lane1 = _entity1.Lane1, Lane2 = _entity1.Lane2, Lane3 = _entity1.Lane3, NoOfLens = _entity1.NoOfLens, ChanelNo = _entity1.ChanelNo, IsEdgeAnalytics = _entity1.IsEdgeAnalytics, IPAddress = _entity1.NVR.IPAddress }; result.Add(_deviceDto); } catch (Exception ES) { InsertBrokerOperationLog.AddProcessLog("Camera status service GetDevicesCollection()Exception : " + ES.Message); } } else { try { var _deviceDto = new DeviceDto { DeviceId = _entity.DeviceId, ExternalId = _entity.ExternalId, Description = _entity.Description, Metadata = _entity.Metadata, Type = _entity.Type, Lat = _entity.Lat, Long = _entity.Long, Altitude = _entity.Altitude, LocationDescription = _entity.LocationDescription, CameraGUID = _entity.CameraGuid, NvrId = _entity.NvrId, SiteId = _entity.SiteId.HasValue ? _entity.SiteId.Value : 0, ActiveAlert = _entity.ActiveAlert, InterfaceId = _entity.InterfaceId.HasValue ? _entity.InterfaceId.Value : 0, IsMovable = _entity.IsMovable, Name = _entity.Name }; result.Add(_deviceDto); } catch (Exception es) { InsertBrokerOperationLog.AddProcessLog("Camera status service GetDevicesCollection()Exception 1: " + es.Message); } } } InsertBrokerOperationLog.AddProcessLog("Camera status service GetDevicesCollection() Count : " + resultsCollection.Count()); _logger.Info(" items count: {0}", resultsCollection.Count()); _logger.Info("------------------------------------"); ClearMemory(); return(result); } } catch (SecurityException ex) { InsertBrokerOperationLog.AddProcessLog("Camera status service GetDevicesCollection() SecurityException : " + ex.Message); _logger.Info("ControllerServiceImpl GetDevicesCollectionImpl() Exception:" + ex.Message); _logger.Error(ex); } finally { ClearMemory(); } // return(null); }
private IEnumerable <DeviceDto> GetDevicesCollection() { InsertBrokerOperationLog.AddProcessLog("DeviceTimeSync Service GetDevicesCollection(): Start"); try { int cnt = 0; using (var context = new CentralDBEntities()) { _DeviceCollection = new List <DeviceDto>(); var resultsCollection = context.Device.Where(x => x.Type == "NvrCamera"); var result2 = resultsCollection.Select(x => x).ToList(); foreach (var _entity in result2) { if (_entity is AMS.Broker.DataStore.NvrCamera) { try { var _entity1 = _entity as AMS.Broker.DataStore.NvrCamera; var _deviceDto = new NvrCameraDto() { DeviceId = _entity1.DeviceId, ExternalId = _entity1.ExternalId, Description = _entity1.Description, Metadata = _entity1.Metadata, Type = _entity1.Type, Lat = _entity1.Lat, Long = _entity1.Long, Altitude = _entity1.Altitude, LocationDescription = _entity1.LocationDescription, CameraGUID = _entity1.CameraGuid, NvrId = _entity1.NvrId, SiteId = _entity1.SiteId.HasValue ? _entity1.SiteId.Value : 0, ActiveAlert = _entity1.ActiveAlert, InterfaceId = _entity1.InterfaceId.HasValue ? _entity1.InterfaceId.Value : 0, IsMovable = _entity1.IsMovable, Name = _entity1.Name, AnalyticAlgorithmTypeId = _entity1.AnalyticAlgorithmTypeId, //None FPS = _entity1.FPS, Version = _entity1.Version, MaxBlobSize = _entity1.MaxBlobSize, MinBlobSize = _entity1.MinBlobSize, AlarmDelay = _entity1.AlarmDelay, UpdateRate = _entity1.UpdateRate, Width = _entity1.Width, Height = _entity1.Height, ZoneRows = _entity1.ZoneRows, ZoneColumns = _entity1.ZoneColumns, ZoneData = null, AnalyticsEventTemplateId = _entity1.AnalyticsEventTemplateId, IsPtz = _entity1.IsPtz, CameraIp = _entity1.CameraIp, LineStart = _entity1.LineStart, LineEnd = _entity1.LineEnd, DirectionFlag = _entity1.DirectionFlag, CameraUrl = _entity1.CameraUrl, CamUser = _entity1.CamUser, CamPassword = _entity1.CamPassword, CameraPort = _entity1.CameraPort, CameraType = _entity1.CameraType, MaxBlobHeight = _entity1.MaxBlobHeight, MaxBlobWidth = _entity1.MaxBlobWidth, MinBlobHeight = _entity1.MinBlobHeight, MinBlobWidth = _entity1.MinBlobWidth, AnalyticsServerIp = _entity1.AnalyticsServerIp, Lane1 = _entity1.Lane1, Lane2 = _entity1.Lane2, Lane3 = _entity1.Lane3, NoOfLens = _entity1.NoOfLens, ChanelNo = _entity1.ChanelNo, IsEdgeAnalytics = _entity1.IsEdgeAnalytics, IPAddress = _entity1.NVR.IPAddress }; // using (var contextNvr = new CentralDBEntities()) //{ try { // var nvr = _NvrCollection.FirstOrDefault(x => x.InterfaceId == _deviceDto.InterfaceId); var DvrNvrDeviceID = _tblTimeSyncinfoDtoCollection.FirstOrDefault(x => x.DeviceID == _deviceDto.DeviceId); if (DvrNvrDeviceID != null) { var dvrNvrType = _DvrNvrCollection.FirstOrDefault(x => x.DvrNvrTypeId == DvrNvrDeviceID.DVRNVRTypeID); if (dvrNvrType != null) { _deviceDto.InterafaceType = dvrNvrType.Name; } } } catch (Exception ex) { InsertBrokerOperationLog.AddProcessLog("DeviceTimeSync service GetDvrNvrType Exception : " + ex.Message); } //} cnt++; DeviceCollectionDictionary.Add(cnt, _deviceDto); // _DeviceCollection.Add(_deviceDto); } catch (Exception ES) { InsertBrokerOperationLog.AddProcessLog("DeviceTimeSync service GetDevicesCollection()Exception : " + ES.Message); } } } InsertBrokerOperationLog.AddProcessLog("DeviceTimeSync service GetDevicesCollection() Count : " + resultsCollection.Count()); _logger.Info(" items count: {0}", resultsCollection.Count()); _logger.Info("------------------------------------"); ClearMemory(); return(_DeviceCollection); } } catch (SecurityException ex) { InsertBrokerOperationLog.AddProcessLog("DeviceTimeSync service GetDevicesCollection() SecurityException : " + ex.Message); _logger.Info("DeviceTimeSync service GetDevicesCollectionImpl() Exception:" + ex.Message); _logger.Error(ex); } finally { ClearMemory(); } // return(null); }
public List <DeviceDto> GetDeviceCollection() { try { if (DeviceCollection.Count() < 1) { var result = new List <DeviceDto>(); using (var ctxdev = new CentralDBEntities()) { var resultDb = (from dev in ctxdev.Device select dev).ToList(); if (resultDb != null) { foreach (var _dev in resultDb) { // var _devdto = Mapper.Map<DeviceDto>(_dev); //amit 26092016 if (_dev is NvrCamera) { try { var _entity1 = _dev as NvrCamera; var _deviceDto = new NvrCameraDto() { DeviceId = _entity1.DeviceId, ExternalId = _entity1.ExternalId, Description = _entity1.Description, Metadata = _entity1.Metadata, Type = _entity1.Type, Lat = _entity1.Lat, Long = _entity1.Long, Altitude = _entity1.Altitude, LocationDescription = _entity1.LocationDescription, CameraGUID = _entity1.CameraGuid, NvrId = _entity1.NvrId, SiteId = _entity1.SiteId.HasValue ? _entity1.SiteId.Value : 0, ActiveAlert = _entity1.ActiveAlert, // HasPvAnalytics = _entity1.HasPvAnalytics, // HasSzAnalytics = _entity1.HasSzAnalytics, // HasAbAnalytics = _entity1.HasAbAnalytics, InterfaceId = _entity1.InterfaceId.HasValue ? _entity1.InterfaceId.Value : 0, IsMovable = _entity1.IsMovable, Name = _entity1.Name, AnalyticAlgorithmTypeId = _entity1.AnalyticAlgorithmTypeId, //None FPS = _entity1.FPS, Version = _entity1.Version, MaxBlobSize = _entity1.MaxBlobSize, MinBlobSize = _entity1.MinBlobSize, AlarmDelay = _entity1.AlarmDelay, UpdateRate = _entity1.UpdateRate, Width = _entity1.Width, Height = _entity1.Height, ZoneRows = _entity1.ZoneRows, ZoneColumns = _entity1.ZoneColumns, ZoneData = null, AnalyticsEventTemplateId = _entity1.AnalyticsEventTemplateId, IsPtz = _entity1.IsPtz, CameraIp = _entity1.CameraIp, LineStart = _entity1.LineStart, LineEnd = _entity1.LineEnd, DirectionFlag = _entity1.DirectionFlag, CameraUrl = _entity1.CameraUrl, CamUser = _entity1.CamUser, CamPassword = _entity1.CamPassword, CameraPort = _entity1.CameraPort, CameraType = _entity1.CameraType, MaxBlobHeight = _entity1.MaxBlobHeight, MaxBlobWidth = _entity1.MaxBlobWidth, MinBlobHeight = _entity1.MinBlobHeight, MinBlobWidth = _entity1.MinBlobWidth, AnalyticsServerIp = _entity1.AnalyticsServerIp, Lane1 = _entity1.Lane1, Lane2 = _entity1.Lane2, Lane3 = _entity1.Lane3, NoOfLens = _entity1.NoOfLens, ChanelNo = _entity1.ChanelNo, IsEdgeAnalytics = _entity1.IsEdgeAnalytics, IPAddress = _entity1.NVR.IPAddress }; result.Add(_deviceDto); } catch (Exception ES) { } } else { try { var _deviceDto = new DeviceDto { DeviceId = _dev.DeviceId, ExternalId = _dev.ExternalId, Description = _dev.Description, Metadata = _dev.Metadata, Type = _dev.Type, Lat = _dev.Lat, Long = _dev.Long, Altitude = _dev.Altitude, LocationDescription = _dev.LocationDescription, CameraGUID = _dev.CameraGuid, NvrId = _dev.NvrId, SiteId = _dev.SiteId.HasValue ? _dev.SiteId.Value : 0, ActiveAlert = _dev.ActiveAlert, //HasPvAnalytics = _entity.HasPvAnalytics, // HasSzAnalytics = _entity.HasSzAnalytics, // HasAbAnalytics = _entity.HasAbAnalytics, InterfaceId = _dev.InterfaceId.HasValue ? _dev.InterfaceId.Value : 0, IsMovable = _dev.IsMovable, Name = _dev.Name }; result.Add(_deviceDto); } catch (Exception es) { } } } } } DeviceCollection = result; } return(DeviceCollection); } catch (Exception ex) { } finally { } return(null); }
public void Can_Add_InterfaceNvr() { var accounts = _accountService.GetAccounts(); var accountDto = new AccountDto(); var siteDto = new SiteDto(); foreach (var account in accounts) { var sites = _siteService.GetSiteForAccount(account.AccountId); if (sites != null && sites.Any()) { accountDto = account; siteDto = sites.FirstOrDefault(); break; } } var sysIterface = new InterfaceDto { AccountId = accountDto.AccountId, Name = "Nvr Interface Name", Description = "Nvr", InterfaceTypeId = 1 }; var addedInterface = _systemService.AddInterface(sysIterface, accountDto.AccountId, siteDto.SiteId); var getInterface = _systemService.GetInterface(addedInterface.InterfaceId); Assert.IsNotNull(getInterface); var newDeviceDto = new NvrCameraDto() { Altitude = 100, Description = "Device Description", ExternalId = "External Id", LocationDescription = "Location Description", InterfaceId = getInterface.InterfaceId, Lat = 100, Long = 100, SiteId = siteDto.SiteId, Type = "FireAlarm", ActiveAlert = false, Name = "Device Name", FPS = 21, AnalyticAlgorithmType = _algorithms.First(), AnalyticAlgorithmTypeId = _algorithms.First().AnalyticAlgorithmId, AlarmDelay = 60, Version = "1.0.0.167", MaxBlobSize = 1000, MinBlobSize = 100, UpdateRate = (decimal)20.5, Width = 100, Height = 100, ZoneRows = 13, ZoneColumns = 14, ZoneData = null }; var addedDeviceDto = _systemService.AddDeviceToInterface(newDeviceDto, getInterface.InterfaceId); Assert.NotNull(addedDeviceDto); var updayedDevice = _systemService.UpdateDevice(addedDeviceDto, getInterface.InterfaceId); bool deletedDevice = _systemService.DeleteDevice(updayedDevice.DeviceId); Assert.IsTrue(deletedDevice); bool deletedInterface = _systemService.Delete(getInterface.InterfaceId); Assert.IsTrue(deletedInterface); }