Beispiel #1
0
        /// <summary>
        /// 日志模式,不显示界面UI
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void chkLog_CheckedChanged(object sender, EventArgs e)
        {
            ClientObj clientObj = chkIfSelectedTree();

            if (clientObj != null)
            {
                clientObj.IsLogModel = this.chkLog.Checked;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 新增连接对象
        /// </summary>
        /// <param name="client"></param>
        public void AddNewClient(ClientObj client)
        {
            TreeNode clientNode = new TreeNode();

            clientNode.Text = client.RemoteIp + ":" + client.RemotePort + "(" + client.Account + ")" + "[已连接]";
            clientNode.Tag  = client.Id;
            almClientTable.Add(clientNode.Tag, client);
            treeView2.Nodes.Add(clientNode);
        }
Beispiel #3
0
        /// <summary>
        /// 切换是否需要发送心跳包
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            ClientObj clientObj = chkIfSelectedTree();

            if (clientObj != null)
            {
                clientObj.HeartBeat = this.checkBox2.Checked;
            }
        }
Beispiel #4
0
        /// <summary>
        /// 发送登录消息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            ClientObj clientObj = chkIfSelectedTree();

            if (clientObj != null)
            {
                clientObj.sendLoginMessage(this.radioButton1.Checked?0:1);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 告警树切换不同连接对象
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void treeView2_AfterSelect(object sender, TreeViewEventArgs e)
        {
            this.activeClientObjId = e.Node.Tag.ToString();
            ClientObj client = (ClientObj)almClientTable[activeClientObjId];

            this.checkBox2.Checked = client.HeartBeat;
            this.chkLog.Checked    = client.IsLogModel;
            this.RefrashOperInfoGrid(this.activeClientObjId, client.getOperInfoList());
            this.RefrashRtAlmGrid(this.activeClientObjId, client.getRtAlmList());
        }
Beispiel #6
0
        /// <summary>
        /// 同步告警消息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button7_Click(object sender, EventArgs e)
        {
            ClientObj client = chkIfSelectedTree();

            if (client != null)
            {
                SyncMsg syncDialog = new SyncMsg(client);
                syncDialog.StartPosition = FormStartPosition.CenterScreen;
                syncDialog.ShowDialog();
            }
        }
Beispiel #7
0
        /// <summary>
        /// 打开自定义消息界面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCustomMsg_Click(object sender, EventArgs e)
        {
            ClientObj client = chkIfSelectedTree();

            if (client != null)
            {
                CustomMsg dialog = new CustomMsg(client);
                dialog.StartPosition = FormStartPosition.CenterScreen;
                dialog.ShowDialog();
            }
        }
Beispiel #8
0
        /// <summary>
        /// 告警树公共方法
        /// </summary>
        /// <returns></returns>
        public ClientObj chkIfSelectedTree()
        {
            TreeNode selClientNode = this.treeView2.SelectedNode;

            if (selClientNode == null)
            {
                MessageBox.Show("请先选中对应节点!", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
            string    key       = selClientNode.Tag.ToString();
            ClientObj clientObj = (ClientObj)almClientTable[key];

            return(clientObj);
        }
Beispiel #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            string remoteIp   = this.textBox3.Text.Trim();
            string remotePort = this.textBox4.Text.Trim();
            string account    = this.textBox1.Text.Trim();
            string pwd        = this.textBox2.Text.Trim();

            if (!Util.IsIP(remoteIp))
            {
                MessageBox.Show("pls input a valid ip address!", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            int port = 0;

            try
            {
                port = int.Parse(remotePort);
            }
            catch
            {
                MessageBox.Show("pls input a valid port!", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (string.IsNullOrEmpty(account) || string.IsNullOrEmpty(pwd))
            {
                MessageBox.Show("pls input a valid acc&pwd!", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            ClientObj clientObj = new ClientObj(this.mainFrame, remoteIp, port, account, pwd);

            if (!clientObj.connect())
            {
                MessageBox.Show("can not connect to remote ip!", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                //succ
                mainFrame.AddNewClient(clientObj);
                this.Close();
            }
        }
Beispiel #10
0
        /// <summary>
        /// 告警根据key获取节点并关闭公共方法
        /// </summary>
        /// <param name="key"></param>
        public void closeAlmClient(string key)
        {
            TreeNode selClientNode = null;

            foreach (TreeNode node in treeView2.Nodes)
            {
                if (node.Tag.ToString() == key)
                {
                    selClientNode = node;
                    break;
                }
            }
            ClientObj clientObj = (ClientObj)almClientTable[key];

            clientObj.sendCloseMessage();
            clientObj.Closed = true;

            treeView2.Invoke(new DelCloseAlmClient(changeTreeNodeText), new object[] { selClientNode });
            //almClientTable.Remove(key);
            //this.treeView2.Nodes.Remove(selClientNode);
            //this.activeClientObjId = null;
        }
Beispiel #11
0
 public SyncMsg(ClientObj c)
 {
     InitializeComponent();
     this.client = c;
 }
Beispiel #12
0
 public CustomMsg(ClientObj c)
 {
     InitializeComponent();
     this.client = c;
 }