public static object CheckApproveRight(string strUsername, string strPassword, string strPageName) { //First validate user at UIP //then check permission for this page here MA_USER user = UserUIP.ValidateUser(SessionInfo, strUsername, strPassword , Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings[AppSettingName.AD_LOGIN])); if (user == null) { return(new { Result = "ERROR", Message = "Invalid username or password." }); } else { //Check Permission List <PermisionModel> permissions = ProfileFunctionalUIP.GetPermissionByProfileID(user.USER_PROFILE_ID); var query = permissions.FirstOrDefault(p => p.FunctionalCode.Contains(strPageName)); if (query == null || !query.IsApprovable) { return(new { Result = "ERROR", Message = "User has no right to approve limit." }); } else { return(new { Result = "OK", Message = "" }); } } }
public static object Update(SessionInfo sessioninfo, MA_USER record, int intCheckAD) { try { UserBusiness _userBusiness = new UserBusiness(); if (intCheckAD == 1) { bool validUser = LDAPHelper.UserExists(record.USERCODE); if (!validUser) { return new { Result = "ERROR", Message = "User is not exist." } } ; } record.DEPARTMENT = record.DEPARTMENT.ToUpper(); record.NAME = record.NAME.ToUpper(); record.USER_OPICS = record.USER_OPICS.ToUpper(); record.USERCODE = record.USERCODE.ToUpper(); record.ISACTIVE = record.ISACTIVE == null || !record.ISACTIVE.Value ? false : true; record.ISLOCKED = record.ISLOCKED == null || !record.ISACTIVE.Value ? false : true; record.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId; record.LOG.MODIFYDATE = DateTime.Now; var addedStudent = _userBusiness.UpdateUser(sessioninfo, record); return(new { Result = "OK" }); } catch (Exception ex) { return(new { Result = "ERROR", Message = ex.Message }); } }
public MA_USER UpdateUser(SessionInfo sessioninfo, MA_USER user) { using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { var checkDuplicate = unitOfWork.MA_USERRepository.GetAll().FirstOrDefault(p => p.USERCODE.ToLower() == user.USERCODE.ToLower() && p.ID != user.ID); if (checkDuplicate != null) { throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA); } var foundUser = unitOfWork.MA_USERRepository.GetAll().FirstOrDefault(p => p.ID == user.ID); if (foundUser == null) { throw this.CreateException(new Exception(), Messages.DATA_NOT_FOUND); } else { LogBusiness logBusiness = new LogBusiness(); var oldRecord = new { DEPARTMENT = foundUser.DEPARTMENT, ISACTIVE = foundUser.ISACTIVE , ISLOCKED = foundUser.ISLOCKED, NAME = foundUser.NAME , USERCODE = foundUser.USERCODE, USER_OPICS = foundUser.USER_OPICS , USER_PROFILE = foundUser.MA_USER_PROFILE.LABEL }; var newRecord = new { DEPARTMENT = user.DEPARTMENT, ISACTIVE = user.ISACTIVE , ISLOCKED = user.ISLOCKED, NAME = user.NAME , USERCODE = user.USERCODE, USER_OPICS = user.USER_OPICS , USER_PROFILE = unitOfWork.MA_USER_PROFILERepository.All().FirstOrDefault(p => p.ID == user.USER_PROFILE_ID).LABEL }; var log = logBusiness.UpdateLogging(sessioninfo, foundUser.ID, LogEvent.USER_AUDIT.ToString(), LookupFactorTables.MA_USER, oldRecord, newRecord); if (log != null) { unitOfWork.DA_LOGGINGRepository.Add(log); } foundUser.ID = user.ID; foundUser.DEPARTMENT = user.DEPARTMENT; foundUser.ISACTIVE = user.ISACTIVE; foundUser.ISLOCKED = user.ISLOCKED; foundUser.LOG.MODIFYBYUSERID = user.LOG.MODIFYBYUSERID; foundUser.LOG.MODIFYDATE = user.LOG.MODIFYDATE; foundUser.NAME = user.NAME; foundUser.USERCODE = user.USERCODE; foundUser.USER_OPICS = user.USER_OPICS; foundUser.USER_PROFILE_ID = user.USER_PROFILE_ID; unitOfWork.Commit(); } } return(user); }
public void CreateUserTest() { UserBusiness target = new UserBusiness(); // TODO: Initialize to an appropriate value SessionInfo sessioninfo = null; // TODO: Initialize to an appropriate value MA_USER user = null; // TODO: Initialize to an appropriate value MA_USER expected = null; // TODO: Initialize to an appropriate value MA_USER actual; actual = target.CreateUser(sessioninfo, user); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void GetByUserCodeTest() { UserBusiness target = new UserBusiness(); // TODO: Initialize to an appropriate value SessionInfo sessioninfo = null; // TODO: Initialize to an appropriate value string usercode = string.Empty; // TODO: Initialize to an appropriate value MA_USER expected = null; // TODO: Initialize to an appropriate value MA_USER actual; actual = target.GetByUserCode(sessioninfo, usercode); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void GetByIDTest() { UserBusiness target = new UserBusiness(); // TODO: Initialize to an appropriate value SessionInfo sessioninfo = null; // TODO: Initialize to an appropriate value Guid ID = new Guid(); // TODO: Initialize to an appropriate value MA_USER expected = null; // TODO: Initialize to an appropriate value MA_USER actual; actual = target.GetByID(sessioninfo, ID); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public static MA_USER GetByUserCode(SessionInfo sessioninfo, string usercode) { try { UserBusiness _userBusiness = new UserBusiness(); //Get data from database MA_USER user = _userBusiness.GetByUserCode(sessioninfo, usercode); //Return result to jTable return(user); } catch (Exception ex) { throw new UIPException(ex); } }
public MA_USER CreateUser(SessionInfo sessioninfo, MA_USER user) { using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { var checkDuplicate = unitOfWork.MA_USERRepository.GetByUserCode(user.USERCODE); if (checkDuplicate != null) { throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA); } LogBusiness logBusiness = new LogBusiness(); unitOfWork.DA_LOGGINGRepository.Add(logBusiness.CreateLogging(sessioninfo, user.ID, LogEvent.USER_AUDIT.ToString(), LookupFactorTables.MA_USER, "User", new { })); unitOfWork.MA_USERRepository.Add(user); unitOfWork.Commit(); } return(user); }
public static MA_USER ValidateUser(SessionInfo sessioninfo, string strUsername, string strPassword, int intADLogin) { UserBusiness _userBusiness = new UserBusiness(); try { bool validUser = true; if (intADLogin == 1) { validUser = LDAPHelper.ValidateUser(strUsername, strPassword); } if (validUser) { MA_USER user = _userBusiness.GetByUserCode(sessioninfo, strUsername); return(user); } else { return(null); } } catch (Exception ex) { throw new UIPException(ex); } //if (strUsername == "Admin") //{ // return new { Result = "OK", Message = "" }; //} //else //{ // return new { Result = "ERROR", Message = "User has no right to approve limit." }; //} }
/// <summary> /// Add the current user name to the cookie to be used when displaying at the top of the screen /// </summary> /// <param name="sessioninfo">The sessioninfo.</param> private void AddUsernameToCookie(SessionInfo sessioninfo) { HttpCookie cookie = new HttpCookie("UserName"); try { // Get the user data for the current user. //xuser userData = userUIP.GetUserLoginByID(sessioninfo, sessioninfo.CurrentUserID.ToString()); MA_USER userData = UserUIP.GetByUserCode(sessioninfo, sessioninfo.UserLogon); // Build the concatenation of the first and last names. // Add the user name to the cookie. cookie.Value = userData.USERCODE; Context.Response.Cookies.Add(cookie); } catch (Exception ex) { throw ex; } finally { cookie = null; } }
public static object UpdateUser(MA_USER record) { return(UserUIP.Update(SessionInfo, record , Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings[AppSettingName.CHECK_AD_USER]))); }