// GET: Login public ActionResult Index(LoginStateEnum loginState = LoginStateEnum.Not_Set) { try { LoginState state = new LoginState { LoginStateValue = loginState }; return(View(state)); } catch (Exception e) { log.Error("Exception Caught" + e.ToString()); TempData["errorLog"] = new ErrorLog(e); return(RedirectToAction("ShowError", "Error")); } }
/// <summary> /// 用户登录 /// </summary> /// <param name="_userName"></param> /// <param name="_pwd"></param> public LoginStateEnum Login(string _userName, string _pwd) { LoginStateEnum _state = LoginStateEnum.Error; //处理内容开始 KPS.BLL.UserInfoManager manager = new BLL.UserInfoManager(); DataSet _dt = manager.GetList(string.Format("userName='******'", _userName)); if (_dt != null && _dt.Tables[0].Rows.Count > 0) { int thisuserID = 0; foreach (DataRow _row in _dt.Tables[0].Rows) { if (_row["userPwd"].ToString() == _pwd) { thisuserID = Convert.ToInt32(_row["ID"]); _state = LoginStateEnum.Correct; break; } } if (_state == LoginStateEnum.Correct) { userinfo = new LoginUserInfo(_userName); userinfo.UserID = thisuserID; if (_userName == "admin") { userinfo.IsAdministrator = false; userinfo.UserName = "******"; } //保存登录记录 LoginRecordsManager.Instance.SaveRecord(new LoginRecordsInfo(_userName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))); } } else { _state = LoginStateEnum.NoExt; } //处理内容结束 return(_state); }
/// <summary> /// 获取登录状态 /// </summary> /// <param name="state"></param> /// <returns></returns> public static string GetLoginState(LoginStateEnum state) { try { switch (state) { case LoginStateEnum.Default: return("默认"); case LoginStateEnum.Check: return("审核"); case LoginStateEnum.Edit: return("编辑"); } return(string.Empty); } catch (Exception ex) { CYQ.Data.Log.WriteLogToTxt(ex.Message + Environment.NewLine + ex.StackTrace); return(string.Empty); } }
public LoginMainState(LoginStateEnum stateType, LoginManager controller) : base(stateType, controller) { }