/// <summary>
        /// Constructor for TMBizController
        /// creates channel to Data server
        /// </summary>
        TMBizControllerImpl()
        {
            ChannelFactory <ITMDataController> channelFactory;

            NetTcpBinding tcpBinding = new NetTcpBinding();
            string        url        = "net.tcp://localhost:50001/TMData";

            try
            {
                // incease default message size quota
                tcpBinding.MaxReceivedMessageSize      = System.Int32.MaxValue;
                tcpBinding.ReaderQuotas.MaxArrayLength = System.Int32.MaxValue;

                // bind channel to url
                channelFactory = new ChannelFactory <ITMDataController>(tcpBinding, url); // bind url to channel factory

                m_tmData = channelFactory.CreateChannel();                                // create true marbledata on remote server
                m_hist   = new BrowseHistory();
            }
            catch (ArgumentNullException e1)
            {
                Console.WriteLine("\nError: Binding URL to ChannelFactory\n" + e1.Message);
                Environment.Exit(1);
            }
            catch (CommunicationException e2)
            {
                Console.WriteLine("\nError: Communicating with Data Server \n" + e2.Message);
                Environment.Exit(1);
            }
            catch (InvalidOperationException e3)
            {
                Console.WriteLine("\nError: Modifying TcpBinding Message Quota\n" + e3.Message);
                Environment.Exit(1);
            }
        }
Exemplo n.º 2
0
        public TMBizControllerImpl()
        {
            //Biz server connects to server
            ChannelFactory <ITMDataController> tmData;
            NetTcpBinding tcpBinding = new NetTcpBinding();

            //sets max values for tcp binding
            tcpBinding.MaxReceivedMessageSize      = System.Int32.MaxValue;
            tcpBinding.ReaderQuotas.MaxArrayLength = System.Int32.MaxValue;
            string sURL = "net.tcp://localhost:50001/TMData";

            try
            {
                tmData   = new ChannelFactory <ITMDataController>(tcpBinding, sURL);
                m_tmData = tmData.CreateChannel();
            }
            catch (FaultException)
            {
                Console.WriteLine("Fault Exception thrown in MainWindow.xaml.cs > Window_Loaded");
            }

            browseH = new BrowseHistory();

            Console.WriteLine("Biz Server Started");
        }
Exemplo n.º 3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ChannelFactory <ITMDataController> ITMChannel;
            NetTcpBinding tcpBind = new NetTcpBinding();
            string        sURL    = "net.tcp://localhost:65000/TMData";         //same URL as server's

            tcpBind.MaxReceivedMessageSize      = System.Int32.MaxValue;        //assigning the max amount of message size and array length
            tcpBind.ReaderQuotas.MaxArrayLength = System.Int32.MaxValue;
            ITMChannel = new ChannelFactory <ITMDataController>(tcpBind, sURL); //binds the url with channel
            m_tmData   = ITMChannel.CreateChannel();                            //opens channel
        }
Exemplo n.º 4
0
        public TMBizControllerImpl()
        {
            Console.WriteLine("A new client has connected!");
            try {
                ChannelFactory <ITMDataController> trueMarbleChannelFactory;
                NetTcpBinding tcpBinding = new NetTcpBinding();

                tcpBinding.MaxReceivedMessageSize      = System.Int32.MaxValue;
                tcpBinding.ReaderQuotas.MaxArrayLength = System.Int32.MaxValue;

                trueMarbleChannelFactory = new ChannelFactory <ITMDataController>(tcpBinding, "net.tcp://localhost:50001/TMData");
                m_data = trueMarbleChannelFactory.CreateChannel();
            } catch (FaultException exception) {
                Console.WriteLine("Connection faiure! " + exception);
            }
        }
        //This will enable biz tier to provide service as server to the gui clients and be a client to the data tier
        public TMBizControllerImpl()
        {
            NetTcpBinding ntb = new NetTcpBinding();

            //To relax the maximum size of a message in .net(Since images are being passed arround)
            ntb.MaxReceivedMessageSize      = System.Int32.MaxValue;
            ntb.ReaderQuotas.MaxArrayLength = System.Int32.MaxValue;
            try
            {
                ChannelFactory <ITMDataController> TMFactory = new ChannelFactory <ITMDataController>(ntb, "net.tcp://localhost:50001/TMData");

                m_data = TMFactory.CreateChannel();

                //Creating a new browse history object
                m_hist = new BrowseHistory();

                System.Console.WriteLine("New GUI Client Connected!");
            }

            //If URI is invalid or uri Cannot be parsed or empty uri
            catch (UriFormatException)
            {
                Console.WriteLine("Error : The URI is invalid or corrupted");
            }
            //If endpoint is null
            catch (InvalidOperationException)
            {
                Console.WriteLine("Error : The method cannot be executed according to the object's current state ");
            }

            //If address is null
            catch (ArgumentNullException)
            {
                Console.WriteLine("Error : Address of data tier could'nt be found");
            }
        }