コード例 #1
0
        public void UpdateArticle(string articleId, ArticleInfo_Add article)
        {
            using (var biz = new GameBiz.Business.GameBizBusinessManagement())
            {
                biz.BeginTran();
                using (var manager = new ArticleManager())
                {
                    var entity = manager.GetArticleById(articleId);
                    if (entity == null)
                    {
                        throw new ArgumentException("指定编号的文章不存在");
                    }

                    var keyWordsList = manager.QuerKeywordOfArticle();
                    var content      = DeepReplaceContent(article.Description, keyWordsList);

                    var tagList = new List <string>();
                    tagList.Add("script");
                    content = UsefullHelper.ReplaceHtmlTag(content, tagList);

                    entity.Title                 = article.Title;
                    entity.KeyWords              = article.KeyWords;
                    entity.DescContent           = article.DescContent;
                    entity.GameCode              = article.GameCode;
                    entity.Description           = content;
                    entity.IsRedTitle            = article.IsRedTitle;
                    entity.Category              = article.Category;
                    entity.UpdateTime            = DateTime.Now;
                    entity.UpdateUserKey         = article.CreateUserKey;
                    entity.UpdateUserDisplayName = article.CreateUserDisplayName;
                    manager.UpdateArticle(entity);
                }
                biz.CommitTran();
            }
        }
コード例 #2
0
        public string SubmitArticle(ArticleInfo_Add article)
        {
            var id           = BusinessHelper.GetArticleId();
            var manager      = new ArticleManager();
            var keyWordsList = manager.QuerKeywordOfArticle();
            var content      = DeepReplaceContent(article.Description, keyWordsList);

            var tagList = new List <string>();

            tagList.Add("script");
            content = UsefullHelper.ReplaceHtmlTag(content, tagList);

            var staticPath     = string.Format("/statichtml/zixun/details/{0}/{1}.html", DateTime.Now.ToString("yyyyMMdd"), id);
            var lastId         = string.Empty;
            var lastTitle      = string.Empty;
            var lastStaticPath = string.Empty;
            var last           = manager.QueryLastArticle(article.Category);

            if (last != null)
            {
                lastId         = last.Id;
                lastTitle      = last.Title.Length > 50 ? last.Title.Substring(0, 50) : last.Title;
                lastStaticPath = last.StaticPath;

                last.NextId         = id;
                last.NextTitle      = article.Title.Length > 50 ? article.Title.Substring(0, 50) : article.Title;
                last.NextStaticPath = staticPath;
                manager.UpdateArticle(last);
            }

            var entity = new Article
            {
                Id                    = id,
                GameCode              = article.GameCode,
                Title                 = article.Title,
                KeyWords              = article.KeyWords,
                DescContent           = article.DescContent,
                Description           = content,
                IsRedTitle            = article.IsRedTitle,
                Category              = article.Category,
                ShowIndex             = 0,
                ReadCount             = 0,
                CreateTime            = DateTime.Now,
                CreateUserKey         = article.CreateUserKey,
                CreateUserDisplayName = article.CreateUserDisplayName,
                UpdateTime            = DateTime.Now,
                UpdateUserKey         = article.CreateUserKey,
                UpdateUserDisplayName = article.CreateUserDisplayName,
                PreId                 = lastId,
                PreTitle              = lastTitle,
                PreStaticPath         = lastStaticPath,
                StaticPath            = "",
            };

            manager.AddArticle(entity);
            return(id);
        }