Пример #1
0
        public IEnumerable <object> GetCameraAdditionalInfo(NvrDto nvr)
        {
            try
            {
                var cameraInfoRequest = new AdditionalCameraInfoRequest();

                var camerasInfoCollection = ExecuteRequest <AdditionalCameraInfoResponse, IEnumerable <Object> >(nvr, cameraInfoRequest,
                                                                                                                 result =>
                {
                    var camerasInfos = result.CamerasInfoCollection;
                    return(camerasInfos);
                },
                                                                                                                 exception => _logger.Error("Failed to get camera info collection from server. Error information:\r\n{0}", exception));

                return(camerasInfoCollection.EmptyIfNull());
            }
            catch (Exception ex)
            {
                _logger.Info("NvrService GetCameraAdditionalInfo() Exception:" + ex.Message);
                string Message = "NvrService-GetCameraAdditionalInfo -- Exception = " + ex.Message;
                //InsertBrokerOperationLog.AddProcessLog(Message);
                InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
            }
            finally
            {
                ClearMemory();
            }
            return(null);
        }
Пример #2
0
        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);
        }