Пример #1
0
        private void Unsubscribe()
        {
            Client <SubscriptionServiceClient> c = null;

            try
            {
                c = ExternalClientFactory.ConstructSubscriptionServiceClient(ExternalLib.Endpoint.SubscriptionEndpointName, ExternalLib.Endpoint.ExternalUserName, ExternalLib.Endpoint.ExternalUserPassword);

                CancelDataSubscriptionRequest CancelReq = new CancelDataSubscriptionRequest();
                CancelReq.SystemName = this._systemName;

                c.ServiceClient.CancelDataSubscription(CancelReq);
                c.ServiceClient.Close();
            }
            catch (FaultException <Itron.Ami.Facade.WebServices.Subscriptions.V200908.ClientProxy.SubscriberEndpointNotFoundFault> )
            {
            }
            catch (FaultException <Itron.Ami.Facade.WebServices.Subscriptions.V200908.ClientProxy.SubscriberNotFoundFault> )
            {
            }
            finally
            {
                if ((null != c) && (null != c.ServiceClient) &&
                    (c.ServiceClient.State != CommunicationState.Closed))
                {
                    c.ServiceClient.Close();
                }
            }
        }
Пример #2
0
        private void Subscribe()
        {
            Client <SubscriptionServiceClient> c = null;
            SubscribeToEndpointDataRequest     SubscribeEndpointRequest = null;
            SubscriptionRequest SubscriptionRequest = null;

            try
            {
                c = ExternalClientFactory.ConstructSubscriptionServiceClient(ExternalLib.Endpoint.SubscriptionEndpointName, ExternalLib.Endpoint.ExternalUserName, ExternalLib.Endpoint.ExternalUserPassword);

                SubscribeEndpointRequest                     = new SubscribeToEndpointDataRequest();
                SubscriptionRequest                          = new SubscriptionRequest();
                SubscriptionRequest.SystemName               = this._systemName;
                SubscriptionRequest.UriCollection            = new Uri[] { this._systemUri };
                SubscribeEndpointRequest.SubscriptionRequest = SubscriptionRequest;

                c.ServiceClient.SubscribeToEndpointData(SubscribeEndpointRequest);
                c.ServiceClient.Close();
            }
            catch (FaultException <Itron.Ami.Facade.WebServices.Subscriptions.V200908.ClientProxy.DuplicateSubscriberFault> )
            {
            }
            finally
            {
                if ((null != c) && (null != c.ServiceClient) &&
                    (c.ServiceClient.State != CommunicationState.Closed))
                {
                    c.ServiceClient.Close();
                }
            }
        }
Пример #3
0
        private void Subscribe()
        {
            Client <SubscriptionServiceClient> c = null;
            SubscriptionRequest subRequest       = null;

            try
            {
                if ((null != this._systemName) && (null != this._systemUri))
                {
                    c = ExternalClientFactory.ConstructSubscriptionServiceClient(ExternalLib.Endpoint.SubscriptionEndpointName, ExternalLib.Endpoint.ExternalUserName, ExternalLib.Endpoint.ExternalUserPassword);

                    subRequest               = new SubscriptionRequest();
                    subRequest.SystemName    = this._systemName;
                    subRequest.UriCollection = new Uri[] { this._systemUri };

                    SubscribeToEndpointEventsRequest request = new SubscribeToEndpointEventsRequest();
                    request.SubscriptionRequest = subRequest;

                    c.ServiceClient.SubscribeToEndpointEvents(request);
                    c.ServiceClient.Close();
                }
            }
            catch (FaultException <Itron.Ami.Facade.WebServices.Subscriptions.V200908.ClientProxy.DuplicateSubscriberFault> )
            {
                bool duplicate = false;

                // Subscription already exists (i.e. a data subscription with the same system name already exists)
                // we need to determine whether or not we're going to add this endpoint to the subscription.
                try
                {
                    SubscriberRequest req = new SubscriberRequest();
                    req.SystemName = this._systemName;
                    req.Uri        = this._systemUri;

                    c.ServiceClient.AddEventSubscriberEndpointAddress(req);
                    c.ServiceClient.Close();
                }
                catch (FaultException <Itron.Ami.Facade.WebServices.Subscriptions.V200908.ClientProxy.DuplicateSubscriberEndpointFault> )
                {
                    // Ok, it's clear now that the subscription already exists and that this endpoint address is already a part of that
                    // subscription.  So, we're good to go.
                    duplicate = true;
                }

                if (!duplicate)
                {
                    throw;
                }
            }
            finally
            {
                if ((null != c) && (null != c.ServiceClient) &&
                    (c.ServiceClient.State != CommunicationState.Closed))
                {
                    c.ServiceClient.Close();
                }
            }
        }
Пример #4
0
        private void Unsubscribe()
        {
            Client <SubscriptionServiceClient> c = null;

            try
            {
                if ((null != this._systemName) && (null != this._systemUri))
                {
                    c = ExternalClientFactory.ConstructSubscriptionServiceClient(ExternalLib.Endpoint.SubscriptionEndpointName, ExternalLib.Endpoint.ExternalUserName, ExternalLib.Endpoint.ExternalUserPassword);

                    SubscriberRequest req = new SubscriberRequest();
                    req.SystemName = this._systemName;
                    req.Uri        = this._systemUri;

                    c.ServiceClient.DeleteEventSubscriberEndpointAddress(req);
                    c.ServiceClient.Close();
                }
            }
            catch (FaultException <Itron.Ami.Facade.WebServices.Subscriptions.V200908.ClientProxy.ArgumentFault> )
            {
                // Looks like this is the last endpoint for the service.  So, we'll simply cancel the subscription at this point.

                CancelEventSubscriptionRequest request = new CancelEventSubscriptionRequest();
                request.SystemName = this._systemName;
                c.ServiceClient.CancelEventSubscription(request);
                c.ServiceClient.Close();
            }
            catch (FaultException <Itron.Ami.Facade.WebServices.Subscriptions.V200908.ClientProxy.SubscriberEndpointNotFoundFault> )
            {
            }
            catch (FaultException <Itron.Ami.Facade.WebServices.Subscriptions.V200908.ClientProxy.SubscriberNotFoundFault> )
            {
            }
            finally
            {
                if ((null != c) && (null != c.ServiceClient) &&
                    (c.ServiceClient.State != CommunicationState.Closed))
                {
                    c.ServiceClient.Close();
                }
            }
        }