private static void Run(Options options)
        {
            using (var xprotect = new XProtectHelper())
            {
                xprotect.Connect(new Uri($"http://{options.Server}:{options.Port}/"));
                if (!xprotect.State.HasFlag(XProtectHelper.XProtectState.Connected))
                {
                    Console.WriteLine(xprotect.LastError);
                    return;
                }

                IXProtectDataProcessor dataProcessor = null;
                if (options.Kind.StartsWith("hardware", StringComparison.OrdinalIgnoreCase) && !options.NewHardware)
                {
                    dataProcessor = new XProtectHardwareDataProcessor(xprotect, options);
                }
                if (options.Kind.StartsWith("hardware", StringComparison.OrdinalIgnoreCase) && options.NewHardware)
                {
                    dataProcessor = new XProtectNewHardwareDataProcessor(xprotect);
                }
                else if (options.Kind.StartsWith("cam", StringComparison.OrdinalIgnoreCase))
                {
                    dataProcessor = new XProtectCameraDataProcessor(xprotect);
                }
                else if (options.Kind.StartsWith("record", StringComparison.OrdinalIgnoreCase))
                {
                    dataProcessor = new XProtectRecorderDataProcessor(xprotect);
                }
                else if (options.Kind.StartsWith("mic", StringComparison.OrdinalIgnoreCase))
                {
                    dataProcessor = new XProtectMicrophoneDataProcessor(xprotect);
                }
                else if (options.Kind.StartsWith("speak", StringComparison.OrdinalIgnoreCase))
                {
                    dataProcessor = new XProtectSpeakerDataProcessor(xprotect);
                }
                else if (options.Kind.StartsWith("meta", StringComparison.OrdinalIgnoreCase))
                {
                    dataProcessor = new XProtectMetadataDataProcessor(xprotect);
                }
                else if (options.Kind.StartsWith("in", StringComparison.OrdinalIgnoreCase))
                {
                    dataProcessor = new XProtectInputDataProcessor(xprotect);
                }
                else if (options.Kind.StartsWith("out", StringComparison.OrdinalIgnoreCase))
                {
                    dataProcessor = new XProtectOutputDataProcessor(xprotect);
                }

                if (dataProcessor != null)
                {
                    ProcessData(dataProcessor, options);
                }
            }
        }
        private MicInfo ConvertToDto(Microphone microphone, XProtectHelper xprotect)
        {
            var hardware        = new Hardware(Configuration.Instance.ServerFQID.ServerId, microphone.ParentItemPath);
            var recordingServer = new RecordingServer(Configuration.Instance.ServerFQID.ServerId, hardware.ParentItemPath);

            return(new MicInfo()
            {
                Enabled = microphone.Enabled,
                ReadOnlyId = new Guid(microphone.Id),
                Name = microphone.DisplayName,
                ReadOnlyRecordingServer = recordingServer.DisplayName,
                ReadOnlyChannel = microphone.Channel,
                ReadOnlyHardwareName = hardware.DisplayName,
                RecordingEnabled = microphone.RecordingEnabled
            });
        }
        private RecorderInfo ConvertRecorderToRecorderInfo(RecordingServer recorder, XProtectHelper xprotect)
        {
            var ms = new ManagementServer(recorder.ServerId);

            return(new RecorderInfo()
            {
                ReadOnlyId = new Guid(recorder.Id),
                Name = recorder.DisplayName,
                ReadOnlyVersion = GetRecorderVersion(recorder),
                ReadOnlyDevicePack = GetDevicePack(recorder),
                ReadOnlyHostName = recorder.HostName,
                ReadOnlyManagementServer = ms.DisplayName,
                ReadOnlyPort = recorder.PortNumber,
                ReadOnlyTimeZoneName = recorder.TimeZoneName
            });
        }
Example #4
0
        private SpeakerInfo ConvertToDto(Speaker speaker, XProtectHelper xprotect)
        {
            var hardware        = new Hardware(Configuration.Instance.ServerFQID.ServerId, speaker.ParentItemPath);
            var recordingServer = new RecordingServer(Configuration.Instance.ServerFQID.ServerId, hardware.ParentItemPath);

            return(new SpeakerInfo
            {
                Enabled = speaker.Enabled,
                ReadOnlyId = new Guid(speaker.Id),
                Name = speaker.DisplayName,
                ReadOnlyRecordingServer = recordingServer.DisplayName,
                ReadOnlyChannel = speaker.Channel,
                ReadOnlyHardwareName = hardware.DisplayName,
                RecordingEnabled = speaker.RecordingEnabled
            });
        }
Example #5
0
        private MetadataInfo ConvertToDto(Metadata metaData, XProtectHelper xprotect)
        {
            var hardware        = new Hardware(Configuration.Instance.ServerFQID.ServerId, metaData.ParentItemPath);
            var recordingServer = new RecordingServer(Configuration.Instance.ServerFQID.ServerId, hardware.ParentItemPath);

            return(new MetadataInfo
            {
                Enabled = metaData.Enabled,
                ReadOnlyId = new Guid(metaData.Id),
                Name = metaData.DisplayName,
                ReadOnlyRecordingServer = recordingServer.DisplayName,
                ReadOnlyChannel = metaData.Channel,
                ReadOnlyHardwareName = hardware.DisplayName,
                RecordingEnabled = metaData.RecordingEnabled
            });
        }
        private CameraInfo ConvertCameraToCameraInfo(Camera camera, XProtectHelper xprotect)
        {
            var hardware        = new Hardware(Configuration.Instance.ServerFQID.ServerId, camera.ParentItemPath);
            var recordingServer = new RecordingServer(Configuration.Instance.ServerFQID.ServerId, hardware.ParentItemPath);
            var driver          = HardwareDriverCacheHelper.GetDriver(hardware, recordingServer);

            return(new CameraInfo()
            {
                Enabled = camera.Enabled,
                ReadOnlyId = new Guid(camera.Id),
                Name = camera.DisplayName,
                ReadOnlyResolution = GetDefaultStreamResolution(camera),
                ReadOnlyRecordingServer = recordingServer.DisplayName,
                ReadOnlyChannel = camera.Channel,
                ReadOnlyHardwareName = hardware.DisplayName,
                RecordingEnabled = camera.RecordingEnabled,
                ReadOnlyDriverName = driver?.DisplayName,
                ReadOnlyDriverNumber = driver?.Number ?? -1
            });
        }
Example #7
0
        private object ConvertToDto(object io, XProtectHelper xprotect)
        {
            switch (io)
            {
            case InputEvent input:
            {
                var hardware        = new Hardware(Configuration.Instance.ServerFQID.ServerId, input.ParentItemPath);
                var recordingServer = new RecordingServer(Configuration.Instance.ServerFQID.ServerId, hardware.ParentItemPath);
                return(new InputInfo
                    {
                        Enabled = input.Enabled,
                        ReadOnlyId = new Guid(input.Id),
                        Name = input.DisplayName,
                        ReadOnlyRecordingServer = recordingServer.DisplayName,
                        ReadOnlyChannel = input.Channel,
                        ReadOnlyHardwareName = hardware.DisplayName
                    });
            }

            case Output output:
            {
                var hardware        = new Hardware(Configuration.Instance.ServerFQID.ServerId, output.ParentItemPath);
                var recordingServer = new RecordingServer(Configuration.Instance.ServerFQID.ServerId, hardware.ParentItemPath);
                return(new OutputInfo
                    {
                        Enabled = output.Enabled,
                        ReadOnlyId = new Guid(output.Id),
                        Name = output.DisplayName,
                        ReadOnlyRecordingServer = recordingServer.DisplayName,
                        ReadOnlyChannel = output.Channel,
                        ReadOnlyHardwareName = hardware.DisplayName
                    });
            }
            }
            return(null);
        }
 public XProtectMicrophoneDataProcessor(XProtectHelper xprotect)
 {
     _xprotect = xprotect;
 }
 public XProtectCameraDataProcessor(XProtectHelper xprotect)
 {
     _xprotect = xprotect;
 }
 public XProtectRecorderDataProcessor(XProtectHelper xprotect)
 {
     _xprotect = xprotect;
 }
Example #11
0
 public XProtectSpeakerDataProcessor(XProtectHelper xprotect)
 {
     _xprotect = xprotect;
 }
Example #12
0
 public XProtectMetadataDataProcessor(XProtectHelper xprotect)
 {
     _xprotect = xprotect;
 }
Example #13
0
 public XProtectIoDataProcessor(XProtectHelper xprotect)
 {
     _xprotect = xprotect;
 }
Example #14
0
 public XProtectOutputDataProcessor(XProtectHelper xprotect) : base(xprotect)
 {
     this.TypeOfIo = IoType.Output;
 }