Пример #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            IRecordingServiceProvider provider = new RecordingServiceProvider(new WinFormsScreenMetadataService());

            ISelectRecordAreaView      view      = new SelectRecordAreaView();
            ISelectRecordAreaViewModel viewModel = new SelectRecordAreaViewModel(provider, new NavigationService());

            view.DataContext = viewModel;
            view.ShowDialog();
        }
Пример #2
0
        public void QueryRecordings()
        {
            DiscoveredDevices         devices      = ContextController.GetDiscoveredDevices();
            string                    address      = devices != null ? devices.ServiceAddress : string.Empty;
            DeviceEnvironment         env          = ContextController.GetDeviceEnvironment();
            ManagementServiceProvider deviceClient = new ManagementServiceProvider(address, env.Timeouts.Message);

            ReportOperationStarted();
            Thread thread = new Thread(new ThreadStart(new Action(() =>
            {
                try
                {
                    DeviceServicesInfo info         = deviceClient.GetCapabilitiesDefineSecurity(new Onvif.CapabilityCategory[] { Onvif.CapabilityCategory.All });
                    Onvif.Capabilities capabilities = info.Capabilities;

                    string recordingControlAddress = string.Empty;

                    if (capabilities != null)
                    {
                        if (capabilities.Extension != null)
                        {
                            if (capabilities.Extension.Recording != null)
                            {
                                recordingControlAddress = capabilities.Extension.Recording.XAddr;
                            }
                        }
                    }

                    if (string.IsNullOrEmpty(recordingControlAddress))
                    {
                        if (info.Services != null)
                        {
                            Onvif.Service service = Tests.Common.CommonUtils.Extensions.FindService(
                                info.Services, OnvifService.RECORIDING);
                            if (service != null)
                            {
                                recordingControlAddress = service.XAddr;
                            }
                        }
                        else
                        {
                            throw new Exception("Unable to get service address");
                        }
                    }
                    if (string.IsNullOrEmpty(recordingControlAddress))
                    {
                        throw new Exception("Device does not support Recording service");
                    }

                    RecordingServiceProvider client =
                        new RecordingServiceProvider(recordingControlAddress, env.Timeouts.Message);
                    client.Security = deviceClient.Security;
                    List <Onvif.GetRecordingsResponseItem> recordings = client.GetRecordings();
                    List <string> tokens = recordings.Select(R => R.RecordingToken).ToList();
                    if ((tokens != null) && (tokens.Count > 0))
                    {
                        View.SettingsView.SetRecordings(tokens);
                    }
                    else
                    {
                        throw new Exception("No Recordings returned by device");
                    }
                }
                catch (System.Exception ex)
                {
                    View.ShowError(ex);
                }
                finally
                {
                    ReportOperationCompleted();
                }
            })));

            thread.CurrentUICulture = System.Globalization.CultureInfo.InvariantCulture;
            thread.Start();
        }