public async Task <bool> UpdateWorkAccount(DTOWorkAccount workAccount) { WorkAccount mapWorkAccount = _mapper.Map <WorkAccount>(workAccount); await _workAccountRepository.Update2(mapWorkAccount); bool success = true; try { await _workAccountRepository.SaveChanges(); } catch (Exception e) { if (!_workAccountRepository.WorkAccountExists(workAccount.WorkAccountID)) { success = false; } else { throw; } } return(success); }
public async Task <bool> DeleteWorkAccount(int id) { WorkAccount workAccount = await _workAccountRepository.Delete(id); if (workAccount == null) { return(false); } else { await _workAccountRepository.SaveChanges(); return(true); } }
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); } }
public async Task <bool> AddWorkAccount(DTOWorkAccount workAccount) { WorkAccount mapWorkAccount = _mapper.Map <WorkAccount>(workAccount); _workAccountRepository.Add(mapWorkAccount); bool success = true; try { await _workAccountRepository.SaveChanges(); } catch { success = false; } return(success); }
private void UCTTBinhLuan_VisibleChanged(object sender, EventArgs e) { // trường hợp khi bình luận tiếp tục sửa đổi từ cơ sở dữ liệu if (ktblcu != 0) { //load lại các bình luận đã lưu DataTable dt = WorkComment.LoadListNoiDungBL(idpost, taikhoan); LsNoiDungBinhLuan.Items.Clear(); for (int i = 0; i < dt.Rows.Count; i++) { LsNoiDungBinhLuan.Items.Add(dt.Rows[i]["NoiDung"].ToString()); } //kết thúc load lại các bình luận đã lưu //load lại số lượng và khoảng thời gian dt = Work.LoadDuLieuLamViecCu(taikhoan, idpost); numKhoangTime.Value = int.Parse(dt.Rows[0]["KhoangTime"].ToString()); numSoBL.Value = int.Parse(dt.Rows[0]["TongComment"].ToString()); //kết thúc load lại số lượng và khoảng thời gian //set tài khoản bình luận if (loadlist == 0) { LoadListAccount(); loadlist = 1; } for (int i = 0; i < tichcuc.Rows.Count; i++) { //nếu như tìm thấy tài khoản bình luận trong danh sách if (WorkAccount.CheckTK(tichcuc.Rows[i]["NumberIDAccount"].ToString(), taikhoan, idpost)) { lsCheckTKTichCuc.SetItemChecked(i + 1, true); } } for (int i = 0; i < tieucuc.Rows.Count; i++) { //nếu như tìm thấy tài khoản bình luận trong danh sách if (WorkAccount.CheckTK(tieucuc.Rows[i]["NumberIDAccount"].ToString(), taikhoan, idpost)) { lsCheckTKTieuCuc.SetItemChecked(i + 1, true); } } //kết thúc set tài khoản bình luận ktblcu = 0; } }
public async Task <DTOWorkAccount> GetWorkAccount(int id) { WorkAccount workAccount = await _workAccountRepository.Get(id); return(_mapper.Map <DTOWorkAccount>(workAccount)); }
private void btnBatDauBinhLuan_Click(object sender, EventArgs e) { // lấy danh sách bình luận idTaiKhoanBinhLuan = new List <string>(); //lấy ra list tài khoản sử dụng để bình luận foreach (var item in lsCheckTKTichCuc.CheckedIndices) { string i = item.ToString(); if (i == "0") { for (int t = 0; t < tichcuc.Rows.Count; t++) { idTaiKhoanBinhLuan.Add(tichcuc.Rows[t]["NumberIDAccount"].ToString()); } } else { idTaiKhoanBinhLuan.Add(tichcuc.Rows[int.Parse(i) - 1]["NumberIDAccount"].ToString()); } } foreach (var item in lsCheckTKTieuCuc.CheckedIndices) { string i = item.ToString(); if (i == "0") { for (int t = 0; t < tieucuc.Rows.Count; t++) { idTaiKhoanBinhLuan.Add(tieucuc.Rows[t]["NumberIDAccount"].ToString()); } } else { idTaiKhoanBinhLuan.Add(tieucuc.Rows[int.Parse(i) - 1]["NumberIDAccount"].ToString()); } } //kết thúc lấy danh sách bình luận //cập nhật lại thông tin bài viết tblPost p = new tblPost(); p.IDPost = idpost; p.TimePost = DateTime.Parse(timepost); if (danhgia == "Tích cực") { p.Status = "Tích cực"; } else { p.Status = "Tiêu cực"; } Post.Sua(p); //kết thúc cập nhật thông tin bài viết //kiểm tra xem bài viết đã được bình luận chưa if (Work.LoadDuLieuLamViecCu(taikhoan, idpost).Rows.Count != 0) { //xóa dữ liệu đã lưu cũ //xoá trong work Work.Xoa(idpost, taikhoan); WorkAccount.Xoa(idpost, taikhoan); WorkComment.Xoa(idpost, taikhoan); } //kết thúc kiểm tra bài viết đã được bình luận chưa //lưu các thông số bình luận lại //lưu tài khoản bình luận lại vào bảng workaccount tblWorkAccount wa = new tblWorkAccount(); wa.IDPost = idpost; wa.TaiKhoan = taikhoan; for (int i = 0; i < idTaiKhoanBinhLuan.Count; i++) { wa.IDAccountComment = idTaiKhoanBinhLuan[i]; WorkAccount.Them(wa); } //lưu các nội dung sẽ bình luận tblWorkComment wc = new tblWorkComment(); wc.IDPost = idpost; wc.TaiKhoan = taikhoan; for (int i = 0; i < LsNoiDungBinhLuan.Items.Count; i++) { wc.Noidung = LsNoiDungBinhLuan.Items[i].Text; WorkComment.Them(wc); } // lưu thông tin công việc bình luận lại tblWork w = new tblWork(); w.TaiKhoan = taikhoan; w.IDPost = idpost; w.KhoangTime = (int)numKhoangTime.Value; w.TongComment = (int)numSoBL.Value; w.TienDo = 0; w.TrangThai = "Đang bình luận"; Work.Them(w); //Thêm thành công thông tin TuDongBinhLuan r = new TuDongBinhLuan(idpost, numKhoangTime.Value.ToString(), numSoBL.Value.ToString(), taikhoan); Thread tudong = new Thread(r.DoWork); tudong.SetApartmentState(ApartmentState.STA); tudong.Start(); // chỗ này chưa đc vì chưa thêm đc vào danh sách luồng đang chạy chung danhsach.Add(idpost, tudong); Work.updatetrangthai(idpost, "Đang bình luận", taikhoan); MessageBox.Show("Đã thêm công việc thành công"); }