Example #1
0
 //Initialize and connect to ATC Controller master.
 public AirportConverter()
 {
     try //Create connection to Server.
     {
         DuplexChannelFactory <IATCBizControllerMaster> factory;
         NetTcpBinding tcpBinding = new NetTcpBinding();
         tcpBinding.MaxReceivedMessageSize      = System.Int32.MaxValue; //Change max message & array size.
         tcpBinding.ReaderQuotas.MaxArrayLength = System.Int32.MaxValue;
         string sURL = "net.tcp://localhost:50001/ATCBiz";
         factory = new DuplexChannelFactory <IATCBizControllerMaster>(new dummyCallback(), tcpBinding, sURL);
         IATCBizControllerMaster ATCBiz = factory.CreateChannel(); //Create connection.
         m_airports = ATCBiz.GetAirports();
     }
     catch (FaultException ex) //SOAP fault.
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
     }
     catch (CommunicationException ex) //Communication error.
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
     }
     catch (TimeoutException ex) //Server likely has died or halted.
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
     }
     catch (Exception ex) //Generic exception for unknown problem.
     {
         System.Diagnostics.Debug.WriteLine("Exception type: " + ex.GetType());
         System.Diagnostics.Debug.WriteLine("Exception message: " + ex.Message);
     }
 }
Example #2
0
 //Establish connection to business controller master and initialize list of airports.
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     try //To create connection to Server.
     {
         DuplexChannelFactory <IATCBizControllerMaster> factory;
         NetTcpBinding tcpBinding = new NetTcpBinding();
         tcpBinding.MaxReceivedMessageSize      = System.Int32.MaxValue; //Change max message & array size.
         tcpBinding.ReaderQuotas.MaxArrayLength = System.Int32.MaxValue;
         string sURL = "net.tcp://localhost:50001/ATCBiz";
         factory    = new DuplexChannelFactory <IATCBizControllerMaster>(new dummyCallback(), tcpBinding, sURL);
         m_ATCBiz   = factory.CreateChannel(); //Create connection.
         m_airports = m_ATCBiz.GetAirports();
         lvwAirports.ItemsSource = m_airports; //Set listview of airports.
     }
     catch (FaultException ex)                 //SOAP fault.
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
         MessageBox.Show("Communication error, cannot continue at this time.");
     }
     catch (CommunicationException ex) //Communication error.
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
         MessageBox.Show("Can't connect to Server");
     }
     catch (TimeoutException ex) //Server likely has died or halted.
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
         MessageBox.Show("Server timed out");
     }
     catch (Exception ex) //Generic exception for unknown problem.
     {
         System.Diagnostics.Debug.WriteLine("Exception type: " + ex.GetType());
         System.Diagnostics.Debug.WriteLine("Exception message: " + ex.Message);
         MessageBox.Show("Unexpected error, cannot continue at this time.");
     }
 }