Beispiel #1
0
        /// <summary>
        /// 用于判别返回结果
        /// </summary>
        /// <param name="command">返回结果的字符串</param>
        private void ContorlCommand(object obj)
        {
            SocketInfo socketinfo = (SocketInfo)obj;
            string     command    = socketinfo.Command;
            string     ip         = socketinfo.Ip;

            Show.SetIpAndRec(command, ip);
            if (command.IndexOf("SHOW-2") != -1)
            {
                Show.ShwStuatsforView(frmMain.FormList, handle.QueryHandle(command), ip);
                //MessageInfo info = new MessageInfo(command, ip, "查询返回", DateTime.Now.ToString());
                //Database.insert(info);
                // Database.insert(info);//写入数据库
            }
            else if (command.IndexOf("+主机设防") != -1)
            {
                MessageInfo info = new MessageInfo(command, ip, "设防返回", DateTime.Now.ToString());
                Database.insert(info);
            }
            else if (command.IndexOf("SHOW-6") != -1)
            {
                Show.ShwStuatsforView(frmMain.FormList, handle.QueryHandle(command), ip);
            }
            //--------------------------------------------------------------
            else if (command.IndexOf("SHOW-9[") != -1)
            {
                DateTime dt = DateTime.Now;
                command = "+" + command;
                string[]    str  = command.Split('[', ']');
                MessageInfo info = new MessageInfo(frmMain.Decode(str[1]), ip, "警报", DateTime.Now.ToString());//将转发记录转码后保存
                Database.insert(info);
            }
            //--------------------------------------------------------------------------------
            else if (command.IndexOf("SHOW-8[") != -1)
            {
                DateTime dt = DateTime.Now;
                command = "+" + command;
                string[]    str  = command.Split('[', ']');
                MessageInfo info = new MessageInfo(frmMain.Decode(str[1]), ip, "警报", DateTime.Now.ToString());//将转发记录转码后保存
                Database.insert(info);
                //-------------------------------------------------------------向主机发数据--------------------------
                byte[] bytearray = Encoding.Unicode.GetBytes(command);
                foreach (string host in frmMain.HostIp)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        string GJ = "-OK";

                        if (SendAcy(host, bytearray, GJ))
                        {
                            //MessageBox.Show("转发成功");
                            break;
                        }
                        else
                        {
                            Thread.Sleep(2000);
                            continue;
                        }
                    }
                }
            }
            else if (command.IndexOf("SWT-OK") != -1)
            {
                recflag = command;
                DictRecoutObject[socketinfo.Ip].Set();
            }
            else if (command.IndexOf("REC-OK") != -1)
            {
                recflag = command;
                DictRecoutObject[socketinfo.Ip].Set();
            }
            else if (command.IndexOf("LedGengXin") != -1)
            {
                recflag = command;
                DictRecoutObject[socketinfo.Ip].Set();
                frmMain.fm.GengXin_OK();
                Thread.Sleep(1000);
            }
            else if (command.IndexOf("CHK-OK") != -1)
            {
                recflag = command;
                DictRecoutObject[socketinfo.Ip].Set();
            }
            else if (command.IndexOf("OAL-OK") != -1)
            {
                recflag = command;
                DictRecoutObject[socketinfo.Ip].Set();
            }
            else if (command.IndexOf("CAL-OK") != -1)
            {
                recflag = command;
                DictRecoutObject[socketinfo.Ip].Set();
            }
            else if (command.IndexOf("LED-OK") != -1)
            {
                recflag = command;
                DictRecoutObject[socketinfo.Ip].Set();
            }
        }
Beispiel #2
0
        /// <summary>
        /// 用于判别返回结果
        /// </summary>
        /// <param name="command">返回结果的字符串</param>
        private void ContorlCommand(object obj)
        {
            SocketInfo socketinfo = (SocketInfo)obj;
            string     command    = socketinfo.Command;
            string     ip         = socketinfo.Ip;

            Show.SetIpAndRec(command, ip);
            if (command.IndexOf("SHOW-2") != -1)
            {
                Show.ShwStuatsforView(frmMain.FormList, handle.QueryHandle(command), ip);
                //MessageInfo info = new MessageInfo(command, ip, "查询返回", DateTime.Now.ToString());
                //Database.insert(info);
                // Database.insert(info);//写入数据库
                recflag = command;
                DictSendoutObject[socketinfo.Ip].Set();
                return;
            }
            else if (command.IndexOf("SHOW-6") != -1)
            {
                Show.ShwStuatsforView(frmMain.FormList, handle.QueryHandle(command), ip);
                recflag = command;
                // MessageBox.Show(command);
                DictSendoutObject[socketinfo.Ip].Set();

                return;
            }
            //--------------------------------------------------------------
            else if (command.IndexOf("SHOW-9[") != -1)
            {
                DateTime dt = DateTime.Now;
                command = "+" + command;
                string[]    str  = command.Split('[', ']');
                MessageInfo info = new MessageInfo(frmMain.Decode(str[1]), ip, "警报记录", DateTime.Now.ToString());//将转发记录转码后保存
                Database.insert(info);
                recflag = command;
                DictSendoutObject[socketinfo.Ip].Set();

                return;
            }
            //--------------------------------------------------------------------------------
            else if (command.IndexOf("SHOW-8[") != -1)
            {
                DateTime dt = DateTime.Now;
                command = "+" + command;
                string[]    str  = command.Split('[', ']');
                MessageInfo info = new MessageInfo(frmMain.Decode(str[1]), ip, "警报记录", DateTime.Now.ToString());//将转发记录转码后保存
                Database.insert(info);
                //-------------------------------------------------------------向主机发数据--------------------------
                byte[] bytearray = Encoding.Unicode.GetBytes(command);

                foreach (string host in frmMain.HostIp)
                {                                                     //--------------------------------
                    int    len1 = Findipname(frmMain.FormList, host); //找出主机在列表位置
                    string Luxi = frmMain.FormList.Items[len1].SubItems[2].Text;
                    if (Luxi == "在线")                                 //判别主机是否在线
                    {
                        //------------------------------------------------------------在(STE)
                        for (int i = 0; i < 3; i++)
                        {
                            string GJ = "-OK";
                            Buf1 = "";
                            if (SendAcy(host, bytearray, GJ))
                            {
                                //MessageBox.Show("转发成功");
                                MessageInfo info1 = new MessageInfo("成功转发信息" + frmMain.Decode(str[1]), host, "转发记录", DateTime.Now.ToString());                    //将转发记录转码后保存
                                Database.insert(info1);
                                //MessageBox.Show("OK-" + host);
                                break;
                            }
                            else
                            {
                                recflag = command;
                                DictSendoutObject[socketinfo.Ip].Set();
                                Thread.Sleep(30000);
                                continue;
                            }
                        }
                        //----------------------------------------------------------------在(OK)
                    }
                    // else{MessageBox.Show("[" + host+"]不在线");}
                }
                recflag = command;
                DictSendoutObject[socketinfo.Ip].Set();

                return;
            }
            else if (command.IndexOf("SHOW-1") != -1)
            {
                frmMain.fm.textBox8.Text = "收到回复[" + command + "]\r\n";
                recflag = command;
                DictRecoutObject[socketinfo.Ip].Set();
                return;
            }
            else if (command.IndexOf("SWT-OK") != -1)
            {
                recflag = command;
                DictRecoutObject[socketinfo.Ip].Set();
                return;
            }
            else if (command.IndexOf("REC-OK") != -1)
            {
                recflag = command;
                DictRecoutObject[socketinfo.Ip].Set();
                return;
            }
            else if (command.IndexOf("LedGengXin") != -1)
            {
                recflag = command;
                DictRecoutObject[socketinfo.Ip].Set();
                Thread.Sleep(1000);
                frmMain.fm.GengXin_OK();
                return;

                //
            }
            else if (command.IndexOf("CHK-OK") != -1)
            {
                recflag = command;

                DictRecoutObject[socketinfo.Ip].Set();
                // return;
            }
            else if (command.IndexOf("OAL-OK") != -1)
            {
                recflag = command;
                DictRecoutObject[socketinfo.Ip].Set();
                // return;
            }
            else if (command.IndexOf("CAL-OK") != -1)
            {
                recflag = command;
                DictRecoutObject[socketinfo.Ip].Set();
                //return;
            }
            else if (command.IndexOf("LED-OK") != -1)
            {
                recflag = command;
                DictRecoutObject[socketinfo.Ip].Set();
                //return;
            }
            else if (command.IndexOf("-OK") != -1)
            {
                recflag = command;
                DictRecoutObject[socketinfo.Ip].Set();
                //return;
            }
            Buf1 = recflag;
        }