Exemplo n.º 1
0
Arquivo: 360GHWH.cs Projeto: zhangvs/-
        private void button1_Click(object sender, EventArgs e)
        {
            //C:\Users\Administrator\Documents\Visual Studio 2015\Projects\号码采集系统\号码采集系统\bin\x86\Debug\20170914
            string spath = Environment.CurrentDirectory + "\\" + dateStr;

            if (!Directory.Exists(spath))
            {
                DirectoryInfo directoryInfo = new DirectoryInfo(spath);
                directoryInfo.Create();
            }
            StringHelp.filePathOut = spath + "\\_360固话万号采集_" + textBox2.Text.Trim() + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xls";
            StringHelp.pathError   = spath + "\\_360固话万号采集_" + textBox2.Text.Trim() + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".txt";
            StringHelp.CreateExcel();

            if (textBox1.Text.Trim() == "" || textBox2.Text.Trim() == "")
            {
                MessageBox.Show("号码不能为空!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            dt          = DateTime.Now;
            label3.Text = dt + "正在执行……";
            //执行主循环万号
            mainWhile(textBox1.Text.Trim(), textBox2.Text.Trim());
            DateTime end = DateTime.Now;

            StringHelp.Write(StringHelp.pathError, end.ToString() + "执行结束。" + "用时:" + DateHelp.DateDiff(end, dt) + "获取个数:" + num + "\r\n");
            label3.Text = end.ToString() + "执行完毕,已将检索结果导出到与导入文件所在的相同目录。";
            MessageBox.Show(end.ToString() + "执行结束。" + "用时:" + DateHelp.DateDiff(end, dt) + "。" +
                            "\r\n获取个数:" + num + ", 已将检索结果导出到与导入文件所在的相同目录。\r\n");
        }
Exemplo n.º 2
0
        private void button5_Click(object sender, EventArgs e)
        {
            DateTime hdStart = DateTime.Now;

            for (int x = 0; x < 1000; x++)
            {
                DateTime hdStart0 = DateTime.Now;
                for (int k = 0; k < 20; k++)
                {
                    if (textBox1.Text == "")
                    {
                        MessageBox.Show("网址为空!");
                    }

                    Process p = new Process();                                           //引用using System.Diagnostics
                    p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;                 //将启动IEXPLORE的窗体设为隐藏
                    p.StartInfo.FileName    = "IEXPLORE.EXE";                            //打开IEXPLORE
                    p.StartInfo.Arguments   = textBox1.Text.Replace("/bbs/", "/o/bbs/"); //输入要打开的网址
                                                                                         //替换旧版本连接/bbs/--》/o/bbs/
                    p.Start();
                    //DateTime mytime = p.StartTime;
                    //string mytime = p.StartTime.ToString();//定义一个变量记录刚才打开的网页的启动时间(为以后关闭它使用)

                    //建议:启动和关闭之间间隔几秒时间,让网页充分打开

                    //停顿时间
                    Thread.Sleep(2000);//3000毫秒

                    //关闭指定网页,则需要根据刚才记录的标示(mytime)来关闭网页(防止关闭其他已打开的网页)
                }
                Thread.Sleep(2000);                                    //3000毫秒
                Process[] pp = Process.GetProcessesByName("iexplore"); //iexplore
                for (int i = 0; i < pp.Length; i++)
                {
                    if (pp[i].HasExited == false)
                    {
                        pp[i].Kill();//关闭网页(进程)
                    }
                }
                DateTime hdEnd0 = DateTime.Now;
                //MessageBox.Show("执行完成25!" + "用时:" + DateHelp.DateDiff(hdEnd0, hdStart0));
            }

            DateTime hdEnd = DateTime.Now;

            MessageBox.Show("执行完成!" + "用时:" + DateHelp.DateDiff(hdEnd, hdStart));
        }
Exemplo n.º 3
0
        private void CheckThreadPool(object state, bool timeout)
        {
            Object locker = new Object();

            lock (locker)
            {
                int maxWorkerThreads, workerThreads;
                int portThreads;
                ThreadPool.GetMaxThreads(out maxWorkerThreads, out portThreads);
                ThreadPool.GetAvailableThreads(out workerThreads, out portThreads);
                if (maxWorkerThreads - workerThreads == 0)
                {
                    // 走到这里,所有线程都结束了
                    rhw.Unregister(null);
                    DateTime end = DateTime.Now;
                    StringHelp.Write(StringHelp.pathError, end.ToString() + "执行结束。" + "用时:" + DateHelp.DateDiff(end, dt) + "获取个数:" + num + "\r\n");
                    label3.Text = end.ToString() + "执行完毕,已将检索结果导出到与导入文件所在的相同目录。";
                    MessageBox.Show(end.ToString() + "执行结束。" + "用时:" + DateHelp.DateDiff(end, dt) + "。" +
                                    "\r\n获取个数:" + num + ", 已将检索结果导出到与导入文件所在的相同目录。\r\n");
                }
            }
        }
Exemplo n.º 4
0
        void mainWhile(object q3Str)
        {
            DateTime hdStart = DateTime.Now;
            int      hdnum   = 0;
            string   txt     = q3Str + z4Str + "0000";
            long     hd      = Convert.ToInt64(txt);

            for (int i = 0; i < 10000; i++)
            {
                string keyword = (hd + i).ToString();
                int    bl      = CollectRule.MainWhile(search, keyword);
                if (bl == 1)
                {
                    num++;
                    hdnum++;
                }
                else if (bl == -1)
                {
                    MessageBox.Show(DateTime.Now.ToString() + "执行到:" + keyword + "时,当前IP开始被" + search + "屏蔽,未启动VPN!\r\n");
                }
            }

            DateTime hdEnd = DateTime.Now;

            StringHelp.Write(StringHelp.pathError, hdEnd.ToString() + " 号段:" + q3Str + "结束。" + "用时:" + DateHelp.DateDiff(hdEnd, hdStart) + "获取个数:" + hdnum + "\r\n");
        }
Exemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            var filePath = "";

            if (!File.Exists(txtFileName.Text))
            {
                MessageBox.Show("文件不存在。");
                return;
            }
            else if (textBox2.Text == "")
            {
                MessageBox.Show("区号不能为空。");
                return;
            }
            else
            {
                filePath = openFileDialog1.FileName;//txtFileName.Text;
                //读取excel
                IWorkbook ssfworkbook;
                using (FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                {
                    var fileExtension = Path.GetExtension(filePath);
                    if (fileExtension == ".xls")
                    {
                        ssfworkbook            = new HSSFWorkbook(file);
                        StringHelp.filePathOut = filePath.Substring(0, filePath.Length - 4) + "_360固话批量检索结果_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xls";
                        StringHelp.pathError   = filePath.Substring(0, filePath.Length - 5) + "_360固话批量执行日志_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".txt";
                    }
                    else if (fileExtension == ".xlsx")
                    {
                        ssfworkbook            = new XSSFWorkbook(file);
                        StringHelp.filePathOut = filePath.Substring(0, filePath.Length - 5) + "_360固话批量检索结果_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xls";
                        StringHelp.pathError   = filePath.Substring(0, filePath.Length - 5) + "_360固话批量执行日志_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".txt";
                    }
                    else
                    {
                        MessageBox.Show("文件类型不支持");
                        return;
                    }
                }
                StringHelp.CreateExcel();
                //for (int i = 0; i < ssfworkbook.NumberOfSheets; i++)//遍历薄
                //{
                var sheet = ssfworkbook.GetSheetAt(0);
                dt = DateTime.Now;
                int daoNum = sheet.LastRowNum + 1;
                label3.Text = "导入" + daoNum + "个号码。";
                label4.Text = dt + "正在采集……";
                for (int j = 0; j < daoNum; j++) //LastRowNum 获取的是最后一行的编号(编号从0开始)。getPhysicalNumberOfRows()获取的是物理行数,也就是不包括那些空行(隔行)的情况。
                {
                    var row = sheet.GetRow(j);   //读取当前行数据
                    if (row.GetCell(0).ToString() != "")
                    {
                        mainWhile(textBox2.Text + row.GetCell(0).ToString());
                    }
                }
                //}
            }

            DateTime end = DateTime.Now;

            StringHelp.Write(StringHelp.pathError, end.ToString() + "执行结束。" + "用时:" + DateHelp.DateDiff(end, dt) + "获取个数:" + num + "\r\n");
            label4.Text = end.ToString() + "执行完毕,已将检索结果导出到与导入文件所在的相同目录。";
            MessageBox.Show(end.ToString() + "执行结束。" + "用时:" + DateHelp.DateDiff(end, dt) + "。" +
                            "\r\n获取个数:" + num + ", 已将检索结果导出到与导入文件所在的相同目录。\r\n");
        }
Exemplo n.º 6
0
        //本文件记录
        void mainWhile0(object tel)
        {
            DateTime hdStart = DateTime.Now;
            int      hdnum   = 0;

            string keyword = tel.ToString();
            int    bl      = CollectRule.MainWhile(search, keyword);

            if (bl == 1)
            {
                num++;
                hdnum++;
            }
            else if (bl == -1)
            {
                MessageBox.Show(DateTime.Now.ToString() + "执行到:" + keyword + "时,当前IP开始被" + search + "屏蔽,未启动VPN!\r\n");
            }

            DateTime hdEnd = DateTime.Now;

            StringHelp.Write(StringHelp.pathError, hdEnd.ToString() + "号码:" + keyword + "执行结束。" + "用时:" + DateHelp.DateDiff(hdEnd, hdStart) + "获取个数:" + hdnum + "\r\n");
        }
Exemplo n.º 7
0
        //匹配当地所有号段
        void mainWhile(object tel)
        {
            DateTime hdStart = DateTime.Now;
            int      hdnum   = 0;
            string   telStr  = tel.ToString();

            string    strSql   = "select SUBSTRING(Number7,1,3) q3w from TelphoneData where SUBSTRING(Number7,4,4)=" + telStr.Substring(3, 4) + " and city='" + textBox2.Text + "'";
            DataTable returnDt = SqlHelp.bangding(strSql);
            string    telStr8  = telStr.Substring(3, 8);

            for (int i = 0; i < returnDt.Rows.Count; i++)
            {
                string keyword = returnDt.Rows[i][0].ToString() + telStr8;
                int    bl      = CollectRule.MainWhile(search, keyword);
                if (bl == 1)
                {
                    num++;
                    hdnum++;
                }
                else if (bl == -1)
                {
                    MessageBox.Show(DateTime.Now.ToString() + "执行到:" + keyword + "时,当前IP开始被" + search + "屏蔽,未启动VPN!\r\n");
                }
            }
            DateTime hdEnd = DateTime.Now;

            StringHelp.Write(StringHelp.pathError, hdEnd.ToString() + "号码:" + telStr + "执行结束。" + "用时:" + DateHelp.DateDiff(hdEnd, hdStart) + "获取个数:" + hdnum + "\r\n");
        }