• 我记录综合系统学习研究之用户管理四(用户空间)


    在用户列表中选择一个用户进入用户空间去看一看

    可以看到空间有这样几个菜单。这些是在哪里来的呢。

    答案是注册用户的时候。 

    public void SaveReg() {

    addUserAppAndMenus

    }

    保存注册里有一句addUserAppAndMenus,该方法在UserMenu数据库表中,保存了每个菜单对应的url,也即相应的Controller action。

    appid http://www.wojilu.com/space/xchsp/Blog2402/Blog/Index

    appid = 2042,每新增一个用户appid加1.

    我们分析一下这里比较有趣的主页菜单实现。

    可以看到主页部分是由很多块组成的。都有哪些块呢

    我们看一下Content1/Content/Index,也就是ContentController的Index action

    Index action->IndexPage()->bindRows( app, sections );最终调用到

    private void bindSectionList( IBlock sectionBlock, IList sections ) {

    foreach (ContentSection section in sections) {

    sectionBlock.Set( "section.Id", section.Id );

    String content = getSectionContent( section );
    sectionBlock.Set( "section.Content", content );
    sectionBlock.Next();

    }
    }

    getSectionContent最终调用到getAutoData

    private String getAutoData( ContentSection section ) {

    Dictionary<string, string> presult = getDefaultValue( section );

    IList data = ServiceContext.GetData( section.ServiceId, section.GetServiceParamValues(), presult );

    if (section.TemplateId <= 0) return getJsonResult( section, data );

    ContentSectionTemplate sectionTemplate = TplService.GetById( section.TemplateId );
    Template currentView = utils.getTemplateByFileName( BinderUtils.GetBinderTemplatePath( sectionTemplate ) );
    ISectionBinder binder = BinderUtils.GetBinder( sectionTemplate, ctx, currentView );
    binder.Bind( section, data ); // custom template : SectionUtil.loadTemplate
    ControllerBase sectionController = binder as ControllerBase;
    return sectionController.utils.getActionResult();
    }

    ContentSectionTemplate sectionTemplate = TplService.GetById( section.TemplateId );

    Template currentView = utils.getTemplateByFileName( BinderUtils.GetBinderTemplatePath( sectionTemplate ) );

    这2句就是在获取主页里的一个个动态显示块。我们调查一下section.TemplateId

    ContentSection数据库表中记录着TemplateId

    上面的TemplateId对应着哪些模板视图呢,秘密在于

    \wojilu1.8\wojilu.Web\framework\data\wojilu.Apps.Content.Domain.ContentSectionTemplate.config

    [

    {Id:10, OrderId:0, Name:"我的信息", TemplateName:"MyInfo", ThumbUrl:"", Description:"" },
    {Id:11, OrderId:0, Name:"我的最新分享", TemplateName:"MyShare", ThumbUrl:"", Description:"" },
    {Id:12, OrderId:0, Name:"我的最新动态", TemplateName:"MyFeed", ThumbUrl:"", Description:"" },
    {Id:13, OrderId:0, Name:"头像列表", TemplateName:"UserFaces", ThumbUrl:"", Description:"" },
    {Id:14, OrderId:0, Name:"我的头像", TemplateName:"MyFace", ThumbUrl:"", Description:"" },
    {Id:15, OrderId:0, Name:"我的迷你博客", TemplateName:"MyMicroblog", ThumbUrl:"", Description:"" },
    {Id:16, OrderId:0, Name:"我的留言", TemplateName:"MyFeedback", ThumbUrl:"", Description:"" },
    {Id:17, OrderId:0, Name:"我的博客", TemplateName:"MyBlog", ThumbUrl:"", Description:"" },
    {Id:18, OrderId:0, Name:"用户登录", TemplateName:"Login", ThumbUrl:"", Description:"" },
    {Id:19, OrderId:0, Name:"简单列表(带时间)", TemplateName:"ListTime", ThumbUrl:"", Description:"" },
    {Id:20, OrderId:0, Name:"文章排行", TemplateName:"Rank", ThumbUrl:"", Description:"" },
    {Id:21, OrderId:0, Name:"头条要闻", TemplateName:"Focus", ThumbUrl:"", Description:"" }
    ]

    对应的controller在

    ContentSection数据库里的记录是在何时增加的呢?

    addUserAppAndMenus->new UserHomeInstaller().Install->createPortal

    createPortal

    createLayout()

    还有一处解释一下,section.ServiceId

     IList data = ServiceContext.GetData( section.ServiceId, section.GetServiceParamValues(), presult );

    位于wojilu1.8\wojilu.Web\framework\data\wojilu.SOA.Service.config

    [
    { Id:10, Name:"我的最新图片", Type:"wojilu.Apps.Photo.Service.PhotoPostService", Method:"GetMyNew", Params:"显示数量=IntTextbox", ParamsDefault:"ownerId=int", Tags:"PageSection", Note:"Img", Status:0, Description:"", Owner:"wojilu.Members.Users.Domain.User" },
    { Id:11, Name:"我的博客", Type:"wojilu.Apps.Blog.Service.BlogPostService", Method:"GetMyRecent", Params:"显示数量=IntTextbox", ParamsDefault:"ownerId=int", Tags:"PageSection", Note:"List;List2;MyBlog", Status:0, Description:"", Owner:"wojilu.Members.Users.Domain.User" },
    { Id:12, Name:"我的头像", Type:"wojilu.Members.Users.Service.UserService", Method:"GetCurrent", Params:"", Tags:"PageSection", Note:"MyFace", Status:0, Description:"", Owner:"wojilu.Members.Users.Domain.User" },
    { Id:13, Name:"我的微博", Type:"wojilu.Common.Microblogs.Service.MicroblogService", Method:"GetCurrent", Params:"显示数量=IntTextbox", ParamsDefault:"ownerId=int", Tags:"PageSection", Note:"MyMicroblog", Status:0, Description:"", Owner:"wojilu.Members.Users.Domain.User" },
    { Id:14, Name:"我的留言", Type:"wojilu.Common.Msg.Service.FeedbackService", Method:"GetRecent", Params:"显示数量=IntTextbox", ParamsDefault:"ownerId=int", Tags:"PageSection", Note:"MyFeedback", Status:0, Description:"", Owner:"wojilu.Members.Users.Domain.User" },
    { Id:15, Name:"群组:最新群组帖子", Type:"wojilu.Apps.Forum.Service.ForumTopicService", Method:"GetNewGroupTopic", Params:"显示数量=IntTextbox", Tags:"PageSection", Note:"List;List2", Status:0, Description:"", Owner:"wojilu.Members.Sites.Domain.Site" },
    { Id:16, Name:"论坛:最新帖子", Type:"wojilu.Apps.Forum.Service.ForumPostService", Method:"GetNewSitePost", Params:"显示数量=IntTextbox", Tags:"PageSection", Note:"List;List2", Status:0, Description:"", Owner:"wojilu.Members.Sites.Domain.Site" },
    { Id:17, Name:"论坛:特定论坛帖子", Type:"wojilu.Apps.Forum.Service.ForumPostService", Method:"GetNewBoardPost", Params:"板块ID(多个Id之间用逗号分隔)=StringTextbox;显示数量=IntTextbox", Tags:"PageSection", Note:"List;List2", Status:0, Description:"", Owner:"wojilu.Members.Users.Domain.User" },
    { Id:18, Name:"Rss新闻源", Type:"wojilu.Apps.Reader.Service.FeedSourceService", Method:"GetFeed", Params:"rss网址=StringTextbox;显示数量=IntTextbox", Tags:"PageSection", Note:"List", Status:1, Description:"", Owner:"wojilu.Members.Users.Domain.User" },
    { Id:19, Name:"用户:用户登录", Type:"wojilu.Members.Users.Service.LoginService", Method:"GetLoginInfo", Params:"", Tags:"PageSection", Note:"Login", Status:0, Description:"", Owner:"wojilu.Members.Sites.Domain.Site" },
    { Id:20, Name:"cms:指定区块的文章", Type:"wojilu.Apps.Content.Service.ContentPostService", Method:"GetBySectionIds", Params:"区块Id(多个Id之间用逗号分隔)=StringTextbox;显示数量=IntTextbox", Tags:"PageSection", Note:"List;List2", Status:0, Description:"", Owner:"wojilu.Members.Sites.Domain.Site" },
    ]

     这里也可以参考这篇帖子http://www.wojilu.com/Common/Page/57

  • 相关阅读:
    使用ATL开发ActiveX控件
    [Silverlight]AutoCompleteBox控件的一个Bug?
    [Silverlight]一个简单的GroupBox控件
    WCF安全之ASP.NET兼容模式
    Mysql 性能优化记录
    【Python+Django+Pytest】数据库异常pymysql.err.InterfaceError: (0, '') 解决方案
    Django在使用logging日志模块时报错无法操作文件 logging error Permission Error [WinError 32]
    isinstance 判断一个对象属于或不属于多种数据类型
    CentOS 系统 查看 cpu核数
    我踩过的python的坑
  • 原文地址:https://www.cnblogs.com/xchsp/p/2858992.html
Copyright © 2020-2023  润新知