示例#1
0
        //浏览器地址跳转事件
        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            //登录成功
            if (e.Url.ToString().IndexOf("https://passport.baidu.com/center") != -1)
            {
                webBrowser1.Url = new Uri("https://tieba.baidu.com/");
            }

            //贴吧首页
            if (e.Url.ToString().IndexOf("https://tieba.baidu.com/") != -1)
            {
                string cookie = GetCookie("https://tieba.baidu.com/");
                string yhm    = Tieba.GetBaiduYongHuMing(cookie);
                if (string.IsNullOrEmpty(yhm))
                {
                    //失败
                    MessageBox.Show(text: " 登录失败,请重新登录", caption: "笨蛋雪说:", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error);
                }
                else
                {
                    //成功
                    QuanJu.Cookie     = cookie;
                    QuanJu.YongHuMing = yhm;
                }

                Dispose();
            }
        }
示例#2
0
        public static bool InsertTieba(Tieba Tb)
        {
            bool        ok;
            DbcontextDB db  = new DbcontextDB();
            int         row = Convert.ToInt32(db.Insert(Tb));

            return(row == 1 ? ok = false : ok = true);
        }
示例#3
0
        /// <summary>
        ///  编辑框 头像 文本有变动
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void textBox_touXiang_TextChanged(object sender, EventArgs e)
        {
            string touXiang = Tieba.GuoLvTouXiangID(textBox_touXiang.Text);

            if (string.IsNullOrEmpty(touXiang))
            {
                return;
            }

            TiebaMingPianJieGou mingPianJieGou = TiebaWeb.GetTiebaMingPian(touXiang);

            if (!mingPianJieGou.HuoQuChengGong)
            {
                return;
            }

            pictureBox1.ImageLocation = $"http://tb.himg.baidu.com/sys/portrait/item/{touXiang}";

            textBox_zhuXianZhangHao.Text = Tools.HuoQuZhuXianZhangHao(mingPianJieGou);
        }
示例#4
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            JieGou = new FengJinXinXi.JieGou
            {
                TouXiang             = textBox_touXiang.Text,
                TiebaName            = textBox_tiebaName.Text,
                ZhuXianZhangHao      = textBox_zhuXianZhangHao.Text,
                XunHuanKaiShiShiJian = dateTimePicker1.Text,
                XunHuanJieShuShiJian = dateTimePicker2.Text
            };

            //自动获取头像ID
            if (JieGou.ZhuXianZhangHao.Length > 0 && Tieba.GuoLvTouXiangID(JieGou.TouXiang).Length <= 0)
            {
                TiebaMingPianJieGou mingPianJieGou = TiebaWeb.GetTiebaMingPian(JieGou.ZhuXianZhangHao);
                if (!mingPianJieGou.HuoQuChengGong)
                {
                    MessageBox.Show("头像ID获取失败,请人工填写或重试", "笨蛋雪说:", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Exclamation);
                    return;
                }

                pictureBox1.ImageLocation = $"http://tb.himg.baidu.com/sys/portrait/item/{mingPianJieGou.TouXiang}";

                textBox_touXiang.Text = mingPianJieGou.TouXiang;
                JieGou.TouXiang       = mingPianJieGou.TouXiang;

                if (MessageBox.Show("请查看头像,确定用户信息是否正确", "笨蛋雪说:", buttons: MessageBoxButtons.YesNo, icon: MessageBoxIcon.Information) == DialogResult.No)
                {
                    return;
                }
            }

            //新建
            if (ZhuangTai == ZhuangTaiLeiXing.XinJian)
            {
                if (string.IsNullOrEmpty(JieGou.TouXiang))
                {
                    MessageBox.Show("请填写头像ID", "笨蛋雪说:", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Exclamation);
                    return;
                }

                if (!JieGou.TouXiang.Contains("tb."))
                {
                    MessageBox.Show("头像ID格式错误", "笨蛋雪说:", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Exclamation);
                    return;
                }

                if (string.IsNullOrEmpty(JieGou.TiebaName))
                {
                    MessageBox.Show("请填写贴吧名", "笨蛋雪说:", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Exclamation);
                    return;
                }
            }

            //获取封禁时长
            if (Tools.HuoQuFengJinShiChang(dateTimePicker1, dateTimePicker2) <= 0)
            {
                MessageBox.Show("封禁时长必须大于0", "笨蛋雪说:", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Exclamation);
                return;
            }

            //新建
            if (ZhuangTai == ZhuangTaiLeiXing.XinJian)
            {
                TiebaMingPianJieGou mingPianJieGou = TiebaWeb.GetTiebaMingPian(JieGou.TouXiang);
                if (!mingPianJieGou.HuoQuChengGong)
                {
                    MessageBox.Show("用户信息获取失败", "笨蛋雪说:", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error);
                    return;
                }

                //更新任务参数
                JieGou.ZhuXianZhangHao = mingPianJieGou.YongHuMing;
                JieGou.TouXiang        = mingPianJieGou.TouXiang;

                //检查重复
                if (Form1.access.GetDataTable($"select * from 封禁列表 where 头像='{JieGou.TouXiang}' and 贴吧名='{JieGou.TiebaName}'").Rows.Count > 0)
                {
                    MessageBox.Show($"{JieGou.ZhuXianZhangHao}已经在{JieGou.TiebaName}吧添加过了", "笨蛋雪说:", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Asterisk);
                    return;
                }

                int jieGuo = Form1.access.DoCommand($"insert into 封禁列表 (用户名,头像,贴吧名,最后封禁时间,循环开始时间,循环结束时间)" +
                                                    $" values('{JieGou.ZhuXianZhangHao}','{JieGou.TouXiang}','{JieGou.TiebaName}','1970-01-01','{JieGou.XunHuanKaiShiShiJian}','{JieGou.XunHuanJieShuShiJian}')");
                if (jieGuo > 0)
                {
                    Dispose();
                }
                else
                {
                    MessageBox.Show("添加失败", "笨蛋雪说:", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error);
                }
            }
            //编辑
            else if (ZhuangTai == ZhuangTaiLeiXing.BianJi)
            {
                int jieGuo = Form1.access.DoCommand($"update 封禁列表 set 用户名='{JieGou.ZhuXianZhangHao}',循环开始时间='{JieGou.XunHuanKaiShiShiJian}',循环结束时间='{JieGou.XunHuanJieShuShiJian}' where 头像='{JieGou.TouXiang}' and 贴吧名='{JieGou.TiebaName}'");
                if (jieGuo > 0)
                {
                    Dispose();
                }
                else
                {
                    MessageBox.Show("更新失败", "笨蛋雪说:", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error);
                }
            }
        }
示例#5
0
        public static bool AddTieba(Tieba T)
        {
            DbcontextDB db = new DbcontextDB();

            return(Convert.ToInt32(db.Insert(T)) > 0);
        }