/// <summary> /// 登录验证 /// </summary> /// <param name="username">用户名</param> /// <param name="password">密码</param> /// <returns></returns> public UserEntity CheckLogin(string username, string password) { UserEntity userEntity = InstanceDAL.CheckLogin(username); if (userEntity != null) { if (userEntity.EnabledMark == 1) { string dbPassword = Md5Helper.MD5(DESEncrypt.Encrypt(password.ToLower(), userEntity.Secretkey).ToLower(), 32).ToLower(); if (dbPassword == userEntity.Password) { DateTime LastVisit = DateTime.Now; int LogOnCount = (userEntity.LogOnCount).ToInt() + 1; if (userEntity.LastVisit != null) { userEntity.PreviousVisit = userEntity.LastVisit.ToDate(); } userEntity.LastVisit = LastVisit; userEntity.LogOnCount = LogOnCount; userEntity.UserOnLine = 1; InstanceDAL.UpdateEntity(userEntity); return(userEntity); } else { throw new Exception("密码和账户名不匹配"); } } else { throw new Exception("账户名被系统锁定,请联系管理员"); } } else { throw new Exception("账户不存在,请重新输入"); } }
/// <summary> /// 修改用户信息 /// </summary> /// <param name="userEntity">实体对象</param> public void UpdateEntity(UserEntity userEntity) { InstanceDAL.UpdateEntity(userEntity); }