public Sys_AccountInfo CheckLogin(Sys_AccountInfo entity) { Sys_AccountInfo Sys_AccountInfo_Entity_ = service.GetUserInfoEntity(entity); if (Sys_AccountInfo_Entity_ != null) { return(Sys_AccountInfo_Entity_); } else { throw new Exception("密码不正确,请重新输入"); } }
public ActionResult CheckLogin(string username, string password) { Sys_AccountInfo Sys_AccountInfo_Entity_ = new Sys_AccountInfo(); Sys_AccountInfo_Entity_.PF_UName = username; Sys_AccountInfo_Entity_.PF_UPwd = password; Sys_Log_Entity sys_Log_Entity = new Sys_Log_Entity(); //记录日志 sys_Log_Entity.PF_ModelName = "访客登陆"; sys_Log_Entity.PF_Type = DbLogType.Login.ToString(); //枚举操作类型 try { var userEntity = new UserApp().CheckLogin(Sys_AccountInfo_Entity_); if (userEntity != null) { OperatorModel operatorModel = new OperatorModel(); operatorModel.UserId = userEntity.PF_ID; operatorModel.UserName = userEntity.PF_UName; operatorModel.LoginIPAddress = Net.Ip; operatorModel.LoginIPAddressName = Net.GetLocation(operatorModel.LoginIPAddress); operatorModel.LoginTime = DateTime.Now; operatorModel.LoginToken = DESEncrypt.Encrypt(Guid.NewGuid().ToString()); OperatorProvider.Provider.AddCurrent(operatorModel); return(Content(new AjaxResult { state = ResultType.success.ToString(), message = "登录成功。" }.ToJson())); } else { return(Content(new AjaxResult { state = ResultType.error.ToString(), message = "登录失败。" }.ToJson())); } } catch (Exception ex) { return(Content(new AjaxResult { state = ResultType.error.ToString(), message = "登录失败。" }.ToJson())); } }
public Sys_AccountInfo GetUserInfoEntity(Sys_AccountInfo item) { return(db.Queryable <Sys_AccountInfo>().First(x => x.PF_UName == item.PF_UName && x.PF_UPwd == item.PF_UPwd)); }