Пример #1
0
        public MenusData GetMenus()
        {
            var result = new MenusData();

            try
            {
                var menus = Cache.Instance["mango_menus"];
                if (menus == null)
                {
                    result = RoleRightDA.GetMenus();
                    if (result == null || result.PageRight == null ||
                        result.PageRight.Count == 0)
                    {
                        throw new Exception("没有配置菜单项");
                    }

                    Cache.Instance.Add("mango_menus", result);
                }
                else
                {
                    result = menus as MenusData;
                }
            }
            catch (Exception ex)
            {
                Logger.WriteException("GetMenus", ex, "");
                throw new Exception("没有配置菜单项");
            }

            return(result);
        }
Пример #2
0
        public int CreateMenuExternal(string Name, string Link)
        {
            if (StringUtils.IsNullOrWhiteSpace(Name))
            {
                return(-1);
            }

            var q = from _menu in GetMenuExternals()
                    where _menu.Name == Name
                    select _menu;

            if (q.Count() > 0)
            {
                return(-1);
            }

            Menu_External menu = new Menu_External
            {
                Name = Name,
                Link = Link
            };

            MenusData.Menu_Externals.InsertOnSubmit(menu);
            MenusData.SubmitChanges();

            return(menu.ItemId);
        }
Пример #3
0
        public void DeleteMenu(int MenuId)
        {
            var menu = GetMenu(MenuId);

            MenusData.Menus.DeleteOnSubmit(menu);
            MenusData.SubmitChanges();
        }
Пример #4
0
        public void DeleteMenuExternal(int ItemId)
        {
            var menu = GetMenuExternal(ItemId);

            MenusData.Menu_Externals.DeleteOnSubmit(menu);
            MenusData.SubmitChanges();
        }
Пример #5
0
        public int CreateMenu(string Name, string Description)
        {
            if (StringUtils.IsNullOrWhiteSpace(Name))
            {
                return(-1);
            }

            var q = from _menu in GetMenus()
                    where _menu.Name == Name
                    select _menu;

            if (q.Count() > 0)
            {
                return(-1);
            }

            Menu menu = new Menu
            {
                Name        = Name,
                Description = Description
            };

            MenusData.Menus.InsertOnSubmit(menu);
            MenusData.SubmitChanges();

            return(menu.MenuId);
        }
Пример #6
0
        public int UpdatePage(int PageId, string DisplayName, string Title, string Description, string Keywords, string Url, int?GroupId, bool Virtual)
        {
            var q = from _page in GetPages()
                    where _page.DisplayName == DisplayName && _page.PageId != PageId
                    select _page;

            if (q.Count() > 0)
            {
                return(-1);
            }

            Page page = MenusData.Pages.Single(temp => temp.PageId == PageId);

            page.DisplayName = DisplayName;
            page.Title       = Title;
            page.Description = Description;
            page.Keywords    = Keywords;
            page.Url         = Url;
            page.GroupId     = GroupId;
            page.Virtual     = Virtual;

            MenusData.SubmitChanges();

            return(PageId);
        }
Пример #7
0
        public void DeletePage(int PageId)
        {
            var page = GetPage(PageId);

            MenusData.Pages.DeleteOnSubmit(page);
            MenusData.SubmitChanges();
        }
Пример #8
0
        public int CreatePage(string DisplayName, string Title, string Description, string Keywords, string Url, int?GroupId, bool Virtual)
        {
            if (StringUtils.IsNullOrWhiteSpace(DisplayName))
            {
                return(-1);
            }

            var q = from _page in GetPages()
                    where _page.DisplayName == DisplayName
                    select _page;

            if (q.Count() > 0)
            {
                return(-1);
            }

            Page page = new Page
            {
                DisplayName = DisplayName,
                Title       = Title,
                Description = Description,
                Keywords    = Keywords,
                Url         = Url,
                GroupId     = GroupId,
                Virtual     = Virtual
            };

            MenusData.Pages.InsertOnSubmit(page);
            MenusData.SubmitChanges();

            return(page.PageId);
        }
Пример #9
0
        public void DeleteMenuItem(int Id)
        {
            var menu = GetMenuItem(Id);

            MenusData.Menu_Items.DeleteOnSubmit(menu);
            MenusData.SubmitChanges();
        }
Пример #10
0
        public int UpdateMenuItem(int Id, int?MenuId, int?ItemId, string Title, string Description, short Type, int?SubMenuId, bool?NewWindow)
        {
            var q = from _menu in GetMenuItems()
                    where _menu.Id == Id
                    select _menu;

            if (q.Count() > 0)
            {
                return(-1);
            }

            Menu_Item menu = MenusData.Menu_Items.Single(temp => temp.Id == Id);

            menu.MenuId      = MenuId;
            menu.ItemId      = ItemId;
            menu.Title       = Title;
            menu.Description = Description;
            menu.Type        = Type;
            menu.SubMenuId   = SubMenuId;
            menu.NewWindow   = NewWindow;

            MenusData.SubmitChanges();

            return(Id);
        }
Пример #11
0
        public static MenusData GetMenus()
        {
            var result = new MenusData();
            var cmd    = DataCommandManager.GetDataCommand("RoleRight_GetMenus");
            var dt     = cmd.ExecuteDataSet();

            if (dt != null && dt.Tables.Count > 0)
            {
                result.PageRight = Valon.Framework.Data.EntityBuilder.BuildEntityList <MenuData>(dt.Tables[0]);
                if (dt.Tables.Count > 1)
                {
                    result.PageRightExtend = Valon.Framework.Data.EntityBuilder.BuildEntityList <MenuExtentData>(dt.Tables[1]);
                }
            }

            return(result);
        }
Пример #12
0
        public int CreateMenuItem(int?MenuId, int?ItemId, string Title, string Description, short Type, int?SubMenuId, bool?NewWindow)
        {
            Menu_Item menu = new Menu_Item
            {
                MenuId      = MenuId,
                ItemId      = ItemId,
                Title       = Title,
                Description = Description,
                Type        = Type,
                SubMenuId   = SubMenuId,
                NewWindow   = NewWindow
            };

            MenusData.Menu_Items.InsertOnSubmit(menu);
            MenusData.SubmitChanges();

            return(menu.Id);
        }
Пример #13
0
        public int UpdateMenu(int MenuId, string Name, string Description)
        {
            var q = from _menu in GetMenus()
                    where _menu.Name == Name && _menu.MenuId != MenuId
                    select _menu;

            if (q.Count() > 0)
            {
                return(-1);
            }

            Menu menu = MenusData.Menus.Single(temp => temp.MenuId == MenuId);

            menu.Name        = Name;
            menu.Description = Description;

            MenusData.SubmitChanges();

            return(MenuId);
        }
Пример #14
0
        public int UpdateMenuExternal(int ItemId, string Name, string Link)
        {
            var q = from _menu in GetMenuExternals()
                    where _menu.Name == Name && _menu.ItemId != ItemId
                    select _menu;

            if (q.Count() > 0)
            {
                return(-1);
            }

            Menu_External menu = MenusData.Menu_Externals.Single(temp => temp.ItemId == ItemId);

            menu.Name = Name;
            menu.Link = Link;

            MenusData.SubmitChanges();

            return(ItemId);
        }