예제 #1
0
        public JsonResult ModifyPassWord(string pwd, string againpwd)
        {
            bool result = false;

            if (string.IsNullOrEmpty(pwd) || string.IsNullOrEmpty(againpwd))
            {
                return(new CustomerJsonResult(new ResponseResult {
                    code = ResponseHelper.ORPARAMCODE, msg = "密码和确认密码不能为空"
                }));
            }
            if (pwd != againpwd)
            {
                return(new CustomerJsonResult(new ResponseResult {
                    code = ResponseHelper.ORPARAMCODE, msg = "两次输入密码不一致"
                }));
            }
            result = ISysUserService.UpdatePwd("UserCode", UserInfo.UserCode, DESEncryptHelper.GetMd5Hash(pwd));
            if (result)
            {
                return(new CustomerJsonResult(new ResponseResult {
                    code = ResponseHelper.ESUCCESSCODE, msg = "状态操作成功"
                }));
            }
            else
            {
                return(new CustomerJsonResult(new ResponseResult {
                    code = ResponseHelper.FAILCODE, msg = "状态操作失败"
                }));
            }
        }
예제 #2
0
        public JsonResult SaveUser(SysUserEntity model)
        {
            var  menuname = StringHelper.GetStrLength(model.Username);
            bool power    = true;

            if (menuname == 0 || menuname > 30)
            {
                return(new CustomerJsonResult(new ResponseResult {
                    code = ResponseHelper.ORPARAMCODE, msg = "名称不合法"
                }));
            }
            if (string.IsNullOrWhiteSpace(model.Usercode))
            {
                return(new CustomerJsonResult(new ResponseResult {
                    code = ResponseHelper.ORPARAMCODE, msg = "代码不能为空"
                }));
            }
            if (string.Equals("Admin", model.Username, StringComparison.InvariantCultureIgnoreCase))
            {
                return(new CustomerJsonResult(new ResponseResult {
                    code = ResponseHelper.ESUCCESSCODE, msg = "用户名已被占用"
                }));
            }
            string strwhere = " and  username='******'";

            SysUserEntity savemodel = null;

            if (model.Id > 0)
            {
                power = SysPower(SysMenuConstant.MENU_USER_MANAGE, SysMenuConstant.FUN_UPDATE, UserInfo.UserCode, false);
                if (!power)
                {
                    return(new CustomerJsonResult(new ResponseResult {
                        code = ResponseHelper.FAILCODE, msg = "权限不足"
                    }));
                }
                savemodel = ISysUserService.GetById(model.Id.Value);
                strwhere += " and  id!=" + model.Id;
            }
            int count = ISysUserService.Query(strwhere).Count;

            if (count > 0)
            {
                power = SysPower(SysMenuConstant.MENU_USER_MANAGE, SysMenuConstant.FUN_ADD, UserInfo.UserCode, false);
                if (!power)
                {
                    return(new CustomerJsonResult(new ResponseResult {
                        code = ResponseHelper.FAILCODE, msg = "权限不足"
                    }));
                }
                return(new CustomerJsonResult(new ResponseResult {
                    code = ResponseHelper.ESUCCESSCODE, msg = "用户名已被占用"
                }));
            }
            model.Createby   = UserInfo.UserCode;
            model.Createdate = DateTime.Now;

            if (Request.Form["isenable"].ToString() == "0")
            {
                model.Isenable = false;
            }
            else
            {
                model.Isenable = true;
            }

            SysUserinfoEntity userinfo = new SysUserinfoEntity();

            model.JobcodeName   = Request.Form["jobName"].ToString();
            model.PositionsName = Request.Form["positName"].ToString();

            #region 获取userinfo 参数
            userinfo.Usercode      = model.Usercode;
            userinfo.Realname      = RequestHelper.FilterParam(Request.Form["Realname"]);
            userinfo.Photo         = RequestHelper.FilterParam(Request.Form["photo"]);
            userinfo.Political     = RequestHelper.FilterParam(Request.Form["political"]);
            userinfo.Maritalstatus = RequestHelper.FilterParam(Request.Form["maritalstatus"]);
            if (!string.IsNullOrEmpty(Request.Form["birthdate"]))
            {
                userinfo.Birthdate = Request.Form["birthdate"].ToString().GetValueOrNull <DateTime>();
            }
            userinfo.Sex            = RequestHelper.FilterParam(Request.Form["sex"]);
            userinfo.Nation         = RequestHelper.FilterParam(Request.Form["nation"]);
            userinfo.Placeorigin    = RequestHelper.FilterParam(Request.Form["placeorigin"]);
            userinfo.Education      = RequestHelper.FilterParam(Request.Form["education"]);
            userinfo.Telephone      = RequestHelper.FilterParam(Request.Form["telephone"]);
            userinfo.University     = RequestHelper.FilterParam(Request.Form["university"]);
            userinfo.Specialty      = RequestHelper.FilterParam(Request.Form["specialty"]);
            userinfo.Presentaddress = RequestHelper.FilterParam(Request.Form["presentaddress"]);
            userinfo.Email          = RequestHelper.FilterParam(Request.Form["email"]);
            userinfo.Hobby          = RequestHelper.FilterParam(Request.Form["hobby"]);
            userinfo.Perspecialty   = RequestHelper.FilterParam(Request.Form["perspecialty"]);
            userinfo.Comprehensive  = RequestHelper.FilterParam(Request.Form["comprehensive"]);
            userinfo.Selfevaluation = RequestHelper.FilterParam(Request.Form["selfevaluation"]);
            userinfo.Selfevaluation = RequestHelper.FilterParam(Request.Form["selfevaluation"]);
            userinfo.Createdate     = DateTime.Now;
            userinfo.Createby       = UserInfo.UserCode;
            #endregion

            #region 概要说明
            List <SysUserReumeEntity> list = new List <SysUserReumeEntity>();
            string study = Request.Form["BeginEndYearStu"] == null ? "" : Request.Form["BeginEndYearStu"].ToString();
            //学习经历
            if (study != "")
            {
                string   stucontent   = Request.Form["ContentStu"] == null ? "" : Request.Form["ContentStu"].ToString();
                string   stumajorduty = Request.Form["MajorDutyStu"] == null ? "" : Request.Form["MajorDutyStu"].ToString();
                string[] studylist    = study.Split(',');
                string[] itemcontent  = stucontent.Split(',');
                string[] itemmajor    = stumajorduty.Split(',');
                for (int i = 0; i < studylist.Length; i++)
                {
                    list.Add(new SysUserReumeEntity
                    {
                        Usercode     = model.Usercode,
                        Retype       = 0,
                        Beginendyear = studylist[i],
                        Content      = itemcontent[i],
                        Majorduty    = itemmajor[i]
                    });
                }
            }
            string work = Request.Form["BeginEndYearWork"] == null ? "" : Request.Form["BeginEndYearWork"].ToString();
            //工作经历
            if (study != "")
            {
                string   workcontent   = Request.Form["ContentWork"] == null ? "" : Request.Form["ContentWork"].ToString();
                string   workmajorduty = Request.Form["MajorDutyWork"] == null ? "" : Request.Form["MajorDutyWork"].ToString();
                string[] worklist      = work.Split(',');
                string[] itemcontent   = workcontent.Split(',');
                string[] itemmajor     = workmajorduty.Split(',');
                for (int i = 0; i < worklist.Length; i++)
                {
                    list.Add(new SysUserReumeEntity
                    {
                        Usercode     = model.Usercode,
                        Retype       = 1,
                        Beginendyear = worklist[i],
                        Content      = itemcontent[i],
                        Majorduty    = itemmajor[i]
                    });
                }
            }
            #endregion

            #region 角色
            var listrole = RequestHelper.GetStringListNoNull("userroles");
            List <SysUserroleEntity> lsrole = new List <SysUserroleEntity>();
            if (listrole.Count > 0)
            {
                foreach (var item in listrole)
                {
                    lsrole.Add(new SysUserroleEntity {
                        Rolecode = item, Usercode = model.Usercode
                    });
                }
            }
            #endregion

            #region 组织机构
            var listorg = RequestHelper.GetStringListNoNull("userorgs");
            List <SysOrganizeuserEntity> lsorg = new List <SysOrganizeuserEntity>();
            if (listorg.Count > 0)
            {
                foreach (var item in listorg)
                {
                    lsorg.Add(new SysOrganizeuserEntity {
                        Orgcode = item, Usercode = model.Usercode
                    });
                }
            }
            #endregion
            int result = 0;

            if (model.Id > 0)
            {
                var md5pwd = DESEncryptHelper.GetMd5Hash(model.Userpwd);

                if (md5pwd != savemodel.Userpwd)
                {
                    model.Userpwd = md5pwd;
                }
                result = ISysUserService.UpdateUser(model, userinfo, list, lsorg, lsrole);
            }
            else
            {
                model.Userpwd    = DESEncryptHelper.GetMd5Hash(model.Userpwd);
                model.Createdate = DateTime.Now;
                model.Createby   = UserInfo.UserCode;
                result           = ISysUserService.InsertUser(model, userinfo, list, lsorg, lsrole);
            }
            if (result > 0)
            {
                return(new CustomerJsonResult(new ResponseResult {
                    code = ResponseHelper.ESUCCESSCODE, msg = "保存成功"
                }));
            }
            else
            {
                return(new CustomerJsonResult(new ResponseResult {
                    code = ResponseHelper.FAILCODE, msg = "保存失败"
                }));
            }
        }
예제 #3
0
        public JsonResult Loging()
        {
            string name     = Request.Form["name"].ToString();
            string pwd      = Request.Form["pwd"].ToString();
            string strwhere = string.Empty;

            if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(pwd))
            {
                return(new CustomerJsonResult(new ResponseResult {
                    code = ResponseHelper.ORPARAMCODE, msg = "账号密码不能为口空"
                }));
            }
            else
            {
                strwhere = " and  username='******'";
            }
            var dic = RequestHelper.GetSystemConfig();

            if (name == "Admin")
            {
                if (dic["Admin"] == DESEncryptHelper.GetMd5Hash(pwd))
                {
                    SysUserModel suser = new SysUserModel
                    {
                        UserCode  = "ADMIN",
                        UserName  = "******",
                        RoleName  = "管理员",
                        UserPhoto = "/Content/images/head.png"
                    };

                    SetUserLogin(dic["LoginProvider"], suser);
                    ContainerBuilderHelper.Instance.AddLog(new Entitys.SysLogsEntity
                    {
                        Createtime = DateTime.Now,
                        Logtype    = 1,
                        Logmsg     = suser.UserName + "[" + suser.UserCode + "]登录成功",
                        Logsource  = "Login/Loging"
                    });
                    return(new CustomerJsonResult(new ResponseResult {
                        code = ResponseHelper.ESUCCESSCODE, msg = "登录成功"
                    }));
                }
                else
                {
                    return(new CustomerJsonResult(new ResponseResult {
                        code = ResponseHelper.FAILCODE, msg = "账号或密码不正确"
                    }));
                }
            }
            else
            {
                var model = ISysUserService.Query(strwhere).FirstOrDefault();

                if (model != null && model.Username == name && model.Userpwd == DESEncryptHelper.GetMd5Hash(pwd))
                {
                    var          userinfo = ISysUserService.GetUserInfo(" and usercode='" + model.Usercode + "'");
                    SysUserModel suser    = new SysUserModel
                    {
                        UserCode  = model.Usercode,
                        UserName  = model.Username,
                        RoleName  = model.Rolenames,
                        UserPhoto = userinfo.Photo
                    };
                    SetUserLogin(dic["LoginProvider"], suser);
                    ContainerBuilderHelper.Instance.AddLog(new Entitys.SysLogsEntity {
                        Createtime = DateTime.Now,
                        Logtype    = 1,
                        Logmsg     = suser.UserName + "[" + suser.UserCode + "]登录成功",
                        Logsource  = "Login/Loging"
                    });
                    return(new CustomerJsonResult(new ResponseResult {
                        code = ResponseHelper.ESUCCESSCODE, msg = "登录成功"
                    }));
                }
                else
                {
                    return(new CustomerJsonResult(new ResponseResult {
                        code = ResponseHelper.FAILCODE, msg = "账号或密码不正确"
                    }));
                }
            }
        }