Пример #1
0
 /// <summary>
 /// 获取被评论对象名称
 /// </summary>
 /// <param name="commentedObjectId">被评论对象Id</param>
 /// <param name="tenantTypeId">租户类型Id</param>
 /// <returns></returns>
 public string GetCommentedObjectName(long commentedObjectId, string tenantTypeId)
 {
     if (tenantTypeId == TenantTypeIds.Instance().WikiPage())
     {
         WikiPage page = new WikiService().Get(commentedObjectId);
         if (page != null)
         {
             return(page.Title);
         }
     }
     return(string.Empty);
 }
Пример #2
0
        /// <summary>
        /// 获取被评论对象(部分)
        /// </summary>
        /// <param name="commentedObjectId"></param>
        /// <returns></returns>
        public CommentedObject GetCommentedObject(long commentedObjectId)
        {
            WikiPage page = new WikiService().Get(commentedObjectId);

            if (page != null)
            {
                CommentedObject commentedObject = new CommentedObject();
                commentedObject.DetailUrl = SiteUrls.Instance().PageDetail(commentedObjectId);
                commentedObject.Name      = page.Title;
                commentedObject.Author    = page.Author;
                commentedObject.UserId    = page.UserId;
                return(commentedObject);
            }
            return(null);
        }
Пример #3
0
        /// <summary>
        /// 转换成WikiPage
        /// </summary>
        public WikiPage AsWikiPage()
        {
            WikiPage    page    = WikiPage.New();
            WikiService service = new WikiService();

            if (this.PageId < 1)//创建
            {
                if (this.OwnerId.HasValue)
                {
                    page.OwnerId = this.OwnerId.Value;
                }
                else
                {
                    page.OwnerId = UserContext.CurrentUser.UserId;
                }

                page.UserId = UserContext.CurrentUser.UserId;
                page.Author = UserContext.CurrentUser.DisplayName;


                page.Title = this.Title;
            }
            else//编辑词条
            {
                page = service.Get(this.PageId);
            }
            page.IsLocked = this.IsLocked;

            page.FeaturedImageAttachmentId = this.FeaturedImageAttachmentId;
            if (page.FeaturedImageAttachmentId > 0)
            {
                Attachment attachment = new AttachmentService(TenantTypeIds.Instance().WikiPage()).Get(this.FeaturedImageAttachmentId);
                if (attachment != null)
                {
                    page.FeaturedImage = attachment.GetRelativePath() + "\\" + attachment.FileName;
                }
                else
                {
                    page.FeaturedImageAttachmentId = 0;
                }
            }
            else
            {
                page.FeaturedImage = string.Empty;
            }

            return(page);
        }
Пример #4
0
        /// <summary>
        /// 转换成WikiPageVersion
        /// </summary>
        public WikiPageVersion AsWikiPageVersion()
        {
            WikiPageVersion pageVersion = WikiPageVersion.New();

            if (this.PageId > 0)
            {
                WikiService service = new WikiService();
                WikiPage    page    = service.Get(this.PageId);
                if (page != null)
                {
                    pageVersion.Title = page.Title;
                }
            }
            else
            {
                pageVersion.Title = this.Title;
            }

            if (this.OwnerId.HasValue)
            {
                pageVersion.OwnerId = this.OwnerId.Value;
            }
            else
            {
                pageVersion.OwnerId = UserContext.CurrentUser.UserId;
            }

            pageVersion.UserId = UserContext.CurrentUser.UserId;
            pageVersion.Author = UserContext.CurrentUser.DisplayName;
            pageVersion.PageId = this.PageId;

            if (!string.IsNullOrEmpty(this.Summary))
            {
                pageVersion.Summary = this.Summary;
            }
            pageVersion.Body = this.Body;
            if (!string.IsNullOrEmpty(this.Reason))
            {
                pageVersion.Reason = this.Reason;
            }

            return(pageVersion);
        }