public JsonResult AchieveLeftAuthNode() { if (Utits.IsLogin) { #region 设置IP string GetIP = RequestParameters.Pstring("YlyClientIP"); //登录IP var itemUsers = new Users(); itemUsers.UserID = Utits.CurrentUserID; itemUsers.UserCode = GetIP; var cBllUsers = new UsersBll(); bool IsFlagUsers = cBllUsers.AddOrUpdate(itemUsers, false); #endregion var listLeftAuthNode = new AuthRoleNodeBll().SearchListByLeftUserId(Utits.CurrentUserID, Utits.IsSuper); if (listLeftAuthNode != null) { var listAchieveAuthNode = listLeftAuthNode.Select(itemNode => new TreeModel { Id = itemNode.NodeId, Pid = itemNode.ParentID, Name = itemNode.NodeName, Target = itemNode.NodeTarget, Url = itemNode.NodePath, NodeClassName = itemNode.NodeClassName, Remark = itemNode.Remark }).OrderBy(c => c.Remark).ToList(); if (listAchieveAuthNode.Count > 0) { return(Json(listAchieveAuthNode)); } } } return(Json("[]")); }
public JsonResult AddOrUpdate() { #region 权限控制 int[] iRangePage = { AddPageNodeId, EditPageNodeId, DetailPageNodeId }; int iCurrentPageNodeId = RequestParameters.Pint("NodeId"); bool isAdd = iCurrentPageNodeId == AddPageNodeId ? true : false; int iCurrentButtonId = (int)EButtonType.Save; var tempNoAuth = Utits.IsOperateAuth(iRangePage, iCurrentPageNodeId, iCurrentButtonId); if (tempNoAuth.ErrorType != 1) { return(Json(tempNoAuth)); } #endregion #region AddOrUpdate var welfareCentreId = Utits.WelfareCentreID; string UserCode = RequestParameters.Pstring("UserCode"); string UserName = RequestParameters.Pstring("UserName"); string RealName = RequestParameters.Pstring("RealName"); string Password = RequestParameters.Pstring("Password"); Guid DeptId = RequestParameters.PGuid("DeptId"); Guid RoleId = RequestParameters.PGuid("RoleId"); int UserType = RequestParameters.Pint("UserType"); string Remark = RequestParameters.Pstring("Remark"); string IcCardNO = RequestParameters.Pstring("IcCardNO"); if (UserName.Length <= 0) { var sRetrunModel = new ResultMessage(); sRetrunModel.ErrorType = 0; sRetrunModel.MessageContent = "用户名不能为空."; return(Json(sRetrunModel)); } var cBll = new UsersBll(); Guid ID = RequestParameters.PGuid("ID"); bool isFlagValidation = false; if (ID == Guid.Empty) { isFlagValidation = cBll.ValidationUserName(UserName, welfareCentreId); } else { isFlagValidation = cBll.ValidationUserName(ID, UserName, welfareCentreId); } if (!isFlagValidation) { var sRetrunModel = new ResultMessage(); sRetrunModel.ErrorType = 0; sRetrunModel.MessageContent = "用户名已存在."; return(Json(sRetrunModel)); } if (RealName.Length <= 0) { var sRetrunModel = new ResultMessage(); sRetrunModel.ErrorType = 0; sRetrunModel.MessageContent = "真实姓名不能为空."; return(Json(sRetrunModel)); } if (DeptId == Guid.Empty) { var sRetrunModel = new ResultMessage(); sRetrunModel.ErrorType = 0; sRetrunModel.MessageContent = "部门参数错误,请返回列表页面重新操作."; return(Json(sRetrunModel)); } if (RoleId == Guid.Empty) { var sRetrunModel = new ResultMessage(); sRetrunModel.ErrorType = 0; sRetrunModel.MessageContent = "角色参数错误,请返回列表页面重新操作."; return(Json(sRetrunModel)); } var item = new Users(); if (ID == Guid.Empty) { item.UserID = Guid.NewGuid(); item.CreateDate = DateTime.Now; item.IsValid = 1; if (Password.Length <= 0) { Password = HashEncrypt.md5(CommonLib.Config.SystemInitPassword); } item.Password = CommonLib.HashEncrypt.BgPassWord(Password); } else { item.UserID = ID; if (Password.Length > 0) { item.Password = CommonLib.HashEncrypt.BgPassWord(Password); } } item.WelfareCentreID = welfareCentreId; item.OperateDate = DateTime.Now; item.UserCode = UserCode; item.UserName = UserName; item.RealName = RealName; item.DeptID = DeptId; item.RoleID = RoleId; item.Remark = Remark; item.UserType = UserType; item.IcCardNo = IcCardNO; ParamState = "1"; ParamID = item.UserID.ToString(); bool IsFlag = cBll.AddOrUpdate(item); if (IsFlag) { var cLog = new LogsBll(); cLog.Log(ParamID, ParamName, ParamState, Utits.CurrentUserID.ToString(), Utits.CurrentRealName.ToString(), Utits.WelfareCentreID.ToString(), Utits.ClientIPAddress.ToString()); var sRetrunModel = new ResultMessage(); sRetrunModel.ErrorType = 1; sRetrunModel.MessageContent = "操作成功."; return(Json(sRetrunModel)); } else { var sRetrunModel = new ResultMessage(); sRetrunModel.ErrorType = 0; sRetrunModel.MessageContent = "操作失败."; return(Json(sRetrunModel)); } #endregion }
/// <summary> /// 登录验证 /// </summary> /// <returns></returns> public JsonResult LoginSystem() { //System.Threading.Thread.Sleep(5000); int isCookieUp = 1; //1:cookie用户名和密码;2:cookie用户名;3:不要cookie bool isCode = true; //是否有验证码,默认有(true) string UserName = RequestParameters.Pstring("UserName"); string Password = RequestParameters.Pstring("Password"); bool Remember = RequestParameters.Pstring("Remember") == "1";//记住密码 string code = RequestParameters.Pstring("code"); if (UserName.Length <= 0) { var sReturnModel = new ResultMessage(); sReturnModel.ErrorType = 0; sReturnModel.MessageContent = "用户名不能为空."; return(Json(sReturnModel)); } if (Password.Length <= 0) { var sReturnModel = new ResultMessage(); sReturnModel.ErrorType = 0; sReturnModel.MessageContent = "密码不能为空."; return(Json(sReturnModel)); } if (code.Length <= 0) { var sReturnModel = new ResultMessage(); sReturnModel.ErrorType = 0; sReturnModel.MessageContent = "验证码不能为空."; return(Json(sReturnModel)); } if (!IsOkValidateCode(isCode, code)) { ClearValidateCode(isCode); var sReturnModel = new ResultMessage { ErrorType = 0, MessageContent = "验证码错误." }; return(Json(sReturnModel)); } ClearValidateCode(isCode); var usersBll = new UsersBll(); if (usersBll.ValidationUserName(UserName)) { var sReturnModel = new ResultMessage { ErrorType = 0, MessageContent = "用户名不存在." }; return(Json(sReturnModel)); } var item = usersBll.LoginUsers(UserName, HashEncrypt.BgPassWord(Password)); if (item != null) { #region 设置IP string GetIP = RequestParameters.Pstring("YlyClientIP"); //登录IP var itemUsers = new Users(); itemUsers.UserID = Utits.CurrentUserID; itemUsers.UserCode = GetIP; var cBllUsers = new UsersBll(); bool IsFlagUsers = cBllUsers.AddOrUpdate(itemUsers, false); #endregion try { Session["USERID"] = HashEncrypt.EncryptQueryString(item.UserID.ToString()); Session["WelfareCentreId"] = HashEncrypt.EncryptQueryString(item.WelfareCentreID.ToString()); if (Remember) { #region 记住内容详细 if (isCookieUp == 1) //记住用户名和密码 { #region Cookie HttpCookie cookies = Request.Cookies["USERINFO"]; if (cookies != null) { cookies.Expires = DateTime.Now.AddDays(-30); Response.AppendCookie(cookies); } HttpCookie cookie = new HttpCookie("USERINFO"); cookie.Values.Add("USERNAME", HashEncrypt.EncryptQueryString(UserName)); cookie.Values.Add("PASSWORD", HashEncrypt.EncryptQueryString(HashEncrypt.BgPassWord(Password))); cookie.Values.Add("WelfareCentreId", HashEncrypt.EncryptQueryString(item.WelfareCentreID.ToString())); cookie.Expires = DateTime.Now.AddDays(30); Response.Cookies.Add(cookie); #endregion } else if (isCookieUp == 2) //记住用户名不记住密码 { #region Cookie HttpCookie cookies = Request.Cookies["USERINFO"]; if (cookies != null) { cookies.Expires = DateTime.Now.AddDays(-30); Response.AppendCookie(cookies); } HttpCookie cookie = new HttpCookie("USERINFO"); cookie.Values.Add("USERNAME", HashEncrypt.EncryptQueryString(UserName)); cookie.Expires = DateTime.Now.AddDays(30); Response.Cookies.Add(cookie); #endregion } else //都不用记 { } #endregion } } catch (Exception ex) { Console.WriteLine(ex.Message); } var sReturnModel = new ResultMessage { ErrorType = 1, MessageContent = "登录成功." }; return(Json(sReturnModel)); } else { var sReturnModel = new ResultMessage { ErrorType = 0, MessageContent = "密码错误." }; return(Json(sReturnModel)); } }