Beispiel #1
0
        /// <summary>
        ///  新增用户权限
        /// </summary>
        /// <param name="projectId">projectId</param>
        /// <param name="userId">The user identifier.</param>
        /// <param name="company">The company.</param>
        /// <param name="rule">The rule.</param>
        /// Author  : Napoleon
        /// Created : 2015-01-23 09:48:45
        public ActionResult SavePermitAdd(string projectId, string userId, string company, string rule)
        {
            SystemUserAndRule rules = new SystemUserAndRule();

            rules.ProjectId    = projectId;
            rules.Id           = CustomId.GetCustomId();
            rules.UserId       = userId;
            rules.RuleParentId = company;
            rules.RuleId       = rule;
            int    count = _userAndRuleService.InsertUserRule(rules);
            string status = "failue", msg, json;

            switch (count)
            {
            case -1:
                msg = "添加失败,该用户已经拥有类似权限,不能重复添加!";
                break;

            case 1:
                status = "success";
                msg    = "添加成功!";
                break;

            default:
                msg = "添加失败!";
                break;
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #2
0
        /// <summary>
        ///  更新用户信息
        /// </summary>
        /// Author  : Napoleon
        /// Created : 2015-01-19 15:53:14
        public ActionResult UpdateUser(string id, string projectId, string userName, string realName, string mobilePhone, string isUse, string userAddress, decimal sort, string remark)
        {
            SystemUser user = new SystemUser();

            user.Id          = id;
            user.UserName    = userName;
            user.RealName    = realName;
            user.MobilePhone = mobilePhone;
            user.IsUse       = isUse;
            user.UserAddress = userAddress;
            user.Sort        = sort;
            user.Remark      = remark;
            user.Operator    = PublicFields.UserCookie.ReadCookie <SystemUser>().UserName;
            user.ProjectId   = projectId;
            int    count = _userService.UpdateUser(user);
            string status = "failue", msg, json;

            switch (count)
            {
            case -1:
                msg = "更新失败,该账号已存在!";
                break;

            case 1:
                status = "success";
                msg    = "更新成功!";
                break;

            default:
                msg = "更新失败!";
                break;
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #3
0
        /// <summary>
        ///  用户校验
        /// </summary>
        /// <param name="userName">用户账号</param>
        /// <param name="passWord">用户密码</param>
        /// Author  : Napoleon
        /// Created : 2015-01-07 10:04:36
        public ActionResult CheckUser(string userName, string passWord)
        {
            SystemUser user = _userService.CheckUser(userName, passWord, PublicFields.ProjectId);
            string     status = "failue", msg = "登录失败!", json;

            if (user != null)
            {
                if (user.IsUse.Equals(PublicFields.IsDefaultUse))
                {
                    //用户信息
                    user.WriteCookie(PublicFields.UserCookie);
                    //用户权限
                    SystemUserAndRule rule = _userAndRuleService.GetRule(user.Id, PublicFields.ProjectId);
                    if (rule == null)
                    {
                        msg = "登录失败,该账号不能登录本系统!";
                    }
                    else
                    {
                        rule.RuleId.WriteCookie(PublicFields.RuleIdCookies);
                        status = "success";
                        msg    = "登录成功!";
                    }
                }
                else
                {
                    msg = "登录失败,该账号已禁用,请联系管理员!";
                }
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #4
0
        /// <summary>
        ///  保存新增的导航菜单
        /// </summary>
        /// <param name="menuName">导航菜单名称</param>
        /// <param name="menuType">菜单类型</param>
        /// <param name="menuId">新闻菜单</param>
        /// <param name="menuUrl">链接地址</param>
        /// <param name="isUse">是否可用</param>
        /// <param name="orderBy">排序</param>
        /// Author  : Napoleon
        /// Created : 2015-06-09 15:37:10
        public ActionResult SaveAdd(string menuName, string menuType, string menuId, string menuUrl, string isUse, decimal orderBy)
        {
            string        status = "failue", msg = "新增失败!", json;
            SystemNavMenu nav = new SystemNavMenu();

            nav.Id            = CustomId.GetCustomId();
            nav.MenuName      = menuName;
            nav.MenuType      = int.Parse(menuType);
            nav.MenuId        = menuId;
            nav.MenuUrl       = menuUrl;
            nav.IsUse         = int.Parse(isUse);
            nav.OrderBy       = orderBy;
            nav.OperationTime = DateTime.Now;
            int i = _navMenuService.InsertSystemNavMenu(nav);

            switch (i)
            {
            case 1:
                status = "success";
                msg    = "新增成功!";
                break;
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #5
0
        /// <summary>
        ///  更新新闻菜单
        /// </summary>
        /// <param name="hiddenId">ID</param>
        /// <param name="menuName">导航菜单名称</param>
        /// <param name="menuType">菜单类型</param>
        /// <param name="menuId">新闻菜单</param>
        /// <param name="menuUrl">链接地址</param>
        /// <param name="isUse">是否可用</param>
        /// <param name="orderBy">排序</param>
        /// Author  : Napoleon
        /// Created : 2015-06-09 15:37:10
        public ActionResult UpdateEdit(string hiddenId, string menuName, string menuType, string menuId, string menuUrl, string isUse, decimal orderBy)
        {
            string        status = "failue", msg = "更新失败!", json;
            SystemNavMenu nav = new SystemNavMenu();

            nav.Id            = hiddenId;
            nav.MenuName      = menuName;
            nav.MenuType      = string.IsNullOrWhiteSpace(menuType) ? 0 : int.Parse(menuType);
            nav.MenuId        = menuId;
            nav.MenuUrl       = menuUrl;
            nav.IsUse         = int.Parse(isUse);
            nav.OrderBy       = orderBy;
            nav.OperationTime = DateTime.Now;
            int i = _navMenuService.UpdateSystemNavMenu(nav);

            switch (i)
            {
            case 1:
                status = "success";
                msg    = "更新成功!";
                break;
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #6
0
        /// <summary>
        ///  新增菜单
        /// </summary>
        /// Author  : Napoleon
        /// Created : 2015-01-24 16:19:31
        public ActionResult SaveMenu(string projectName, string projectId, string parentId, string htmlId, string url, string icon, string sort, string remark)
        {
            SystemMenu menu = new SystemMenu();

            menu.ProjectId = projectId;
            menu.Id        = CustomId.GetCustomId();
            menu.ParentId  = string.IsNullOrWhiteSpace(parentId) ? "0" : parentId;
            menu.Name      = projectName;
            menu.HtmlId    = htmlId;
            menu.Url       = url;
            menu.Icon      = icon;
            menu.Sort      = Convert.ToDecimal(sort);
            menu.Remark    = remark;
            menu.Operator  = PublicFields.UserCookie.ReadCookie <SystemUser>().UserName;
            int    count = _menuService.InsertMenu(menu);
            string status = "failue", msg, json;

            switch (count)
            {
            case -1:
                msg = "添加失败,该菜单名称已经存在,请不要重复添加!";
                break;

            case 1:
                status = "success";
                msg    = "添加成功!";
                break;

            default:
                msg = "添加失败!";
                break;
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #7
0
        /// <summary>
        ///  根据ID更新信息
        /// </summary>
        /// Author  : Napoleon
        /// Created : 2015-01-26 16:21:38
        public ActionResult UpdateMenu(string id, string projectName, string parentId, string htmlId, string url, string icon, string sort, string remark)
        {
            SystemMenu menu = new SystemMenu();

            menu.Id       = id;
            menu.Name     = projectName;
            menu.ParentId = parentId;
            menu.HtmlId   = htmlId;
            menu.Url      = url;
            menu.Icon     = icon;
            menu.Sort     = Convert.ToDecimal(sort);
            menu.Remark   = remark;
            menu.Operator = PublicFields.UserCookie.ReadCookie <SystemUser>().UserName;
            int    count = _menuService.UpdateMenu(menu);
            string status = "failue", msg, json;

            switch (count)
            {
            case -1:
                msg = "该菜单已经存在,请不要使用重复的菜单名!";
                break;

            case 1:
                status = "success";
                msg    = "更新成功!";
                break;

            default:
                msg = "更新失败!";
                break;
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
        /// <summary>
        ///  新增系统
        /// </summary>
        /// Author  : Napoleon
        /// Created : 2015-01-24 09:29:42
        public ActionResult SaveAdd(string projectId, string projectName, string remark)
        {
            SystemProject project = new SystemProject();

            project.ProjectId   = projectId;
            project.ProjectName = projectName;
            project.Remark      = remark;
            project.Operator    = PublicFields.UserCookie.ReadCookie <SystemUser>().UserName;
            int    count = _projectService.InsertProject(project);
            string status = "failue", msg, json;

            if (count > 0)
            {
                status = "success";
                msg    = "添加成功!";
            }
            else if (count == 0)
            {
                msg = "添加失败!";
            }
            else
            {
                msg = "添加失败,该系统代码已经存在,请不要重复添加!";
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #9
0
        /// <summary>
        ///  保存新增
        /// </summary>
        /// <param name="projectId">The project identifier.</param>
        /// <param name="parentId">The parent identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="sort">The sort.</param>
        /// <param name="remark">The remark.</param>
        /// Author  : Napoleon
        /// Created : 2015-01-27 16:03:55
        public ActionResult SaveRule(string projectId, string parentId, string name, decimal sort, string remark)
        {
            SystemRule rule = new SystemRule();

            rule.ProjectId = projectId;
            rule.Id        = CustomId.GetCustomId();
            rule.ParentId  = string.IsNullOrWhiteSpace(parentId) ? "0" : parentId;
            rule.Name      = name;
            rule.Sort      = sort;
            rule.Remark    = remark;
            rule.Operator  = PublicFields.UserCookie.ReadCookie <SystemUser>().UserName;
            int    count = _ruleService.InsertRule(rule);
            string status = "failue", msg, json;

            switch (count)
            {
            case -1:
                msg = "添加失败,该角色名称已经存在,请不要重复添加!";
                break;

            case 1:
                status = "success";
                msg    = "添加成功!";
                break;

            default:
                msg = "添加失败!";
                break;
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #10
0
        /// <summary>
        ///  更新角色权限
        /// </summary>
        /// <param name="json">The json.</param>
        /// Author  : Napoleon
        /// Created : 2015-02-04 20:44:19
        public ActionResult SaveRule(string json)
        {
            json = HttpUtility.UrlDecode(json);
            List <SystemMenuAndRule> list = JsonConvert.DeserializeObject <List <SystemMenuAndRule> >(json);
            int    count = _menuAndRuleService.UpdateRuleMenu(list[0].RuleId, list[0].ProjectId, list);
            string status = "failue", msg, jsons;

            msg    = count > 0 ? "更新成功,请重新登陆!" : "更新失败!";
            status = count > 0 ? "success" : "failue";
            jsons  = PublicFunc.ModelToJson(status, msg);
            return(Content(jsons));
        }
Beispiel #11
0
        /// <summary>
        ///  初始化密码
        /// </summary>
        /// <param name="ids">The ids.</param>
        /// Author  : Napoleon
        /// Created : 2015-01-19 20:39:21
        public ActionResult UpdatePassWord(string ids)
        {
            int    count = _userService.UpdatePassWord(PublicFields.DefaultPw.GetMd5(), ids);
            string status = "failue", msg = "初始化失败", json;

            if (count > 0)
            {
                status = "success";
                msg    = "初始化成功!";
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #12
0
        /// <summary>
        ///  根据ID删除新闻菜单数据
        /// </summary>
        /// <param name="id">新闻菜单ID</param>
        /// Author  : Napoleon
        /// Created : 2015-06-09 16:23:50
        public ActionResult Delete(string id)
        {
            string status = "failue", msg = "删除失败!", json;
            int    i = _navMenuService.DeleteSystemNavMenu(id);

            switch (i)
            {
            case 1:
                status = "success";
                msg    = "删除成功!";
                break;
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #13
0
        public ActionResult SaveAdd(string newsMenuId, string newsType, string newsTitle, string httpUrl, string attachId, string indexImg, string attachContent1, string attachContent2, string attachContent3, string attachContent4, string content)
        {
            string status = "failue", msg = "保存失败!", json;

            try
            {
                NewsContents contents = new NewsContents();
                contents.Id         = CustomId.GetCustomId();
                contents.NewsMenuId = newsMenuId;
                contents.NewsTitle  = newsTitle;
                contents.NewsType   = newsType.StringToInt();
                switch (contents.NewsType)
                {
                case 2015014:
                    contents.AttachContent1 = attachContent1;
                    contents.AttachContent2 = attachContent2;
                    contents.AttachContent3 = attachContent3;
                    contents.AttachContent4 = attachContent4;
                    contents.IndexImg       = indexImg;
                    contents.NewsContent    = content;
                    break;

                case 2015015:
                    contents.HttpUrl = httpUrl;
                    break;

                case 2015016:
                    contents.AttachId = attachId;
                    break;
                }
                contents.RleaseTime = DateTime.Now;
                contents.NewsStatus = 2015009;//未通过审核
                int i = _newsContentsService.InsertNewsContents(contents);
                if (i > 0)
                {
                    status = "success";
                    msg    = "保存成功!";
                }
            }
            catch (Exception exception)
            {
                msg = "保存出错!";
                Log4Dao.InsertLog4(exception.Message);
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #14
0
        /// <summary>
        ///  删除用户
        /// </summary>
        /// <param name="id">id</param>
        /// Author  : Napoleon
        /// Created : 2015-01-17 15:52:54
        public ActionResult DeleteUser(string id)
        {
            int    count = _userService.DeleteUser(id);
            string status = "failue", msg, json;

            if (count > 0)
            {
                status = "success";
                msg    = "删除成功!";
            }
            else
            {
                msg = count == -1 ? "删除失败,请先删除用户对应的权限!" : "删除失败!";
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
        /// <summary>
        ///  删除系统
        /// </summary>
        /// <param name="projectId">projectId</param>
        /// Author  : Napoleon
        /// Created : 2015-01-24 10:40:18
        public ActionResult DeleteProject(string projectId)
        {
            int    count = _projectService.DeleteProject(projectId);
            string status = "failue", msg, json;

            if (count > 0)
            {
                status = "success";
                msg    = "删除成功!";
            }
            else
            {
                msg = count == -1 ? "删除失败,请先删除该系统对应的菜单或权限!" : "删除失败!";
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #16
0
        public ActionResult UpdateEdit(string hiddenId, string newsMenuId, string newsType, string newsTitle, string httpUrl, string attachId, string indexImg, string attachContent1, string attachContent2, string attachContent3, string attachContent4, string content)
        {
            string status = "failue", msg = "更新失败!", json;

            try
            {
                NewsContents contents = new NewsContents();
                contents.Id         = hiddenId;
                contents.NewsMenuId = newsMenuId;
                contents.NewsTitle  = newsTitle;
                contents.NewsType   = newsType.StringToInt();
                switch (contents.NewsType)
                {
                case 2015014:
                    contents.AttachContent1 = attachContent1;
                    contents.AttachContent2 = attachContent2;
                    contents.AttachContent3 = attachContent3;
                    contents.AttachContent4 = attachContent4;
                    contents.IndexImg       = indexImg;
                    contents.NewsContent    = content;
                    break;

                case 2015015:
                    contents.HttpUrl = httpUrl;
                    break;

                case 2015016:
                    contents.AttachId = attachId;
                    break;
                }
                int i = _newsContentsService.UpdateNewsContents(contents);
                if (i > 0)
                {
                    status = "success";
                    msg    = "更新成功!";
                }
            }
            catch (Exception exception)
            {
                msg = "更新出错!";
                Log4Dao.InsertLog4(exception.Message);
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
        /// <summary>
        ///  更新
        /// </summary>
        /// <param name="projectId">The project identifier.</param>
        /// <param name="projectName">Name of the project.</param>
        /// <param name="remark">The remark.</param>
        /// Author  : Napoleon
        /// Created : 2015-01-24 10:37:25
        public ActionResult UpdateProject(string projectId, string projectName, string remark)
        {
            SystemProject project = new SystemProject();

            project.ProjectId   = projectId;
            project.ProjectName = projectName;
            project.Remark      = remark;
            int    count = _projectService.UpdateProject(project);
            string status = "failue", msg = "更新失败!", json;

            if (count > 0)
            {
                status = "success";
                msg    = "更新成功!";
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #18
0
        /// <summary>
        ///  根据ID删除新闻菜单数据
        /// </summary>
        /// <param name="id">新闻菜单ID</param>
        /// Author  : Napoleon
        /// Created : 2015-06-09 16:23:50
        public ActionResult Delete(string id)
        {
            string status = "failue", msg = "删除出错!", json;
            int    i = _menuService.DeleteNewsMenu(id);

            switch (i)
            {
            case 1:
                status = "success";
                msg    = "删除成功!";
                break;

            case -1:
                msg = "请先删除对应的子菜单!";
                break;
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #19
0
        /// <summary>
        ///  保存密码
        /// </summary>
        /// <param name="id">id</param>
        /// <param name="password">password</param>
        /// <param name="newPw">newPw</param>
        /// Author  : Napoleon
        /// Created : 2015-01-17 13:30:42
        public ActionResult SaveUser(string id, string password, string newPw)
        {
            int    count = _userModule.ChangePwXml(id, password, newPw);
            string status = "failue", msg = "修改失败!", json;

            switch (count)
            {
            case -1:
                msg = "修改失败,请输入正确的原密码!";
                break;

            case 1:
                status = "success";
                msg    = "修改成功,请重新登陆系统";
                break;
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #20
0
        /// <summary>
        ///  根据ID删除用户权限数据
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// Author  : Napoleon
        /// Created : 2015-01-21 15:58:33
        public ActionResult DeletePermit(string id)
        {
            int    count = _userAndRuleService.DeleteRuleById(id);
            string status = "failue", msg, json;

            switch (count)
            {
            case 1:
                status = "success";
                msg    = "删除成功!";
                break;

            default:
                msg = "删除失败!";
                break;
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #21
0
        /// <summary>
        ///  确认
        /// </summary>
        /// <param name="ids">操作的ID</param>
        /// <param name="verifyId">审核结果</param>
        /// Author  : Napoleon
        /// Created : 2015-06-25 11:13:01
        public ActionResult SureVerify(string ids, string verifyId)
        {
            string status = "failue", msg = "确认失败!", json;

            try
            {
                if (_newsContentsService.UpdateNewsVerify(ids, verifyId) > 0)
                {
                    status = "success";
                    msg    = "确认成功!";
                }
            }
            catch (Exception exception)
            {
                msg = "确认出错!";
                Log4Dao.InsertLog4(exception.Message);
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #22
0
        /// <summary>
        ///  根据ID删除数据
        /// </summary>
        /// Author  : Napoleon
        /// Created : 2015-06-24 15:59:36
        public ActionResult Delete(string ids)
        {
            string status = "failue", msg = "删除失败!", json;

            try
            {
                int i = _newsContentsService.DeleteNewsContents(ids);
                if (i > 0)
                {
                    status = "success";
                    msg    = "删除成功!";
                }
            }
            catch (Exception exception)
            {
                msg = "删除出错!";
                Log4Dao.InsertLog4(exception.Message);
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #23
0
        /// <summary>
        ///  保存新增的用户信息
        /// </summary>
        /// Author  : Napoleon
        /// Created : 2015-01-19 10:46:59
        public ActionResult SaveAdd(string projectId, string userName, string realName, string mobilePhone, string isUse, string userAddress, decimal sort, string remark)
        {
            SystemUser user = new SystemUser();

            user.Id          = CustomId.GetCustomId();
            user.UserName    = userName;
            user.PassWords   = PublicFields.DefaultPw.EncrypteRc2(PublicFields.Rc2Key);
            user.RealName    = realName;
            user.MobilePhone = mobilePhone;
            user.IsUse       = isUse;
            user.UserAddress = userAddress;
            user.Sort        = sort;
            user.Remark      = remark;
            user.Operator    = PublicFields.UserCookie.ReadCookie <SystemUser>().UserName;
            user.ProjectId   = projectId;
            int    count = _userService.SaveAddUser(user);
            string status = "failue", msg, json;

            switch (count)
            {
            case -1:
                msg = "保存失败,该账号已存在!";
                break;

            case 1:
                status = "success";
                msg    = "保存成功!";
                break;

            default:
                msg = "保存失败!";
                break;
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #24
0
        /// <summary>
        ///  保存新增的新闻菜单
        /// </summary>
        /// <param name="menuName">菜单名称</param>
        /// <param name="isParent">是否父菜单</param>
        /// <param name="parentId">父菜单ID</param>
        /// <param name="isUse">是否可用</param>
        /// <param name="orderBy">排序</param>
        /// Author  : Napoleon
        /// Created : 2015-06-09 15:37:10
        public ActionResult SaveAdd(string menuName, string isParent, string parentId, string isUse, decimal orderBy)
        {
            string   status = "failue", msg = "新增失败!", json;
            NewsMenu menu = new NewsMenu();

            menu.Id            = CustomId.GetCustomId();
            menu.MenuName      = menuName;
            menu.ParentId      = parentId;
            menu.IsParent      = isParent;
            menu.IsUse         = int.Parse(isUse);
            menu.OrderBy       = orderBy;
            menu.OperationTime = DateTime.Now;
            int i = _menuService.InsertNewsMenu(menu);

            switch (i)
            {
            case 1:
                status = "success";
                msg    = "新增成功!";
                break;
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }
Beispiel #25
0
        /// <summary>
        ///  验证用户信息
        /// </summary>
        /// Author  : Napoleon
        /// Created : 2015-06-06 16:29:44
        public ActionResult CheckUser(string userName, string passWord)
        {
            string status = "failue", msg, json;

            try
            {
                SystemUser user = _service.CheckUserXml(userName, passWord, PublicFields.ProjectId);
                if (user != null)
                {
                    user.WriteCookie(PublicFields.UserCookies);
                    //用户权限
                    SystemUserAndRule rule = _service.GetRuleXml(user.Id, PublicFields.ProjectId);
                    if (rule == null)
                    {
                        msg = "登录失败,该账号不能登录本系统!";
                    }
                    else
                    {
                        rule.RuleId.WriteCookie(PublicFields.RuleIdCookies);
                        status = "success";
                        msg    = "登录成功!";
                    }
                }
                else
                {
                    msg = "登录失败,账号或密码错误!";
                }
            }
            catch (Exception exception)
            {
                msg = "登录出错!";
                Log4Dao.InsertLog4(exception.Message);
            }
            json = PublicFunc.ModelToJson(status, msg);
            return(Content(json));
        }