Exemplo n.º 1
0
 public bool Cmp(cmsLinkageAlert LA)
 {
     if (
         LA.LinkInfo == this.LinkInfo &&
         LA.IpPortNodes == this.IpPortNodes
         )
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
0
        private void btn_Done_Click(object sender, EventArgs e)
        {
            if (FormMain.LinkageSelect == 1)
            {
                if (textBox_Node.Text != "" &&
                    comboBox_StaName.Text != "" &&
                    comboBox_SerialNum.Text != "" &&
                    comboBox_DeviceAdd.Text != "" &&
                    textBox_port.Text != "")
                {
                    string msg = "";
                    int    all = textBox_Node.Text.Split(',').Count();
                    for (int i = 0; i < textBox_Node.Text.Split(',').Count(); i++)
                    {
                        if (textBox_Node.Text.Split(',')[i] == "")
                        {
                            all--;
                        }
                        else
                        {
                            try { byte num = Convert.ToByte(textBox_Node.Text.Split(',')[i]); msg += num.ToString() + " "; }
                            catch { all--; }
                        }
                    }

                    string LinkageNodes   = msg.Trim().Replace(' ', ',');
                    string LinkageConnect = comboBox_SerialNum.Text.Trim() + ":" + textBox_port.Text;
                    Console.WriteLine(LinkageConnect);
                    int area = 1;
                    if (comboBox_Position.Items.Count == 2)
                    {
                        area = comboBox_Position.SelectedIndex + 1;
                    }

                    FormMain.LinkageBuff[lb_thisip.Text + "-" + comboBox_DeviceAdd.Text + "-" + area.ToString()] = LinkageConnect + "-" + LinkageNodes;

                    string cmd = "insert into tb_LinkageAlert (IpPortNodes,LinkInfo) values(";
                    cmd += "'" + LinkageConnect + "-" + LinkageNodes + "',";
                    cmd += "'" + lb_thisip.Text + "-" + comboBox_DeviceAdd.Text + "-" + area.ToString() + "'";
                    cmd += ")";
                    bool isUpdate = false;
                    for (int i = 0; i < FormMain.DataModel.LinkageAlert.Count; i++)
                    {
                        cmsLinkageAlert updLA = FormMain.DataModel.LinkageAlert[i];
                        if (updLA.LinkInfo == lb_thisip.Text + "-" + comboBox_DeviceAdd.Text + "-" + area.ToString())
                        {
                            updLA.IpPortNodes = LinkageConnect + "-" + LinkageNodes;
                            FormMain.DataModel.LinkageAlert[i] = updLA;
                            isUpdate = true;
                            break;
                        }
                    }
                    if (!isUpdate)
                    {
                        cmsLinkageAlert addLA = new cmsLinkageAlert();
                        addLA.IpPortNodes = LinkageConnect + "-" + LinkageNodes;
                        addLA.LinkInfo    = lb_thisip.Text + "-" + comboBox_DeviceAdd.Text + "-" + area.ToString();
                        FormMain.DataModel.LinkageAlert.Add(addLA);
                    }

                    MessageBox.Show("Total" + all.ToString() + "node(s) are set\r\n" + LinkageNodes + "");
                }
                else
                {
                    MessageBox.Show("Please complete the filling", "Linkage settings");
                }
            }
            else if (FormMain.LinkageSelect == 2)
            {
            }
        }