コード例 #1
0
        public void AddOnvifCamera(OnvifCameraSetting device)
        {
            using (var scopedLock = configLock.WriterLock())
            {
                onvifCameras[device.Id] = device;

                SetValue(nameof(device.Name), device.Name, device.Id);
                SetValue(nameof(device.CameraHost), device.CameraHost, device.Id);
                SetValue(nameof(device.Login), device.Login, device.Id);
                SetValue(nameof(device.Password), HS.EncryptString(device.Password, nameof(device.Password)), device.Id);
                SetValue(nameof(device.AlarmCancelInterval), (long)device.AlarmCancelInterval.TotalSeconds, device.Id);
                SetValue(nameof(device.SnapshotDownloadDirectory), device.SnapshotDownloadDirectory, device.Id);

                SetValue(OnvifCameraIds, onvifCameras.Keys.Aggregate((x, y) => x + idsSeparator + y));
            }
        }
コード例 #2
0
        public void AddHikvisionIsapiCamera(Camera.Hikvision.Isapi.CameraSettings device)
        {
            using (var scopedLock = configLock.WriterLock())
            {
                hikvisionIsapiCameras[device.Id] = device;

                SetValue(nameof(device.Name), device.Name, device.Id);
                SetValue(nameof(device.CameraHost), device.CameraHost, device.Id);
                SetValue(nameof(device.Login), device.Login, device.Id);
                SetValue(nameof(device.Password), HS.EncryptString(device.Password, nameof(device.Password)), device.Id);
                SetValue(nameof(device.AlarmCancelInterval), (long)device.AlarmCancelInterval.TotalSeconds, device.Id);
                SetValue(nameof(device.CameraPropertiesRefreshInterval), (long)device.CameraPropertiesRefreshInterval.TotalSeconds, device.Id);
                SetValue(nameof(device.SnapshotDownloadDirectory), device.SnapshotDownloadDirectory, device.Id);
                SetValue(nameof(device.VideoDownloadDirectory), device.VideoDownloadDirectory, device.Id);

                SetValue(HikvisionIsapiCameraIds, hikvisionIsapiCameras.Keys.Aggregate((x, y) => x + idsSeparator + y));
            }
        }
コード例 #3
0
        public void AddDevice(AirVisualNode device)
        {
            configLock.EnterWriteLock();
            try
            {
                devices[device.Id] = device;

                SetValue(NameKey, device.Name, device.Id);
                SetValue(IPAddressKey, device.DeviceIP.ToString(), device.Id);
                SetValue(UserNameKey, device.Username, device.Id);
                SetValue(PasswordKey, HS.EncryptString(device.Password, EncryptPassword), device.Id);

                SetValue(DeviceIds, devices.Keys.Aggregate((x, y) => x + DeviceIdsSeparator + y));
            }
            finally
            {
                configLock.ExitWriteLock();
            }
        }
コード例 #4
0
        public void AddDevice(MPowerDevice device)
        {
            configLock.EnterWriteLock();
            try
            {
                devices[device.Id] = device;

                SetValue(NameKey, device.Name, device.Id);
                SetValue(IPAddressKey, device.DeviceIP.ToString(), device.Id);
                SetValue(UserNameKey, device.Username, device.Id);
                SetValue(PasswordKey, HS.EncryptString(device.Password, EncryptPassword), device.Id);

                foreach (var item in System.Enum.GetValues(typeof(DeviceType)))
                {
                    SetValue(item.ToString(), device.EnabledTypes.Contains((DeviceType)item), device.Id);
                }

                foreach (var pair in device.Resolution)
                {
                    SetValue(ResolutionKey(pair.Key), pair.Value, device.Id);
                }

                if (device.EnabledPorts.Count > 0)
                {
                    SetValue(PortsEnabledKey, device.EnabledPorts
                             .Select(x => x.ToString(CultureInfo.InvariantCulture))
                             .Aggregate((x, y) => x + PortsEnabledSeparator + y), device.Id);
                }
                else
                {
                    SetValue(PortsEnabledKey, string.Empty, device.Id);
                }

                SetValue(DeviceIds, devices.Keys.Aggregate((x, y) => x + DeviceIdsSeparator + y));
            }
            finally
            {
                configLock.ExitWriteLock();
            }
        }