Beispiel #1
0
 private void AddMapper_transItem(object sender, EventArgs e)
 {
     Database.work_group wg = (Database.work_group)sender;
     if (this.lVMapper.SelectedItems.Count > 0)
     {
         if ((int)this.lVMapper.SelectedItems[0].Tag == wg.T1ID)
         {
             this.lVMapper.SelectedItems[0].Text             = wg.T1NAME;
             this.lVMapper.SelectedItems[0].SubItems[1].Text = wg.T1INIP;
             this.lVMapper.SelectedItems[0].SubItems[2].Text = wg.T1INPORT.ToString();
             this.lVMapper.SelectedItems[0].SubItems[3].Text = wg.T1OUTIP;
             this.lVMapper.SelectedItems[0].SubItems[4].Text = wg.T1OUTPORT.ToString();
             this.lVMapper.SelectedItems[0].SubItems[5].Text = wg.T1SINGLEMAX.ToString();
             this.lVMapper.SelectedItems[0].SubItems[6].Text = wg.T1MAXNUM.ToString();
             this.lVMapper.SelectedItems[0].SubItems[7].Text = wg.T1STARTTIME.ToString();
             this.lVMapper.SelectedItems[0].SubItems[8].Text = wg.T1STOPTIME.ToString();
             ItemToGroup(PmList.Where(x => x.Id == wg.T1ID).First(), lVMapper.SelectedItems[0]);
         }
         else
         {
             lVMapper.Items.Add(objToItem(wg));
             PortMap pm = new PortMap();
             ItemToGroup(pm, objToItem(wg));
             PmList.Add(pm);
         }
     }
     else
     {
         lVMapper.Items.Add(objToItem(wg));
         PortMap pm = new PortMap();
         ItemToGroup(pm, objToItem(wg));
         PmList.Add(pm);
     }
 }
Beispiel #2
0
        private void TsBtnRun_Click(object sender, EventArgs e)
        {
            if (!Ischeck)
            {
                if (!checkIP())
                {
                    return;
                }
            }
            if (lVMapper.SelectedItems.Count < 1)
            {
                return;
            }
            var     result = PmList.Where(x => x.Id == Convert.ToInt32(lVMapper.SelectedItems[0].Tag));
            PortMap pm     = result.First();

            if (result.Count() == 0)
            {
                return;
            }

            string result1 = pm.StartMap();

            if (result1 != "")
            {
                LogHelpMe.WriteLog(string.Format("映射组'{0}'无法启动", pm.Name), LogHelpMe.LogEnum.提示);
                return;
            }
            LogHelpMe.WriteLog(string.Format("映射组'{0}'手动成功启动\n", pm.Name), LogHelpMe.LogEnum.提示);
            pm.IsRun = true;
            lVMapper.SelectedItems[0].ImageIndex = 0;
            this.tsBtnRun.Enabled  = false;
            this.tsBtnStop.Enabled = true;
        }
Beispiel #3
0
 private void ItemToGroup(PortMap pm, ListViewItem lvItem)
 {
     pm.Name           = lvItem.Text;
     pm.Id             = Convert.ToInt32(lvItem.Tag);
     pm.IsAuto         = true;
     pm.Point_in_host  = lvItem.SubItems[1].Text;
     pm.Point_in_port  = Convert.ToInt32(lvItem.SubItems[2].Text);
     pm.Point_out_host = lvItem.SubItems[3].Text;
     pm.Point_out_port = Convert.ToUInt16(lvItem.SubItems[4].Text);
     pm.SingleNum      = Convert.ToInt32(lvItem.SubItems[5].Text);
     pm.MaxNum         = Convert.ToInt32(lvItem.SubItems[6].Text);
     pm.Start_time     = lvItem.SubItems[7].Text;
     pm.Stop_time      = lvItem.SubItems[8].Text;
 }
Beispiel #4
0
        private static void ClearClientSockets(PortMap pm)
        {
            Task.Factory.StartNew(() =>
            {
                foreach (var sock in pm.tcpClientList)
                {
                    CloseSocket(sock.Client);
                }

                try
                {
                    //   pm.ServerSocket.Shutdown(SocketShutdown.Both);

                    pm.serverListener.Server.Close();
                }
                catch (Exception ee) { }
            });
        }
Beispiel #5
0
        private void TsBtnDelete_Click(object sender, EventArgs e)
        {
            if (this.lVMapper.SelectedItems.Count < 1)
            {
                return;
            }
            var     result = PmList.Where(x => x.Id == Convert.ToInt32(lVMapper.SelectedItems[0].Tag));
            PortMap pm     = result.First();

            if (result.First().IsRun)
            {
                return;
            }
            if (MessageBox.Show("确认删除?", "提示", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }
            Database.work_group.Delete(Convert.ToInt32(this.lVMapper.SelectedItems[0].Tag));
            this.lVMapper.Items.Remove(this.lVMapper.SelectedItems[0]);
            PmList.Remove(pm);
        }
Beispiel #6
0
        private void LoadData()
        {
            DataTable dt = Database.work_group.SelectDataTableBase("select * from work_group");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                PortMap pm = new PortMap();
                pm.Id            = Convert.ToInt32(dt.Rows[i]["T1ID"]);
                pm.Name          = dt.Rows[i]["T1NAME"].ToString();
                pm.Point_in_host = dt.Rows[i]["T1INIP"].ToString();

                pm.Point_in_port  = Convert.ToInt32(dt.Rows[i]["T1INPORT"]);
                pm.Point_out_host = dt.Rows[i]["T1OUTIP"].ToString();
                pm.Point_out_port = Convert.ToInt32(dt.Rows[i]["T1OUTPORT"]);
                pm.SingleNum      = Convert.ToInt32(dt.Rows[i]["T1SINGLEMAX"]);
                pm.MaxNum         = Convert.ToInt32(dt.Rows[i]["T1MAXNUM"]);
                pm.Start_time     = dt.Rows[i]["T1STARTTIME"].ToString();
                pm.Stop_time      = dt.Rows[i]["T1STOPTIME"].ToString();
                PmList.Add(pm);
            }
        }