Пример #1
0
        public void GetChannels(string serverAddress)
        {
            List <ChannelInfo> channels = new List <ChannelInfo>();
            ChannelInformationRetrieverClient client = null;

            try
            {
                WriteStatus("Connecting to server...");
                EndpointAddress epAddress = new EndpointAddress(serverAddress);
                client = new ChannelInformationRetrieverClient(new WSDualHttpBinding(WSDualHttpSecurityMode.None), epAddress);

                WriteStatus("Getting channel data...");
                if (client != null)
                {
                    long channelCount = client.GetChannelsCount();
                    SetProgressBarLimits((int)channelCount);
                    for (long i = 0; i < channelCount; i++)
                    {
                        channels.Add(client.GetChannel(i));
                        SetProgressBarValue((int)i);
                    }
                }
                client.Close();
            }
            catch (Exception exception)
            {
                string message = string.Format("Error during connection to server: {0}", exception.Message);
                if (client != null && client.State == CommunicationState.Opened)
                {
                    client.Close();
                }
                NotifyOperationComplete(false, channels.ToArray(), message);
                return;
            }

            NotifyOperationComplete(true, channels.ToArray(), "");
        }
 public void DeInit()
 {
     client.Close();
     server.Stop();
 }