Ejemplo n.º 1
0
        void DoNotify(object parameters)
        {
            Thread.Sleep(5000);

            NotifyParameters param = (NotifyParameters)parameters;

            CameraWebService.Notification.NotificationProvider provider = new CameraWebService.Notification.NotificationProvider();
            provider.Notify(param.Address, param.Request);
        }
Ejemplo n.º 2
0
        void NotifyReceiverStateChange(string receiverToken, string state)
        {
            if (!Application.AllKeys.Contains("consumer"))
            {
                return;
            }

            NotifyParameters parameters = new NotifyParameters();

            Events.EndpointReferenceType reference = (Events.EndpointReferenceType)Application["consumer"];
            string address = reference.Address.Value;

            parameters.Address = address;

            string requestPattern = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> " +
                                    "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\" xmlns:wstop=\"http://docs.oasis-open.org/wsn/t-1\" xmlns:wsnt=\"http://docs.oasis-open.org/wsn/b-2\" xmlns:tet=\"http://www.onvif.org/ver10/events/wsdl\" xmlns:tns1=\"http://www.onvif.org/ver10/topics\" xmlns:tt=\"http://www.onvif.org/ver10/schema\"> " +
                                    "<SOAP-ENV:Header>" +
                                    "<wsa:Action>urn:#Notify</wsa:Action>" +
                                    "<wsa:ReplyTo><wsa:Address>http://example.com/business/client1</wsa:Address></wsa:ReplyTo>" +
                                    "<wsa:MessageID>http://example.com/6B29FC40-CA47-1067-B31D-00DD010662DA  http://example.com/6B29FC40-CA47-1067-B31D-00DD010662DA</wsa:MessageID>" +
                                    "</SOAP-ENV:Header>" +
                                    "<SOAP-ENV:Body>" +
                                    "<wsnt:Notify>" +
                                    "<wsnt:NotificationMessage>" +
                                    "<wsnt:Topic Dialect=\"http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet\">" +
                                    "tns1:Receiver/ChangeState" +
                                    "</wsnt:Topic>" +
                                    "<wsnt:Message>" +
                                    "<tt:Message UtcTime=\"{0}\">" +
                                    "<tt:Source>" +
                                    "<tt:SimpleItem Name=\"ReceiverToken\" Value=\"{1}\"/>" +
                                    "</tt:Source>" +
                                    "<tt:Data>" +
                                    "<tt:SimpleItem Name=\"NewState\" Value=\"{2}\"/>" +
                                    "</tt:Data>" +
                                    "</tt:Message>" +
                                    "</wsnt:Message>" +
                                    "</wsnt:NotificationMessage>" +
                                    "<tet:CurrentTime>{3}</tet:CurrentTime>" +
                                    "<tet:TerminationTime>{4}</tet:TerminationTime>" +
                                    "</wsnt:Notify>" +
                                    "</SOAP-ENV:Body>" +
                                    "</SOAP-ENV:Envelope>";

            System.DateTime currentTime       = System.DateTime.Now;
            string          notificationTime  = System.Xml.XmlConvert.ToString(currentTime.AddSeconds(-1), XmlDateTimeSerializationMode.Utc);
            string          serverCurrentTime = System.Xml.XmlConvert.ToString(currentTime, XmlDateTimeSerializationMode.Utc);
            string          terminationTime   = System.Xml.XmlConvert.ToString(currentTime.AddSeconds(20), XmlDateTimeSerializationMode.Utc);

            string request = string.Format(requestPattern, notificationTime, receiverToken, state, serverCurrentTime, terminationTime);

            parameters.Request = request;
            System.Threading.Thread thread = new Thread(new ParameterizedThreadStart(DoNotify));
            thread.Start(parameters);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Send notification to provided channel.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='labName'>
 /// The name of the lab.
 /// </param>
 /// <param name='name'>
 /// The name of the notificationChannel.
 /// </param>
 /// <param name='notifyParameters'>
 /// Properties for generating a Notification.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task NotifyAsync(this INotificationChannelsOperations operations, string resourceGroupName, string labName, string name, NotifyParameters notifyParameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.NotifyWithHttpMessagesAsync(resourceGroupName, labName, name, notifyParameters, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Send notification to provided channel.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='labName'>
 /// The name of the lab.
 /// </param>
 /// <param name='name'>
 /// The name of the notificationChannel.
 /// </param>
 /// <param name='notifyParameters'>
 /// Properties for generating a Notification.
 /// </param>
 public static void Notify(this INotificationChannelsOperations operations, string resourceGroupName, string labName, string name, NotifyParameters notifyParameters)
 {
     operations.NotifyAsync(resourceGroupName, labName, name, notifyParameters).GetAwaiter().GetResult();
 }