Exemple #1
0
        /// <summary>
        /// 发布
        /// </summary>
        /// <param name="ArticleId"></param>
        public static void Publish(string ArticleId, string MarkDownContent, string HTMLContent)
        {
            Article article = GetArticleBySn(ArticleId);

            if (article.IsFirstPage)
            {
                //首页的处理
                article.PublishDateTime = DateTime.Now;
                switch (article.PublishStatus)
                {
                case ApproveStatus.None:
                    //未发布
                    article.PublishStatus = ApproveStatus.Pending;
                    UpdateArticle(article);
                    ArticleListManager.RemoveArticleItemBody(article.Sn);
                    ArticleContent.SaveMarkDownVersion(ArticleId, MarkDownContent, article.OwnerId, RevisionType.First);
                    switch (UserInfo.GetUserInfoBySn(article.OwnerId).Privilege)
                    {
                    case UserType.Admin:
                    case UserType.Editor:
                    case UserType.Author:
                        //管理员,编辑,特约作者直接获得批准
                        Accept(ArticleId);
                        break;

                    default:
                        break;
                    }
                    break;

                case ApproveStatus.Pending:
                    //第一次发布,还没有获得批准的
                    ArticleContent.SaveMarkDownVersion(ArticleId, MarkDownContent, article.OwnerId, RevisionType.First);
                    break;

                case ApproveStatus.Accept:
                    //已经发布的
                    ArticleContent.SaveMarkDownVersion(ArticleId, MarkDownContent, article.OwnerId, RevisionType.Current);
                    break;

                case ApproveStatus.Reject:
                    //拒绝的,变成待审核状态
                    article.PublishStatus = ApproveStatus.Pending;
                    UpdateArticle(article);
                    ArticleListManager.RemoveArticleItemBody(article.Sn);
                    ArticleContent.SaveMarkDownVersion(ArticleId, MarkDownContent, article.OwnerId, RevisionType.First);
                    break;

                default:
                    break;
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 接受首页申请
        /// </summary>
        /// <param name="ArticleId"></param>
        public static void Accept(string ArticleId)
        {
            var article = GetArticleBySn(ArticleId);

            article.PublishStatus    = ApproveStatus.Accept;
            article.ConfirmDateTime  = DateTime.Now;
            article.FirstPageMessage = "审核通过";
            UpdateArticle(article);
            ArticleListManager.RemoveArticleItemBody(article.Sn);
            var md = ArticleContent.GetMarkDown(ArticleId, RevisionType.First);

            md.Revision = RevisionType.Current;
            ArticleContent.InsertArticleContent(md, md.OwnerId);
            string SearchMethod = ConfigurationManager.AppSettings["SearchMethod"];

            if (SearchMethod.Equals("ElasticSearch") && !article.IsPrivate)
            {
                //非私有的进行索引
                SearchManager.Index(article);
            }
        }
        /// <summary>
        /// 保存HTML
        /// </summary>
        /// <param name="strArticleId"></param>
        /// <param name="strContent"></param>
        /// <param name="OwnerId"></param>
        public static void SaveHTMLVersion(string strArticleId, string strContent, string OwnerId)
        {
            //HTML只保存当前版本,为了制作PDF用
            IMongoQuery ArticleIdQuery = Query.EQ(nameof(ArticleID), strArticleId);
            IMongoQuery HTMLExistQuery = Query.EQ(nameof(ContentType), HTML);
            var         FirstFind      = MongoDbRepository.GetFirstRec <ArticleContent>(Query.And(ArticleIdQuery, HTMLExistQuery));

            if (FirstFind != null)
            {
                FirstFind.Content     = strContent;
                FirstFind.ContentType = HTML;
                MongoDbRepository.UpdateRec(FirstFind);
            }
            else
            {
                ArticleContent NewFirst = new ArticleContent();
                NewFirst.ArticleID   = strArticleId;
                NewFirst.Revision    = RevisionType.Current;
                NewFirst.Content     = strContent;
                NewFirst.ContentType = HTML;
                InsertArticleContent(NewFirst, OwnerId);
            }
        }
        /// <summary>
        /// 保存MarkDown
        /// </summary>
        /// <param name="strArticleId"></param>
        /// <param name="strContent"></param>
        /// <param name="OwnerId"></param>
        public static void SaveMarkDownVersion(string strArticleId, string strContent, string OwnerId, RevisionType step)
        {
            IMongoQuery ArticleIdQuery     = Query.EQ(nameof(ArticleID), strArticleId);
            IMongoQuery RevisionQuery      = Query.EQ(nameof(Revision), step);
            IMongoQuery MarkDownExistQuery = Query.EQ(nameof(ContentType), MarkDown);
            var         FirstFind          = MongoDbRepository.GetFirstRec <ArticleContent>(Query.And(ArticleIdQuery, RevisionQuery, MarkDownExistQuery));

            if (FirstFind != null)
            {
                FirstFind.Content     = strContent;
                FirstFind.ContentType = MarkDown;
                MongoDbRepository.UpdateRec(FirstFind);
            }
            else
            {
                ArticleContent NewFirst = new ArticleContent();
                NewFirst.ArticleID   = strArticleId;
                NewFirst.Revision    = step;
                NewFirst.Content     = strContent;
                NewFirst.ContentType = MarkDown;
                InsertArticleContent(NewFirst, OwnerId);
            }
        }
Exemple #5
0
 /// <summary>
 /// 删除文章MarkDown内容
 /// </summary>
 /// <param name="DropArticleContent"></param>
 public static void DropArticleContent(ArticleContent DropArticleContent)
 {
     MongoDbRepository.DeleteRec(DropArticleContent);
 }
Exemple #6
0
 /// <summary>
 /// 插入文章MarkDown内容
 /// </summary>
 /// <param name="NewArticleContent"></param>
 /// <param name="OwnerId"></param>
 /// <returns>序列号</returns>
 public static string InsertArticleContent(ArticleContent NewArticleContent, string OwnerId)
 {
     return(OwnerTableOperator.InsertRec(NewArticleContent, OwnerId));
 }
Exemple #7
0
 /// <summary>
 /// 修改文章MarkDown内容
 /// </summary>
 /// <param name="OldArticleContent"></param>
 public static void UpdateArticleContent(ArticleContent OldArticleContent)
 {
     MongoDbRepository.UpdateRec(OldArticleContent);
 }