コード例 #1
0
        /// <summary>
        /// 绑定导航栏
        /// </summary>
        void BindNavigator()
        {
            Expression <Func <Navigator, bool> > predicate      = n => n.Enabled && n.ParentID == ConstValue.EMPTY_GUID_STR;
            Expression <Func <Navigator, int> >  orderCondition = n => n.OrderNum;

            var source = NavigatorGeneration.GenerateNavSource(predicate, orderCondition);

            if (source != null && source.Count > 0)
            {
                rptNavigator.DataSource = source;
                rptNavigator.DataBind();
            }
        }
コード例 #2
0
        protected void rptNavigator_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                //查找内嵌的Repeater
                var rptCategory = e.Item.FindControl("rptChildNav") as Repeater;

                var nav = e.Item.DataItem as Navigator;

                Expression <Func <Navigator, bool> > predicate      = n => n.Enabled && n.ParentID == nav.ID;
                Expression <Func <Navigator, int> >  orderCondition = n => n.OrderNum;

                var categories = NavigatorGeneration.GenerateNavSource(predicate, orderCondition);

                rptCategory.DataSource = categories;
                rptCategory.DataBind();
            }
        }
コード例 #3
0
ファイル: AuthrizedBase.cs プロジェクト: liuying0525/lyprotal
        protected void Page_Init(object sender, EventArgs e)
        {
            var navId = Request["CurNavId"];

            if (navId == null)
            {
                //return;
                Response.Write("缺少CurNavId参数,或参数不为指定的值");
                Response.End();
            }

            try
            {
                var nav = new DZAFCPortal.Service.NavigateService().GenericService.GetModel(navId);
                if (nav == null)
                {
                    throw new Exception(string.Format("系统中无法检索[ID]为{0}的记录。", navId));
                }

                var curUserId = Utils.CurrentUser.ID;
                var roleIds   = new DZAFCPortal.Authorization.DAL.RoleUserService().GenericService.GetAll(r => r.UserID == curUserId).Select(r => r.RoleID).ToArray();

                if (
                    !DZAFCPortal.Config.AppSettings.DefaultAccounts.Contains(Utils.CurrentUser.Account)
                    &&
                    !string.IsNullOrEmpty(nav.ApplyRoles)
                    &&
                    !NavigatorGeneration.IsNavVisible(nav.ApplyRoles.Split(','), roleIds)
                    )
                {
                    throw new Exception(string.Format("您没有权限访问该页面。", navId));
                }
            }
            catch (Exception ex)
            {
                Response.Write("<h2>" + ex.Message + "</h2>");
                Response.End();
            }
        }