/// <summary> /// 登录验证 /// </summary> /// <param name="username">用户名</param> /// <param name="password">密码</param> /// <returns></returns> public RegisterUserEntity CheckLogin(string username, string password) { RegisterUserEntity userEntity = service.CheckLogin(username); if (userEntity != null) { if (userEntity.EnabledMark == 1) { if (userEntity.VerifyMark == 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; service.UpdateEntity(userEntity); return(userEntity); } else { throw new Exception("密码和账户名不匹配"); } } else if (userEntity.VerifyMark == 0) { throw new Exception("账户正在审核中"); } else { throw new Exception("账户审核未通过,请联系管理员"); } } else { throw new Exception("账户名被系统锁定,请联系管理员"); } } else { throw new Exception("账户不存在,请重新输入"); } }