private void button1_Click(object sender, EventArgs e)
        {
            resolver    = textBox1.Text;
            titleTask   = textBox2.Text;
            information = textBox3.Text;
            status      = textBox4.Text;

            Model.Validators valid = new Model.Validators();
            Boolean          flag  = valid.validNewTask(titleTask, information, status, resolver);

            if (flag == true)
            {
                string param = createdPerson + "/" + nowTime + "/" + status + "/" + information + "/" + titleTask + "/" + resolver;

                string code = "102";
                string data = param;

                Model.Base64Converter _encodeData = new Model.Base64Converter();
                data = _encodeData.encodeBase64string(data);
                Controller.ServerConnect send = new Controller.ServerConnect();
                send.sendMessage(code + "~" + data, connect, "", null);

                Close();
            }
            else
            {
                MessageBox.Show("Probably any value is incorrect!.", "Error in input value.", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void sendParamToServer(String val)
        {
            Model.Base64Converter encode = new Model.Base64Converter();
            val = encode.encodeBase64string(val);

            Controller.ServerConnect send = new Controller.ServerConnect();
            send.sendMessage("100~" + val, tcpclnt, "", null);

            foreach (Form f in Application.OpenForms)
            {
                if (f.Name == "Form1")
                {
                    Hide();
                    f.Show();
                }
            }
        }
Exemplo n.º 3
0
        public void sendMessage(String str, TcpClient tcpclnt, string alltask, DataGridView panel)
        {
            ASCIIEncoding asen = new ASCIIEncoding();

            byte[] ba = asen.GetBytes(str);
            Console.WriteLine("Transmitting.....");

            Stream stm = tcpclnt.GetStream();

            stm.Write(ba, 0, ba.Length);

            byte[] bb   = new byte[1048576];
            int    k    = stm.Read(bb, 0, 1048576);
            string test = "";

            for (int i = 0; i < k; i++)
            {
                test += Convert.ToChar(bb[i]);
            }
            char[]   separator = { '~' };
            String[] paramStr  = test.Split(separator);

            Model.Base64Converter cnwt = new Model.Base64Converter();
            String ttt = "";

            if (paramStr.Length > 1)
            {
                try
                {
                    ttt = cnwt.decodeBase64string(paramStr[1]);
                }catch (Exception err)
                {
                    ttt = cnwt.decodeBase64string(paramStr[0]);
                }
            }

            alltask = paramStr[0];
            Client.Controller.ServiceCodeNumber codeService = new Controller.ServiceCodeNumber();
            codeService.codeArg(paramStr[0], ttt, tcpclnt, panel);
        }