public bool XoaListTheoID(List <int> listID) { bool kq = true; Entities entities = ContextFactory.GetInstance(); try { using (TransactionScope trans = new TransactionScope()) { foreach (int id in listID) { HT_NSD obj = new HT_NSD(); obj = entities.HT_NSD.FirstOrDefault(e => e.ID == id); entities.HT_NSD.DeleteObject(obj); entities.SaveChanges(); } trans.Complete(); } } catch (System.Exception ex) { kq = false; LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex); throw ex; } finally { entities = null; } return(kq); }
public HT_NSD Sua(HT_NSD obj) { HT_NSD kq = null; Entities entities = ContextFactory.GetInstance(); EntityKey key = null; object original = null; try { key = entities.CreateEntityKey(ENTITY_SET_NAME, obj); if (entities.TryGetObjectByKey(key, out original)) { entities.ApplyCurrentValues(key.EntitySetName, obj); } entities.SaveChanges(); kq = obj; } catch (System.Exception ex) { kq = null; LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex); throw ex; } finally { entities = null; } return(kq); }
public bool ThoaiDuyetListTheoID(List <int> listID) { bool kq = true; Entities entities = ContextFactory.GetInstance(); try { using (TransactionScope trans = new TransactionScope()) { foreach (int id in listID) { HT_NSD obj = new HT_NSD(); obj = entities.HT_NSD.FirstOrDefault(e => e.ID == id); obj.TTHAI_NVU = BusinessConstant.TrangThaiNghiepVu.THOAI_DUYET.layGiaTri(); entities.SaveChanges(); } trans.Complete(); } } catch (System.Exception ex) { kq = false; LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex); throw ex; } finally { entities = null; } return(kq); }
public HT_NSD GetNguoiDung(string userName) { HT_NSD htNguoiDungTemp = null; try { Entities entities = ContextFactory.GetInstance(); htNguoiDungTemp = entities.HT_NSD.FirstOrDefault(e => e.MA_DANG_NHAP.Equals(userName)); //htNguoiDungTemp = entities.HT_NSD.Where(e => e.MA_DANG_NHAP == userName && e.MAT_KHAU == passWord).First(); return(htNguoiDungTemp); } catch (System.Exception ex) { LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex); throw ex; } }
public HT_NSD doLogin(string userName, string passWord) { HT_NSD htNguoiDung = null; // Mã hóa mật khẩu string passWordEncoding = passWord; try { htNguoiDung = GetNguoiDung(userName, passWord); return(htNguoiDung); } catch (Exception ex) { LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex); throw ex; } }
public HT_NSD GetByTenDangNhap(string tenDangNhap) { HT_NSD kq = null; try { using (Entities entities = ContextFactory.GetInstance()) { kq = entities.HT_NSD.FirstOrDefault(e => e.MA_DANG_NHAP.Equals(tenDangNhap)); return(kq); } } catch (System.Exception ex) { kq = null; LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex); throw ex; } }
public HT_NSD GetById(int id) { HT_NSD kq = null; try { using (Entities entities = ContextFactory.GetInstance()) { kq = entities.HT_NSD.FirstOrDefault(e => e.ID == id); return(kq); } } catch (System.Exception ex) { kq = null; LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex); throw ex; } }
public HT_NSD GetNguoiDung(string userName, string passWord) { HT_NSD htNguoiDungTemp = null; try { //mFinanceCoreEntities context = ContextFactory.GetInstance(); //mFinanceCoreEntities context = new mFinanceCoreEntities(); var context = new Entities(); htNguoiDungTemp = context.HT_NSD.FirstOrDefault(e => e.MA_DANG_NHAP == userName && e.MAT_KHAU == passWord); if (htNguoiDungTemp != null) { return(htNguoiDungTemp); } } catch (System.Exception ex) { LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogLevel.Error, ex); } return(htNguoiDungTemp); }
public bool Xoa(HT_NSD obj) { bool kq = true; Entities entities = ContextFactory.GetInstance(); try { entities.HT_NSD.Attach(obj); entities.HT_NSD.DeleteObject(obj); entities.SaveChanges(); } catch (System.Exception ex) { kq = false; LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex); throw ex; } finally { entities = null; } return(kq); }
public HT_NSD Them(HT_NSD obj) { HT_NSD kq = null; Entities entities = ContextFactory.GetInstance(); try { entities.HT_NSD.AddObject(obj); entities.SaveChanges(); kq = obj; } catch (System.Exception ex) { kq = null; LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex); throw ex; } finally { entities = null; } return(kq); }
/// <summary> /// Kiểm tra thông tin truy cập của NSD dựa vào địa chỉ MAC và IP. /// Trả về true nếu hợp lệ. /// Trả về false nếu không hợp lệ. /// </summary> /// <param name="objNSD"></param> /// <param name="diaChiMAC"></param> /// <param name="diaChiIP"></param> /// <returns></returns> public bool KiemTraTruyCap(HT_NSD objNSD, string diaChiMAC, string diaChiIP) { if (objNSD.HAN_CHE_TRUY_CAP.Equals(BusinessConstant.CoKhong.CO.layGiaTri())) { int hopLeMAC = 0; int hopLeIP = 0; List <HT_TRUY_CAP> lstNSD = null; List <HT_TRUY_CAP> lstNhomNSD = null; #region Kiểm tra NSD lstNSD = new DS_HT_TRUY_CAP().GetByDoiTuong(objNSD.ID, BusinessConstant.LoaiDoiTuong.NGUOI_SDUNG.layGiaTri()); hopLeMAC = KiemTraHopLeMAC(lstNSD, diaChiMAC); hopLeIP = KiemTraHopLeIP(lstNSD, diaChiIP); //Nếu cả địa chỉ MAC và IP của NSD hợp lệ -> Hợp lệ if (hopLeMAC == 1 && hopLeIP == 1) { return(true); } //Nếu chỉ địa chỉ MAC hoặc IP của NSD không hợp lệ -> Không hợp lệ else if (hopLeMAC == -1 || hopLeIP == -1) { return(false); } #endregion #region Kiểm tra nhóm người sử dụng nếu NSD chưa xác định được hợp lệ hay không List <HT_NHNSD> lstNhom = new DS_HT_NHNSD().GetByIdNSD(objNSD.ID); //Nếu người dùng không thuộc nhóm nào -> không hợp lệ if (lstNhom == null || lstNhom.Count == 0) { return(false); } //Nếu tồn tại 1 nhóm không hạn chế truy cập -> hợp lệ else if (lstNhom.Exists(e => e.HAN_CHE_TRUY_CAP.Equals(BusinessConstant.CoKhong.KHONG.layGiaTri()))) { return(true); } //Ngược lại nếu tất cả các nhóm đều hạn chế truy cập thì kiểm tra các địa chỉ mà các nhóm đã hạn chế else { List <int> lstIDNhom = lstNhom.Select(e => e.ID).ToList(); lstNhomNSD = new DS_HT_TRUY_CAP().GetByListIdDoiTuong(lstIDNhom, BusinessConstant.LoaiDoiTuong.NHOM_NGUOI_SDUNG.layGiaTri()); hopLeMAC = KiemTraHopLeMAC(lstNhomNSD, diaChiMAC); hopLeIP = KiemTraHopLeIP(lstNhomNSD, diaChiIP); //Nếu cả địa chỉ MAC và IP của NSD hợp lệ -> Hợp lệ if (hopLeMAC == 1 && hopLeIP == 1) { return(true); } //Ngược lại -> không hợp lệ else { return(false); } } #endregion } else { return(true); //Không hạn chế truy cập -> hợp lệ } }