Example #1
0
        public static void MuestraInfo(string uri)
        {
            System.DateTime UTCTime = System.DateTime.UtcNow;

            Console.Write(string.Format("Client UTC Time: {0}", UTCTime.ToString("HH:mm:ss")));

            HttpTransportBindingElement httpTransport = new HttpTransportBindingElement();
            var httpTransportBinding = new HttpTransportBindingElement {
                AuthenticationScheme = AuthenticationSchemes.Digest
            };
            var textMessageEncodingBinding = new TextMessageEncodingBindingElement {
                MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None)
            };
            var customBinding = new CustomBinding(textMessageEncodingBinding, httpTransportBinding);
            TextMessageEncodingBindingElement textMessageEncoding = new TextMessageEncodingBindingElement(MessageVersion.Soap12, Encoding.UTF8);

            EndpointAddress         serviceAddress = new EndpointAddress(uri);
            ChannelFactory <Device> channelFactory = new ChannelFactory <Device>(customBinding, serviceAddress);

            var passwordDigestBehavior = new PasswordDigestBehavior("julian", "julian");

            channelFactory.Endpoint.Behaviors.Remove(typeof(ClientCredentials));
            channelFactory.Endpoint.Behaviors.Add(passwordDigestBehavior);

            var deviceClient = new DeviceClient(customBinding, serviceAddress);

            deviceClient.Endpoint.Behaviors.Add(passwordDigestBehavior);

            var unitTime = deviceClient.GetSystemDateAndTime();

            Console.Write((string.Format(" Camera UTC Time: {0}:{1}:{2}", unitTime.UTCDateTime.Time.Hour, unitTime.UTCDateTime.Time.Minute, unitTime.UTCDateTime.Time.Second)));

            ServiceReference1.CapabilityCategory[] cc = new ServiceReference1.CapabilityCategory[100];
            deviceClient.GetCapabilities(cc);

            Console.Write(" GetHostname: " + deviceClient.GetHostname().Name);
            Console.Write(" GetWsdlUrl: " + deviceClient.GetWsdlUrl());


            string model, firmwareVersion, serialNumber, hardwareId;

            deviceClient.GetDeviceInformation(out model, out firmwareVersion, out serialNumber, out hardwareId);
            Console.Write(" Model: " + model);
            Console.Write(" firmwareVersion: " + firmwareVersion);
            Console.Write(" serialNumber: " + serialNumber);
            Console.WriteLine("hardwareId: " + hardwareId + "\n\n");
        }
Example #2
0
        public static void ManejaEventos(string uri)
        {
            try
            {
                ServicePointManager.Expect100Continue = false;
                EndpointAddress             endPointAddress      = new EndpointAddress(uri);
                HttpTransportBindingElement httpTransportBinding = new HttpTransportBindingElement {
                    AuthenticationScheme = AuthenticationSchemes.Digest
                };
                httpTransportBinding.KeepAliveEnabled = true;
                TextMessageEncodingBindingElement textMessageEncodingBinding = new TextMessageEncodingBindingElement {
                    MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.WSAddressing10)
                };
                PasswordDigestBehavior passwordDigestBehavior = new PasswordDigestBehavior("julian", "julian");

                CustomBinding customBinding = new CustomBinding(textMessageEncodingBinding, httpTransportBinding);
                customBinding.SendTimeout = new TimeSpan(0, 0, 10);



                EventPortTypeClient ept = new EventPortTypeClient(customBinding, endPointAddress);
                ept.Endpoint.Behaviors.Add(passwordDigestBehavior);
                Console.WriteLine("Status 1 : " + ept.State.ToString());

                ept.Open();
                Console.WriteLine("Status 2 : " + ept.State.ToString());

                ept.GetType();

                ept.GetHashCode();



                FilterType filter       = new FilterType();
                string     initTermTime = null;
                CreatePullPointSubscriptionSubscriptionPolicy policy =
                    new CreatePullPointSubscriptionSubscriptionPolicy();

                XmlElement[]               elems1 = new XmlElement[10];
                System.DateTime            time1  = new System.DateTime();
                Nullable <System.DateTime> time2  = new System.DateTime();

                EndpointReferenceType endpoint = ept.CreatePullPointSubscription(filter, "PT60M", policy, ref elems1, out time1, out time2);


                System.DateTime CurrentTime = new System.DateTime();
                NotificationMessageHolderType[] NotificationMessages = new NotificationMessageHolderType[0];
                PullPointSubscriptionClient.PullMessages()

                PullPointSubscriptionClient.PullMessages("PT5M", 99, Any, out CurrentTime, out NotificationMessages);


                PullPointSubscriptionClient subbind = new PullPointSubscriptionClient(customBinding, endPointAddress);
                subbind.Endpoint.Behaviors.Add(passwordDigestBehavior);



                string          timeOut  = "PT60.000S";
                int             mesLimit = 100;
                XmlElement[]    elemns2  = new XmlElement[10];
                System.DateTime termTime = new System.DateTime();
                NotificationMessageHolderType[] messHolder =
                    new NotificationMessageHolderType[0];



                subbind.PullMessages(timeOut, mesLimit, elemns2, out termTime, out messHolder);

                for (int i = 0; i < messHolder.Length; i++)
                {
                    Console.WriteLine("parsing");
                }


                Console.WriteLine("--------- NO CATCH --------- ");
            }
            catch (Exception eee)
            {
                Console.WriteLine("manejando eventos: " + eee);
            }
        }