Пример #1
0
        protected override GetMenuListRD ProcessRequest(DTO.Base.APIRequest <EmptyRequestParameter> pRequest)
        {
            var rd = new GetMenuListRD();

            var           loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            AppSysService appSysService      = new AppSysService(loggingSessionInfo);

            rd.MenuList = appSysService.GetRoleMenus(this.CurrentUserInfo, CurrentUserInfo.CurrentUserRole.RoleId);//根据当前用户的角色,来取他拥有的页面
            return(rd);
        }
Пример #2
0
        /// <summary>
        /// 通过RoleID获取菜单列表
        /// </summary>
        public string GetSysMenuListByRoleIdData()
        {
            var appSysService         = new AppSysService(CurrentUserInfo);
            IList <MenuModel> data    = new List <MenuModel>();
            string            content = string.Empty;

            IList <MenuModel> src = new List <MenuModel>();

            string appSysId = "";
            string key      = string.Empty;

            if (Request("role_id") != null && Request("role_id") != string.Empty)
            {
                key = Request("role_id").ToString().Trim();
            }

            if (Request("app_sys_id") != null && Request("app_sys_id") != string.Empty)
            {
                appSysId = Request("app_sys_id").ToString().Trim();
            }

            src = appSysService.GetAllMenusByAppSysId(appSysId);

            IList <MenuModel> roleMenuList = new List <MenuModel>();

            roleMenuList = appSysService.GetRoleMenus(CurrentUserInfo, key);

            foreach (var tmpSrcMenuObj in src)
            {
                foreach (var tmpRoleMenuObj in roleMenuList)
                {
                    if (tmpRoleMenuObj.Menu_Id == tmpSrcMenuObj.Menu_Id)
                    {
                        tmpSrcMenuObj.check_flag = "true";
                        break;
                    }
                    else
                    {
                        tmpSrcMenuObj.check_flag = "false";
                    }
                }
            }

            data = src.Where(c => c.Menu_Level == 1).ToList();
            foreach (var tmpMenuObj in data)
            {
                tmpMenuObj.leaf_flag     = tmpMenuObj.Menu_Level == 1 ? "false" : "true";
                tmpMenuObj.expanded_flag = tmpMenuObj.Menu_Level == 1 ? "true" : "false";
                //tmpMenuObj.cls_flag = tmpMenuObj.Menu_Level == 1 ? "folder" : "";

                foreach (var tmpSrcMenuObj in src)
                {
                    if (tmpSrcMenuObj.Parent_Menu_Id == tmpMenuObj.Menu_Id)
                    {
                        if (tmpMenuObj.children == null)
                        {
                            tmpMenuObj.children = new List <MenuModel>();
                        }
                        tmpSrcMenuObj.leaf_flag = "true";
                        tmpSrcMenuObj.cls_flag  = "";
                        tmpMenuObj.children.Add(tmpSrcMenuObj);
                    }
                }
            }

            var jsonData = new JsonData();

            jsonData.totalCount = data.Count.ToString();
            jsonData.data       = data;

            content = jsonData.ToJSON();
            return(content);
        }
Пример #3
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        cPos.Service.AppSysService appSysService = new AppSysService();
        cPos.Service.UnitService   unitService   = new UnitService();

        //设置用户角色
        //按角色登录
        if (e.CommandName == "Go")
        {
            this.UserRoleInfo        = new UserRoleInfo();
            this.UserRoleInfo.RoleId = e.CommandArgument.ToString();

            this.UserRoleInfo.RoleName = appSysService.GetRoleById(loggingSessionInfo, this.UserRoleInfo.RoleId).Role_Name;

            this.UserRoleInfo.UserId   = this.UserInfo.User_Id;
            this.UserRoleInfo.UserName = this.UserInfo.User_Name;

            try
            {
                this.UserRoleInfo.UnitId = userService.GetDefaultUnitByUserIdAndRoleId(this.UserRoleInfo.UserId, this.UserRoleInfo.RoleId);
            }
            catch (Exception ex)
            {
                PageLog.Current.Write(ex);
                Response.Write("找不到默认单位");
                Response.End();
            }

            try
            {
                this.UserRoleInfo.UnitName = unitService.GetUnitById(loggingSessionInfo, UserRoleInfo.UnitId).ShortName;
            }

            catch (Exception ex)
            {
                PageLog.Current.Write(ex);
                Response.Write("找不到单位");
                Response.End();
            }
            //将注册信息写入LoggingSessionInfo 2008-9-19
            this.loggingSessionInfo                  = new LoggingSessionInfo();
            loggingSessionInfo.CurrentUser           = this.UserInfo;
            loggingSessionInfo.CurrentUserRole       = this.UserRoleInfo;
            loggingSessionInfo.CurrentLanguageKindId = this.CurrentLanguageKindId;
            loggingSessionInfo.CurrentLoggingManager = this.LoggingManagerInfo;

            //判断有没有菜单权限
            IList <MenuModel> menus = appSysService.GetRoleMenus(loggingSessionInfo, e.CommandArgument.ToString());
            if (menus.Count == 0)
            {
                this.Label1.Text = "没有菜单" + "&nbsp;<a href=\"~/common/homepage.aspx\">返回首页</a>";
            }
            else
            {
                //转到主页
                if (Request["ReturnPath"] == null)
                {
                    Response.Redirect("~/common/homepage.aspx");
                }
                else
                {
                    Response.Redirect(Request["ReturnPath"].ToString());
                }
            }
        }

        //按单位登录
        //UserService.CheckUserRole
        if (e.CommandName == "UnitGo")
        {
            this.UserRoleInfo          = new UserRoleInfo();
            this.UserRoleInfo.RoleId   = e.CommandArgument.ToString();
            this.UserRoleInfo.RoleName = appSysService.GetRoleById(loggingSessionInfo, this.UserRoleInfo.RoleId).Role_Name;
            this.UserRoleInfo.UserId   = this.UserInfo.User_Id;
            this.UserRoleInfo.UserName = this.UserInfo.User_Name;

            GridViewRow row    = (e.CommandSource as LinkButton).NamingContainer as GridViewRow;
            string      unitId = ((HiddenField)row.FindControl("hfUnitId")).Value;
            try
            {
                this.UserRoleInfo.UnitId = unitId;
            }
            catch (Exception ex)
            {
                PageLog.Current.Write(ex);
                Response.Write("找不到默认单位");
                Response.End();
            }
            try
            {
                this.UserRoleInfo.UnitName = unitService.GetUnitById(loggingSessionInfo, UserRoleInfo.UnitId).ShortName;
            }
            catch (Exception ex)
            {
                PageLog.Current.Write(ex);
                this.UserRoleInfo.UnitName = "单位信息加载出错";
                //throw (ex);
            }

            //检查单位角色信息,没有,添加
            userService.CheckUserRole(this.UserRoleInfo);

            //将注册信息写入LoggingSessionInfo 2008-9-19
            this.loggingSessionInfo                  = new LoggingSessionInfo();
            loggingSessionInfo.CurrentUser           = this.UserInfo;
            loggingSessionInfo.CurrentUserRole       = this.UserRoleInfo;
            loggingSessionInfo.CurrentLanguageKindId = this.CurrentLanguageKindId;
            loggingSessionInfo.CurrentLoggingManager = this.LoggingManagerInfo;

            //判断有没有菜单权限
            IList <MenuModel> menus = appSysService.GetRoleMenus(loggingSessionInfo, e.CommandArgument.ToString());
            if (menus.Count == 0)
            {
                this.Label1.Text = "没有菜单";
            }
            else
            {
                //转到主页
                if (Request["ReturnPath"] == null)
                {
                    Response.Redirect("~/common/homepage.aspx");
                }
                else
                {
                    Response.Redirect(Request["ReturnPath"].ToString());
                }
            }
        }
    }