using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Collections;
namespace CheckDomain
{
    public partial class autoDomain : Form
    {
        ServiceHelper.Service1SoapClient hw = new CheckDomain.ServiceHelper.Service1SoapClient();
        Common.Dba.DbSqlLiteData dba = null;
        Thread thread = null;
      
        public autoDomain()
        {
            InitializeComponent();
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            for (int i = 0; i < this.dataGridView1.Rows.Count - 1; i++)
            {
                if(((CheckBox)sender).Checked)
                this.dataGridView1.Rows[i].Cells[0].Value = "True";
                else
                    this.dataGridView1.Rows[i].Cells[0].Value = "False";
            }
        }
        public void BindData()
        {
            dba = new Common.Dba.DbSqlLiteData("data source=" + Application.StartupPath + "/" + System.Configuration.ConfigurationManager.AppSettings["datasource"]);
            // dba.ConnectionString =
            DataTable tempDT = new DataTable();
            tempDT = dba.GetTable("select domain from domain");

            //tempDT.Columns.Add("Domain");
            //DataRow tr = tempDT.NewRow();
            //tr["Domain"] = "goudiannao.com";
            //tempDT.Rows.Add(tr);
            this.dataGridView1.DataSource = tempDT;
        }
        public void BindMyData()
        {
            //dba = new Common.Dba.DbSqlLiteData("data source=" + Application.StartupPath + "/" + System.Configuration.ConfigurationManager.AppSettings["datasource"]);
            // dba.ConnectionString =
            DataTable tempDT = new DataTable();
            tempDT = dba.GetTable("select DomainName as domain from Mydomain");

            //tempDT.Columns.Add("Domain");
            //DataRow tr = tempDT.NewRow();
            //tr["Domain"] = "goudiannao.com";
            //tempDT.Rows.Add(tr);
            this.dataGridView2.DataSource = tempDT;
        }
        public void SetStatus(DataGridViewRow dr, DomainStatus ds)
        {
            bool status = ds.Status;
            if (status)
            {
                if (ds.Expiration_Date < DateTime.Now)
                {
                    dr.Cells[1].Value = "已过期";
                }
                else
                {
                    dr.Cells[1].Value = "已注册";
                }

            }
            else
            {
                dr.Cells[1].Value = "未注册";
            }

            dr.Cells[2].Value = ds.Create_Date;
            dr.Cells[3].Value = ds.Updated_Date;
            dr.Cells[4].Value = ds.Expiration_Date;
        }

        public void SetStatusEx(DataGridViewRow dr, DomainStatus ds)
        {
            bool status = ds.Status;
            if (status)
            {
                if (ds.Expiration_Date < DateTime.Now)
                {
                    dr.Cells[1].Value = "已过期";
                    dr.Cells[2].Value = ds.Create_Date;
                    dr.Cells[3].Value = ds.Updated_Date;
                    dr.Cells[4].Value = ds.Expiration_Date;
                }
                else
                {
                    dr.Cells[1].Value = "已注册";
                }

            }
            else
            {
                dr.Cells[1].Value = "未注册";
                dr.Cells[2].Value = ds.Create_Date;
                dr.Cells[3].Value = ds.Updated_Date;
                dr.Cells[4].Value = ds.Expiration_Date;
            }

     
        }
        public void SetStatusSoonEx(DataGridViewRow dr, DomainStatus ds)
        {
            bool status = ds.Status;
            if (status)
            {
              
                if (ds.Expiration_Date < DateTime.Now)
                {
                    dr.Cells[1].Value = "已过期";
                    dr.Cells[2].Value = ds.Create_Date;
                    dr.Cells[3].Value = ds.Updated_Date;
                    dr.Cells[4].Value = ds.Expiration_Date;
                }
                else
                {
                    TimeSpan ts = DateTime.Now - ds.Expiration_Date;
                    if (ts.TotalDays < 30)
                    {

                        dr.Cells[1].Value = "即将过期一个月内";
                    }
                    else
                    {

                        dr.Cells[1].Value = "已注册";
                    }
                }

            }
            else
            {
                dr.Cells[1].Value = "未注册";
                dr.Cells[2].Value = ds.Create_Date;
                dr.Cells[3].Value = ds.Updated_Date;
                dr.Cells[4].Value = ds.Expiration_Date;
            }


        }

        private void BtCheck_Click(object sender, EventArgs e)
        {

            //MessageBox.Show(this.dataGridView1.Rows[0].Cells[0].Value.ToString());
            //int tempRowsCount = dataGridView1.Rows.Count-1;
            //DataGridViewRow[] dgrvs = new DataGridViewRow[tempRowsCount];
            //int i = 0;
            ArrayList al = new ArrayList();
            foreach (DataGridViewRow di in dataGridView1.Rows)
            {
                string temp = string.IsNullOrEmpty(Convert.ToString(di.Cells["Column1"].Value)) ? ("") : (Convert.ToString(di.Cells["Column1"].Value));
                string tempDomain = string.IsNullOrEmpty(Convert.ToString(di.Cells["Column2"].Value)) ? ("") : (Convert.ToString(di.Cells["Column2"].Value));
             
                if (temp == "True" && tempDomain.Length>0)
                    al.Add(di);
            }
            ThreadWithData twd = new ThreadWithData(al, new CallBack(SetStatus));
            thread = new Thread(new ThreadStart(twd.Run));
            thread.Start();
            //if (thread == null) {
            //    thread = new Thread(new ThreadStart(twd.Run));
            //}
            //if (thread.ThreadState == System.Threading.ThreadState.Stopped)
            //{
            //    thread.Start();
            //}
            //else
            //{
            //    thread = new Thread(new ThreadStart(twd.Run));
            //    thread.Start();
            //}
           
        }

        private void tabPage1_Click(object sender, EventArgs e)
        {

        }

        private void autoDomain_Load(object sender, EventArgs e)
        {
            BindData();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            BindData();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow di in dataGridView1.Rows)
            {
                string temp = string.IsNullOrEmpty(Convert.ToString(di.Cells["Column1"].Value)) ? ("") : (Convert.ToString(di.Cells["Column1"].Value));
                string tempDomain = string.IsNullOrEmpty(Convert.ToString(di.Cells["Column2"].Value)) ? ("") : (Convert.ToString(di.Cells["Column2"].Value));
                string tempInsertSql = "";
                if (temp == "True" && tempDomain.Length > 0)
                {
                    if (dba.GetOne("select count(1) from MyDomain where domainname='" + tempDomain + "'")=="0")
                    tempInsertSql = string.Format("insert into MyDomain(uid,domainname) values(1,'{0}')", tempDomain);
                    dba.GetState(tempInsertSql);
                }

            }
            MessageBox.Show("成功添加管住的域名!");
        }

        private void checkBox2_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < this.dataGridView2.Rows.Count-1; i++)
            {
                if (((CheckBox)sender).Checked)
                    this.dataGridView2.Rows[i].Cells[0].Value = "True";
                else
                    this.dataGridView2.Rows[i].Cells[0].Value = "False";
            }
        }

        private void 关于我们ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new about().ShowDialog();
        }

        private void tabControl1_TabIndexChanged(object sender, EventArgs e)
        {
            //if(((TabPage)(sender)).c)
            int tempIndex = this.tabControl1.SelectedIndex ;
            if (tempIndex == 1)
            {
                BindMyData();
            }

        }

        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int tempIndex = this.tabControl1.SelectedIndex;
            if (tempIndex == 1)
            {
                BindMyData();
            }
        }

        private void button8_Click(object sender, EventArgs e)
        {
            ArrayList tempAl = new ArrayList();
            foreach (DataGridViewRow di in dataGridView2.Rows)
            {
                string temp = string.IsNullOrEmpty(Convert.ToString(di.Cells["Column11"].Value)) ? ("") : (Convert.ToString(di.Cells["Column11"].Value));
                string tempDomain = string.IsNullOrEmpty(Convert.ToString(di.Cells["Column12"].Value)) ? ("") : (Convert.ToString(di.Cells["Column12"].Value));
                if (temp == "True" && tempDomain.Length > 0)
                    tempAl.Add("delete from mydomain where DomainName='" + tempDomain + "'");
            }
            bool tempStatus = this.dba.GetTranState(tempAl);
            if (tempStatus)
            {
                MessageBox.Show("删除陈功");
                this.BindMyData();
            }
            else
            {
                MessageBox.Show("删除失败请联系作者");
            }
        }

        private void button9_Click(object sender, EventArgs e)
        {
            ArrayList tempAl = new ArrayList();
            foreach (DataGridViewRow di in dataGridView1.Rows)
            {
                string temp = string.IsNullOrEmpty(Convert.ToString(di.Cells["Column1"].Value)) ? ("") : (Convert.ToString(di.Cells["Column1"].Value));
                string tempDomain = string.IsNullOrEmpty(Convert.ToString(di.Cells["Column2"].Value)) ? ("") : (Convert.ToString(di.Cells["Column2"].Value));
                if (temp == "True" && tempDomain.Length > 0)
                    tempAl.Add("delete from domain where domain='" + tempDomain + "'");
            }
            bool tempStatus = this.dba.GetTranState(tempAl);
            if (tempStatus)
            {
                MessageBox.Show("删除陈功");
                this.BindData();
            }
            else
            {
                MessageBox.Show("删除失败请联系作者");
            }

        }

        private void button3_Click(object sender, EventArgs e)
        {
           EditDomain edForm =  new EditDomain();
           edForm.TableName="1";
           edForm.ShowDialog();
        }

        private void button10_Click(object sender, EventArgs e)
        {

        }

        private void button10_Click_1(object sender, EventArgs e)
        {
            ArrayList tempAl = new ArrayList();
            foreach (DataGridViewRow di in dataGridView1.Rows)
            {
                string temp = string.IsNullOrEmpty(Convert.ToString(di.Cells["Column1"].Value)) ? ("") : (Convert.ToString(di.Cells["Column1"].Value));
                string tempDomain = string.IsNullOrEmpty(Convert.ToString(di.Cells["Column2"].Value)) ? ("") : (Convert.ToString(di.Cells["Column2"].Value));
                string tempInsertSql = "";
                if (temp == "True" && tempDomain.Length > 0)
                {
                    tempAl.Add(di);
                }
            }
            ThreadWithData twd = new ThreadWithData(tempAl, new CallBack(SetStatusEx));
            thread = new Thread(new ThreadStart(twd.Run));
            thread.Start();

        }

        private void button11_Click(object sender, EventArgs e)
        {
            ArrayList tempAl = new ArrayList();
            foreach (DataGridViewRow di in dataGridView1.Rows)
            {
                string temp = string.IsNullOrEmpty(Convert.ToString(di.Cells["Column1"].Value)) ? ("") : (Convert.ToString(di.Cells["Column1"].Value));
                string tempDomain = string.IsNullOrEmpty(Convert.ToString(di.Cells["Column2"].Value)) ? ("") : (Convert.ToString(di.Cells["Column2"].Value));
                string tempInsertSql = "";
                if (temp == "True" && tempDomain.Length > 0)
                {
                    tempAl.Add(di);
                }
            }
            ThreadWithData twd = new ThreadWithData(tempAl, new CallBack(SetStatusSoonEx));
            thread = new Thread(new ThreadStart(twd.Run));
            thread.Start();
        }

        private void button7_Click(object sender, EventArgs e)
        {

           
        

            //wdr.
            //int tempRowsCount = dataGridView1.Rows.Count-1;
            //DataGridViewRow[] dgrvs = new DataGridViewRow[tempRowsCount];
            //int i = 0;
            ArrayList al = new ArrayList();
            foreach (DataGridViewRow di in dataGridView2.Rows)
            {
                string temp = string.IsNullOrEmpty(Convert.ToString(di.Cells["Column11"].Value)) ? ("") : (Convert.ToString(di.Cells["Column11"].Value));
                string tempDomain = string.IsNullOrEmpty(Convert.ToString(di.Cells["Column12"].Value)) ? ("") : (Convert.ToString(di.Cells["Column12"].Value));
             
             
                if (temp == "True" && tempDomain.Length > 0)
                    al.Add(di);
            }
            ThreadWithData twd = new ThreadWithData(al, new CallBack(SetStatus));
            thread = new Thread(new ThreadStart(twd.RunMy));
            thread.Start();
        }

        private void button6_Click(object sender, EventArgs e)
        {
            BindMyData();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            EditDomain edForm = new EditDomain();
            edForm.TableName = "2";
            edForm.ShowDialog();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            string domain = this.TbDomain.Text;
            string tempContent = "";
            try
            {
                tempContent = new UrlCheck().GetHttpData("http://whois.hichina.com/cgi-bin/whois?domain=" + domain, "gb2312");
            }
            catch (Exception ex)
            {
                tempContent = "";

            }
            this.richTextBox1.Text = tempContent;
        }
    }
}

posted on 2011-08-31 19:06 sanmao 阅读(254) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 

常用链接

留言簿(5)

随笔分类

随笔档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜