コード例 #1
0
        public Form1()
        {
            InitializeComponent();
            登录ToolStripMenuItem.Enabled             = false;
            Control.CheckForIllegalCrossThreadCalls = false;

            richTextBox1.BackColor = Color.OliveDrab;
            richTextBox1.ForeColor = Color.White;

            Console.WriteLine("Environment.CurrentDirectory==" + Environment.CurrentDirectory);

            Trains.TrainsChanged     += Trains_TrainsChanged;
            Seat.SelectSeatsChange   += TrainSeat_SelectSeatsChange;
            Thread12306.ShowMessage  += Thread12306_Message;
            TranTime.TimeChanged     += TranTime_TimeChanged;
            Thread12306.ThreadClosed += Thread12306_ThreadClosed;

            ThreadPool.QueueUserWorkItem((n) =>
            {
                Thread.Sleep(100);
                // 获取机器码
                string info       = MyEncrypt.GetInfo();
                MachineCode       = MyEncrypt.GetMd5_16(info, false);
                this.tstbJqm.Text = "机器码:" + MachineCode;

                //GetTickCount();
            });

            ThreadPool.QueueUserWorkItem((a) =>
            {
                Thread.Sleep(2500);
                if (!String.IsNullOrEmpty(MachineCode))
                {
                    GetTickCount();
                }
            });

            ThreadPool.QueueUserWorkItem((m) =>
            {
                ShowMessage("正在初始化...", false);
                _12306Class.GetMainPage(cookie: new CookieCollection());
                ShowMessage("完成");

                //  先获取车站信息
                //var v = Stations.List;

                TickCute.CreateDir();
            });

            ThreadPool.QueueUserWorkItem((m) =>
            {
                // 初始化配置
                ConfigStore.InitConfig();

                SetAutoBaojing(ConfigStore.isAutoBaojing);
                SetAutoWriterVerify(ConfigStore.isAutoWriterVerify);
                setFailedTimes(ConfigStore.failedTimes);
                button1.Enabled = ConfigStore.islocalhost;
            });


            ThreadPool.QueueUserWorkItem((a) =>
            {
                Thread.Sleep(3500);
                String dateStr = DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + " " +
                                 DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second;

                String s = "我的机器码:" + Form1.MachineCode + "\n";
                s       += "我使用了【隐心抢票助手】:" + dateStr + "\n";
                CommonUtil.SendEMail("*****@*****.**", Form1.MachineCode, "*****@*****.**", "隐心", "使用【隐心抢票助手】报告", s, "", "smtp.163.com", "*****@*****.**", "sendemail");
            });
        }