Example #1
0
        /// <summary>
        /// Marks this asset complete
        /// </summary>
        public override void Completed()
        {
            //_useRecording = _cameraDetail.UseAutoStart;

            if (_cameraDetail.UseAutoStart)
            {
                using (CameraSessionManager manager = new CameraSessionManager(_cameraDetail.Address, _cameraDetail.ServerUser, _cameraDetail.ServerPassword))
                {
                    try
                    {
                        // Stop the camera
                        manager.StopRecordingCommand(_cameraDetail.CameraId);

                        if (manager.GetCameraState(_cameraDetail.CameraId).IsRecording)
                        {
                            MapElement.UpdateStatus("Could not stop Recording", RuntimeState.Running);
                        }
                        else
                        {
                            MapElement.UpdateStatus("Completed", RuntimeState.Running);
                        }
                    }
                    catch (Exception ex)
                    {
                        TraceFactory.Logger.Error($"Cannot Stop the camera: {_cameraDetail.CameraId}.", ex);
                        MapElement.UpdateStatus($"Camera {_cameraDetail.CameraId} is not stopping properly.", RuntimeState.Warning);
                    }
                }
            }
            //MapElement.UpdateStatus("Completed", RuntimeState.Completed);
        }
Example #2
0
        /// <summary>
        /// Shuts down this asset host
        /// </summary>
        /// <param name="options"></param>
        /// <param name="loopState"></param>
        public override void Shutdown(ShutdownOptions options, ParallelLoopState loopState)
        {
            //_useRecording = _cameraDetail.UseAutoStart;

            if (_cameraDetail.UseAutoStart)
            {
                using (CameraSessionManager manager = new CameraSessionManager(_cameraDetail.Address, _cameraDetail.ServerUser, _cameraDetail.ServerPassword))
                {
                    try
                    {
                        // Stop the camera
                        manager.StopRecordingCommand(_cameraDetail.CameraId);
                    }
                    catch (Exception ex)
                    {
                        TraceFactory.Logger.Error($"Cannot Stop the camera: {_cameraDetail.CameraId}.", ex);
                        MapElement.UpdateStatus($"Camera {_cameraDetail.CameraId} is not stopping properly.", RuntimeState.Warning);
                    }
                }
            }

            base.Shutdown(options, loopState);
        }