public virtual void Insert(ContentPost post, string sectionIds, string tagList) { int[] ids = cvt.ToIntArray(sectionIds); if (ids.Length == 0) { throw new ArgumentException("sectionIds"); } // 保存 post.PageSection = new ContentSection { Id = ids[0] }; // 缓存Section post.insert(); // 多对多处理 ContentPostSection ps = new ContentPostSection(); foreach (int sectionId in ids) { ContentSection section = new ContentSection(); section.Id = sectionId; ps.Post = post; ps.Section = section; ps.insert(); } // tag post.Tag.Save(tagList); }
protected void createPost(ContentSection s, String title, String titleHome, String content, String imgUrl, String videoUrl, int categoryId, int width, int height) { IMember o = this.owner; User u = this.user; ContentPost p = new ContentPost(); p.OwnerId = o.Id; p.OwnerType = o.GetType().FullName; p.OwnerUrl = o.Url; p.Creator = u; p.CreatorUrl = u.Url; p.AppId = s.AppId; p.PageSection = s; p.Author = "作者"; p.Title = title; p.Content = content; p.TitleHome = titleHome; p.ImgLink = imgUrl; p.SourceLink = videoUrl; if (strUtil.HasText(videoUrl)) { p.CategoryId = PostCategory.Video; p.TypeName = typeof(ContentVideo).FullName; p.Width = 290; p.Height = 235; } else if (strUtil.HasText(imgUrl)) { if (categoryId > 0) { p.CategoryId = categoryId; } else { p.CategoryId = PostCategory.Img; } //if (isBigImg) { // p.Width = 290; // p.Height = 210; //} //else { // p.Width = 120; // p.Height = 90; //} p.Width = width; p.Height = height; } p.insert(); }
public virtual void Insert(ContentPost post, string sectionIds, string tagList) { int[] ids = cvt.ToIntArray(sectionIds); post.PageSection = new ContentSection(); // 不再使用旧版一对多关系 post.PageSection.Id = ids[0]; post.insert(); // 多对多处理 ContentPostSection ps = new ContentPostSection(); foreach (int sectionId in ids) { ContentSection section = new ContentSection(); section.Id = sectionId; ps.Post = post; ps.Section = section; ps.insert(); } // 旧版一对多兼容处理 foreach (int sectionId in ids) { updateCachePostIds(sectionId); } post.Tag.Save(tagList); }
private static int importDirect(SpiderArticle art, SpiderImport item, ContentSection section, ContentApp app) { ContentPost post = new ContentPost(); post.Title = art.Title; post.Content = art.Body; if (art.IsPic == 1) { post.CategoryId = PostCategory.Img; post.ImgLink = art.PicUrl; } post.SourceLink = art.Url; post.Creator = item.Creator; post.CreatorUrl = item.Creator.Url; post.PageSection = section; post.OwnerId = app.OwnerId; post.OwnerType = app.OwnerType; post.OwnerUrl = app.OwnerUrl; post.AppId = app.Id; post.insert(); return(post.Id); }
private static Result insertPostByPoll(ContentPoll poll, ContentPost post) { post.OwnerId = poll.OwnerId; post.OwnerType = poll.OwnerType; post.OwnerUrl = poll.OwnerUrl; post.Creator = poll.Creator; post.CreatorUrl = poll.CreatorUrl; post.TypeName = typeof(ContentPoll).FullName; post.AppId = poll.AppId; post.Ip = poll.Ip; post.Title = poll.Title; post.Content = poll.Question; return(post.insert()); }
public Result CreatePoll(int sectionId, ContentPoll poll) { ContentPost post = new ContentPost(); post.OwnerId = poll.OwnerId; post.OwnerType = poll.OwnerType; post.OwnerUrl = poll.OwnerUrl; post.Creator = poll.Creator; post.CreatorUrl = poll.CreatorUrl; post.TypeName = typeof(ContentPoll).FullName; post.AppId = poll.AppId; post.PageSection = new ContentSection { Id = sectionId }; post.Ip = post.Ip; post.Title = poll.Title; Result result = post.insert(); if (result.HasErrors) { return(result); } // 双向引用1 poll.TopicId = post.Id; poll.insert(); // 双向引用2 post.Content = poll.Id.ToString(); post.update("Content"); return(result); }
//------------------------------------------------------------------------------------------------------- /// <summary> /// 完整创建投票,包括客户端提供的SEO等表单数据 /// </summary> /// <param name="sectionId"></param> /// <param name="poll"></param> /// <param name="post"></param> /// <param name="tagList"></param> /// <returns></returns> public virtual Result CreatePoll(long sectionId, ContentPoll poll, ContentPost post, string tagList) { // 1) insert post post.TypeName = typeof(ContentPoll).FullName; post.Content = poll.Question; Result result = post.insert(); if (result.HasErrors) { return(result); } post.Tag.Save(tagList); // 2) insert post_section // 新的多对多关系 insertPostSectionShip(sectionId, post); // 3) insert poll poll.TopicId = post.Id; poll.insert(); return(result); }
public virtual void Insert( ContentPost post, string sectionIds, string tagList ) { int[] ids = cvt.ToIntArray( sectionIds ); if (ids.Length == 0) throw new ArgumentException( "sectionIds" ); // 保存 post.PageSection = new ContentSection { Id = ids[0] }; // 缓存Section post.insert(); // 多对多处理 ContentPostSection ps = new ContentPostSection(); foreach (int sectionId in ids) { ContentSection section = new ContentSection(); section.Id = sectionId; ps.Post = post; ps.Section = section; ps.insert(); } // tag post.Tag.Save( tagList ); }
private static int importDirect( SpiderArticle art, SpiderImport item, ContentSection section, ContentApp app ) { ContentPost post = new ContentPost(); post.Title = art.Title; post.Content = art.Body; if (art.IsPic == 1) { post.CategoryId = PostCategory.Img; post.ImgLink = art.PicUrl; } post.SourceLink = art.Url; post.Creator = item.Creator; post.CreatorUrl = item.Creator.Url; post.PageSection = section; post.OwnerId = app.OwnerId; post.OwnerType = app.OwnerType; post.OwnerUrl = app.OwnerUrl; post.AppId = app.Id; post.insert(); return post.Id; }
protected void createPost( ContentSection s, String title, String titleHome, String content, String imgUrl, String videoUrl, int categoryId, int width, int height ) { IMember o = this.owner; User u = this.user; ContentPost p = new ContentPost(); p.OwnerId = o.Id; p.OwnerType = o.GetType().FullName; p.OwnerUrl = o.Url; p.Creator = u; p.CreatorUrl = u.Url; p.AppId = s.AppId; p.PageSection = s; p.Author = "作者"; p.Title = title; p.Content = content; p.TitleHome = titleHome; p.ImgLink = imgUrl; p.SourceLink = videoUrl; if (strUtil.HasText( videoUrl )) { p.CategoryId = PostCategory.Video; p.TypeName = typeof( ContentVideo ).FullName; p.Width = 290; p.Height = 235; } else if (strUtil.HasText( imgUrl )) { if (categoryId > 0) p.CategoryId = categoryId; else p.CategoryId = PostCategory.Img; //if (isBigImg) { // p.Width = 290; // p.Height = 210; //} //else { // p.Width = 120; // p.Height = 90; //} p.Width = width; p.Height = height; } p.insert(); }
public virtual void Insert( ContentPost post, string sectionIds, string tagList ) { int[] ids = cvt.ToIntArray( sectionIds ); post.PageSection = new ContentSection(); // ����ʹ�þɰ�һ�Զ��ϵ post.PageSection.Id = ids[0]; post.insert(); // ��Զദ�� ContentPostSection ps = new ContentPostSection(); foreach (int sectionId in ids) { ContentSection section = new ContentSection(); section.Id = sectionId; ps.Post = post; ps.Section = section; ps.insert(); } // �ɰ�һ�Զ���ݴ��� foreach (int sectionId in ids) { updateCachePostIds( sectionId ); } post.Tag.Save( tagList ); }