/// <summary> /// 登录验证 /// </summary> /// <param name="username">用户名</param> /// <param name="password">密码</param> /// <returns></returns> public AppUserEntity CheckLogin(string username, string password) { AppUserEntity userEntity = service.CheckLogin(username); if (userEntity != null) { if (!(bool)userEntity.IsLocked) { //string clientdbPassword = Md5Helper.MD5(DESEncrypt.Decrypt(password, userEntity.Password).ToLower(), 32).ToLower(); string dbPassword = CEncoder.Decode(userEntity.Password); dbPassword = Md5Helper.MD5(dbPassword, 32).ToLower(); if (dbPassword == password) { DateTime LastVisit = DateTime.Now; //int LogOnCount = (userEntity.LogOnCount).ToInt() + 1; //if (userEntity.LastLoginTime != null) //{ // userEntity.LastLoginTime = userEntity.LastLoginTime.ToDate(); //} //userEntity.LastLoginTime = LastLoginTime; //userEntity.LogOnCount = LogOnCount; //userEntity.UserOnLine = 1; service.UpdateEntity(userEntity); return(userEntity); } else { throw new Exception("密码和账户名不匹配"); } } else { throw new Exception("账户名被系统锁定,请联系管理员"); } } else { throw new Exception("账户不存在,请重新输入"); } }