public ArrayList query_weibo(int status, out string out_log) { out_log = ""; try { string sql = "select * from weibo order by weibo_id asc limit 100 "; ArrayList list = new ArrayList(); SQLiteDBHelper db = new SQLiteDBHelper(this.app_path + @"\config\" + this.db_name); using (SQLiteDataReader reader = db.ExecuteReader(sql, null)) { while (reader.Read()) { WeiboBean weiboBean = new WeiboBean(); //weiboBean.send_id = reader.GetInt32(0); weiboBean.user_name = reader.GetString(1); weiboBean.pwd = reader.GetString(2); //weiboBean.status = reader.GetString(3); weiboBean.memo = reader.GetString(4); list.Add(weiboBean); } } out_log = ""; return(list); } catch (Exception) { } return(new ArrayList()); }
public bool insert_weibo(WeiboBean weiboBean, out string out_log) { try { DateTime now = DateTime.Now; string sql = "INSERT INTO weibo(user_name,pwd,create_date,memo) values(@user_name,@pwd,@create_date,@memo)"; SQLiteDBHelper db = new SQLiteDBHelper(this.app_path + @"\config\" + this.db_name); SQLiteParameter[] parameters = new SQLiteParameter[] { new SQLiteParameter("@user_name", weiboBean.user_name), new SQLiteParameter("@pwd", weiboBean.pwd), new SQLiteParameter("@create_date", now), new SQLiteParameter("@memo", weiboBean.memo) //, //new SQLiteParameter("@status",weiboBean.status) }; db.ExecuteNonQuery(sql, parameters); out_log = ""; return(true); } catch (Exception exception) { out_log = exception.ToString(); return(false); } }
public static void update_weibo_list(CmsForm cmsForm, string user_name, string cookie) { if (!string.IsNullOrEmpty(cookie) && !string.IsNullOrEmpty(user_name)) { int i = 0; while (i < cmsForm.appBean.weibo_list.Count) { WeiboBean item = (WeiboBean)cmsForm.appBean.weibo_list[i]; if (item.user_name.Equals(user_name)) { LogUtil.log_call(cmsForm, "user_name:" + user_name); item.cookie = cookie; item.status = 1; } i = i + 1; } i = 0; while (cmsForm.dataGridView_weibo.Rows.Count > i) { WeiboBean tag = (WeiboBean)cmsForm.dataGridView_weibo[0, i].Tag; if (tag.user_name.Equals(user_name)) { LogUtil.log_call(cmsForm, "user_name:" + user_name); tag.cookie = cookie; tag.status = 1; cmsForm.dataGridView_weibo[1, i].Value = "已经登陆"; } i = i + 1; } } }
public static void login(CmsForm cmsForm, WeiboBean weiboBean) { //WeiboLogin.login(cmsForm, weiboBean.user_name.Trim(), weiboBean.pwd.Trim()); string out_cookie = ""; string body = WeiboUtil.login(cmsForm, weiboBean.user_name.Trim(), weiboBean.pwd.Trim(), out out_cookie); if (!string.IsNullOrEmpty(out_cookie)) { WeiboUtil.update_weibo_list(cmsForm, weiboBean.user_name, out_cookie); } //LogUtil.log_call(cmsForm,"----"+ body); //HttpUpload httpUpload = new HttpUpload(); //httpUpload.SetFieldValue("type","json"); //FileStream fs = new FileStream(@"E:\work\cs\好品推\Release\config\临时文件夹\selhotshare\20161101091218\20161102010514273.jpg", FileMode.Open); //byte[] buffer = new byte[fs.Length]; //httpUpload.SetFieldValue("pic", "20161102010514273.jpg", "image/png", buffer); //string cotent = ""; //httpUpload.Upload("http://m.weibo.cn/mblogDeal/addPic", out_cookie, out body); //LogUtil.log_call(cmsForm, "----" + body); //LogUtil.log_call(cmsForm, "----" + fs.Length); //Dictionary<string, string> formDataDic = new Dictionary<string, string>(); //formDataDic.Add("type", "json"); //body = HttpUpload.CreateHttpUploadFile(cmsForm,"http://m.weibo.cn/mblogDeal/addPic", fs, "pic", "image/png" // , out_cookie, formDataDic //); //LogUtil.log_call(cmsForm, "----" + body); ////LogUtil.log_call(cmsForm, "----" + out_cookie); //body = WeiboUtil.post(cmsForm, "aadfasdfsd","", out_cookie); //LogUtil.log_call(cmsForm, "----" + body); }
public static void send(CmsForm cmsForm, string content, string content_img, ArrayList imgList, CouponContent couponContent, int url_type, int goods_type) { string out_log = ""; try { if (cmsForm.appBean.weibo_list == null || cmsForm.appBean.weibo_list.Count == 0) { LogUtil.log_call(cmsForm, "没有微博账号!"); return; } int i = 0; while (i < cmsForm.appBean.weibo_list.Count) { if (!cmsForm.appBean.send_status && !cmsForm.appBean.qunfa_genfa_qunfa_status) { out_log = "群发被强制停止"; return; } else { WeiboBean item = (WeiboBean)cmsForm.appBean.weibo_list[i]; if (item.status == 1) { string picId = ""; if (imgList != null && imgList.Count > 0) { int img_i = 0; while (img_i < imgList.Count) { string item_img = (string)imgList[img_i]; string pic_id = WeiboUtil.upload(cmsForm, item_img, item.cookie); if (!string.IsNullOrEmpty(pic_id)) { if (!string.IsNullOrEmpty(picId)) { picId = picId + ","; } picId = picId + pic_id; } img_i = +1; } } content = content.Replace("<BR>", "\n"); WeiboUtil.post(cmsForm, string.Concat(content, QqUtil.weiba(cmsForm, out out_log)), picId, item.cookie); } } i = i + 1; } LogUtil.log_call(cmsForm, "微博发完成!"); } catch (Exception exception) { LogUtil.log_call(cmsForm, string.Concat("[autoSendweibo]出错:", exception.ToString())); } return; }