Exemplo n.º 1
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            string strMsg = "+查询主机\r\n";//指令

            //将要发送的字符串 转成 utf8对应的字节数组

            //获得列表中 选中的KEY
            byte[] data = Encoding.GetEncoding("GBK").GetBytes(strMsg.Trim());
            string GJ   = "-OK";

            if (client.SendAcy(listView1.CheckedItems[0].SubItems[1].Text, data, GJ))
            {
                MessageBox.Show("查询成功");
                strMsg = "[查询成功-Query Success]";
                // MessageInfo info = new MessageInfo(strMsg, listView1.CheckedItems[0].SubItems[1].Text, "查询操作", DateTime.Now.ToString());
                //insert.insert(info);
            }
            else
            {
                MessageBox.Show("查询失败");
                strMsg = "[查询失败-Query Failure]";
            }
            MessageInfo info = new MessageInfo(strMsg, listView1.CheckedItems[0].SubItems[1].Text, "查询操作", DateTime.Now.ToString());

            insert.insert(info);
        }
Exemplo n.º 2
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            string strMsg = "+查询主机\r\n";//指令

            //将要发送的字符串 转成 utf8对应的字节数组

            //获得列表中 选中的KEY

            byte[] data = Encoding.GetEncoding("GBK").GetBytes(strMsg.Trim());
            string GJ   = "CHK-OK";
            string Mif  = listView1.CheckedItems[0].SubItems[3].Text;
            //---------------------------------------------------
            bool fig = false;

            for (int i = 0; i < 3; i++)
            {
                if (client.SendAcy(listView1.CheckedItems[0].SubItems[1].Text, data, GJ))
                {
                    fig = true;
                    break;
                }
                else
                {
                    Thread.Sleep(2000);
                    continue;
                }
            }
            if (fig == true)
            {
                MessageBox.Show("查询[" + Mif + "]成功", "系统提示");
                strMsg = "[查询成功]";
            }
            else
            {
                MessageBox.Show("查询[" + Mif + "]失败", "系统提示");
                strMsg = "[查询失败]";
            }
            //---------------------------------------------------
            MessageInfo info = new MessageInfo(strMsg, listView1.CheckedItems[0].SubItems[1].Text, "查询操作", DateTime.Now.ToString());

            insert.insert(info);
        }