Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            TMDataControllerImpl dc = new TMDataControllerImpl();

            //sets up the server connection
            NetTcpBinding tcpBinding = new NetTcpBinding();

            //sets max value
            tcpBinding.MaxReceivedMessageSize      = System.Int32.MaxValue;
            tcpBinding.ReaderQuotas.MaxArrayLength = System.Int32.MaxValue;
            ServiceHost host = new ServiceHost(dc);

            try
            {
                host.AddServiceEndpoint(typeof(ITMDataController), tcpBinding, "net.tcp://localhost:50001/TMData");
            }
            catch (FaultException)
            {
                Console.WriteLine("Fault Exception thrown in Program.cs > Main");
            }

            //opens connection
            host.Open();
            System.Console.WriteLine("Press Enter to Exit");
            System.Console.ReadLine();
            //closes connection
            host.Close();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            ServiceHost          host             = null;
            NetTcpBinding        tcpBinding       = new NetTcpBinding();
            string               url              = "net.tcp://localhost:50001/TMData";
            TMDataControllerImpl tMDataController = new TMDataControllerImpl();

            try
            {
                // increases message quota to max
                tcpBinding.MaxReceivedMessageSize      = System.Int32.MaxValue;
                tcpBinding.ReaderQuotas.MaxArrayLength = System.Int32.MaxValue;

                host = new ServiceHost(tMDataController);                            // host the implementing class
                host.AddServiceEndpoint(typeof(ITMDataController), tcpBinding, url); // access via the interface class

                host.Open();                                                         // enter listening state ready for client requests
                Console.WriteLine("Press Enter to exit");
                Console.ReadLine();                                                  // block waiting for client requests
            }
            catch (FaultException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (ArgumentNullException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (ObjectDisposedException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (TimeoutException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (CommunicationObjectFaultedException e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                host.Close();
                Environment.Exit(0);
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            try
            {
                TMDataControllerImpl Control = new TMDataControllerImpl();
                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;

                ServiceHost sh = new ServiceHost(Control);
                sh.AddServiceEndpoint(typeof(ITMDataController), ntb, "net.tcp://localhost:50001/TMData");

                sh.Open();
                System.Console.WriteLine("Press enter to close the data tier");
                System.Console.ReadLine();
                sh.Close();
            }
            //If could not add service endpoint(If binding is null or address is null )
            catch (ArgumentNullException)
            {
                Console.WriteLine("Error : The endpoint address is invalid ");
            }

            //If open() / close() method fails - service host object is not in a opened or opening and modifiable state
            //If service host object is in a closed/closing and not modifiable state
            catch (InvalidOperationException)
            {
                Console.WriteLine("Error : Service host object is in either closed/closing/opened/opening state ");
            }

            //If open() / close() method fails - service host object is in a faulted state
            catch (CommunicationObjectFaultedException)
            {
                Console.WriteLine("Error : Service host object is corrupted ");
            }

            //If open() / close() method fails - If defualt time allocated for the operation exceeds
            catch (TimeoutException)
            {
                Console.WriteLine("Error : Data tier program timed out !");
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            TMDataControllerImpl DI = new TMDataControllerImpl();
            ServiceHost          host;
            NetTcpBinding        tcpBinding = new NetTcpBinding();

            tcpBinding.MaxReceivedMessageSize      = System.Int32.MaxValue;
            tcpBinding.ReaderQuotas.MaxArrayLength = System.Int32.MaxValue;
            try {
                host = new ServiceHost(DI);
                host.AddServiceEndpoint(typeof(ITMDataController), tcpBinding, "net.tcp://localhost:5001/TMData");
                host.Open();
                System.Console.WriteLine("Service started");
                Thread.Sleep(Timeout.Infinite);
                host.Close();
            }
            catch (FaultException fe)
            {
                System.Console.WriteLine(fe);
            }
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            //int tileX = 10;
            //int tileY = 20;
            //int numTilesX;
            //int numTilesY;
            //int width;
            //int height;
            //byte[] imageBuf;
            //int bufSize = 100;
            //int jpgSize;
            //int zoomLevel = 10;

            //string generateJPGPath = TrueMarble.generateJPGPath(2, tileX, tileY );
            //int getNumTiles = TrueMarble.GetNumTiles(zoomLevel, out numTilesX, out numTilesY);
            //int getTileSize = TrueMarble.GetTileSize(out width, out height);
            //int getTileImageAsRawJPG = TrueMarble.GetTileImageAsRawJPG(zoomLevel, tileX, tileY, out imageBuf, bufSize, out jpgSize );

            var zoomLevel = 3;
            var tileX     = 3000000;
            var tileY     = 3000000;
            var bufSize   = tileX * tileY * 3;

            TMDataControllerImpl obj = new TMDataControllerImpl(zoomLevel, tileX, tileY, bufSize);

            var GetTileWidth      = obj.GetTileWidth();
            var GetTileHeight     = obj.GetTileHeight();
            var GetNumTilesAcross = obj.GetNumTilesAcross(zoomLevel);
            var GetNumTilesDown   = obj.GetNumTilesDown(zoomLevel);
            var LoadTile          = obj.LoadTile(zoomLevel, tileX, tileY);

            Console.WriteLine("TileWidth: " + GetTileWidth);
            Console.WriteLine("TileHeight: " + GetTileHeight);
            Console.WriteLine("NumTilesAcross: " + GetNumTilesAcross);
            Console.WriteLine("NumTilesDown: " + GetNumTilesDown);
            Console.WriteLine("LoadTile: " + LoadTile.ToString());

            Console.ReadKey();
        }