public object Delete_User(int id_group, int id_user) { int status = 0; string Id = ""; string Token = ""; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = "", link = ""; try { Conds.Add("ID_GROUP", id_group); Conds.Add("ID_USER", id_user); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { if (cnn.Delete(Conds, "TBL_GROUPMEMBER") < 0) { return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError)); } } return(JsonResultCommon.ThanhCong()); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } }
/// <summary> /// kiểm tra email người dùng có tồn tại /// </summary> /// <param name="email">email</param> /// <param name="UserId">0: khi insert, 1: khi update</param> /// <returns></returns> public bool CheckEmail(string email, long UserId) { DataTable Tb = null; using (DpsConnection Conn = new DpsConnection(_config.ConnectionString)) { SqlConditions sqlcond = new SqlConditions(); string sqlq = ""; string idstr = ""; sqlcond.Add("email", email); if (UserId > 0) { idstr = " and UserID <> @Id"; sqlcond.Add("Id", UserId); } sqlq = $"select [UserID] from Dps_User where Deleted = 0 {idstr} and Email=@email"; Tb = Conn.CreateDataTable(sqlq, sqlcond); } if (Tb.Rows.Count == 1) { return(true); } return(false); }
/// <summary> /// reset mật khẩu /// </summary> /// <param name="iduser"></param> /// <param name="password"></param> /// <returns></returns> //public string ResetPass(string iduser, string password) //{ // using (DpsConnection Conn = new DpsConnection(_config.ConnectionString)) // { // var Tb = Conn.CreateDataSet(@"select * from Dps_User where UserID = @Id // select * from Sys_Config where Code='SEND_MAIL_RESET_PASS'", new SqlConditions() { { "Id", iduser } }); // if (Tb == null || Tb.Tables[0].Rows.Count != 1) // return "Tài khoản không tồn tại"; // string newpass = EncryptPassword(password); // var val = new Hashtable(); // val.Add("PasswordHash", newpass); // val.Add("LastUpdatePass", DateTime.Now); // val.Add("GiaHan", 0); // Conn.BeginTransaction(); // if (Conn.Update(val, new SqlConditions { new SqlCondition("UserID", iduser) }, "Dps_User") != 1) // { // Conn.RollbackTransaction(); // return "Không thể thay đổi mật khẩu"; // } // #region gửi mail // try // { // if (Tb.Tables[1].Rows.Count > 0) // { // if (Tb.Tables[1].Rows[0]["Value"].ToString() == "1") // { // if (string.IsNullOrEmpty(Tb.Tables[0].Rows[0]["Email"].ToString())) // { // Conn.RollbackTransaction(); // return "Không thể thay đổi mật khẩu";// "Người dùng không có thông tin Email"; // } // string Error = ""; // //string strHTML = System.IO.File.ReadAllText(_config.LinkAPI + Constant.TEMPLATE_IMPORT_FOLDER + "/User_ForgetPass.html"); // Hashtable kval = new Hashtable(); // kval.Add("{{NewPass}}", password); // kval.Add("$nguoinhan$", Tb.Tables[0].Rows[0]["Fullname"]); // kval.Add("$SysName$", _config.SysName); // MailAddressCollection Lstcc = new MailAddressCollection(); // MailInfo minfo = new MailInfo(MailConfig.Value, int.Parse(Tb.Tables[0].Rows[0]["IdDonVi"].ToString())); // if (minfo.Id > 0) // { // string fileTemp = Path.Combine(_hostingEnvironment.ContentRootPath, Constant.TEMPLATE_IMPORT_FOLDER + "/User_ForgetPass.html"); // var rs = SendMail.Send(fileTemp, kval, Tb.Tables[0].Rows[0]["Email"].ToString(), "RESET MẬT KHẨU NGƯỜI DÙNG", Lstcc, Lstcc, null, false, out Error, minfo); // if (!string.IsNullOrEmpty(Error)) // { // Conn.RollbackTransaction(); // return "Không thể thay đổi mật khẩu";//"Gửi mail thất bại"; // } // } // } // } // } // catch (Exception ex) // { // Conn.RollbackTransaction(); // return "Không thể thay đổi mật khẩu";// "Gửi mail thất bại"; // } // #endregion // Conn.EndTransaction(); // return ""; // } //} /// <summary> /// kiểm tra người dùng có tồn tại /// </summary> /// <param name="UserNameorID">id người dùng hoặc tên đăng nhập</param> /// <param name="loai">0: kiểm tra bằng ID, 1: username</param> /// <returns></returns> public bool CheckNguoiDung(string UserNameorID, int loai) { DataTable Tb = null; using (DpsConnection Conn = new DpsConnection(_config.ConnectionString)) { SqlConditions sqlcond = new SqlConditions(); string sqlq = ""; if (loai == 1) { sqlcond.Add("UserName", UserNameorID); sqlq = "select [UserID] from Dps_User where Deleted = 0 and UserName = @UserName"; } if (loai == 0) { sqlcond.Add("Id", UserNameorID); sqlq = "select [UserID] from Dps_User where Deleted = 0 and UserID = @Id"; } Tb = Conn.CreateDataTable(sqlq, sqlcond); } if (Tb.Rows.Count == 1) { return(true); } return(false); }
public object DeleteGhim(int id_user, int id_thongdiep) { { int status = 0; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataRow[] dr; Hashtable val = new Hashtable(); Hashtable val2 = new Hashtable(); DataTable dt_token = new DataTable(); try { //Conds.Add("email", Email); //Conds.Add("password", Pass); //val.Add("ID_COMMENT", data.id_cmt); //val.Add("ID_BAIDANG", data.ID_BaiDang); Conds.Add("ID_USER", id_user); Conds.Add("ID_THONGDIEP", id_thongdiep); //Conds.Add("ID_USER", data.ID_User); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { // dt = cnn.CreateDataTable(@"SELECT COL_DISABLE FROM TBL_THONGDIEPCEO as g where g.ID_THONGDIEP="+id_thongdiep, Conds); // dr = dt.Select(); // var total = dt.Rows.Count; if (cnn.Delete(Conds, "TBL_GHIM") < 0) { return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError)); } } return(JsonResultCommon.ThanhCong()); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } } }
public Task onDisconnectToken(string infoToken) { try { TokenRequesModel infoDataCon = JsonConvert.DeserializeObject <TokenRequesModel>(infoToken); string Token = infoDataCon.Token; string idUser = infoDataCon.UserID.ToString(); string clientID = checkClientIDWithToken(Token); if (!ConnectedClients.ContainsKey(Token)) { ConnectedClients[Token] = clientID; using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { SqlConditions val = new SqlConditions(); val.Add("Token", Token); cnn.Delete(val, "SignalR_Connect"); ConnectedClients.Remove(Token); } } } catch (Exception ex) { return(base.OnDisconnectedAsync(ex)); } return(base.OnDisconnectedAsync(new Exception())); }
public Task ReconnectToken(string infoToken) { try { TokenRequesModel infoDataCon = JsonConvert.DeserializeObject <TokenRequesModel>(infoToken); string Token = infoDataCon.Token; string idUser = infoDataCon.UserID.ToString(); string clientID = checkClientIDWithToken(Token); if (!ConnectedClients.ContainsKey(Token)) { ConnectedClients[Token] = clientID; using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { Hashtable has = new Hashtable(); has.Add("Token", Token); has.Add("TimeTokenConnect", DateTime.Now); SqlConditions cond = new SqlConditions(); cond.Add("ConnectionId", clientID); if (cnn.Update(has, cond, "SignalR_Connect") == 1) { } } } //return base.OnConnected(); } catch (Exception ex) { return(base.OnDisconnectedAsync(ex)); } return(base.OnConnectedAsync()); }
public object deleteGroup(int id_group) { { SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); Hashtable val = new Hashtable(); DataTable dt_token = new DataTable(); try { Conds.Add("ID_GROUP", id_group); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { if (cnn.Delete(Conds, "TBL_GROUP") < 0) { return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError)); } } return(JsonResultCommon.ThanhCong()); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } } }
public object deleteBaiTrangCaNhan(int id_baidangcanhan) { { SqlConditions Conds = new SqlConditions(); SqlConditions Conds_tb = new SqlConditions(); DataTable dt = new DataTable(); Hashtable val = new Hashtable(); DataTable dt_token = new DataTable(); try { val.Add("COL_DISABLE", true); Conds.Add("ID_BAIDANG_CANHAN", id_baidangcanhan); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { if (cnn.Update(val, Conds, "TBL_BaiDang_TRANGCANHAN") < 0) { return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError)); } } return(JsonResultCommon.ThanhCong()); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } } }
public object UpdateTrangCaNhan(Models.TrangCaNhan data) { { SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); Hashtable val = new Hashtable(); DataTable dt_token = new DataTable(); try { //Conds.Add("email", Email); //Conds.Add("password", Pass); val.Add("TieuSu", data.tieusu); Conds.Add("ID_CANHAN", data.id_canhan); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { if (cnn.Update(val, Conds, "TBL_TRANGCANHAN") < 0) { return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError)); } } return(JsonResultCommon.ThanhCong()); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } } }
public object deleteMedia(int id_media) { { SqlConditions Conds = new SqlConditions(); SqlConditions Conds_tb = new SqlConditions(); DataTable dt = new DataTable(); Hashtable val = new Hashtable(); DataTable dt_token = new DataTable(); try { Conds_tb.Add("ID_MEDIA", id_media); using (DpsConnection cnn = new DpsConnection("ConnectSQLMXH", true)) { //cnn.Delete(Conds_tb, "TBL_THONGBAO"); Thread.Sleep(500); if (cnn.Delete(Conds_tb, "TBL_MEDIA") < 0) { return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError)); } } return(JsonResultCommon.ThanhCong()); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } } }
public object GetUpdateQuyenLoaiBaiDang() { { string Token = lc.GetHeader(Request); LoginData loginData = lc._GetInfoUser(Token); if (loginData == null) { return(JsonResultCommon.DangNhap()); } int status = 0; string Id = ""; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = "", link = ""; DataTable dt_token = new DataTable(); try { Conds.Add("id_user", loginData.Id); //Conds.Add("password", Pass); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { link = "http://192.168.43.236/"; // link = "http://192.168.3.49/"; //link = "https://*****:*****@id_user", Conds); //dt_token = cnn.CreateDataTable("select * from LoginSection where Token = @token and Id = @Id_nv", Conds); dt = cnn.CreateDataTable(@"SELECT ID_LOAIBAIDANG,TENLOAIBAIDANG FROM TBL_LOAIBAIDANG EXCEPT SELECT lbd.ID_LOAIBAIDANG,TENLOAIBAIDANG FROM TBL_NHOM_QUYEN_LOAIBAIDANG as lbd,TBL_LOAIBAIDANG as bd WHERE ID_USER=@id_user and lbd.ID_LOAIBAIDANG=bd.ID_LOAIBAIDANG ", Conds); } var data = from r in dt.AsEnumerable() select new { Id_LoaiDang = r["ID_LOAIBAIDANG"], TenLoaiDang = r["TENLOAIBAIDANG"], check = false, }; return(JsonResultCommon.ThanhCong(data)); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } } }
public object DeleteFlow(int id_canhan) { string Token = lc.GetHeader(Request); LoginData loginData = lc._GetInfoUser(Token); if (loginData == null) { return(JsonResultCommon.DangNhap()); } SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = "", link = ""; Hashtable val = new Hashtable(); DataTable dt_token = new DataTable(); try { Conds.Add("ID_CANHAN", id_canhan); Conds.Add("USER_Flow", loginData.Id); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { if (cnn.Delete(Conds, "TBL_Flow") < 0) { return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError)); } } return(JsonResultCommon.ThanhCong()); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } }
public object DeleteQuyenLoaiBaiDang(int loai) { { string Token = lc.GetHeader(Request); LoginData loginData = lc._GetInfoUser(Token); if (loginData == null) { return(JsonResultCommon.DangNhap()); } int status = 0; string Id = ""; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataRow[] dr; bool Visible = true; Hashtable val = new Hashtable(); List <object> rs = new List <object>(); string title = "", link = ""; DataTable dt_token = new DataTable(); try { //Conds.Add("password", Pass); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { Conds.Add("ID_USER", loginData.Id); Conds.Add("ID_LOAIBAIDANG", loai); if (cnn.Delete(Conds, "TBL_NHOM_QUYEN_LOAIBAIDANG") < 0) { return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError)); } return(JsonResultCommon.ThanhCong()); } } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } } }
public object Update_quyen_Memmber(int id_user, Models.Group.User_Group data) { int status = 0; string Id = ""; int id_group = 0; string Token = ""; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = "", link = ""; Hashtable val = new Hashtable(); Hashtable val_member = new Hashtable(); DataTable dt_token = new DataTable(); DataTable lastid = new DataTable(); string sqlq = ""; try { val.Add("QUYEN_ADMIN", data.quyen_group); Conds.Add("ID_GROUP", data.Id_Group); Conds.Add("ID_USER", id_user); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { if (cnn.Update(val, Conds, "TBL_GROUPMEMBER") < 0) { return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError)); } } return(JsonResultCommon.ThanhCong("Cập nhật thành công !")); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } }
public object UpdateUserName(Models.User.Account data) { { string Token = lc.GetHeader(Request); LoginData loginData = lc._GetInfoUser(Token); if (loginData == null) { return(JsonResultCommon.DangNhap()); } SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); Hashtable val = new Hashtable(); DataTable dt_token = new DataTable(); try { //Conds.Add("email", Email); //Conds.Add("password", Pass); val.Add("TINHTRANG", data.TinhTrang); Conds.Add("ID_USER", loginData.Id); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { if (cnn.Update(val, Conds, "TBL_Account") < 0) { return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError)); } dt = cnn.CreateDataTable("select * from TBL_Account", Conds); } var dl = from r in dt.AsEnumerable() select new { ID_user = r["ID_USER"], ID_NV = r["IDNV"], Username = r["UserName"], Password = r["Pass"], Email = r["Email"], Token = r["Token"], TinhTrang = r["TINHTRANG"], // Roles = r["roles"], Avatar = r["AVATAR"], }; // mangxahoi.PushToAllUsers_CheckOnline(dl, null); return(JsonResultCommon.ThanhCong(dl)); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } } }
public object GetPhanQuyenLoaiBaiDang() { { string Token = lc.GetHeader(Request); LoginData loginData = lc._GetInfoUser(Token); if (loginData == null) { return(JsonResultCommon.DangNhap()); } int status = 0; string Id = ""; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = ""; DataTable dt_token = new DataTable(); try { Conds.Add("id_user", loginData.Id); //Conds.Add("password", Pass); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { //dt = cnn.CreateDataTable("select * from TBL_NHOM_QUYEN_LOAIBAIDANG, TBL_NHOM_QUYEN_USER, TBL_LOAIBAIDANG where TBL_NHOM_QUYEN_LOAIBAIDANG.ID_QUYEN = TBL_NHOM_QUYEN_USER.ID_QUYEN and TBL_NHOM_QUYEN_LOAIBAIDANG.ID_LOAIBAIDANG = TBL_LOAIBAIDANG.ID_LOAIBAIDANG and ID_USER =@id_user", Conds); //dt_token = cnn.CreateDataTable("select * from LoginSection where Token = @token and Id = @Id_nv", Conds); dt = cnn.CreateDataTable("select * from TBL_NHOM_QUYEN_LOAIBAIDANG as qbd,TBL_LOAIBAIDANG as loai where qbd.ID_LOAIBAIDANG = loai.ID_LOAIBAIDANG and ID_USER =@id_user", Conds); dr = dt.Select(); } var data = from r in dr.AsEnumerable() select new { Id_LoaiDang = r["ID_LOAIBAIDANG"], TenLoaiDang = r["TENLOAIBAIDANG"], Icon_BaiDang = r["LINK_ICON_BAIDANG"], Icon_app = r["ICON_APP"], check = true, }; return(JsonResultCommon.ThanhCong(data)); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } } }
public object UpdateThongDiep(Models.ThongDiepCEO data) { int status = 0; string Id = ""; int id_group = 0; string Token = ""; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = "", link = ""; Hashtable val = new Hashtable(); Hashtable val_member = new Hashtable(); DataTable dt_token = new DataTable(); DataTable lastid = new DataTable(); string sqlq = ""; try { using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { val.Add("TIEUDE", data.title); val.Add("NOIDUNG", data.noidung); Conds.Add("ID_THONGDIEP", data.id_thongdiep); if (cnn.Update(val, Conds, "TBL_THONGDIEPCEO") < 0) { return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError)); } } return(JsonResultCommon.ThanhCong()); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } }
public object UpdateGhim(int id_user, int id_thongdiep) { int status = 0; string Id = ""; int id_group = 0; string Token = ""; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = "", link = ""; Hashtable val = new Hashtable(); Hashtable val_member = new Hashtable(); DataTable dt_token = new DataTable(); DataTable lastid = new DataTable(); string sqlq = ""; try { using (DpsConnection cnn = new DpsConnection("ConnectSQLMXH", true)) { val.Add("COL_DISABLE", false); Conds.Add("ID_THONGDIEP", id_thongdiep); if (cnn.Update(val, Conds, "TBL_THONGDIEPCEO") < 0) { return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError)); } } return(JsonResultCommon.ThanhCong()); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } }
public object UpdateGroup(Models.Group.Group data) { int status = 0; string Id = ""; int id_group = 0; string Token = ""; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = "", link = ""; Hashtable val = new Hashtable(); Hashtable val_member = new Hashtable(); DataTable dt_token = new DataTable(); DataTable lastid = new DataTable(); try { val.Add("TEN_GROUP", data.ten_group); val.Add("UPDATE_DATE", DateTime.Now.ToString("MM/dd/yyyy HH:mm")); val.Add("UPDATE_BY", data.CreatedBy); Conds.Add("ID_GROUP", data.id_group); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { if (cnn.Update(val, Conds, "TBL_GROUP") < 0) { return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError)); } } return(JsonResultCommon.ThanhCong()); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } }
public BaseModel <object> DS_ThanhVien_Group(int id_group, [FromBody] QueryRequestParams p) { string Token = lc.GetHeader(Request); LoginData loginData = lc._GetInfoUser(Token); if (loginData == null) { return(JsonResultCommon.DangNhap()); } try { using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { Dictionary <string, string> _sortableFields = new Dictionary <string, string> { { "Username", "Username" }, //{ "DonViTinh", "DonViTinh" } }; Panigator v_panigator = null; IDictionary <string, string> v_dic_keyFilter = new Dictionary <string, string> { { "Username", "Username" }, //{ "DonViTinh", "DonViTinh"}, }; string _select = "", _sqlQuery = "", v_str_paginate = "", _orderBy = "", _whereCondition = ""; SqlConditions _cond = new SqlConditions(); #region Filter, sort, paganitor //filter request have to right and enough , same in code if (p.Filter != null) { if (p.Filter.Count > 0) { var listKeySearch = p.Filter.Where(x => !v_dic_keyFilter.ContainsKey(x.Key)).Select(q => q.Key).ToList(); if (listKeySearch != null && listKeySearch.Count > 0) { return(JsonResultCommon.NotData()); } foreach (string _filter in p.Filter.Keys) { if (!string.IsNullOrEmpty(p.Filter[_filter])) { foreach (string vl in p.Filter.Values) { //_whereCondition += " AND " + v_dic_keyFilter[_filter] + " = @" + _filter; _whereCondition += " AND " + v_dic_keyFilter[_filter] + " LIKE'%"; _whereCondition += vl; _whereCondition += "%'"; _cond.Add(_filter, p.Filter[_filter]); } } } } } //sort column in datatable if (p.Sort != null) { if (!string.IsNullOrEmpty(p.Sort.ColumnName) && v_dic_keyFilter.ContainsKey(p.Sort.ColumnName)) { _orderBy = v_dic_keyFilter[p.Sort.ColumnName] + " " + (p.Sort.Direction.ToLower().Equals("asc") ? "asc" : "desc"); } } int page_index = 0; //set up panigator for datatable if (p.Panigator != null) { //v_str_paginate = $@" OFFSET @PageSize * (@PageNumber - 1) ROWS FETCH NEXT @PageSize ROWS ONLY;"; //// offset fetch là các tùy chọn của mệnh đề order by //_cond.Add("PageSize", p.Panigator.PageSize); //_cond.Add("PageNumber", p.Panigator.PageIndex); page_index = p.Panigator.PageIndex; } #endregion _sqlQuery = $@" select ID_GROUP, U.ID_USER, QUYEN_ADMIN , CREATE_DATE, IDNV, UserName, AVATAR from TBL_GROUPMEMBER AS G, TBL_Account AS U WHERE G.ID_USER = U.ID_USER and ID_GROUP=" + id_group + "" + _whereCondition + ""; DataTable _datatable = cnn.CreateDataTable(_sqlQuery, _cond); int _countRows = _datatable.Rows.Count; if (cnn.LastError != null || _datatable == null) { return(JsonResultCommon.NotData()); } if (_datatable.Rows.Count == 0) { return(JsonResultCommon.NotData()); } else { if (page_index == 0) { p.Panigator.PageSize = _countRows; } v_panigator = new Panigator(p.Panigator.PageIndex, p.Panigator.PageSize, _datatable.Rows.Count); } var _data = from r in _datatable.AsEnumerable().Skip((p.Panigator.PageIndex - 1) * p.Panigator.PageSize).Take(p.Panigator.PageSize).ToList() select new { Id_group = r["ID_GROUP"], id_user = r["ID_USER"], id_nv = r["IDNV"], Username = r["UserName"], quyen_group = r["QUYEN_ADMIN"], create_date = r["CREATE_DATE"], hinhanh = r["AVATAR"], Avatar = LiteController.genLinkAvatar(_config.LinkAPI, r["AVATAR"]), }; return(JsonResultCommon.ThanhCong(_data, v_panigator)); } } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } }
public async Task <object> UpdateAnhBia(int id_canhan, [FromBody] Models.ImageModel data) { DataTable lastid = new DataTable(); DataRow[] dr; string Id = ""; Hashtable val = new Hashtable(); //!string.IsNullOrEmpty(data.image.ToString()) //Data_API_MXH.Assets.Common.getDomain(); if (data.image != null) { string base64 = data.image.ToString(); string filename = data.name; int so = 0; int baidang; try { string x = ""; var fl_name = UploadHelper.UploadImage(base64, filename, null, _hostingEnvironment.ContentRootPath, ref x, true); try { //Conds.Add("email", Email); //Conds.Add("password", Pass); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { SqlConditions Conds = new SqlConditions(); Thread.Sleep(500); val.Add("AnhBia", fl_name); Conds.Add("ID_CANHAN", id_canhan); if (cnn.Update(val, Conds, "TBL_TRANGCANHAN") < 0) { return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError)); } } return(JsonResultCommon.ThanhCong()); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } } return(JsonResultCommon.ThatBai("Cập nhật thất bại")); }
public async Task <object> UpdateAvatarUser([FromBody] Models.ImageModel data) { string Token = lc.GetHeader(Request); LoginData loginData = lc._GetInfoUser(Token); if (loginData == null) { return(JsonResultCommon.DangNhap()); } DataTable lastid = new DataTable(); DataRow[] dr; string Id = ""; Hashtable val = new Hashtable(); //!string.IsNullOrEmpty(data.image.ToString()) //Data_API_MXH.Assets.Common.getDomain(); if (data.image != null) { string base64 = data.image.ToString(); string filename = data.name; int so = 0; int baidang; try { string x = ""; var fl_name = UploadHelper.UploadImageAvatar(base64, filename, null, _hostingEnvironment.ContentRootPath, ref x, true); try { //Conds.Add("email", Email); //Conds.Add("password", Pass); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { SqlConditions Conds = new SqlConditions(); Thread.Sleep(500); val.Add("AVATAR", fl_name); Conds.Add("ID_USER", loginData.Id); if (cnn.Update(val, Conds, "TBL_Account") < 0) { return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError)); } } return(JsonResultCommon.ThanhCong()); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } } return(JsonResultCommon.ThatBai("Cập nhật thất bại")); }
/// <summary> /// Cập nhật quy trình theo bước<para/> /// Quy trình kết thúc khi next=-1 /// https://dpscomvn.visualstudio.com/Webcore%20version%202/_workitems/edit/16344/ /// </summary> /// <param name="IdStep"></param> /// <param name="Next"></param> /// <param name="UserID"></param> /// <param name="note"></param> /// <returns></returns> public bool Update(int IdStep, int Next, long UserID, string note, Boolean IsComeBack = false) { SqlConditions cond = new SqlConditions(); cond.Add(new SqlCondition("Id", Id)); cond.Add(new SqlCondition("IdStep", IdStep)); cond.Add(new SqlCondition("Next", Next)); cond.Add(new SqlCondition("Passed", 0)); cond.Add(new SqlCondition("IsComeBack", IsComeBack)); string sql = @"select * from DP_Process where Id = @Id and IdStep=@IdStep "; sql += " select IdRow from DP_Process p where Id = @Id and IdStep=@IdStep and Next=@Next and IsComeBackPro = @IsComeBack and (select count(*) from DP_Process_Detail d where p.IdRow=d.IdProcess and Checked=1 and Passed=0)=0"; sql += " select * from Tbl_PhanAnhGopY where IsDel=0 and Id=@Id"; DataSet ds = cnn.CreateDataSet(sql, cond); if (ds == null) { Error = "Có gì đó không đúng, vui lòng thử lại sau"; return(false); } if (ds.Tables[2] == null || ds.Tables[2].Rows.Count == 0) { Error = "Phản ánh không tồn tại"; return(false); } if (ds.Tables[0] == null || ds.Tables[0].Rows.Count == 0 || ds.Tables[1] == null || ds.Tables[1].Rows.Count == 0) { Error = "Không tìm thấy bước xử lý hoặc bước xử lý đã được thực hiện"; return(false); } DateTime now = DateTime.Now; DataTable dt = ds.Tables[0]; foreach (DataRow dr in dt.Rows) { string idProcess = dr["IdRow"].ToString(); //Đánh dấu đã xử lý các DP_Process_Detail này Hashtable valPassed = new Hashtable(); valPassed.Add("Passed", 1); if (IdLS == 0) { valPassed.Add("IdLS", DBNull.Value); } else { valPassed.Add("IdLS", IdLS); } valPassed.Add("CheckDate", now); cnn.Update(valPassed, new SqlConditions() { { "IdProcess", idProcess }, { "Passed", 0 } }, "DP_Process_Detail"); } ; //cập nhật checker cho process này vào bảng DP_Process_Detail Hashtable val = new Hashtable(); val.Add("Checked", 1); val.Add("CheckNote", note); cnn.Update(val, new SqlConditions() { { "IdProcess", ds.Tables[1].Rows[0][0].ToString() }, { "Checker", UserID } }, "DP_Process_Detail"); //tìm checkers tiếp theo khi chưa hoàn tất if (Next != -1) { List <string> lstUserPos = new List <string>(); string lstUser = ""; sql = "exec sp_FindXuLyTiepTheo_Checker @Id ,@IdStep ,@Next,@IsComeBack "; DataSet dsNext = cnn.CreateDataSet(sql, new SqlConditions { { "Id", Id }, { "IdStep", IdStep }, { "Next", Next }, { "IsComeBack", IsComeBack } }); DataTable dtNext = dsNext.Tables[0]; foreach (DataRow dr in dtNext.Rows)//1, 3 IdStep=2 { List <string> lst = GetCheckers(dr["IdStep"].ToString(), dr["Next"].ToString(), Convert.ToBoolean(dr["IsComeBackPro"])); if (!string.IsNullOrEmpty(Error)) { return(false); } if (lst.Count > 0 && dr["IdForm"].ToString() != "6") { ///huy thi k can thong bao lstUserPos.AddRange(lst); } foreach (string id in lst) { Hashtable val1 = new Hashtable(); val1["IdProcess"] = dr["IdRow"]; val1["Checker"] = id; cnn.Insert(val1, "DP_Process_Detail"); if (cnn.LastError != null) { return(false); } } } if (lstUserPos.Count > 0) { lstUserPos = lstUserPos.Distinct().ToList(); } lstUser = string.Join(",", lstUserPos); if (string.IsNullOrEmpty(lstUser)) { string str58 = @" select distinct UserID from Tbl_User_GroupUser gu inner join Dps_UserGroupRoles gr on gu.IdGroupUser=gr.IdGroupUser inner join Dps_Roles on IdRole = gr.IDGroupRole inner join DPS_User u on u.UserID = gu.IdUser inner join v_QuyenUser qu on qu.IdUser=u.UserID and qu.IdRole=Dps_Roles.IdRole where Dps_Roles.IdRole = 1084 and Deleted = 0 and u.Active =1 "; DataTable dtUser58 = cnn.CreateDataTable(str58); var temp = dtUser58.AsEnumerable().Select(x => x["UserID"].ToString()).ToList(); lstUser = string.Join(",", temp); } } return(true); }