/// <summary> /// Determines whether the specified <see cref="System.Object"/> is equal to this instance. /// </summary> /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param> /// <returns> /// <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>. /// </returns> /// <exception cref="T:System.NullReferenceException"> /// The <paramref name="obj"/> parameter is null. /// </exception> public override bool Equals(object obj) { ChannelStatusView channel = obj as ChannelStatusView; return(this.Name.Equals(channel.Name)); }
/// <summary> /// Checks the channels. /// </summary> private void CheckChannels() { try { List<ChannelStatusView> channels = new List<ChannelStatusView>(); while (true) { channels.Clear(); foreach (GatewayConfig gwConfig in GatewayConfig.All().OrderBy(gw => gw.Id)) { try { EventAction action = new EventAction(StringEnum.GetStringValue(EventNotificationType.QueryGatewayStatus)); action.ActionType = EventAction.Synchronous; action.Values.Add(EventParameter.GatewayId, gwConfig.Id); EventResponse response = RemotingHelper.NotifyEvent(ServiceEventListenerUrl, action); ChannelStatusView channel = new ChannelStatusView(); channel.Name = gwConfig.Id; channel.Port = gwConfig.ComPort; if (StringEnum.GetStringValue(EventNotificationResponse.Failed).Equals(response.Status)) { channel.Status = StringEnum.GetStringValue(GatewayStatus.Stopped); } else { channel.Status = response.Results[EventParameter.GatewayStatus]; channel.Operator = response.Results[EventParameter.GatewayOperator]; channel.SignalStrength = response.Results[EventParameter.GatewaySignalStrength]; } channels.Add(channel); } catch (Exception ex) { log.Error(string.Format("Error checking channel - [{0}]", gwConfig.Id)); log.Error(ex.Message, ex); } } RefreshView(channels); Thread.Sleep(ChannelPollingInterval); } } catch (Exception ex) { log.Error(ex.Message, ex); } }