示例#1
0
        public static MvcContext GetOne(IMember objOwner, int appId)
        {
            IWebContext webContext = MockWebContext.New(1, "http://localhost/", new System.IO.StringWriter());

            MvcContext ctx = new MvcContext(webContext);

            // route
            Route route = new wojilu.Web.Mvc.Routes.Route();

            route.setAppId(appId);   // 为了让生成的link链接中有appId,必须设置此项
            ctx.utils.setRoute(route);

            // viewer: 某些地方需要判断viewer
            ViewerContext viewer = new ViewerContext();

            viewer.obj = new User();
            ctx.utils.setViewerContext(viewer);

            // owner
            OwnerContext owner = new OwnerContext();

            owner.Id  = objOwner.Id;
            owner.obj = objOwner;
            ctx.utils.setOwnerContext(owner);

            // app
            IAppContext app = new AppContext();

            app.Id  = appId;
            app.obj = BlogApp.findById(appId);
            app.setAppType(typeof(BlogApp));     // 如果要使用alang语言包,必须设置此项
            ctx.utils.setAppContext(app);

            return(ctx);
        }
示例#2
0
        private static void updateAppCount(BlogPost post)
        {
            int     count = db.count <BlogPost>("AppId=" + post.AppId);
            BlogApp app   = BlogApp.findById(post.AppId);

            app.BlogCount = count;
            app.update("BlogCount");
        }
示例#3
0
        public virtual RssChannel getRssByApp(int appId, int count)
        {
            List <BlogPost> newListAll = null;

            if (appId > 0)
            {
                newListAll = this.GetNewBlog(appId, count);
            }
            else
            {
                newListAll = this.GetNewListAll(count);
            }

            BlogApp    app  = BlogApp.findById(appId);
            User       user = User.findById(app.OwnerId);
            IMemberApp uapp = new UserAppService().GetByApp(app);

            RssChannel channel = new RssChannel();

            channel.Title = uapp.Name + " -- " + user.Name + "'s blog";
            channel.Link  = Link.ToMember(user);

            foreach (BlogPost post in newListAll)
            {
                RssItem rssItem = new RssItem();
                rssItem.Title       = post.Title;
                rssItem.Description = post.Content;
                rssItem.Category    = post.Category.Name;
                rssItem.PubDate     = post.Created;
                rssItem.Author      = post.Creator.Name;

                rssItem["CreatorLink"] = channel.Link;
                rssItem["CreatorFace"] = post.Creator.PicSmall;
                rssItem.Link           = alink.ToAppData(post);

                channel.RssItems.Add(rssItem);
            }


            return(channel);
        }
示例#4
0
        public virtual void UpdateCommentCount(int appId)
        {
            BlogApp blogApp = BlogApp.findById(appId);

            this.UpdateCommentCount(blogApp);
        }