/// <summary> /// 登录验证 /// </summary> /// <param name="account">账户</param> /// <param name="password">密码</param> /// <param name="pwd"></param> /// <param name="token"></param> /// <returns></returns> public ActionResult CheckLogin(string account, string password, string pwd, string token) { account = HttpUtility.UrlDecode(account, Encoding.UTF8); string msg = ""; try { IPScanerHelper objScan = new IPScanerHelper(); string ipAddress = Net.GetIPAddress(); objScan.IP = ipAddress; objScan.DataPath = Server.MapPath("~/Resource/IPScaner/QQWry.Dat"); string ipAddressName = objScan.IPLocation(); VerifyIPAddress(account, ipAddress, ipAddressName, token); //系统管理 if (account == Config.GetValue("CurrentUserName")) { if (Config.GetValue("CurrentPassword") == password) { var us = DataFactory.Database().FindEntity <BaseUser>("1109001"); IManageUser imanageuser = new IManageUser { UserId = us.UserId, Account = us.Account, UserName = "******", Gender = "男", Code = "System", LogTime = DateTime.Now, CompanyId = us.CompanyId, DepartmentId = us.DepartmentId, IPAddress = ipAddress, IPAddressName = ipAddressName, IsSystem = true }; ManageProvider.Provider.AddCurrent(imanageuser); //对在线人数全局变量进行加1处理 HttpContext rq = System.Web.HttpContext.Current; rq.Application["OnLineCount"] = (int)rq.Application["OnLineCount"] + 1; msg = "3";//验证成功 BaseSysLogBll.Instance.WriteLog(account, OperationType.Login, "1", "登陆成功、IP所在城市:" + ipAddressName); } else { return(Content("4")); } } else { var outmsg = ""; BaseUser baseUser = _baseUserbll.UserLogin(account, password, pwd, out outmsg); switch (outmsg) { case "-1": //账户不存在 msg = "-1"; BaseSysLogBll.Instance.WriteLog(account, OperationType.Login, "-1", "账户不存在、IP所在城市:" + ipAddressName); break; case "lock": //账户锁定 msg = "2"; BaseSysLogBll.Instance.WriteLog(account, OperationType.Login, "-1", "账户锁定、IP所在城市:" + ipAddressName); break; case "error": //密码错误 msg = "4"; BaseSysLogBll.Instance.WriteLog(account, OperationType.Login, "-1", "密码错误、IP所在城市:" + ipAddressName); break; case "succeed": //验证成功 CheckOnLine(account); IManageUser imanageuser = new IManageUser { UserId = baseUser.UserId, Account = baseUser.Account, UserName = baseUser.RealName, Gender = baseUser.Gender, Password = baseUser.Password, Code = baseUser.Code, Secretkey = baseUser.Secretkey, LogTime = DateTime.Now, CompanyId = baseUser.CompanyId, DepartmentId = baseUser.DepartmentId }; imanageuser.ObjectId = _baseObjectuserrelationbll.GetObjectId(imanageuser.UserId); imanageuser.IPAddress = ipAddress; imanageuser.IPAddressName = ipAddressName; imanageuser.IsSystem = false; ManageProvider.Provider.AddCurrent(imanageuser); //对在线人数全局变量进行加1处理 HttpContext rq = System.Web.HttpContext.Current; rq.Application["OnLineCount"] = (int)rq.Application["OnLineCount"] + 1; msg = "3"; //验证成功 BaseSysLogBll.Instance.WriteLog(account, OperationType.Login, "1", "登陆成功、IP所在城市:" + ipAddressName); break; default: break; } } } catch (Exception ex) { msg = ex.Message; } return(Content(msg)); }
/// <summary> /// 登录验证 /// </summary> /// <param name="account">账户</param> /// <param name="password">密码</param> /// <returns></returns> public ActionResult CheckLogin(string account, string password, string token) { string msg = ""; try { IPScanerHelper objScan = new IPScanerHelper(); string IPAddress = NetHelper.GetIPAddress(); objScan.IP = IPAddress; objScan.DataPath = Server.MapPath("~/Resource/IPScaner/QQWry.Dat"); string IPAddressName = objScan.IPLocation(); string outmsg = ""; VerifyIPAddress(account, IPAddress, IPAddressName, token); //系统管理 if (account == ConfigHelper.AppSettings("CurrentUserName")) { if (ConfigHelper.AppSettings("CurrentPassword") == password) { IManageUser imanageuser = new IManageUser(); imanageuser.UserId = "System"; imanageuser.Account = "System"; imanageuser.UserName = "******"; imanageuser.Gender = "男"; imanageuser.Code = "System"; imanageuser.LogTime = DateTime.Now; imanageuser.CompanyId = "系统"; imanageuser.DepartmentId = "系统"; imanageuser.IPAddress = IPAddress; imanageuser.IPAddressName = IPAddressName; imanageuser.IsSystem = true; imanageuser.ObjectId = _baseObjectuserrelationbll.GetObjectId(imanageuser.UserId); ManageProvider.Provider.AddCurrent(imanageuser); //对在线人数全局变量进行加1处理 HttpContext rq = System.Web.HttpContext.Current; rq.Application["OnLineCount"] = (int)rq.Application["OnLineCount"] + 1; msg = "3"; //验证成功 BaseSysLogBll.Instance.WriteLog(account, OperationType.Login, "1", "登陆成功、IP所在城市:" + IPAddressName); } else { return(Content("4")); } } else { Base_User baseUser = _baseUserbll.UserLogin(account, password, out outmsg); switch (outmsg) { case "-1": //账户不存在 msg = "-1"; BaseSysLogBll.Instance.WriteLog(account, OperationType.Login, "-1", "账户不存在、IP所在城市:" + IPAddressName); break; case "lock": //账户锁定 msg = "2"; BaseSysLogBll.Instance.WriteLog(account, OperationType.Login, "-1", "账户锁定、IP所在城市:" + IPAddressName); break; case "error": //密码错误 msg = "4"; BaseSysLogBll.Instance.WriteLog(account, OperationType.Login, "-1", "密码错误、IP所在城市:" + IPAddressName); break; case "succeed": //验证成功 IManageUser imanageuser = new IManageUser(); imanageuser.UserId = baseUser.UserId; imanageuser.Account = baseUser.Account; imanageuser.UserName = baseUser.RealName; imanageuser.Gender = baseUser.Gender; imanageuser.Password = baseUser.Password; imanageuser.Code = baseUser.Code; imanageuser.Secretkey = baseUser.Secretkey; imanageuser.LogTime = DateTime.Now; imanageuser.CompanyId = baseUser.CompanyId; imanageuser.DepartmentId = baseUser.DepartmentId; imanageuser.ObjectId = _baseObjectuserrelationbll.GetObjectId(imanageuser.UserId); imanageuser.IPAddress = IPAddress; imanageuser.IPAddressName = IPAddressName; imanageuser.IsSystem = false; ManageProvider.Provider.AddCurrent(imanageuser); //对在线人数全局变量进行加1处理 HttpContext rq = System.Web.HttpContext.Current; rq.Application["OnLineCount"] = (int)rq.Application["OnLineCount"] + 1; msg = "3"; //验证成功 BaseSysLogBll.Instance.WriteLog(account, OperationType.Login, "1", "登陆成功、IP所在城市:" + IPAddressName); break; default: break; } } } catch (Exception ex) { msg = ex.Message; } return(Content(msg)); }