Exemple #1
0
        public JsonResult ResetPassword()
        {
            #region 权限控制
            //显示申明哪几个节点具有该功能->解决已拥有部分权限,而想跳过权限判断问题。
            int[] iRangePage         = { AddPageNodeId, EditPageNodeId, DetailPageNodeId };
            int   iCurrentPageNodeId = RequestParameters.Pint("NodeId");
            int   iCurrentButtonId   = (int)EButtonType.ResetPassword;
            var   tempNoAuth         = Utits.IsOperateAuth(iRangePage, iCurrentPageNodeId, iCurrentButtonId);
            if (tempNoAuth.ErrorType != 1)
            {
                return(Json(tempNoAuth));
            }
            #endregion

            string szIds = RequestParameters.Pstring("ids");
            if (string.IsNullOrEmpty(szIds))
            {
                var sRetrunModel = new ResultMessage();
                sRetrunModel.ErrorType      = 0;
                sRetrunModel.MessageContent = "参数错误.";
                return(Json(sRetrunModel));
            }
            string[] strids = szIds.Split(',');
            System.Collections.ArrayList arrayList = new System.Collections.ArrayList();
            foreach (string t in strids)
            {
                if (RegexValidate.IsGuid(t))
                {
                    arrayList.Add(t);
                }
            }
            string[] ids = (string[])arrayList.ToArray(typeof(string));
            if (!ids.Any())
            {
                var sRetrunModel = new ResultMessage
                {
                    ErrorType      = 0,
                    MessageContent = "参数错误."
                };
                return(Json(sRetrunModel));
            }

            var  cBll   = new UsersBll();
            bool isFlag = cBll.ResetPassword(ids);
            if (isFlag)
            {
                var sRetrunModel = new ResultMessage();
                sRetrunModel.ErrorType      = 1;
                sRetrunModel.MessageContent = string.Format("操作成功,重置后的密码为:{0}.", CommonLib.Config.SystemInitPassword);
                return(Json(sRetrunModel));
            }
            else
            {
                var sRetrunModel = new ResultMessage();
                sRetrunModel.ErrorType      = 0;
                sRetrunModel.MessageContent = "操作失败.";
                return(Json(sRetrunModel));
            }
        }