Exemplo n.º 1
0
        public ContentResult RightsToConfig(int id, string[] idlist)
        {
            if (idlist == null || idlist.Length <= 0)
            {
                return(Content("分配角色权限失败,请选择要分配的权限!"));
            }
            List <int> rList = new List <int>();

            foreach (string sid in idlist)
            {
                int tid = 0;
                if (int.TryParse(sid, out tid))
                {
                    rList.Add(tid);
                }
            }
            if (B_Role.RelevanceRightsList(id, rList))
            {
                B_MenuRights.ClearHashMenuRights();
            }
            else
            {
                return(Content("分配角色权限失败!"));
            }
            return(Content("ok"));
        }
Exemplo n.º 2
0
        public ContentResult MenusToDel(int id)
        {
            if (B_Menu.DeleteAll(id))
            {
                B_MenuRights.ClearHashMenuRights();

                return(Content("ok"));
            }
            return(Content("删除出错"));
        }
Exemplo n.º 3
0
        public ContentResult MenusToEdit(B_Menu menu)
        {
            menu.IsShow  = Request["IsShow"] != null && Request["IsShow"].ToString() == "on" ? true : false;
            menu.IsValid = Request["IsValid"] != null && Request["IsValid"].ToString() == "on" ? true : false;
            menu.IsRobot = Request["IsRobot"] != null && Request["IsRobot"].ToString() == "on" ? false : true;

            if (string.IsNullOrWhiteSpace(menu.MenuName))
            {
                return(Content("名称不能为空"));
            }
            if (RepeatHelper.NoRepeat("B_Menu", "MenuName", menu.MenuName, menu.ID) > 0)
            {
                return(Content("菜单名已存在"));
            }
            if (!string.IsNullOrWhiteSpace(menu.MenuUrl) && RepeatHelper.NoRepeat("B_Menu", "MenuUrl", menu.MenuUrl, menu.ID) > 0)
            {
                return(Content("菜单链接已存在"));
            }
            int rtn = menu.UpdateByID();

            if (rtn > 0)
            {
                bool hasMainMenuTag          = false;
                bool hasError                = false;
                List <B_MenuRights> muRights = null;
                if (string.IsNullOrWhiteSpace(menu.MenuUrl) == false)
                {
                    menu.MenuUrl = menu.MenuUrl.Trim().TrimEnd('/');
                    try
                    {
                        string   tmpUrl = menu.MenuUrl.TrimStart('/').Split('?')[0];
                        string[] arrUrl = tmpUrl.Split('/');
                        Type     type   = Type.GetType("WeBusiness.Controllers." + arrUrl[0] + "Controller");
                        muRights = BaseAuthorizeHelper.GetBOMenuRightsByControllerType(type, arrUrl[1], out hasMainMenuTag);
                    }
                    catch (Exception ex)
                    {
                        DAL.Log.Instance.Write(ex.ToString(), "BOMenu_Update");
                        hasError = true;
                    }
                }
                if (hasMainMenuTag && muRights != null)
                {
                    B_MenuRights.RelevanceList(menu.ID, muRights);
                }
                if (hasError)
                {
                    return(Content("修改菜单成功,但菜单没有添加权限!"));
                }
                B_MenuRights.ClearHashMenuRights();
                return(Content("ok"));
            }
            return(Content("保存出错"));
        }
Exemplo n.º 4
0
        public ContentResult ToSetUserDesktop(string DesktopIDSet)
        {
            if (B_Role.SetUserDesktopAuth(CurrentUser.RoleID, CurrentUser.UserName, DesktopIDSet))
            {
                B_MenuRights.ClearHashMenuRights();
            }
            else
            {
                return(Content("分配角色权限失败!"));
            }

            return(Content("ok"));
        }
Exemplo n.º 5
0
 public ContentResult UpdateAllRights()
 {
     try
     {
         List <B_Menu> menus    = B_Menu.GetEntitysAll();
         string        ErrorStr = "";
         foreach (B_Menu menu in menus)
         {
             if (menu.ParentID == 0)
             {
                 continue;
             }
             bool hasMainMenuTag          = false;
             List <B_MenuRights> muRights = null;
             if (string.IsNullOrWhiteSpace(menu.MenuUrl) == false)
             {
                 menu.MenuUrl = menu.MenuUrl.Trim().TrimEnd('/');
                 try
                 {
                     string   tmpUrl = menu.MenuUrl.TrimStart('/').Split('?')[0];
                     string[] arrUrl = tmpUrl.Split('/');
                     Type     type   = Type.GetType("WeBusiness.Controllers." + arrUrl[0] + "Controller");
                     muRights = BaseAuthorizeHelper.GetBOMenuRightsByControllerType(type, arrUrl[1], out hasMainMenuTag);
                 }
                 catch (Exception ex)
                 {
                     DAL.Log.Instance.Write(ex.ToString(), "BOMenu_Update");
                     ErrorStr += "【" + menu.MenuName + "】";
                 }
             }
             if (hasMainMenuTag && muRights != null)
             {
                 B_MenuRights.RelevanceList(menu.ID, muRights);
             }
             B_MenuRights.ClearHashMenuRights();
         }
         if (!string.IsNullOrWhiteSpace(ErrorStr))
         {
             return(Content("更新失败的菜单:" + ErrorStr));
         }
         return(Content("ok"));
     }
     catch (Exception ex)
     {
         DAL.Log.Instance.Write(ex.ToString(), "B_Menu_UpdateAllRights_error");
         return(Content("更新失败"));
     }
 }