/// <summary>
 /// 获取指定用户例外权限的菜单
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 public IDictionary<long, string> GetAuthorExceptionMenuDict(AuthorMenuRightExceptionEntity authorExceptionMenuEntity)
 {
     IDictionary<long, string> dictAuthorExceptionMap = new Dictionary<long, string>();
     StringBuilder sqlCommandText = new StringBuilder();
     sqlCommandText.Append("SELECT a.MenuID,m.MenuUrl FROM dbo.AuthorMenuRightException a WITH(NOLOCK),dbo.Menu m WITH(NOLOCK) WHERE a.MenuID = m.MenuID AND a.AuthorID=@AuthorID AND a.JournalID=@JournalID");
     DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString());
     db.AddInParameter(cmd, "@JournalID", DbType.Int64, authorExceptionMenuEntity.JournalID);
     db.AddInParameter(cmd, "@AuthorID", DbType.Int64, authorExceptionMenuEntity.AuthorID);
     long MenuID = 0;
     int MenuIDIndex = 0;
     int MenuUrlIndex = 0;
     using (IDataReader dr = db.ExecuteReader(cmd))
     {
         MenuIDIndex = dr.GetOrdinal("MenuID");
         MenuUrlIndex = dr.GetOrdinal("MenuID");
         while (dr.Read())
         {
             MenuID = WKT.Common.Utils.TypeParse.ToLong(dr[MenuIDIndex], 0);
             if (!dictAuthorExceptionMap.ContainsKey(MenuID))
             {
                 dictAuthorExceptionMap.Add(MenuID, dr[MenuUrlIndex].ToString());
             }
         }
         dr.Close();
     }
     return dictAuthorExceptionMap;
 }
 public IDictionary<long, string> GetAuthorExceptionMenu(AuthorMenuRightExceptionEntity authorExcMenu)
 {
     IDictionary<long, string> dictHaveRightMenu = new Dictionary<long, string>();
     IRoleMenuService menuRoleService = ServiceContainer.Instance.Container.Resolve<IRoleMenuService>();
     dictHaveRightMenu = menuRoleService.GetAuthorExceptionMenuDict(authorExcMenu);
     return dictHaveRightMenu;
 }
 public ExecResult SetAuthorExceptionMenuRight(AuthorMenuRightExceptionEntity authorMenuRightException)
 {
     ExecResult result = new ExecResult();
     try
     {
         IRoleMenuService roleMenuService = ServiceContainer.Instance.Container.Resolve<IRoleMenuService>();
         bool flag = roleMenuService.SetAuthorExceptionMenuRight(authorMenuRightException);
         if (flag)
         {
             result.result = EnumJsonResult.success.ToString();
             result.msg = "成功";
         }
         else
         {
             result.result = EnumJsonResult.failure.ToString();
             result.msg = "设置作者菜单权限例外失败,请确认设置信息是否正确";
         }
     }
     catch (Exception ex)
     {
         result.result = EnumJsonResult.error.ToString();
         result.msg = "设置作者菜单权限例外失败:" + ex.Message;
     }
     return result;
 }
        /// <summary>
        /// 获取菜单列表,带有权限标示
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public IList<TreeModel> GetHaveRightMenuAjaxByRole(RoleMenuQuery queryRoleMenu)
        {
            HttpClientHelper clientHelper = new HttpClientHelper();

            // 给指定的作者设置了例外的菜单
            IDictionary<long, string> dictExceptionRightMenu = new Dictionary<long, string>();
            if (queryRoleMenu.AuthorID != null)
            {
                AuthorMenuRightExceptionEntity authorExecEntity = new AuthorMenuRightExceptionEntity();
                authorExecEntity.AuthorID = queryRoleMenu.AuthorID.Value;
                authorExecEntity.JournalID = queryRoleMenu.JournalID;
                dictExceptionRightMenu = clientHelper.PostAuth<IDictionary<long, string>, AuthorMenuRightExceptionEntity>(GetAPIUrl(APIConstant.SYSGETAUTHOREXCEPTIONRIGHTMENU), authorExecEntity);
            }

            IList<MenuEntity> listHaveRightMenuList = clientHelper.Post<IList<MenuEntity>, RoleMenuQuery>(GetAPIUrl(APIConstant.SYSGETHAVERIGHTMENULIST), queryRoleMenu);
            IList<TreeModel> listResult = new List<TreeModel>();
            if (listHaveRightMenuList != null)
            {
                IList<MenuEntity> listRoot = listHaveRightMenuList.Where(item => item.PMenuID == 0).ToList<MenuEntity>();
                TreeModel treeNode = null;
                foreach (MenuEntity item in listRoot)
                {
                    treeNode = new TreeModel();
                    treeNode.key = item.MenuID.ToString();
                    treeNode.text = item.MenuName;
                    treeNode.url = SiteConfig.RootPath + item.MenuUrl;
                    treeNode.icon = SiteConfig.RootPath + item.IconUrl;
                    treeNode.isexpand = queryRoleMenu.IsExpend;
                    treeNode.ischecked = dictExceptionRightMenu.ContainsKey(item.MenuID) ? false : true;

                    IList<MenuEntity> listChild = listHaveRightMenuList.Where(p => p.PMenuID == item.MenuID).ToList<MenuEntity>();
                    if (listChild != null)
                    {
                        // 二级
                        foreach (MenuEntity itemChild in listChild)
                        {

                            TreeModel treeChildNode = new TreeModel();
                            treeChildNode.key = itemChild.MenuID.ToString();
                            treeChildNode.text = itemChild.MenuName;
                            treeChildNode.url = SiteConfig.RootPath + itemChild.MenuUrl;
                            treeChildNode.icon = SiteConfig.RootPath + itemChild.IconUrl;
                            treeChildNode.isexpand = queryRoleMenu.IsExpend;
                            treeChildNode.ischecked = dictExceptionRightMenu.ContainsKey(itemChild.MenuID) ? false : true;
                            treeNode.children.Add(treeChildNode);
                            // 三级
                            IList<MenuEntity> lastListChild = listHaveRightMenuList.Where(p => p.PMenuID == itemChild.MenuID).ToList<MenuEntity>();
                            foreach (MenuEntity lastChild in lastListChild)
                            {

                                TreeModel treeLastNode = new TreeModel();
                                treeLastNode.key = lastChild.MenuID.ToString();
                                treeLastNode.text = lastChild.MenuName;
                                treeLastNode.url = SiteConfig.RootPath + lastChild.MenuUrl;
                                treeLastNode.icon = SiteConfig.RootPath + lastChild.IconUrl;
                                treeLastNode.isexpand = queryRoleMenu.IsExpend;
                                treeLastNode.ischecked = dictExceptionRightMenu.ContainsKey(lastChild.MenuID) ? false : true;
                                treeChildNode.children.Add(treeLastNode);
                            }
                        }
                    }
                    listResult.Add(treeNode);
                }
            }
            return listResult;
        }
        /// <summary>
        /// 获取菜单列表,带有权限标示
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public IList<TreeModel> GetHaveRightMenu(RoleMenuQuery queryRoleMenu)
        {
            if (queryRoleMenu.GroupID == 2)
            {
                MenuQuery query = new MenuQuery();
                query.JournalID = queryRoleMenu.JournalID;
                query.GroupID = 2;
                query.Status = 1;
                return GetTreeNodeList(query);
            }

            # region 找到内容菜单,添加栏目列表

            Func<IList<TreeModel>> funcGetSiteChanneNodes = () =>
            {
                IList<TreeModel> channelTreeList = new List<TreeModel>();
                SiteChannelQuery channelQuery = new SiteChannelQuery();
                channelQuery.JournalID = queryRoleMenu.JournalID;
                channelQuery.Status = 1;
                SiteConfigFacadeAPIService siteConfigAPIService = new SiteConfigFacadeAPIService();
                channelTreeList = siteConfigAPIService.GetSiteChannelTreeList(channelQuery,true);
                TreeModel root = channelTreeList.Single(p => p.Id == 0);
                return root.children;
            };

            # endregion

            IList<TreeModel> listResult = new List<TreeModel>();

            HttpClientHelper clientHelper = new HttpClientHelper();

            // 给指定的作者设置了例外的菜单
            IDictionary<long, string> dictExceptionRightMenu = new Dictionary<long, string>();
            if (queryRoleMenu.AuthorID != null)
            {
                AuthorMenuRightExceptionEntity authorExecEntity = new AuthorMenuRightExceptionEntity();
                authorExecEntity.AuthorID = queryRoleMenu.AuthorID.Value;
                authorExecEntity.JournalID = queryRoleMenu.JournalID;
                dictExceptionRightMenu = clientHelper.PostAuth<IDictionary<long, string>, AuthorMenuRightExceptionEntity>(GetAPIUrl(APIConstant.SYSGETAUTHOREXCEPTIONRIGHTMENU), authorExecEntity);
            }
            IList<MenuEntity> listHaveRightMenuList = clientHelper.Post<IList<MenuEntity>, RoleMenuQuery>(GetAPIUrl(APIConstant.SYSGETHAVERIGHTMENULIST), queryRoleMenu);

            if (listHaveRightMenuList != null)
            {
                IList<MenuEntity> listRoot = listHaveRightMenuList.Where(item => item.PMenuID == 0).ToList<MenuEntity>();
                TreeModel treeNode = null;
                foreach (MenuEntity item in listRoot)
                {
                    if (!dictExceptionRightMenu.ContainsKey(item.MenuID))
                    {
                        bool first = true;

                        treeNode = new TreeModel();
                        treeNode.key = item.MenuID.ToString();
                        treeNode.text = item.MenuName;
                        treeNode.url = SiteConfig.RootPath + item.MenuUrl;
                        treeNode.icon = SiteConfig.RootPath + item.IconUrl;
                        treeNode.isexpand = queryRoleMenu.IsExpend;

                        IList<MenuEntity> listChild = listHaveRightMenuList.Where(p => p.PMenuID == item.MenuID).ToList<MenuEntity>();
                        if (listChild != null)
                        {
                            treeNode.isexpand = (first != queryRoleMenu.IsExpend) && first ? first : queryRoleMenu.IsExpend;
                            // 二级
                            foreach (MenuEntity itemChild in listChild)
                            {
                                if (!dictExceptionRightMenu.ContainsKey(itemChild.MenuID))
                                {
                                    TreeModel treeChildNode = new TreeModel();
                                    treeChildNode.key = itemChild.MenuID.ToString();
                                    treeChildNode.text = itemChild.MenuName;
                                    treeChildNode.url = SiteConfig.RootPath + itemChild.MenuUrl;
                                    treeChildNode.icon = SiteConfig.RootPath + itemChild.IconUrl;
                                    treeChildNode.isexpand = queryRoleMenu.IsExpend;
                                    // 如果是网站内容管理节点,则载入站点栏目设置
                                    if (itemChild.IsContentMenu)
                                    {
                                        treeChildNode.children = funcGetSiteChanneNodes();
                                        treeNode.children.Add(treeChildNode);
                                    }
                                    else
                                    {
                                        treeNode.children.Add(treeChildNode);
                                        // 三级
                                        IList<MenuEntity> lastListChild = listHaveRightMenuList.Where(p => p.PMenuID == itemChild.MenuID).ToList<MenuEntity>();
                                        foreach (MenuEntity lastChild in lastListChild)
                                        {
                                            if (!dictExceptionRightMenu.ContainsKey(lastChild.MenuID))
                                            {
                                                TreeModel treeLastNode = new TreeModel();
                                                treeLastNode.key = lastChild.MenuID.ToString();
                                                treeLastNode.text = lastChild.MenuName;
                                                treeLastNode.url = SiteConfig.RootPath + lastChild.MenuUrl;
                                                treeLastNode.icon = SiteConfig.RootPath + lastChild.IconUrl;
                                                treeLastNode.isexpand = queryRoleMenu.IsExpend;
                                                treeChildNode.children.Add(treeLastNode);
                                            }
                                        }
                                    }
                                }
                            }
                            first = false;
                        }
                        listResult.Add(treeNode);
                    }
                }
            }
            return listResult;
        }
 /// <summary>
 /// 给指定角色内的用户设置例外菜单权限
 /// </summary>
 /// <param name="authorExceptionRight"></param>
 /// <returns></returns>
 public bool SetAuthorExceptionMenuRight(AuthorMenuRightExceptionEntity authorExceptionRight)
 {
     return RoleMenuDataAccess.Instance.SetAuthorExceptionMenuRight(authorExceptionRight);
 }
 /// <summary>
 /// 获取指定用户例外权限的菜单
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 public IDictionary<long, string> GetAuthorExceptionMenuDict(AuthorMenuRightExceptionEntity authorExceptionMenuEntity)
 {
     return RoleMenuDataAccess.Instance.GetAuthorExceptionMenuDict(authorExceptionMenuEntity);
 }
Beispiel #8
0
 /// <summary>
 /// 获取指定用户例外权限的菜单
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 public IDictionary<long, string> GetAuthorExceptionMenuDict(AuthorMenuRightExceptionEntity authorExceptionMenuEntity)
 {
     return RoleMenuBusProvider.GetAuthorExceptionMenuDict(authorExceptionMenuEntity);
 }
Beispiel #9
0
 /// <summary>
 /// 给指定角色内的用户设置例外菜单权限
 /// </summary>
 /// <param name="authorExceptionRight"></param>
 /// <returns></returns>
 public bool SetAuthorExceptionMenuRight(AuthorMenuRightExceptionEntity authorExceptionRight)
 {
     return RoleMenuBusProvider.SetAuthorExceptionMenuRight(authorExceptionRight);
 }
Beispiel #10
0
        public ActionResult SetAurhorException(long RoleID,long[] AuthorIDArray, long[] IDAarry)
        {
            ExecResult execResult = new ExecResult();

            try
            {
                foreach (long AuthorID in AuthorIDArray)
                {
                    AuthorMenuRightExceptionEntity authorMenuRightExceptionEntity = new AuthorMenuRightExceptionEntity();
                    authorMenuRightExceptionEntity.AuthorID = AuthorID;
                    authorMenuRightExceptionEntity.MenuIDList = IDAarry.ToList<long>();
                    authorMenuRightExceptionEntity.JournalID = JournalID;
                    authorMenuRightExceptionEntity.RoleID = RoleID;
                    IAuthorFacadeService authorService = ServiceContainer.Instance.Container.Resolve<IAuthorFacadeService>();
                    execResult = authorService.SetAurhorMenuRightException(authorMenuRightExceptionEntity);
                    if (execResult.result == EnumJsonResult.error.ToString() || execResult.result == EnumJsonResult.failure.ToString())
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                execResult.result = EnumJsonResult.error.ToString();
                execResult.msg = "设置用户菜单权限例外时现异常:" + ex.Message;
                WKT.Log.LogProvider.Instance.Error("设置用户菜单权限例外时现异常:" + ex.Message);
            }

            return Content(JsonConvert.SerializeObject(execResult));
        }