public static bool Them(tblWorked wd) { try { string sTruyVan = string.Format("Insert into tblWorked(IDPost,TaiKhoan,IDAccoutFB,NoiDung,TimeComment) values(N'{0}',N'{1}',N'{2}',N'{3}',N'{4}')", wd.IDPost, wd.TaiKhoan, wd.IDAccoutFB, wd.NoiDung, wd.TimeComment); con = DataProvider.KetNoi(); DataProvider.ThucThiTruyVanNonQuery(sTruyVan, con); DataProvider.DongKetNoi(con); return(true); } catch { return(false); } }
public void DoWork() { for (;;) { Thread.Sleep(30000); if (Work.KiemTraTienDo(idpost, taikhoan) == false) { MessageBox.Show("Đã bình luận xong với bài viết có id= " + idpost); //load lại csdl try { getreload(); } catch { } break; } //làm công tác bình luận string idaccountbl = WorkAccount.LayIDBinhLuan(idpost, taikhoan); // đăng xuất ThuVienLamViecFacebook.DangXuat(); DataTable dtac = AccountFB.LoadDuLieuByID(idaccountbl); //đăng nhập và lấy fb-dtsg string fb_dtsg = ThuVienLamViecFacebook.DNLay_fb_dtsg(dtac.Rows[0]["Email"].ToString(), dtac.Rows[0]["Password"].ToString()); string noidungcomment = WorkComment.LayNoiDungComment(idpost, taikhoan); // bắt đầu bình luận ThuVienLamViecFacebook.BinhLuan(idpost, noidungcomment, idaccountbl, fb_dtsg); //thay đổi trạng thái của hoạt động //lưu thông tin vào worked tblWorked wd = new tblWorked(); wd.IDPost = idpost; wd.IDAccoutFB = idaccountbl; wd.NoiDung = noidungcomment; wd.TaiKhoan = taikhoan; wd.TimeComment = DateTime.Now; Worked.Them(wd); //kết thúc lưu thông tin vào worked Work.updatetiendo(idpost, taikhoan); try { getreload(); } catch { } Thread.Sleep(int.Parse(time.ToString()) * 60000); } }