Exemple #1
0
 /// <summary>
 /// Verify if this object is Equals to the specified other object instance.
 /// </summary>
 /// <param name="other">The other to compare with.</param>
 ///   <c>true</c> if the specified <see cref="ServiceInfoData" /> is equal to this instance; otherwise, <c>false</c>.
 /// </returns>
 public bool Equals(ServiceInfoData other)
 {
     return(other != null &&
            other.vehiclePhysicalId == vehiclePhysicalId &&
            other.carId == carId &&
            other.carIdStr == carIdStr &&
            other.deviceId == deviceId &&
            other.deviceName == deviceName &&
            other.serviceId == serviceId &&
            other.name == name &&
            other.operatorId == operatorId &&
            other.AID == AID &&
            other.SID == SID &&
            other.serviceIPAddress == serviceIPAddress &&
            other.servicePortNumber == servicePortNumber &&
            other.isAvailable == isAvailable);
 }
Exemple #2
0
        /// <summary>
        /// Updates the service data.
        /// </summary>
        /// <param name="systemId">The system identifier.</param>
        /// <param name="serviceData">The service data.</param>
        public void UpdateServiceData(string systemId, ServiceInfoData serviceData)
        {
            ServiceInfoData clonedService = serviceData.Clone();
            int             serviceIndex  = Array.IndexOf(SupportedServices, serviceData.serviceId);

            if (serviceIndex >= 0)
            {
                lock (_serviceDataLock)
                {
                    ServiceInfoData existingService;
                    if (_serviceData[serviceIndex].TryGetValue(systemId, out existingService))
                    {
                        if (existingService.Equals(serviceData))
                        {
                            clonedService = null;
                        }
                    }

                    if (clonedService != null)
                    {
                        _serviceData[serviceIndex][systemId] = clonedService;
                    }
                }

                string notificationUrl;
                bool   subscribed;
                lock (_serviceSubscriptionLock)
                {
                    subscribed      = _serviceSubscriptions[serviceIndex] == true;
                    notificationUrl = _serviceNotificationUrl;
                }

                if (subscribed)
                {
                    bool isOnline = _identificationService.IsSystemOnline(systemId);
                    DataPackageTests.T2GServiceInterface.Notification.serviceList serviceList = new DataPackageTests.T2GServiceInterface.Notification.serviceList();
                    serviceList.Capacity = 1;

                    if (isOnline || clonedService.isAvailable == false)
                    {
                        serviceList.Add(clonedService);
                    }
                    else
                    {
                        serviceList.Add(clonedService.Clone());
                        serviceList[0].isAvailable = false;
                    }

                    EndpointAddress address = new EndpointAddress(notificationUrl);
                    using (NotificationClient client = new NotificationClient("NotificationClient", address))
                    {
                        try
                        {
                            client.Open();
                            client.onServiceNotification(systemId, isOnline, serviceIndex + 1, serviceList);
                        }
                        finally
                        {
                            if (client.State == CommunicationState.Faulted)
                            {
                                client.Abort();
                            }
                        }
                    }
                }
            }
        }