Exemplo n.º 1
0
        /// <summary>
        /// 设定用户部门
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="deptId"></param>
        /// <returns></returns>
        public JsonMessage UpdateUserDept(string userId, string deptId)
        {
            JsonMessage jsonMsg = new JsonMessage(); //返回Json
            int         result  = -1;                //类型(成功 、失败)

            try
            {
                DataTable dt = _userRep.GetById(userId);
                if (ValidateHelper.IsDataTableNotData(dt))
                {
                    throw new CustomException(0, "该用户不存在");//
                }
                result = _userRep.UpdateUserDept(userId, deptId);

                jsonMsg = ServiceResult.Message(result, "更新成功");
            }
            catch (CustomException ex)
            {
                jsonMsg = ServiceResult.Message(ex.ResultFlag, ex.Message);
            }
            catch (Exception ex)
            {
                jsonMsg = ServiceResult.Message(-1, ex.Message);
                WriteSystemException(ex, this.GetType(), OPT_MODEL, "设定用户部门失败");
            }

            //写入log
            WriteSystemLog(jsonMsg, CREATE, OPT_MODEL, "设定用户部门");

            return(jsonMsg);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 删除操作码
        /// </summary>
        /// <param name="moId"></param>
        /// <param name="menu_id"></param>
        /// <returns></returns>
        public JsonMessage Delete(string moId, string menu_id)
        {
            JsonMessage jsonMsg = new JsonMessage(); //返回Json
            int         result  = -1;                //类型(成功 、失败)

            try
            {
                DataTable dt = _menuOpApp.GetById(moId, menu_id);

                if (ValidateHelper.IsDataTableNotData(dt))
                {
                    throw new CustomException(0, "操作码删除失败,操作码不存在");
                }
                result  = _menuOpApp.Delete(moId, menu_id);
                jsonMsg = ServiceResult.Message(1, "操作码删除成功");
            }
            catch (CustomException ex)
            {
                jsonMsg = ServiceResult.Message(ex.ResultFlag, ex.Message);
            }
            catch (Exception ex)
            {
                jsonMsg = ServiceResult.Message(-1, ex.Message);
                WriteSystemException(ex, this.GetType(), OPT_MODEL, menu_id + ":" + moId + ":删除操作码失败");
            }

            //写入log
            WriteSystemLog(jsonMsg, DELETE, OPT_MODEL, menu_id + ":" + moId + ":删除操作码");

            return(jsonMsg);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取app最新版本号
        /// </summary>
        /// <returns></returns>
        public AppVersionModel GetNewAppVersion()
        {
            DataTable dt = _appRep.GetNewAppVersion();

            if (ValidateHelper.IsDataTableNotData(dt))
            {
                return(new AppVersionModel());
            }
            IList <AppVersionModel> list = ConverHelper.ToList <AppVersionModel>(dt);

            return(list[0]);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 添加部门
        /// </summary>
        /// <param name="code"></param>
        /// <param name="name"></param>
        /// <param name="parentId"></param>
        /// <param name="site_code"></param>
        /// <param name="site_name"></param>
        /// <param name="sort"></param>
        /// <param name="type"></param>
        /// <param name="desc"></param>
        /// <param name="isAble"></param>
        /// <param name="isEnd"></param>
        /// <returns></returns>
        public JsonMessage Insert(string code, string name, string parent_code, string site_code, string site_name, int sort, string type, string desc, bool isAble, bool isEnd)
        {
            JsonMessage jsonMsg = new JsonMessage(); //返回Json
            int         result  = -1;                //类型(成功 、失败)

            try
            {
                DataTable dt = _deptRep.GetById(parent_code);
                if (dt == null || dt.Rows.Count < 1)
                {
                    throw new CustomException(0, "添加失败,父节点不存在,请刷新后在试");//添加失败,父节点不存在,请刷新后在试
                }

                DataTable dt2 = _deptRep.GetByCodeOrName(code, name);
                if (!ValidateHelper.IsDataTableNotData(dt2))
                {
                    throw new CustomException(0, "添加失败,部门编号或名称已存在");
                }

                SysDeptModel model = new SysDeptModel();
                model.DEPT_CODE   = code;
                model.DEPT_NAME   = name;
                model.PARENT_CODE = parent_code;
                model.SITE_CODE   = site_code;
                model.SITE_NAME   = site_name;
                model.DEPT_SORT   = sort;
                model.DEPT_TYPE   = "LOCAL";
                model.DEPT_DESC   = desc;
                model.IS_ABLE     = isAble ? 1 : 0;
                model.IS_END      = isEnd ? 1 : 0;
                model.CREATE_USER = UserID;
                model.LM_USER     = UserID;

                result  = _deptRep.Insert(model);
                jsonMsg = ServiceResult.Message(1, "添加成功");
            }
            catch (CustomException ex)
            {
                jsonMsg = ServiceResult.Message(ex.ResultFlag, ex.Message);
            }
            catch (Exception ex)
            {
                jsonMsg = ServiceResult.Message(-1, ex.Message);
                WriteSystemException(ex, this.GetType(), OPT_MODEL, name + ":添加部门信息失败");
            }

            //写入log
            WriteSystemLog(jsonMsg, CREATE, OPT_MODEL, name + ":添加部门信息");

            return(jsonMsg);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="userId">用户账号</param>
        /// <param name="oldPwd">旧密码</param>
        /// <param name="newPwd">新密码</param>
        /// <param name="newPwdOk">二次新密码</param>
        /// <param name="isQR">是否更改二维码</param>
        /// <param name="QRCode">加密二维码</param>
        /// <returns></returns>
        public JsonMessage EditPassword(string userId, string oldPwd, string newPwd, string newPwdOk, bool isQR, string QRCode)
        {
            JsonMessage jsonMsg = new JsonMessage(); //返回Json
            int         result  = -1;                //类型(成功 、失败)

            try
            {
                SysUserModel model = null;
                DataTable    dt    = _userRep.Login(userId, oldPwd);
                if (ValidateHelper.IsDataTableNotData(dt))
                {
                    throw new CustomException(0, "旧密码不正确");
                }
                if (ValidateHelper.IsNullOrEmpty(userId))
                {
                    throw new CustomException(0, "非法操作,用户名不能为空");
                }
                if (ValidateHelper.IsNullOrEmpty(newPwd))
                {
                    throw new CustomException(0, "新密码不能为空");
                }
                if (oldPwd == newPwd)
                {
                    throw new CustomException(0, "旧密码不能已新密码一致");
                }
                if (newPwd != newPwdOk)
                {
                    throw new CustomException(0, "两次密码不一致");
                }

                result  = _userRep.EditPassword(userId, newPwd, isQR, QRCode);
                jsonMsg = ServiceResult.Message(result, "密码修改成功");
            }
            catch (CustomException ex)
            {
                jsonMsg = ServiceResult.Message(ex.ResultFlag, ex.Message);
            }
            catch (Exception ex)
            {
                jsonMsg = ServiceResult.Message(-1, ex.Message);
                WriteSystemException(ex, this.GetType(), OPT_MODEL, "用户自行修改密码失败");
            }

            //写入log
            WriteSystemLog(jsonMsg, UPDATE, OPT_MODEL, "用户修改密码");

            return(jsonMsg);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 修改用户信息
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="userName"></param>
        /// <param name="e_mail"></param>
        /// <param name="tel"></param>
        /// <param name="sex"></param>
        /// <param name="post"></param>
        /// <param name="resetPwd"></param>
        /// <param name="qrCode"></param>
        /// <param name="isAble"></param>
        /// <param name="isChangePwd"></param>
        /// <param name="desc"></param>
        /// <returns></returns>
        public JsonMessage Edit(string userId, string userName, string e_mail, string tel, bool sex, string post, bool resetPwd, bool qrCode, bool isAble, bool isChangePwd, string desc)
        {
            JsonMessage jsonMsg = new JsonMessage(); //返回Json
            int         result  = -1;                //类型(成功 、失败)

            try
            {
                DataTable dt = _userRep.GetById(userId);
                if (ValidateHelper.IsDataTableNotData(dt))
                {
                    throw new CustomException(0, "该用户不存在");
                }

                string       newPwd = "123456";
                SysUserModel model  = new SysUserModel();
                model.USER_CODE  = userId;
                model.USER_NAME  = userName;
                model.USER_PWD   = resetPwd ? MD5Cryption.MD5(newPwd) : dt.Rows[0]["USER_PWD"].ToString();
                model.USER_EMAIL = e_mail;
                model.USER_TEL   = tel;
                model.USER_SEX   = sex ? 1 : 0;
                model.USER_POST  = post;
                model.IS_ABLED   = isAble ? 1 : 0;
                model.IS_C_PWD   = isChangePwd ? 1 : 0;
                model.QR_CODE    = qrCode ? DESCryption.Encrypt(userId + newPwd) : dt.Rows[0]["QR_CODE"].ToString();
                model.USER_DESC  = desc;
                model.LM_USER    = UserID;
                result           = _userRep.Edit(model);

                jsonMsg = ServiceResult.Message(result, "修改用户成功");
            }
            catch (CustomException ex)
            {
                jsonMsg = ServiceResult.Message(ex.ResultFlag, ex.Message);
            }
            catch (Exception ex)
            {
                jsonMsg = ServiceResult.Message(-1, ex.Message);
                WriteSystemException(ex, this.GetType(), OPT_MODEL, "修改用户失败");
            }

            //写入log
            WriteSystemLog(jsonMsg, CREATE, OPT_MODEL, "修改用户");

            return(jsonMsg);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 修改菜单
        /// </summary>
        /// <param name="menuId"></param>
        /// <param name="menuName"></param>
        /// <param name="parentId"></param>
        /// <param name="code"></param>
        /// <param name="link"></param>
        /// <param name="icon"></param>
        /// <param name="sort"></param>
        /// <param name="type"></param>
        /// <param name="desc"></param>
        /// <param name="isable"></param>
        /// <param name="isend"></param>
        /// <returns></returns>
        public JsonMessage Edit(string menuId, string menuName, string parentId, string code, string link, string icon, int sort, string type, string desc, bool isable, bool isend)
        {
            JsonMessage jsonMsg = new JsonMessage(); //返回Json
            int         result  = -1;                //类型(成功 、失败)

            try
            {
                DataTable dt = _menuRep.GetById(menuId);
                if (ValidateHelper.IsDataTableNotData(dt))
                {
                    throw new CustomException(0, "菜单不存在,刷新后尝试");
                }
                SysMenuModel model = new SysMenuModel();
                model.MENU_ID     = menuId;
                model.MENU_NAME   = menuName;
                model.PARENT_ID   = parentId;
                model.MENU_CODE   = code;
                model.MENU_PATH   = link;
                model.MENU_ICON   = icon;
                model.MENU_SORT   = sort;
                model.MENU_TYPE   = type;
                model.MENU_DESC   = desc;
                model.IS_ABLED    = isable ? 1 : 0;
                model.IS_END      = isend ? 1 : 0;
                model.CREATE_USER = UserID;
                model.LM_USER     = UserID;
                result            = _menuRep.Edit(model);

                jsonMsg = ServiceResult.Message(1, "菜单修改成功");
            }
            catch (CustomException ex)
            {
                jsonMsg = ServiceResult.Message(ex.ResultFlag, ex.Message);
            }
            catch (Exception ex)
            {
                jsonMsg = ServiceResult.Message(-1, ex.Message);
                WriteSystemException(ex, this.GetType(), OPT_MODEL, menuId + ":修改系统菜单失败");
            }

            //写入log
            WriteSystemLog(jsonMsg, UPDATE, OPT_MODEL, menuId + ":修改系统菜单");

            return(jsonMsg);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 更新部门信息
        /// </summary>
        /// <param name="dept_code"></param>
        /// <param name="name"></param>
        /// <param name="parent_code"></param>
        /// <param name="site_code"></param>
        /// <param name="site_name"></param>
        /// <param name="sort"></param>
        /// <param name="type"></param>
        /// <param name="desc"></param>
        /// <param name="isAble"></param>
        /// <param name="isEnd"></param>
        /// <returns></returns>
        public JsonMessage Edit(string dept_code, string name, string parent_code, string site_code, string site_name, int sort, string type, string desc, bool isAble, bool isEnd)
        {
            JsonMessage jsonMsg = new JsonMessage(); //返回Json
            int         result  = -1;                //类型(成功 、失败)

            try
            {
                DataTable dt = _deptRep.GetById(dept_code);
                if (ValidateHelper.IsDataTableNotData(dt))
                {
                    throw new CustomException(0, "更新失败,该部门不存在,请刷新后再试");//
                }

                SysDeptModel model = new SysDeptModel();
                model.DEPT_CODE   = dept_code;
                model.DEPT_NAME   = name;
                model.PARENT_CODE = parent_code;
                model.SITE_CODE   = site_code;
                model.SITE_NAME   = site_name;
                model.DEPT_SORT   = sort;
                model.DEPT_TYPE   = "LOCAL";
                model.DEPT_DESC   = desc;
                model.IS_ABLE     = isAble ? 1 : 0;
                model.IS_END      = isEnd ? 1 : 0;
                model.LM_USER     = UserID;

                result  = _deptRep.Edit(model);
                jsonMsg = ServiceResult.Message(1, "更新成功");
            }
            catch (CustomException ex)
            {
                jsonMsg = ServiceResult.Message(ex.ResultFlag, ex.Message);
            }
            catch (Exception ex)
            {
                jsonMsg = ServiceResult.Message(-1, ex.Message);
                WriteSystemException(ex, this.GetType(), OPT_MODEL, dept_code + ":更新部门信息失败");
            }

            //写入log
            WriteSystemLog(jsonMsg, UPDATE, OPT_MODEL, dept_code + ":更新部门信息");

            return(jsonMsg);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 添加角色信息
        /// </summary>
        /// <param name="roleName"></param>
        /// <param name="desc"></param>
        /// <returns></returns>
        public JsonMessage Insert(string roleName, string desc)
        {
            JsonMessage jsonMsg = new JsonMessage(); //返回Json
            int         result  = -1;                //类型(成功 、失败)

            try
            {
                DataTable dt = _roleRep.GetByRoleName(roleName);
                if (!ValidateHelper.IsDataTableNotData(dt))
                {
                    throw new CustomException(0, "角色名称重复,请重新填写 ");//角色名称重复,请重新填写
                }
                SysRoleModel model = new SysRoleModel();
                model.ROLE_ID     = GuidHelper.GenerateComb().ToString().ToUpper();
                model.ROLE_NAME   = roleName;
                model.ROLE_DESC   = desc;
                model.CREATE_USER = UserID;
                model.LM_USER     = UserID;
                result            = _roleRep.Insert(model);
                if (result == 1)
                {
                    _rightRep.InsertSysRight(model.CREATE_USER, model.LM_USER);
                }
                jsonMsg = ServiceResult.Message(1, "角色添加成功");
            }
            catch (CustomException ex)
            {
                jsonMsg = ServiceResult.Message(ex.ResultFlag, ex.Message);
            }
            catch (Exception ex)
            {//记录异常
                jsonMsg = ServiceResult.Message(-1, ex.Message);
                WriteSystemException(ex, this.GetType(), OPT_MODEL, "添加角色失败");
            }

            //写入log
            WriteSystemLog(jsonMsg, CREATE, OPT_MODEL, "添加角色信息");

            return(jsonMsg);
        }
Exemplo n.º 10
0
        public JsonMessage Delete(string dept_code)
        {
            JsonMessage jsonMsg = new JsonMessage(); //返回Json
            int         result  = -1;                //类型(成功 、失败)

            try
            {
                if (dept_code == "0000000000")
                {
                    throw new CustomException(0, "删除失败,顶级菜单不能删除");//
                }
                DataTable dt = _deptRep.GetByParentId(dept_code);
                if (!ValidateHelper.IsDataTableNotData(dt))
                {
                    throw new CustomException(0, "删除失败,该部门下存在子部门,请先删除子部门"); //
                }
                DataTable dt_n = _deptRep.GetById(dept_code);
                if (ValidateHelper.IsDataTableNotData(dt_n))
                {
                    throw new CustomException(0, "删除失败,该部门不存在,请刷新后再试");//
                }

                result  = _deptRep.Delete(dept_code);
                jsonMsg = ServiceResult.Message(1, "删除成功");
            }
            catch (CustomException ex)
            {
                jsonMsg = ServiceResult.Message(ex.ResultFlag, ex.Message);
            }
            catch (Exception ex)
            {
                jsonMsg = ServiceResult.Message(-1, ex.Message);
                WriteSystemException(ex, this.GetType(), OPT_MODEL, dept_code + ":删除部门信息失败");
            }

            //写入log
            WriteSystemLog(jsonMsg, DELETE, OPT_MODEL, dept_code + ":删除部门信息");

            return(jsonMsg);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 添加操作码
        /// </summary>
        /// <param name="keyCode"></param>
        /// <param name="name"></param>
        /// <param name="menuId"></param>
        /// <param name="isValid"></param>
        /// <param name="desc"></param>
        /// <returns></returns>
        public JsonMessage Insert(string keyCode, string name, string menuId, bool isValid, string desc)
        {
            JsonMessage jsonMsg = new JsonMessage(); //返回Json
            int         result  = -1;                //类型(成功 、失败)

            try
            {
                DataTable dt = _menuOpApp.GetByCodeOrName(menuId, name, keyCode);
                if (!ValidateHelper.IsDataTableNotData(dt))
                {
                    throw new CustomException(0, " 添加操作码失败,操作码名称或代码重复");
                }
                SysMenuOptModel model = new SysMenuOptModel();
                model.MO_CODE     = keyCode;
                model.MO_NAME     = name;
                model.MENU_ID     = menuId;
                model.IS_ABLED    = isValid ? 1 : 0;
                model.MO_DESC     = desc;
                model.CREATE_USER = UserID;
                model.LM_USER     = UserID;
                result            = _menuOpApp.Insert(model);

                jsonMsg = ServiceResult.Message(1, "添加操作码成功");
            }
            catch (CustomException ex)
            {
                jsonMsg = ServiceResult.Message(ex.ResultFlag, ex.Message);
            }
            catch (Exception ex)
            {
                jsonMsg = ServiceResult.Message(-1, ex.Message);
                WriteSystemException(ex, this.GetType(), OPT_MODEL, "为菜单[" + menuId + "]添加操作码[" + keyCode + "]失败");
            }

            //写入log
            WriteSystemLog(jsonMsg, CREATE, OPT_MODEL, menuId + ":" + keyCode + ":添加操作码");

            return(jsonMsg);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 删除角色
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public JsonMessage Delete(string roleId)
        {
            JsonMessage jsonMsg = new JsonMessage(); //返回Json
            int         result  = -1;                //类型(成功 、失败)

            try
            {
                DataTable dt = _roleRep.GetById(roleId);
                if (ValidateHelper.IsDataTableNotData(dt))
                {
                    throw new CustomException(0, "角色删除失败,角色不存在");//
                }

                result = _roleRep.Delete(roleId);
                if (result > 0)
                {
                    _userRep.DeleteSysUserRoleByRoleId(roleId);//根据角色ID 删除用户与角色的对应关系
                    _roleRep.ClearUnusedRightOpt();
                }
                jsonMsg = ServiceResult.Message(1, "角色删除成功");
            }
            catch (CustomException ex)
            {
                jsonMsg = ServiceResult.Message(ex.ResultFlag, ex.Message);
            }
            catch (Exception ex)
            {
                jsonMsg = ServiceResult.Message(-1, ex.Message);
                WriteSystemException(ex, this.GetType(), OPT_MODEL, "删除角色失败");
            }

            //写入log
            WriteSystemLog(jsonMsg, DELETE, OPT_MODEL, "删除角色");

            return(jsonMsg);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 修改角色
        /// </summary>
        /// <param name="roleId"></param>
        /// <param name="roleName"></param>
        /// <param name="desc"></param>
        /// <returns></returns>
        public JsonMessage Edit(string roleId, string roleName, string desc)
        {
            JsonMessage jsonMsg = new JsonMessage(); //返回Json
            int         result  = -1;                //类型(成功 、失败)

            try
            {
                DataTable dt = _roleRep.GetById(roleId);
                if (ValidateHelper.IsDataTableNotData(dt))
                {
                    throw new CustomException(0, "角色修改失败,角色不存在");//
                }

                SysRoleModel model = new SysRoleModel();
                model.ROLE_ID   = roleId;
                model.ROLE_NAME = roleName;
                model.ROLE_DESC = desc;
                model.LM_USER   = UserID;
                result          = _roleRep.Edit(model);
                jsonMsg         = ServiceResult.Message(1, "角色修改成功");
            }
            catch (CustomException ex)
            {
                jsonMsg = ServiceResult.Message(ex.ResultFlag, ex.Message);
            }
            catch (Exception ex)
            {
                jsonMsg = ServiceResult.Message(-1, ex.Message);
                WriteSystemException(ex, this.GetType(), OPT_MODEL, "修改角色失败");
            }

            //写入log
            WriteSystemLog(jsonMsg, UPDATE, OPT_MODEL, "修改角色信息");

            return(jsonMsg);
        }
Exemplo n.º 14
0
        public JsonMessage Insert(string menuName, string parentId, string code, string link, string icon, int sort, string type, string desc, bool isable, bool isend)
        {
            JsonMessage jsonMsg = new JsonMessage(); //返回Json
            int         result  = -1;                //类型(成功 、失败)

            _menuRep.BeginTransaction();
            try
            {
                DataTable dt = _menuRep.GetByCodeOrName(code, menuName);
                if (!ValidateHelper.IsDataTableNotData(dt))
                {
                    throw new CustomException(0, "添加失败,菜单名称或编码已存在");
                }

                SysMenuModel model = new SysMenuModel();
                model.MENU_ID     = GuidHelper.GenerateComb().ToString().ToUpper();
                model.MENU_NAME   = menuName;
                model.PARENT_ID   = parentId;
                model.MENU_CODE   = code;
                model.MENU_PATH   = link;
                model.MENU_ICON   = icon;
                model.MENU_SORT   = sort;
                model.MENU_TYPE   = type;
                model.MENU_DESC   = desc;
                model.IS_ABLED    = isable ? 1 : 0;
                model.IS_END      = isend ? 1 : 0;
                model.CREATE_USER = UserID;
                model.LM_USER     = UserID;

                result = _menuRep.Insert(model);
                if (result == 1)
                {
                    SysMenuOptModel optModel = new SysMenuOptModel();
                    optModel.MO_CODE     = "browse";
                    optModel.MO_NAME     = "浏览";
                    optModel.MENU_ID     = model.MENU_ID;
                    optModel.IS_ABLED    = 1;
                    optModel.MO_DESC     = "请勿删除,默认添加项,误删除请重新添加上";
                    optModel.CREATE_USER = UserID;
                    optModel.LM_USER     = UserID;
                    _menuOptRep.Insert(optModel);
                    _rightRep.InsertSysRight(model.CREATE_USER, model.LM_USER);
                }
                _menuRep.CommitTransaction();

                jsonMsg = ServiceResult.Message(1, "菜单添加成功");
            }
            catch (CustomException ex)
            {
                _menuRep.RollbackTransaction();
                jsonMsg = ServiceResult.Message(ex.ResultFlag, ex.Message);
            }
            catch (Exception ex)
            {
                _menuRep.RollbackTransaction();
                jsonMsg = ServiceResult.Message(-1, ex.Message);
                WriteSystemException(ex, this.GetType(), OPT_MODEL, code + ":添加系统菜单失败");
            }

            //写入log
            WriteSystemLog(jsonMsg, CREATE, OPT_MODEL, code + ":添加系统菜单");

            return(jsonMsg);
        }