Beispiel #1
0
        public void send(MessageViewModel msg)
        {
            // msg targer search

            TargetServerInfoViewModel tsivm = TargerServerMap_[msg.TargetCode_];

            AsynchronousClient client = new AsynchronousClient();

            //client.StartClient(msg, tsivm);

            this.result_ = "message recieve complete";
        }
Beispiel #2
0
        //public void StartClient(MessageViewModel msg, TargetServerInfoViewModel tsivm)
        public void StartClient(string messageXml, TargetServerInfoViewModel tsivm)
        {
            // Connect to a remote device.
            try
            {
                // Establish the remote endpoint for the socket.
                // The name of the
                // remote device is "host.contoso.com".

                IPEndPoint remoteEP = tsivm.IPEndPoint_;
                //string msgStr = msg.getMessegeStr() + "<EOF>";
                string msgStr = messageXml + "<EOF>";
                // Create a TCP/IP socket.
                Socket client = new Socket(AddressFamily.InterNetwork,
                                           //SocketType.Stream, ProtocolType.Tcp);
                                           SocketType.Stream, ProtocolType.Tcp);

                // Connect to the remote endpoint.
                client.BeginConnect(remoteEP,
                                    new AsyncCallback(ConnectCallback), client);

                if (!connectDone.WaitOne(5000))
                {
                    throw new Exception("calculation server connection fail.");
                }

                // Send test data to the remote device.
                Send(client, msgStr);

                if (!sendDone.WaitOne(5000))
                {
                    throw new Exception("calculation server connection fail.");
                }
                // Receive the response from the remote device.
                Receive(client);
                receiveDone.WaitOne();

                // Write the response to the console.
                //Console.WriteLine("Response received : {0}", response_);
                Console.WriteLine("Response received");

                // Release the socket.
                client.Shutdown(SocketShutdown.Both);
                client.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
Beispiel #3
0
        public void loadServerInformation()
        {
            this.TargerServerMap_ = new Dictionary <string, TargetServerInfoViewModel>();
            TargetServerInfoViewModel tsivm = new TargetServerInfoViewModel();

            IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
            IPAddress   ipAddress  = ipHostInfo.AddressList[0];
            int         port       = 11000;
            IPEndPoint  remoteEP   = new IPEndPoint(ipAddress, port);

            tsivm.IPHostInfo_ = ipHostInfo;
            tsivm.IPAddress_  = ipAddress;
            tsivm.IPEndPoint_ = remoteEP;

            this.TargerServerMap_.Add("gridCalculation", tsivm);
        }
Beispiel #4
0
        // constructor
        public CalculationBatchController()
        {
            this.BatchItemViewModelQueueList_ = new List <BatchItemViewModel>();
            this.serverInfoList_ = new List <TargetServerInfoViewModel>();

            this.localServerInfo_ = new TargetServerInfoViewModel();

            IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
            IPAddress   ipAddress  = ipHostInfo.AddressList[0];
            int         port       = 12000;
            IPEndPoint  remoteEP   = new IPEndPoint(ipAddress, port);

            this.localServerInfo_.IPHostInfo_ = ipHostInfo;
            this.localServerInfo_.IPAddress_  = ipAddress;
            this.localServerInfo_.IPEndPoint_ = remoteEP;
        }
        //public void StartClient(MessageViewModel msg, TargetServerInfoViewModel tsivm)
        public void StartClient(string messageXml, TargetServerInfoViewModel tsivm)
        {
            // Connect to a remote device.
            try
            {
                // Establish the remote endpoint for the socket.
                // The name of the 
                // remote device is "host.contoso.com".

                IPEndPoint remoteEP = tsivm.IPEndPoint_;
                //string msgStr = msg.getMessegeStr() + "<EOF>";
                string msgStr = messageXml + "<EOF>";
                // Create a TCP/IP socket.
                Socket client = new Socket(AddressFamily.InterNetwork,
                    //SocketType.Stream, ProtocolType.Tcp);
                    SocketType.Stream, ProtocolType.Tcp);

                // Connect to the remote endpoint.
                client.BeginConnect(remoteEP,
                    new AsyncCallback(ConnectCallback), client);

                if (!connectDone.WaitOne(5000))
                    throw new Exception("calculation server connection fail.");

                // Send test data to the remote device.
                Send(client, msgStr);

                if (!sendDone.WaitOne(5000))
                    throw new Exception("calculation server connection fail.");
                // Receive the response from the remote device.
                Receive(client);
                receiveDone.WaitOne();

                // Write the response to the console.
                //Console.WriteLine("Response received : {0}", response_);
                Console.WriteLine("Response received");

                // Release the socket.
                client.Shutdown(SocketShutdown.Both);
                client.Close();

            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
        public void loadServerInformation()
        {
            this.TargerServerMap_ = new Dictionary<string, TargetServerInfoViewModel>();
            TargetServerInfoViewModel tsivm = new TargetServerInfoViewModel();

            IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
            IPAddress ipAddress = ipHostInfo.AddressList[0];
            int port = 11000;
            IPEndPoint remoteEP = new IPEndPoint(ipAddress, port);

            tsivm.IPHostInfo_ = ipHostInfo;
            tsivm.IPAddress_ = ipAddress;
            tsivm.IPEndPoint_ = remoteEP;

            this.TargerServerMap_.Add("gridCalculation", tsivm);

        }
        private TargetServerInfoViewModel AliveServer()
        {
            CALCULATION_SERVER_STATUS_Table_DAOManager daoM = new CALCULATION_SERVER_STATUS_Table_DAOManager();

            daoM.SERVER_STATUS_ = "idle";

            daoM.select(DataBaseConnectManager.ConnectionFactory(DataBaseConnectManager.ConnectionString_));

            TargetServerInfoViewModel tsivm = new TargetServerInfoViewModel();

            //tsivm.buildFromDAO(daoM.DAOList_[0]);

            return tsivm;

        }
        // constructor
        public CalculationBatchController()
        {
            this.BatchItemViewModelQueueList_ = new List<BatchItemViewModel>();
            this.serverInfoList_ = new List<TargetServerInfoViewModel>();

            this.localServerInfo_ = new TargetServerInfoViewModel();

            IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
            IPAddress ipAddress = ipHostInfo.AddressList[0];
            int port = 12000;
            IPEndPoint remoteEP = new IPEndPoint(ipAddress, port);

            this.localServerInfo_.IPHostInfo_ = ipHostInfo;
            this.localServerInfo_.IPAddress_ = ipAddress;
            this.localServerInfo_.IPEndPoint_ = remoteEP;
            

        }