Exemple #1
0
 protected void ButtonIpExcel_Click(object sender, EventArgs e)
 {
     if (Request.Cookies[LearnSite.Common.CookieHelp.mngCookieNname] != null)
     {
         if (FileUploadip.HasFile)
         {
             if (Request.QueryString["Hid"] != null)
             {
                 string hid = Request.QueryString["Hid"].ToString();
                 string aa  = LearnSite.Common.DataExcel.SaveIpExcel(FileUploadip);
                 if (!string.IsNullOrEmpty(aa))
                 {
                     LearnSite.BLL.Ip bll = new LearnSite.BLL.Ip();
                     bll.DeleteIhid(Int32.Parse(hid));//清空该机房的电脑IP对应表
                     Labelmsg.Text = LearnSite.Common.DataExcel.DataSettoIps(aa, Int32.Parse(hid));
                     System.Threading.Thread.Sleep(500);
                     showIp();
                 }
             }
         }
         else
         {
             Labelmsg.Text = "请选择要导入电脑编号与IP对应表格!";
         }
     }
     else
     {
         string ch = "请登录后执行操作!";
         LearnSite.Common.WordProcess.Alert(ch, this.Page);
     }
 }
Exemple #2
0
    protected void ButtonIp_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["Hid"] != null)
        {
            string hid     = Request.QueryString["Hid"].ToString();
            string ipgate  = TextBoxIpGate.Text.Trim();
            string ipbegin = TextBoxIpBegin.Text.Trim();
            string ipend   = TextBoxIpEnd.Text.Trim();

            //检验IP, 清除旧列表,创建新列表
            if (ipgate.Length > 6 && LearnSite.Common.WordProcess.IsNum(ipbegin) && LearnSite.Common.WordProcess.IsNum(ipend))
            {
                LearnSite.BLL.Ip ibll = new LearnSite.BLL.Ip();
                int Ihid = Int32.Parse(hid);

                ibll.DeleteIhid(Ihid);
                System.Threading.Thread.Sleep(200);

                int  firstnum   = Int32.Parse(ipbegin);
                int  lastnum    = Int32.Parse(ipend);
                int  count      = System.Math.Abs(lastnum - firstnum) + 1;
                bool ispositive = true;//默认正数
                if (lastnum - firstnum < 0)
                {
                    ispositive = false;//如果负数
                }
                if (!ipgate.EndsWith("."))
                {
                    ipgate = ipgate + ".";//如果网段最后位没带点则加上
                }
                LearnSite.Model.Ip model = new LearnSite.Model.Ip();
                LearnSite.BLL.Ip   bll   = new LearnSite.BLL.Ip();
                for (int i = 0; i < count; i++)
                {
                    string ipstr = ipgate + firstnum.ToString();
                    if (ispositive)
                    {
                        firstnum++;
                    }
                    else
                    {
                        firstnum--;
                    }
                    model.Ihid = Ihid;
                    model.Inum = i + 1;
                    model.Iip  = ipstr;
                    bll.Add(model);
                }
                System.Threading.Thread.Sleep(200);
                showIp();
            }
            else
            {
                LearnSite.Common.WordProcess.Alert("Ip网段和范围填写不正确!", this.Page);
            }
        }
    }