public void Show(string applicationId, string parentID)
        {
            SystemApplicationWrapper application = SystemApplicationWrapper.FindById(int.Parse(applicationId));

            if (application != null)
            {
                this.hidApplicationID.Text   = application.SystemApplicationID.ToString();
                this.lblApplicationName.Text = application.SystemApplicationName;


                if (parentID == "")
                {
                    this.lblParentMenuName.Text          = "作为主菜单";
                    this.fsMenuIsCategory.Disabled       = true;
                    this.fsMenuIsCategory.CheckboxToggle = false;
                }
                else
                {
                    this.lblParentMenuName.Text =
                        SystemMenuWrapper.FindById(int.Parse(parentID)).MenuName;
                    this.hidPMenuID.Text                 = parentID;
                    this.fsMenuIsCategory.Disabled       = false;
                    this.fsMenuIsCategory.CheckboxToggle = true;
                }

                this.txtMenuName.Text        = "";
                this.txtMenuDescription.Text = "";
            }

            this.winSystemMenuAdd.Show();
        }
        public string GetMenuById(int aid)
        {
            try
            {
                Ext.Net.TreeNodeCollection collect = new Ext.Net.TreeNodeCollection();
                Ext.Net.TreeNode           root    = InitRoot();
                List <SystemMenuWrapper>   menus   = SystemMenuWrapper.GetSystemMenusByApplication(aid);
                foreach (SystemMenuWrapper menu in menus)
                {
                    SystemMenuWrapper pMenu = menu.ParentMenuID;
                    if (pMenu == null)
                    {
                        LinqTree(menus, root, 0);
                        break;
                    }
                }

                collect.Add(root);
                ResourceManager.AjaxSuccess = true;
                return(collect.ToJson());
            }
            catch (Exception ex)
            {
                ResourceManager.AjaxSuccess      = false;
                ResourceManager.AjaxErrorMessage = string.Format(ex.Message);
                return("");
            }
        }
        public void SaveNewOrder(string ids)
        {
            try
            {
                Dictionary <string, string>[] sortItems = JSON.Deserialize <Dictionary <string, string>[]>(ids);

                List <int> sortIDs = new List <int>();

                foreach (Dictionary <string, string> row in sortItems)
                {
                    sortIDs.Add(int.Parse(row["value"].ToString()));
                }

                SystemMenuWrapper.UpdateOrder(sortIDs);

                ResourceManager.AjaxSuccess = true;
                return;
            }
            catch (Exception ex)
            {
                ResourceManager.AjaxSuccess      = false;
                ResourceManager.AjaxErrorMessage = ex.Message;
                return;
            }
        }
        protected void btnSaveSystemMenu_Click(object sender, DirectEventArgs e)
        {
            try
            {
                SystemMenuWrapper menuWrapper = SystemMenuWrapper.FindById(int.Parse(this.hidMenuID.Text));

                if (menuWrapper == null)
                {
                    winSystemMenuEdit.Hide();
                    ResourceManager.AjaxSuccess      = false;
                    ResourceManager.AjaxErrorMessage = "Error Message:Record not existed.";
                    return;
                }

                menuWrapper.MenuName         = this.txtMenuName.Text.Trim();
                menuWrapper.MenuCode         = this.txtMenuCode.Text.Trim();
                menuWrapper.MenuDescription  = this.txtMenuDescription.Text.Trim();
                menuWrapper.ApplicationID    = SystemApplicationWrapper.FindById(int.Parse(this.hidApplicationID.Text));
                menuWrapper.MenuIsSystemMenu = this.chkMenuIsSystemMenu.Checked;
                menuWrapper.MenuIsEnable     = this.chkMenuIsEnable.Checked;
                menuWrapper.MenuIconUrl      = this.txtMenuIconUrl.Text.Trim();

                if (this.hidPMenuID.Text.Trim() != "")
                {
                    //menuWrapper.MenuOrder = SystemMenuWrapper.GetNewMaxMenuOrder(int.Parse(this.hidPMenuID.Text.Trim()), int.Parse(this.hidApplicationID.Text));
                    menuWrapper.ParentMenuID = SystemMenuWrapper.FindById(int.Parse(this.hidPMenuID.Text.Trim()));
                }
                else
                {
                    //menuWrapper.MenuOrder = SystemMenuWrapper.GetNewMaxMenuOrder(0, int.Parse(this.hidApplicationID.Text));
                }

                menuWrapper.MenuIsCategory = this.fsMenuIsCategory.Collapsed;

                if (!menuWrapper.MenuIsCategory)
                {
                    menuWrapper.MenuUrl       = this.txtMenuUrl.Text.Trim();
                    menuWrapper.MenuType      = this.cmbMenuType.SelectedItem.Value;
                    menuWrapper.MenuUrlTarget = this.cmbMenuUrlTarget.SelectedItem.Value;
                }
                else
                {
                    menuWrapper.MenuUrl       = "";
                    menuWrapper.MenuType      = "1";
                    menuWrapper.MenuUrlTarget = "1";
                }


                SystemMenuWrapper.Update(menuWrapper);

                winSystemMenuEdit.Hide();
            }
            catch (Exception ex)
            {
                ResourceManager.AjaxSuccess      = false;
                ResourceManager.AjaxErrorMessage = string.Format(this.GetGlobalResourceObject("GlobalResource", "msgServerErrorMsg").ToString(), ex.Message);
            }
        }
        private void InitLeftMenu()
        {
            List <NavMenu> navMenus = SystemMenuWrapper.GetUserAssignedNavMenuByUserLoginID(CurrentLoginUser.UserLoginID);

            foreach (NavMenu m in navMenus)
            {
                TreeNode topnode = CreateMainItem(m, LeftPanel);

                CreateSubItem(m, topnode);
            }
        }
Ejemplo n.º 6
0
        private void InitLeftMenu()
        {
            List <NavMenu> navMenus = SystemMenuWrapper.GetUserAssignedNavMenuByUserLoginID(this.CurrentTokenInfo.LoginUserID);

            foreach (NavMenu m in navMenus)
            {
                TreeNode topnode = WebUIHelper.CreateMainItem(m, LeftPanel);

                WebUIHelper.CreateSubItem(m, topnode, this);
            }
        }
        public SystemMenuEntity GetNewMaxMenuByParentMenuAndApplication(SystemMenuWrapper menuWrapper,
                                                                        SystemApplicationWrapper applicationWrapper)
        {
            if (menuWrapper == null)
            {
                return(this.SelfDataObj.GetNewMaxMenuByParentMenuAndApplication(null, applicationWrapper.entity));
            }

            return(this.SelfDataObj.GetNewMaxMenuByParentMenuAndApplication(menuWrapper.entity,
                                                                            applicationWrapper.entity));
        }
Ejemplo n.º 8
0
        private TreeNodeCollection BuildTree(List <NavMenu> menus, string rootName)
        {
            TreeNodeCollection nodes = new TreeNodeCollection();

            TreeNode root = new TreeNode();

            root.Text = rootName;
            root.Icon = Icon.Folder;

            nodes.Add(root);

            if (menus == null || menus.Count == 0)
            {
                return(nodes);
            }

            List <string> roleAssignedmenuIDs = SystemMenuWrapper.GetRoleAssignedMenuIDs(SystemRoleWrapper.FindById(RoleID));

            foreach (var menu in menus)
            {
                TreeNode mainNode = new TreeNode();
                mainNode.Text   = menu.Name;
                mainNode.NodeID = menu.Id;
                WebUIHelper.SetIcon(menu.Icon, menu.IsCategory, mainNode);
                mainNode.CustomAttributes.Add(new ConfigItem("IsGroup", "1", ParameterMode.Value));
                mainNode.CustomAttributes.Add(new ConfigItem("MenuID", menu.Id, ParameterMode.Value));

                if (roleAssignedmenuIDs.Contains(menu.Id.ToString()))
                {
                    mainNode.Checked = ThreeStateBool.True;
                }
                else
                {
                    mainNode.Checked = ThreeStateBool.False;
                }
                GenerateSubTreeNode(mainNode, menu, roleAssignedmenuIDs);
                root.Nodes.Add(mainNode);
            }



            //foreach (TreeNodeBase treeNodeBase in nodes)
            //{
            //    treeNodeBase.Checked = ThreeStateBool.False;
            //}



            return(nodes);
        }
        protected void btnSaveSystemMenu_Click(object sender, DirectEventArgs e)
        {
            try
            {
                SystemMenuWrapper menuWrapper = new SystemMenuWrapper();
                menuWrapper.MenuName         = this.txtMenuName.Text.Trim();
                menuWrapper.MenuDescription  = this.txtMenuDescription.Text.Trim();
                menuWrapper.ApplicationID    = SystemApplicationWrapper.FindById(int.Parse(this.hidApplicationID.Text));
                menuWrapper.MenuIsSystemMenu = this.chkMenuIsSystemMenu.Checked;
                menuWrapper.MenuIsEnable     = this.chkMenuIsEnable.Checked;

                if (this.hidPMenuID.Text.Trim() != "")
                {
                    menuWrapper.MenuOrder    = SystemMenuWrapper.GetNewMaxMenuOrder(int.Parse(this.hidPMenuID.Text.Trim()), int.Parse(this.hidApplicationID.Text));
                    menuWrapper.ParentMenuID = SystemMenuWrapper.FindById(int.Parse(this.hidPMenuID.Text.Trim()));
                }
                else
                {
                    menuWrapper.MenuOrder = SystemMenuWrapper.GetNewMaxMenuOrder(0, int.Parse(this.hidApplicationID.Text));
                }

                menuWrapper.MenuIsCategory = this.fsMenuIsCategory.Collapsed;

                if (!menuWrapper.MenuIsCategory)
                {
                    menuWrapper.MenuIconUrl   = this.txtMenuIconUrl.Text.Trim();
                    menuWrapper.MenuUrl       = this.txtMenuUrl.Text.Trim();
                    menuWrapper.MenuType      = this.cmbMenuType.SelectedItem.Value;
                    menuWrapper.MenuUrlTarget = this.cmbMenuUrlTarget.SelectedItem.Value;
                }
                else
                {
                    menuWrapper.MenuIconUrl   = "";
                    menuWrapper.MenuUrl       = "";
                    menuWrapper.MenuType      = "1";
                    menuWrapper.MenuUrlTarget = "1";
                }


                SystemMenuWrapper.Save(menuWrapper);

                winSystemMenuAdd.Hide();
            }
            catch (Exception ex)
            {
                ResourceManager.AjaxSuccess      = false;
                ResourceManager.AjaxErrorMessage = "错误信息:" + ex.Message;
            }
        }
Ejemplo n.º 10
0
        public string GetTreeNodes(string selectNodeID)
        {
            int applicationid = int.Parse(selectNodeID);

            SystemApplicationWrapper applicationWrapper = SystemApplicationWrapper.FindById(applicationid);

            if (applicationWrapper != null)
            {
                List <NavMenu> menus = SystemMenuWrapper.GetNavMenuByApplication(applicationWrapper);

                return(BuildTree(menus, applicationWrapper.SystemApplicationName).ToJson());
            }

            return("");
        }
        public void DeleteMenu(string smenuID)
        {
            try
            {
                int menuID = int.Parse(smenuID);

                SystemMenuWrapper.DeleteByID(menuID);

                ResourceManager.AjaxSuccess = true;
            }
            catch (Exception e)
            {
                ResourceManager.AjaxSuccess      = false;
                ResourceManager.AjaxErrorMessage = string.Format(e.Message);
                return;
            }
        }
Ejemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (X.IsAjaxRequest)
            {
                return;
            }

            this.lblUser.Text = string.Format("<b>{0}</b>,Today is {1:D}", this.CurrentSecurityPage.CurrentLoginUser.UserLoginID, System.DateTime.Now);


            List <SystemMenuWrapper> list  = SystemMenuWrapper.FindAll();
            List <SystemMenuWrapper> list1 = LinqTree(list, 0);

            for (int i = 0; i < list1.Count; i++)
            {
                Toolbar2.Items.Insert(i + 1, InitButton(list, list1[i].MenuID, list1[i].MenuName));
            }
        }
        public List <SystemMenuWrapper> GetUserAssignedMenuByLoginID(string loginID)
        {
            //检查用户是否存在
            SystemUserEntity userEntity =
                this.DataObjectsContainerIocID.SystemUserDataObjectInstance.GetUserByLoginID(loginID);

            if (userEntity != null)
            {
                //开发用户直接返回所有的可用的菜单
                if (loginID == SystemUserWrapper.DEV_USER_ID)
                {
                    return
                        (SystemMenuWrapper.ConvertToWrapperList(
                             this.DataObjectsContainerIocID.SystemMenuDataObjectInstance.GetAllAviableMenu()));
                }

                //获取用户分配的角色
                List <SystemRoleEntity> userAssignedRole =
                    this.DataObjectsContainerIocID.SystemUserRoleRelationDataObjectInstance.GetUserAssignedRoles(
                        userEntity);

                if (userAssignedRole != null && userAssignedRole.Count > 0)
                {
                    //查找角色下面分配的所有的菜单,(未排序)
                    List <SystemMenuEntity> listMenu =
                        this.DataObjectsContainerIocID.SystemRoleMenuRelationDataObjectInstance.GetRoleAssignMenu(
                            userAssignedRole);

                    List <int> menuIDs = new List <int>();

                    foreach (SystemMenuEntity menuEntity in listMenu)
                    {
                        menuIDs.Add(menuEntity.MenuID);
                    }

                    //获取重新排序的Menu
                    return
                        (SystemMenuWrapper.ConvertToWrapperList(
                             this.DataObjectsContainerIocID.SystemMenuDataObjectInstance.SortMenu(menuIDs)));
                }
            }

            return(null);
        }
        public void AutoMaticSortSubItems(string appid, string pmenuID)
        {
            try
            {
                int menuID = int.Parse(pmenuID);

                int iappID = int.Parse(appid);

                SystemMenuWrapper.AutoMaticSortSubItems(iappID, menuID);

                ResourceManager.AjaxSuccess = true;
            }
            catch (Exception e)
            {
                ResourceManager.AjaxSuccess      = false;
                ResourceManager.AjaxErrorMessage = string.Format(e.Message);
                return;
            }
        }
        //protected void storeSubMenu_Refresh(object sender, StoreRefreshDataEventArgs e)
        //{
        //    if (e.Parameters[0].Value == "")
        //        return;


        //    List<SystemMenuWrapper> menus = SystemMenuWrapper.GetMenuByParentID(int.Parse(e.Parameters[0].Value));

        //    storeSubMenu.DataSource = SystemApplicationWrapper.FindAll();

        //    storeSubMenu.DataBind();
        //}
        protected void storeSubMenus_Refresh(object sender, StoreRefreshDataEventArgs e)
        {
            int pid = Convert.ToInt32(hidSortPMenuID.Value);
            int aid = Convert.ToInt32(hidSortAppID.Value);

            if (pid == -1)
            {
                this.storeSubMenus.DataSource = new List <SystemMenuWrapper>();
                this.storeSubMenus.DataBind();
            }
            else
            {
                if (pid == 0)
                {
                    this.storeSubMenus.DataSource = SystemMenuWrapper.GetTopMenuByAppID(aid);
                    this.storeSubMenus.DataBind();
                }
                else
                {
                    this.storeSubMenus.DataSource = SystemMenuWrapper.GetMenuByParentID(pid);
                    this.storeSubMenus.DataBind();
                }
            }
        }
        public void Show(int id)
        {
            try
            {
                SystemMenuWrapper menu = SystemMenuWrapper.FindById(id);

                if (menu != null)
                {
                    this.hidMenuID.Text          = menu.MenuID.ToString();
                    this.hidApplicationID.Text   = menu.ApplicationID.SystemApplicationID.ToString();
                    this.lblApplicationName.Text = menu.ApplicationID.SystemApplicationName;


                    if (menu.ParentMenuID == null)
                    {
                        this.lblParentMenuName.Text          = "As root menu";
                        this.fsMenuIsCategory.Disabled       = true;
                        this.fsMenuIsCategory.CheckboxToggle = false;
                    }
                    else
                    {
                        this.lblParentMenuName.Text =
                            menu.ParentMenuID.MenuName;
                        this.hidPMenuID.Text                 = menu.ParentMenuID.MenuID.ToString();
                        this.fsMenuIsCategory.Disabled       = false;
                        this.fsMenuIsCategory.CheckboxToggle = true;
                    }

                    this.txtMenuName.Text            = menu.MenuName;
                    this.txtMenuCode.Text            = menu.MenuCode;
                    this.txtMenuDescription.Text     = menu.MenuDescription;
                    this.chkMenuIsSystemMenu.Checked = (menu.MenuIsSystemMenu.HasValue ? menu.MenuIsSystemMenu.Value : false);
                    this.chkMenuIsEnable.Checked     = (menu.MenuIsEnable.HasValue ? menu.MenuIsEnable.Value : false);
                    this.txtMenuIconUrl.Text         = menu.MenuIconUrl;

                    this.fsMenuIsCategory.Collapsed = menu.MenuIsCategory;


                    if (!menu.MenuIsCategory)
                    {
                        this.txtMenuUrl.Text = menu.MenuUrl;
                        if (string.IsNullOrEmpty(menu.MenuType))
                        {
                            this.cmbMenuType.SelectedIndex = 0;
                        }
                        else
                        {
                            this.cmbMenuType.SetValue(menu.MenuType);
                        }
                        if (string.IsNullOrEmpty(menu.MenuUrlTarget))
                        {
                            this.cmbMenuUrlTarget.SelectedIndex = 0;
                        }
                        else
                        {
                            this.cmbMenuUrlTarget.SetValue(menu.MenuUrlTarget);
                        }
                    }
                    else
                    {
                        this.txtMenuUrl.Text                = "";
                        this.cmbMenuType.SelectedIndex      = 0;
                        this.cmbMenuUrlTarget.SelectedIndex = 0;
                    }

                    winSystemMenuEdit.Show();
                }
                else
                {
                    ResourceManager.AjaxSuccess      = false;
                    ResourceManager.AjaxErrorMessage = "Error Message:Record not existed";
                    return;
                }
            }
            catch (Exception ex)
            {
                ResourceManager.AjaxSuccess      = false;
                ResourceManager.AjaxErrorMessage = string.Format(this.GetGlobalResourceObject("GlobalResource", "msgServerErrorMsg").ToString(), ex.Message);
                return;
            }
        }
        private void LinqTree(List <SystemMenuWrapper> list, Ext.Net.TreeNode tnd, int mid)
        {
            if (list == null)
            {
                list = SystemMenuWrapper.FindAll();
            }
            IEnumerable <SystemMenuWrapper> result = null;

            if (mid == 0)
            {
                result = list.Where(menu => menu.ParentMenuID == null);
            }
            else
            {
                result = list.Where(delegate(SystemMenuWrapper menu)
                {
                    if (menu.ParentMenuID == null)
                    {
                        return(false);
                    }
                    else
                    {
                        if (menu.ParentMenuID.MenuID == mid)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                });
            }
            List <string> menuString = SystemMenuWrapper.GetRoleAssignedMenuIDs(SystemRoleWrapper.FindById(RoleID));

            foreach (SystemMenuWrapper m in result)
            {
                Ext.Net.TreeNode tn = new Ext.Net.TreeNode();
                tn.Qtip = m.MenuID.ToString();;
                tn.Text = m.MenuName;

                if (menuString.Count > 0)
                {
                    tn.Checked = (menuString.Exists(id => id.ToString() == tn.Qtip)) ? ThreeStateBool.True : ThreeStateBool.False;
                }
                else
                {
                    tn.Checked = ThreeStateBool.False;
                }
                tnd.Nodes.Add(tn);

                if (list.Exists(delegate(SystemMenuWrapper menu)
                {
                    if (menu.ParentMenuID == null)
                    {
                        return(false);
                    }
                    else
                    {
                        if (menu.ParentMenuID.MenuID == m.MenuID)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }))
                {
                    LinqTree(list, tn, m.MenuID);
                }
            }
        }
        public void Show(int id)
        {
            try
            {
                SystemMenuWrapper menu = SystemMenuWrapper.FindById(id);

                if (menu != null)
                {
                    this.hidMenuID.Text          = menu.MenuID.ToString();
                    this.hidApplicationID.Text   = menu.ApplicationID.SystemApplicationID.ToString();
                    this.lblApplicationName.Text = menu.ApplicationID.SystemApplicationName;


                    if (menu.ParentMenuID == null)
                    {
                        this.lblParentMenuName.Text          = "作为主菜单";
                        this.fsMenuIsCategory.Disabled       = true;
                        this.fsMenuIsCategory.CheckboxToggle = false;
                    }
                    else
                    {
                        this.lblParentMenuName.Text =
                            menu.ParentMenuID.MenuName;
                        this.hidPMenuID.Text                 = menu.ParentMenuID.MenuID.ToString();
                        this.fsMenuIsCategory.Disabled       = false;
                        this.fsMenuIsCategory.CheckboxToggle = true;
                    }

                    this.txtMenuName.Text            = menu.MenuName;
                    this.txtMenuDescription.Text     = menu.MenuDescription;
                    this.chkMenuIsSystemMenu.Checked = (menu.MenuIsSystemMenu.HasValue ? menu.MenuIsSystemMenu.Value : false);
                    this.chkMenuIsEnable.Checked     = (menu.MenuIsEnable.HasValue ? menu.MenuIsSystemMenu.Value : false);

                    this.fsMenuIsCategory.Collapsed = menu.MenuIsCategory;


                    if (!menu.MenuIsCategory)
                    {
                        this.txtMenuIconUrl.Text = menu.MenuIconUrl;
                        this.txtMenuUrl.Text     = menu.MenuUrl;
                        if (string.IsNullOrEmpty(menu.MenuType))
                        {
                            this.cmbMenuType.SelectedIndex = 0;
                        }
                        else
                        {
                            this.cmbMenuType.SetValue(menu.MenuType);
                        }
                        if (string.IsNullOrEmpty(menu.MenuUrlTarget))
                        {
                            this.cmbMenuUrlTarget.SelectedIndex = 0;
                        }
                        else
                        {
                            this.cmbMenuUrlTarget.SetValue(menu.MenuUrlTarget);
                        }
                    }
                    else
                    {
                        this.txtMenuIconUrl.Text            = "";
                        this.txtMenuUrl.Text                = "";
                        this.cmbMenuType.SelectedIndex      = 0;
                        this.cmbMenuUrlTarget.SelectedIndex = 0;
                    }

                    winSystemMenuEdit.Show();
                }
                else
                {
                    ResourceManager.AjaxSuccess      = false;
                    ResourceManager.AjaxErrorMessage = "错误信息:数据不存在";
                    return;
                }
            }
            catch (Exception ex)
            {
                ResourceManager.AjaxSuccess      = false;
                ResourceManager.AjaxErrorMessage = "错误信息:" + ex.Message;
                return;
            }
        }