Beispiel #1
0
        public IEnumerable <MenuModel> GetMenu()
        {
            List <string> moduleList = new List <string>();

            List <MenuModel> menuList = new List <MenuModel>();
            ModuleDA         moduleDA = null;
            DataTable        dt       = new DataTable();

            try
            {
                moduleDA = new ModuleDA();
                dt       = moduleDA.GetMenuByUserID(UserUID, Operation);


                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr = dt.Rows[i];

                    if ("".Equals(CommUtil.ConvertObjectToString(dr["ModuleCode"])) || moduleList.Contains(CommUtil.ConvertObjectToString(dr["ModuleCode"])))
                    {
                        continue;
                    }
                    else
                    {
                        moduleList.Add(CommUtil.ConvertObjectToString(dr["ModuleCode"]));
                    }

                    MenuModel mm = new MenuModel();
                    mm.ModuleCode       = CommUtil.ConvertObjectToString(dr["ModuleCode"]);
                    mm.ModuleName       = CommUtil.ConvertObjectToString(dr["ModuleName"]);
                    mm.ModuleController = CommUtil.ConvertObjectToString(dr["ModuleController"]);
                    mm.ModuleAction     = CommUtil.ConvertObjectToString(dr["ModuleAction"]);
                    mm.IsFatherNode     = CommUtil.ConvertObjectToBool(dr["IsFatherNode"]);
                    bool isSelect = false;
                    if (mm.IsFatherNode)
                    {
                        mm.SubMenu = GetSubMenu(mm.ModuleCode, 1, out isSelect);
                    }
                    else
                    {
                        isSelect = CheckMenuSelected(mm.ModuleController, mm.ModuleAction);
                    }

                    mm.IsSelect = isSelect;
                    menuList.Add(mm);
                }
            }
            finally
            {
                if (moduleDA != null)
                {
                    moduleDA.CloseConnection();
                }
            }

            return(menuList);
        }