public ActionResult Index(FormCollection form) { try { Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetExpires(DateTime.Today.AddYears(-2)); //调用Mac数据缓存 WebCommon.GetCacheMac(false); //获取生产商信息缓存 //WebCommon.GetCacheBusName(); WebCommon.GetCacheLoca(); WebCommon.GetCacheMacAllList(); string userName = form["txtName"].ToString(); string pwd = StringFilter.getSHA1Code(form["txtPwd"].ToString()); if (Session["ValidateStr"] == null) { ViewBag.errscript = "alert('验证码过期!')"; } else { if (form["txtValidator"].ToString().ToLower() == Session["ValidateStr"].ToString().ToLower()) { //string userName = "******"; //string userName = form["txtName"].ToString().Trim(); //string pwd = StringFilter.getSHA1Code(form["txtPwd"].ToString().Trim()); //string pwd = StringFilter.getSHA1Code("123456").Trim(); UserInfoDAL udal = new UserInfoDAL(); UserInfo user = udal.GetUserInfoDSByLogin(userName, pwd); if (user != null) { Session["userInfo"] = user; log.UID = user.ID; log.Module = "登录管理"; log.What = "登录成功,用户名:" + user.UserName + ";用户Id:" + user.ID; udal.UpdateListtime(user.ID); ChangeValue.AddOpLog(log); new OPLogDAL().InsertLog(log); user.PowerPathList = udal.GetUserPowerFSListToJid(user.JId); IEnumerable <Sys_UserPowerInfo> IElist = user.PowerPathList.OrderBy(a => a.Indexs); user.PowerPathList = IElist.ToList(); user.PowerList = udal.GetUserShowPageByJid(user.JId); List <Sys_UserPowerInfo> sys_list = user.PowerList.Where(a => a.FilePath.Equals("Home/Index")).ToList(); if (sys_list != null && sys_list.Count() > 0) { return(Redirect(Url.Content("~/Home/Index" + ""))); } else { int pid = user.PowerList.Where(A => A.Pid == 0).OrderBy(A => A.Indexs).First().SpId;; string url = user.PowerList.Where(m => m.Pid == pid).OrderBy(m => m.Indexs).First().FilePath; if (!string.IsNullOrEmpty(url)) { return(Redirect(Url.Content("~/" + url + ""))); } else { return(Content("<script>alert('抱歉,没有任何权限');window.location.href='" + Url.Content("~/Login/Index") + "';</script>")); } } } else { Session["ValidateStr"] = null; //return Content("alert('登录失败')"); log.Module = "登录管理"; log.What = "登录失败,用户名:" + userName; ViewBag.errscript = "alert('登录失败')"; } } else { Session["ValidateStr"] = null; ViewBag.errscript = "alert('验证码输入错误,请重新输入')"; } } } catch (SqlException sqlex) { Logger.ErrorLog(sqlex, null); } catch (Exception ex) { Logger.ErrorLog(ex, null); } return(View()); }