Пример #1
0
        /// <summary>
        /// Initializes (and returns) event service address (using GetCapabilities method).
        /// </summary>
        /// <returns></returns>
        protected string GetEventServiceAddress()
        {
            string address = string.Empty;

            RunStep(() =>
            {
                Binding binding =
                    CreateBinding(true,
                                  new IChannelController[] { new SoapValidator(DeviceManagementSchemasSet.GetInstance()) });

                DeviceClient device = new DeviceClient(binding, new EndpointAddress(_cameraAddress));
                AddSecurityBehaviour(device.Endpoint);

                address = device.GetEventServiceAddress(Features);

                device.Close();

                if (string.IsNullOrEmpty(address))
                {
                    throw new DutPropertiesException("Event capabilities not found");
                }
                Uri uri;
                if (!Uri.TryCreate(address, UriKind.Absolute, out uri))
                {
                    throw new AssertException(string.Format("Event service address [{0}] is invalid", address));
                }
            }, "Get Event service address");
            DoRequestDelay();
            _eventServiceAddress = address;
            return(address);
        }
Пример #2
0
        /// <summary>
        /// Returns DUT's media service address
        /// </summary>
        /// <returns>Replay service url</returns>
        protected string GetReplayServiceAddress()
        {
            string address = string.Empty;

            RunStep(() =>
            {
                Binding binding =
                    CreateBinding(false,
                                  new IChannelController[] { new SoapValidator(DeviceManagementSchemasSet.GetInstance()) });

                DeviceClient device = new DeviceClient(binding, new EndpointAddress(_cameraAddress));

                AttachSecurity(device.Endpoint);
                SetupChannel(device.InnerChannel);

                address = device.GetReplayServiceAddress(Features);

                device.Close();

                if (string.IsNullOrEmpty(address))
                {
                    throw new AssertException("The DUT did not return Replay service address");
                }
            }, "Get Replay Service address");
            DoRequestDelay();
            return(address);
        }
Пример #3
0
        private void btnSetDiscoveryMode_Click(object sender, EventArgs e)
        {
            try
            {
                DiscoveryMode mode = (DiscoveryMode)comboBoxDiscoveryMode.SelectedValue;

                DeviceClient service = GetService();

                if (cbTrace.Checked)
                {
                    if (cbLowLevelTrace.Checked)
                    {
                        System.ServiceModel.Channels.CustomBinding cb    = (System.ServiceModel.Channels.CustomBinding)service.Endpoint.Binding;
                        CustomTextMessageBindingElement            ctmbe = (CustomTextMessageBindingElement)cb.Elements[0];

                        string value = "Discoverrable";
                        string path  = "/s:Envelope/s:Body/onvif:SetDiscoveryMode/onvif:DiscoveryMode";
                        Dictionary <string, string> namespaces = new Dictionary <string, string>();
                        namespaces.Add("s", "http://www.w3.org/2003/05/soap-envelope");
                        namespaces.Add("onvif", "http://www.onvif.org/ver10/device/wsdl");
                        ctmbe.AddBreakingBehaviour(new BreakingBehaviour(path, value, namespaces));
                    }
                }

                service.SetDiscoveryMode(mode);
                ShowStatusMessage("Done");
                service.Close();
            }
            catch (Exception ex)
            {
                ShowStatusMessage("Operation failed");
                TraceException(ex);
                MessageBox.Show(ex.Message);
            }
        }
Пример #4
0
 protected override void Release()
 {
     base.Release();
     if (_deviceClient != null)
     {
         _deviceClient.Close();
     }
 }
Пример #5
0
 protected override void Release()
 {
     if (_deviceClient != null)
     {
         if (_deviceClient.State == CommunicationState.Opened)
         {
             _deviceClient.Close();
         }
     }
     base.Release();
 }
 protected override void Release()
 {
     base.Release();
     if (_deviceClient != null)
     {
         _deviceClient.Close();
     }
     if (_pacsServiceHolder != null)
     {
         _pacsServiceHolder.Close();
     }
 }
Пример #7
0
 protected override void Release()
 {
     if (_deviceClient != null)
     {
         _deviceClient.Close();
     }
     if (_recordingClient != null)
     {
         _recordingClient.Close();
     }
     base.Release();
 }
Пример #8
0
 protected override void Release()
 {
     if (_deviceClient != null)
     {
         _deviceClient.Close();
     }
     if (_mediaClient != null)
     {
         _mediaClient.Close();
     }
     if (_deviceIoClient != null)
     {
         _deviceIoClient.Close();
     }
     base.Release();
 }
Пример #9
0
 private void btnGetClientSertificateMode_Click(object sender, EventArgs e)
 {
     try
     {
         DeviceClient service = GetService();
         bool         result  = service.GetClientCertificateMode();
         ShowStatusMessage("Done");
         service.Close();
     }
     catch (Exception ex)
     {
         ShowStatusMessage("Operation failed");
         TraceException(ex);
         MessageBox.Show(ex.Message);
     }
 }
Пример #10
0
        private void btnCall_Click(object sender, EventArgs e)
        {
            try
            {
                ListViewItem lvi = listViewMethods.SelectedItems[0];
                MethodInfo   mi  = (MethodInfo)lvi.Tag;

                if (mi.GetParameters().Length == 0)
                {
                    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;

                    DeviceClient service = GetService();

                    WriteLine(string.Format("Call {0}", mi.Name), System.Drawing.Color.Brown);
                    if (mi.ReturnType != typeof(void))
                    {
                        object result = mi.Invoke(service, new object[0]);
                        if (cbShowResult.Checked)
                        {
                            string         methodInfo = string.Format("Result from {0}", mi.Name);
                            QuickWatchForm form       = new QuickWatchForm(methodInfo, result);
                            form.Show();
                        }
                    }
                    else
                    {
                        mi.Invoke(service, new object[0]);
                    }
                    WriteLine("Done.\n");
                    ShowStatusMessage("Done");
                    service.Close();
                }
            }
            catch (Exception ex)
            {
                WriteLine(string.Format("Error: {0}", ex.Message));
                ShowStatusMessage("Operation failed");
                FaultException faultException = ex.InnerException as FaultException;

                if (faultException != null)
                {
                    WriteLine(string.Format("   InnerException: {0}", faultException.Message), System.Drawing.Color.Red);
                    WriteLine("");
                }
            }
        }
Пример #11
0
        private void SetAccessPolicy_Click(object sender, EventArgs e)
        {
            try
            {
                DeviceClient service = GetService();

                service.SetAccessPolicy("Some parameter");
                ShowStatusMessage("Done");
                service.Close();
            }
            catch (Exception ex)
            {
                ShowStatusMessage("Operation failed");
                TraceException(ex);
                MessageBox.Show(ex.Message);
            }
        }
Пример #12
0
        private void SetZeroConfiguration_Click(object sender, EventArgs e)
        {
            try
            {
                DeviceClient service = GetService();

                service.SetZeroConfiguration("string", false);
                ShowStatusMessage("Done");
                service.Close();
            }
            catch (Exception ex)
            {
                ShowStatusMessage("Operation failed");
                TraceException(ex);
                MessageBox.Show(ex.Message);
            }
        }
Пример #13
0
        private void btnGetDiscoveryMode_Click(object sender, EventArgs e)
        {
            try
            {
                DeviceClient service = GetService();

                DiscoveryMode discoveryMode = service.GetDiscoveryMode();
                ShowStatusMessage("Done");
                service.Close();

                if (cbShowResult.Checked)
                {
                    string         methodInfo = "Result from GetDiscoveryMode";
                    QuickWatchForm form       = new QuickWatchForm(methodInfo, discoveryMode);
                    form.Show();
                }
            }
            catch (Exception ex)
            {
                ShowStatusMessage("Operation failed");
                TraceException(ex);
                MessageBox.Show(ex.Message);
            }
        }
Пример #14
0
        void InitializeProxies(SimulatorStartParameters parameters)
        {
            _proxies = new List <ServiceProxy>();

            string             deviceAddress = parameters.IPAddress + "onvif/device_service/";
            DeviceServiceProxy deviceProxy   = new DeviceServiceProxy(deviceAddress,
                                                                      parameters.DeviceAddress);

            deviceProxy.DataTransmitted += new NetworkEvent(Proxy_DataTransmitted);
            _proxies.Add(deviceProxy);

            //
            // initialize other proxies
            //

            CustomBinding custombindingSoap12 = new CustomBinding();

            custombindingSoap12.Elements.Add(new TextMessageEncodingBindingElement(MessageVersion.Soap12, Encoding.UTF8));
            custombindingSoap12.Elements.Add(new HttpTransportBindingElement());

            Dictionary <string, string> replacements = new Dictionary <string, string>();

            replacements.Add(OnvifService.DEVICE, deviceAddress);

            DeviceClient deviceClient = new DeviceClient(custombindingSoap12, new EndpointAddress(parameters.DeviceAddress));

            Service[] services;
            try
            {
                services = deviceClient.GetServices(false);
            }
            catch (FaultException exc)
            {
                deviceClient.Close();
                deviceClient = new DeviceClient(custombindingSoap12, new EndpointAddress(parameters.DeviceAddress));
                deviceClient.Endpoint.Behaviors.Add(new Transport.SecurityBehavior()
                {
                    UserName = parameters.Username, Password = parameters.Password
                });
                services = deviceClient.GetServices(false);
            }
            deviceClient.Close();

            foreach (Service service in services)
            {
                string localAddress = string.Empty;
                switch (service.Namespace)
                {
                case OnvifService.ACCESSCONTROL:
                    localAddress = "onvif/access_control/";
                    break;

                case OnvifService.DOORCONTROL:
                    localAddress = "onvif/door_control/";
                    break;
                }

                if (!string.IsNullOrEmpty(localAddress))
                {
                    string       address = parameters.IPAddress + localAddress;
                    ServiceProxy proxy   = new ServiceProxy(address, service.XAddr);
                    proxy.DataTransmitted += new NetworkEvent(Proxy_DataTransmitted);
                    _proxies.Add(proxy);
                    replacements.Add(service.Namespace, address);
                }
            }

            deviceProxy.SetReplacements(replacements);
        }