Exemplo n.º 1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     localhost.Service t  = new localhost.Service();
     byte[]            t1 = t.GiaiPT(0, 0, 0);
     string            s  = Encoding.ASCII.GetString(t1);
     Nghiem            m  = Nghiem.XMLtoNghiem(s);
 }
Exemplo n.º 2
0
    public byte[] GiaiPT(float a, float b, float c)
    {
        TamThuc tt = new TamThuc(a, b, c);
        Nghiem  kq = tt.GiaiPT();
        string  s  = kq.ToXMLDocument();

        return(Encoding.ASCII.GetBytes(s));
    }
Exemplo n.º 3
0
        private void ReceiveData(IAsyncResult iar)
        {
            try
            {
                // EndReceive
                Socket server = (Socket)iar.AsyncState;
                int    rec    = server.EndReceive(iar);
                string s      = Encoding.ASCII.GetString(m_Data, 0, rec);

                Nghiem n = Nghiem.XMLtoNghiem(s);
                OutputMessage(n.ToString());

                // Close
                server.Close();
            }
            catch (System.Exception e1)
            {
                MessageBox.Show(e1.ToString());
            }
        }
Exemplo n.º 4
0
        private void ReceiveData(IAsyncResult iar)
        {
            // EndReceive
            Socket Client = (Socket)iar.AsyncState;
            int    rsize  = Client.EndReceive(iar);
            String s      = Encoding.ASCII.GetString(data, 0, rsize);

            OutputMessage("Dữ liệu nhận được là \"" + s + "\"");

            // Chuyen XML thanh TamThuc
            TamThuc tt = new TamThuc();

            tt.GetXMLDocument(s);
            Nghiem n = tt.GiaiPT();
            // BeginSend
            String kq = n.ToXMLDocument();

            byte[] mess = Encoding.ASCII.GetBytes(kq);
            Client.BeginSend(mess, 0, mess.Length, SocketFlags.None, new AsyncCallback(SendData), Client);
            OutputMessage("Dữ liệu gửi đi là \"" + kq + "\"");
        }
Exemplo n.º 5
0
        private void butGiaiPT_Click_1(object sender, EventArgs e)
        {
            txtKetQua.Text = "Xin doi trong giay lat...";

            float  a       = float.Parse(txtA.Text);
            float  b       = float.Parse(txtB.Text);
            float  c       = float.Parse(txtC.Text);
            String strIP   = txtIPServer.Text;
            String strPort = txtPort.Text;

            try
            {
                EquationService.Service es = new EquationService.Service();
                es.Url = "http://" + strIP + ":" + strPort + "/EquationWebService/Service.asmx";
                byte[] arrKQ = es.GiaiPT(a, b, c);
                Nghiem ng    = Nghiem.XMLtoNghiem(Encoding.ASCII.GetString(arrKQ, 0, arrKQ.Length));
                txtKetQua.Text = ng.ToString();
            }
            catch (System.Exception e1)
            {
                MessageBox.Show(e1.ToString());
                txtKetQua.Text = "";
            }
        }