private void buttonStartGetWeibo_Click(object sender, EventArgs e)
        {
            //判断有效条件
            if ((!this.checkBoxGetImageWeibo.Checked && !this.checkBoxGetVideoWeibo.Checked) ||
                this.textBoxGetWeibo.Text.Equals("") ||
                this.checkedListBox1.CheckedItems.Count == 0)
            {
                return;
            }

            //关闭操作功能
            this.checkBoxGetImageWeibo.Enabled = false;
            this.checkBoxGetVideoWeibo.Enabled = false;
            this.textBoxGetWeibo.Enabled       = false;
            this.buttonStartGetWeibo.Enabled   = false;

            //获取图文微博
            if (this.checkBoxGetImageWeibo.Checked)
            {
                //获取微博
                CookieContainer   cookies     = (this.panel1.Controls[0] as UserLable).Cookies;
                List <ImageWeibo> imageWeibos = WeiboOperateTool.GetImageWeibos(this.textBoxGetWeibo.Text, out string oid, cookies);

                for (int i = 0; i < this.checkedListBox1.Items.Count; i++)
                {
                    if (this.checkedListBox1.GetItemChecked(i))
                    {
                        string nickName   = this.checkedListBox1.Items[i].ToString();
                        int    StartCount = SqliteTool.GetLaveWeiboCount(SqliteTool.WeiboType.ImageWeibo, nickName);

                        SqliteTool.InsertImageWebos(imageWeibos, nickName);

                        int endCount = SqliteTool.GetLaveWeiboCount(SqliteTool.WeiboType.ImageWeibo, nickName);

                        UserLog.WriteNormalLog(nickName, String.Format("爬取图文微博{0}条", endCount - StartCount), String.Format("被爬取用户ID:{0}", this.textBoxGetWeibo.Text));

                        string requestStr = DateTime.Now.ToString("yyyy-MM-dd HH:MM:ss") + "\n[" + nickName + "]获取结束:此次共取得图文微博" + (endCount - StartCount).ToString() + "条";
                        this.richTextBox1.Text = this.richTextBox1.Text + requestStr + "\n";

                        //uid可以正常获取数据时说明有效,存入数据库
                        if (endCount - StartCount > 0)
                        {
                            SqliteTool.InsertUidAndOid(this.textBoxGetWeibo.Text, oid, nickName);
                        }
                    }
                }
            }

            //获取视频微博
            if (this.checkBoxGetImageWeibo.Checked)
            {
            }

            //重启界面操作
            this.checkBoxGetImageWeibo.Enabled = true;
            this.checkBoxGetVideoWeibo.Enabled = true;
            this.textBoxGetWeibo.Enabled       = true;
            this.buttonStartGetWeibo.Enabled   = true;
        }
 //发布微博事件
 private void PublishWeiboEvent(object sender, bool isImageWeibo)
 {
     if (isImageWeibo)
     {
         this.PublishAnImageWeibo((UserLable)sender);
     }
     else
     {
         this.PublishAVideoWeibo((UserLable)sender);
     }
     //更新剩余微博数
     ((UserLable)sender).ImageWeiboCount = SqliteTool.GetLaveWeiboCount(SqliteTool.WeiboType.ImageWeibo, ((UserLable)sender).DisplayName).ToString();
     ((UserLable)sender).VideoWeiboCount = SqliteTool.GetLaveWeiboCount(SqliteTool.WeiboType.VideoWeibo, ((UserLable)sender).DisplayName).ToString();
 }
        //更新数据库事件
        private void UpdateSQLiteEvent(object sender)
        {
            List <string> uids = SqliteTool.Get10Uid(((UserLable)sender).DisplayName);

            foreach (string uid in uids)
            {
                int StartCount = SqliteTool.GetLaveWeiboCount(SqliteTool.WeiboType.ImageWeibo, ((UserLable)sender).DisplayName);
                List <ImageWeibo> imageWeibos = WeiboOperateTool.GetImageWeibos(uid, out string oid, ((UserLable)sender).Cookies);
                SqliteTool.InsertImageWebos(imageWeibos, ((UserLable)sender).DisplayName);
                int endCount = SqliteTool.GetLaveWeiboCount(SqliteTool.WeiboType.ImageWeibo, ((UserLable)sender).DisplayName);
                UserLog.WriteNormalLog(((UserLable)sender).DisplayName, String.Format("后台爬取图文微博{0}条", endCount - StartCount), String.Format("被爬取用户ID:{0}", uid));
            }
            //更新微博显示
            ((UserLable)sender).ImageWeiboCount = SqliteTool.GetLaveWeiboCount(SqliteTool.WeiboType.ImageWeibo, ((UserLable)sender).DisplayName).ToString();
            ((UserLable)sender).VideoWeiboCount = SqliteTool.GetLaveWeiboCount(SqliteTool.WeiboType.VideoWeibo, ((UserLable)sender).DisplayName).ToString();
        }
        //登录账号
        private void 登录账号ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LoginView login = new LoginView();

            login.ShowDialog();

            if (login.IsLocked)
            {
                MessageBox.Show("账号异常,请登陆网页微博解除锁定", "提示");
                return;
            }

            if (login.DialogResult == DialogResult.OK)
            {
                UserLable userLable = new UserLable(login.WBLogin.MyCookies, login.WBLogin.Username, login.WBLogin.Password, login.WBLogin.DisplayName, login.WBLogin.UserId);
                if (this.panel1.Controls.Count == 0)
                {
                    userLable.Location = new Point(4, 4);
                }
                else
                {
                    userLable.Location = new Point(4, this.panel1.Controls[this.panel1.Controls.Count - 1].Location.Y + 190 + 6);
                }
                userLable.PublishWeiboEvent  += PublishWeiboEvent;
                userLable.UpdateCookiesEvent += UpdateCookiesEvent;
                userLable.SendEmailEvent     += SendEmailEvent;
                userLable.WriteLogEvent      += WriteLogEvent;
                userLable.UpdateSQLiteEvent  += UpdateSQLiteEvent;
                userLable.FollowFansEvent    += FollowFansEvent;
                //设置头像
                userLable.AvatarImage = login.WBLogin.GetAvatarImage();

                this.panel1.Controls.Add(userLable);
                SqliteTool.CreateDataBase(userLable.DisplayName);
                //更新微博剩余显示
                userLable.ImageWeiboCount = SqliteTool.GetLaveWeiboCount(SqliteTool.WeiboType.ImageWeibo, login.WBLogin.DisplayName).ToString();
                userLable.VideoWeiboCount = SqliteTool.GetLaveWeiboCount(SqliteTool.WeiboType.VideoWeibo, login.WBLogin.DisplayName).ToString();

                this.checkedListBox1.Items.Add(login.WBLogin.DisplayName);
            }
        }
        //发布一条图文微博
        private void PublishAnImageWeibo(UserLable userLable)
        {
            if (SqliteTool.GetLaveWeiboCount(SqliteTool.WeiboType.ImageWeibo, userLable.DisplayName) != 0)
            {
                ImageWeibo weibo = SqliteTool.GetARandomImageWeiboIsNotPublished(SqliteTool.WeiboType.ImageWeibo, userLable.DisplayName);

                if (weibo.Pictures == null || weibo.Pictures.Length == 0)
                {
                    UserLog.WriteNormalLog(userLable.DisplayName, "获取微博失败,类型不明确");
                    return;
                }

                //设置tags
                string weiboText = userLable.IsFrontTagsSet ?
                                   userLable.Tags + weibo.WeiboMessage :
                                   weibo.WeiboMessage + userLable.Tags;
                WeiboOperateTool.SendAnImageWeibo(userLable.Cookies, weiboText, weibo.Pictures);
            }
            else
            {
                this.richTextBox1.Text = this.richTextBox1.Text + userLable.DisplayName + " 微博库已空\n";
                EMailTool.SendMail("微博库已空", String.Format("用户昵称:{0}<br/>登录账号:{1}", userLable.DisplayName, userLable.UserName));
            }
        }