// POST: /Login/ public JsonResult Login(JObject data) { string UserCode = data.Value <string>("user_code"); string Password = data.Value <string>("password"); string IP = data.Value <string>("ip"); string City = data.Value <string>("city"); data["user_code"] = UserCode; data["password"] = Md5Util.MD5(Password); data["LoginIP"] = IP; data["LoginCity"] = City; AppConnectionString = ConfigurationManager.ConnectionStrings["app"].ConnectionString; DataSet dt = base.RunProcedureDataSet(data, "vdp_sys_Login", "app"); //if (dt.Rows.Count > 0) var ResultID = dt.Tables[0].Rows[0]["result_id"]; var ResultMsg = (string)dt.Tables[0].Rows[0]["result_msg"]; //var loginResult = Base_UserService.Instance.Login(UserCode, Md5Util.MD5(Password), IP, City); if (ResultID.ToString() == "0") { Base_User b = new Base_User(); b.city = "";// (string)dt.Rows[0]["city"]; b.RealName = (string)dt.Tables[1].Rows[0]["real_name"]; b.DepartmentID = (int)dt.Tables[1].Rows[0]["department_id"]; b.UserId = (int)dt.Tables[1].Rows[0]["id"]; b.UserCode = (String)dt.Tables[1].Rows[0]["user_code"]; b.RoleIDs = (string)dt.Tables[1].Rows[0]["role_ids"]; b.DepartmentCode = ((int)dt.Tables[1].Rows[0]["department_id"]).ToString(); var loginer = new BaseLoginer { UserId = (int)dt.Tables[1].Rows[0]["id"], //. user.UserId, UserCode = (string)dt.Tables[1].Rows[0]["user_code"], // user.UserCode, // Password = (string)dt.Tables[1].Rows[0]["Password"],// user.Password, UserName = (string)dt.Tables[1].Rows[0]["real_name"], // user.RealName, RoleIDs = (string)dt.Tables[1].Rows[0]["role_ids"], // DepartmentCode =((int)dt.Tables[1].Rows[0]["DepartmentID"]).ToString(), Data = b, IsAdmin = false }; Session["logininfo"] = ""; //set timeout var effectiveHours = Convert.ToInt32(60 * ConfigUtil.GetConfigDecimal("LoginEffectiveHours")); //执行web登录 FormsAuth.SignIn(loginer.UserId.ToString(), loginer, effectiveHours); } else { LogHelper.Write("Login Failed!Account:" + UserCode + ",password:" + Password + "。reason:" + ResultMsg); } return(Json(new { s = ResultID, message = ResultMsg }, JsonRequestBehavior.DenyGet)); }
public JsonResult Login(JObject data) { string UserCode = data.Value <string>("username"); string Password = data.Value <string>("password"); string IP = data.Value <string>("ip"); string City = data.Value <string>("city"); Sys_User user = new Sys_User() { Code = UserCode, Password = MD5Encrypt.Encrypt(Password, 64) }; ISys_UserService bLL = DIFactory.GetService <ISys_UserService>(); var loginResult = bLL.Login(user); if (loginResult.Succeed && loginResult.ResultData != null) { //登录成功后,查询当前用户数据 user = loginResult.ResultData as Sys_User; //调用框架中的登录机制 var loginer = new BaseLoginer { UserId = 0,// user.UserId, ID = user.Id, UserCode = user.Code, Password = user.Password, UserName = user.Name, Data = user, IsAdmin = user.Explain == "管理员用户" //根据用户Explain判断。用户类型:0=未定义 1=超级管理员 2=普通用户 3=其他 }; //读取配置登录默认失效时长:小时 var effectiveHours = Convert.ToInt32(60 * ConfigUtil.GetConfigDecimal("LoginEffectiveHours")); //执行web登录 FormsAuth.SignIn(loginer.ID.ToString(), loginer, effectiveHours); log.Info("登录成功!用户:" + loginer.UserName + ",账号:" + loginer.UserCode + ",密码:---"); //设置服务基类中,当前登录用户信息 // this.CurrentBaseLoginer = loginer; //登陆后处理 //更新用户登陆次数及时间(存储过程登录,数据库已经处理) //添加登录日志 string userinfo = string.Format("用户姓名:{0},用户编号:{1},登录账号:{2},登录密码:{3}", loginer.UserName, loginer.UserCode, loginer.UserCode, "---" /*loginer.Password*/); //更新其它业务 } else { log.Info("登录失败!账号:" + UserCode + ",密码:" + Password + "。原因:" + loginResult.ResultMsg); } return(Json(loginResult, JsonRequestBehavior.DenyGet)); }
// POST: /Login/ public JsonResult Login(JObject data) { string UserCode = data.Value <string>("usercode"); string Password = data.Value <string>("pwd"); string IP = data.Value <string>("ip"); string City = data.Value <string>("city"); var loginResult = Base_UserService.Instance.Login(UserCode, Md5Util.MD5(Password), IP, City); if (loginResult.Succeed) { //登录成功后,查询当前用户数据 var user = Base_UserService.Instance.GetEntity(ParamQuery.Instance() .AndWhere("UserCode", UserCode).AndWhere("Password", Md5Util.MD5(Password)) .AndWhere("Enabled", 1).AndWhere("IsAudit", 1)); //调用框架中的登录机制 var loginer = new BaseLoginer { UserId = user.UserId, UserCode = user.UserCode, Password = user.Password, UserName = user.RealName, Data = user, IsAdmin = user.UserType == 1 //根据用户UserType判断。用户类型:0=未定义 1=超级管理员 2=普通用户 3=其他 }; //读取配置登录默认失效时长:小时 var effectiveHours = Convert.ToInt32(60 * ConfigUtil.GetConfigDecimal("LoginEffectiveHours")); // 无限光年网络科技 //执行web登录 FormsAuth.SignIn(loginer.UserId.ToString(), loginer, effectiveHours); LogHelper.Write("登录成功!用户:" + loginer.UserName + ",账号:" + UserCode + ",密码:" + Password); //设置服务基类中,当前登录用户信息 //this.CurrentBaseLoginer = loginer; //登陆后处理 //更新用户登陆次数及时间(存储过程登录,数据库已经处理) //添加登录日志 string userinfo = string.Format("用户姓名:{0},用户编号:{1},登录账号:{2},登录密码:{3}", loginer.UserName, loginer.UserId, loginer.UserCode, loginer.Password); Base_SysLogService.Instance.AddLoginLog(userinfo, IP, City); //更新其它业务 } else { LogHelper.Write("登录失败!账号:" + UserCode + ",密码:" + Password + "。原因:" + loginResult.ResultMsg); } return(Json(loginResult, JsonRequestBehavior.DenyGet)); }
/// <summary> /// 系统登录者对象,静态实例 /// </summary> //public static BaseLoginer LoginerInstance //{ // get // { // return GetBaseLoginerData(); // } //} /// <summary> /// 获取系统登录者对象 /// </summary> /// <returns>返回BaseLoginer</returns> public static BaseLoginer GetBaseLoginerData() { BaseLoginer result = GetUserData <BaseLoginer>(); return(result); }
public List <VD_Sys_Menu> GetUserMenus(BaseLoginer baseLoginer) { return(MenuList); }
// POST: /Login/ public JsonResult Login(JObject data) { string UserCode = data.Value <string>("user_code"); string Password = data.Value <string>("password"); string IP = data.Value <string>("ip"); string City = data.Value <string>("city"); data["user_code"] = UserCode; data["password"] = Md5Util.MD5(Password); data["LoginIP"] = IP; data["LoginCity"] = City; AppConnectionString = ConfigurationManager.ConnectionStrings["app"].ConnectionString; DataSet dt = base.RunProcedureDataSet(data, "vdp_sys_Login", "app"); //if (dt.Rows.Count > 0) var ResultID = dt.Tables[0].Rows[0]["result_id"]; var ResultMsg = (string)dt.Tables[0].Rows[0]["result_msg"]; //var loginResult = Base_UserService.Instance.Login(UserCode, Md5Util.MD5(Password), IP, City); if (ResultID.ToString() == "0") { ////登录成功后,查询当前用户数据 //var user = Base_UserService.Instance.GetEntity(ParamQuery.Instance() // .AndWhere("UserCode", UserCode).AndWhere("Password", Md5Util.MD5(Password)) // .AndWhere("Enabled", 1).AndWhere("IsAudit", 1)); //user.DepartmentCode = ""; //调用框架中的登录机制 Base_User b = new Base_User(); b.city = "";// (string)dt.Rows[0]["city"]; b.RealName = (string)dt.Tables[1].Rows[0]["real_name"]; b.DepartmentID = (int)dt.Tables[1].Rows[0]["department_id"]; b.UserId = (int)dt.Tables[1].Rows[0]["id"]; b.UserCode = (String)dt.Tables[1].Rows[0]["user_code"]; b.RoleIDs = (string)dt.Tables[1].Rows[0]["role_ids"]; b.DepartmentCode = ((int)dt.Tables[1].Rows[0]["department_id"]).ToString(); var loginer = new BaseLoginer { UserId = (int)dt.Tables[1].Rows[0]["id"], //. user.UserId, UserCode = (string)dt.Tables[1].Rows[0]["user_code"], // user.UserCode, // Password = (string)dt.Tables[1].Rows[0]["Password"],// user.Password, UserName = (string)dt.Tables[1].Rows[0]["real_name"], // user.RealName, RoleIDs = (string)dt.Tables[1].Rows[0]["role_ids"], // DepartmentCode =((int)dt.Tables[1].Rows[0]["DepartmentID"]).ToString(), Data = b, IsAdmin = false// user.UserType == 1 //根据用户UserType判断。用户类型:0=未定义 1=超级管理员 2=普通用户 3=其他 }; Session["logininfo"] = ""; //读取配置登录默认失效时长:小时 var effectiveHours = Convert.ToInt32(60 * ConfigUtil.GetConfigDecimal("LoginEffectiveHours")); //执行web登录 FormsAuth.SignIn(loginer.UserId.ToString(), loginer, effectiveHours); LogHelper.Write("登录成功!用户:" + loginer.UserName + ",账号:" + UserCode + ",密码:---"); //设置服务基类中,当前登录用户信息 //this.CurrentBaseLoginer = loginer; //登陆后处理 //更新用户登陆次数及时间(存储过程登录,数据库已经处理) //添加登录日志 string userinfo = string.Format("用户姓名:{0},用户编号:{1},登录账号:{2},登录密码:{3}", loginer.UserName, loginer.UserId, loginer.UserCode, "---" /*loginer.Password*/); // Base_SysLogService.Instance.AddLoginLog(userinfo, IP, City); //更新其它业务 } else { LogHelper.Write("登录失败!账号:" + UserCode + ",密码:" + Password + "。原因:" + ResultMsg); } return(Json(new { s = ResultID, message = ResultMsg }, JsonRequestBehavior.DenyGet)); }