Ejemplo n.º 1
0
        public bool UpdateArticleCount(long articleID, int rootCategoryId, ArticleCountEnum articleCountEnum)
        {
            string sql = "UPDATE SA_ArticleContent" + rootCategoryId + " SET {0} WHERE ArticleID = @articleID";

            switch (articleCountEnum)
            {
            case ArticleCountEnum.CollectCount:
                sql = string.Format(sql, "CollectCount = CollectCount + 1");
                break;

            case ArticleCountEnum.CommentCount:
                sql = string.Format(sql, "CommentCount = CommentCount + 1");
                break;

            case ArticleCountEnum.EggCount:
                sql = string.Format(sql, "EggCount = EggCount + 1");
                break;

            case ArticleCountEnum.FlowerCount:
                sql = string.Format(sql, "FlowerCount = FlowerCount + 1");
                break;

            case ArticleCountEnum.HitCount:
                sql = string.Format(sql, "WeekHitCount = WeekHitCount + 1,MonthHitCount= MonthHitCount+1, HitCount = HitCount + 1,HitTime = getdate()");
                break;

            default:
                return(false);
            }

            return(SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, new SqlParameter("@articleID", articleID)) > 0);
        }
Ejemplo n.º 2
0
        public ReturnResult<bool> UpdateArticleCount(long articleId, int categoryId, long userKeyId, ArticleCountEnum articleCountEnum)
        {
            int rootCategoryId = articleCategoryService.GetRootCategoryId(categoryId);

            if (rootCategoryId == -1)
            {
                return new ReturnResult<bool>(101, false, "分类参数错误");
            }

            var isNeedVerification = articleCountEnum == ArticleCountEnum.EggCount || articleCountEnum == ArticleCountEnum.FlowerCount || articleCountEnum == ArticleCountEnum.WarnCount;

            if (isNeedVerification && ArticleContentRepository.Instance.IsReview(articleId, categoryId, userKeyId, (int)articleCountEnum))
            {
                return new ReturnResult<bool>(102, false, "已经有过相同操作,不允许重复");
            }

            var ret = ArticleContentRepository.Instance.UpdateArticleCount(articleId, rootCategoryId, articleCountEnum);

            if (isNeedVerification && ret)
            {
                var article = ArticleContentRepository.Instance.GetArticle(rootCategoryId, articleId);
                if (null != article)
                {
                    System.Threading.Tasks.Task.Factory.StartNew(() => ArticleContentRepository.Instance.InsertReViewRecord(new ReviewRecordDataContract()
                    {
                        ArticleID = articleId,
                        CategoryId = categoryId,
                        AuthorUserKeyId = article.UserKeyId,
                        ReviewType = articleCountEnum,
                        Title = article.Title,
                        UserKeyId = userKeyId,
                        PostTime = DateTime.Now
                    }));
                }
            }

            return new ReturnResult<bool>(ret);
        }
Ejemplo n.º 3
0
        public ReturnResult <bool> UpdateArticleCount(long articleId, int categoryId, long userKeyId, ArticleCountEnum articleCountEnum)
        {
            int rootCategoryId = articleCategoryService.GetRootCategoryId(categoryId);

            if (rootCategoryId == -1)
            {
                return(new ReturnResult <bool>(101, false, "分类参数错误"));
            }

            var isNeedVerification = articleCountEnum == ArticleCountEnum.EggCount || articleCountEnum == ArticleCountEnum.FlowerCount || articleCountEnum == ArticleCountEnum.WarnCount;

            if (isNeedVerification && ArticleContentRepository.Instance.IsReview(articleId, categoryId, userKeyId, (int)articleCountEnum))
            {
                return(new ReturnResult <bool>(102, false, "已经有过相同操作,不允许重复"));
            }

            var ret = ArticleContentRepository.Instance.UpdateArticleCount(articleId, rootCategoryId, articleCountEnum);

            if (isNeedVerification && ret)
            {
                var article = ArticleContentRepository.Instance.GetArticle(rootCategoryId, articleId);
                if (null != article)
                {
                    System.Threading.Tasks.Task.Factory.StartNew(() => ArticleContentRepository.Instance.InsertReViewRecord(new ReviewRecordDataContract()
                    {
                        ArticleID       = articleId,
                        CategoryId      = categoryId,
                        AuthorUserKeyId = article.UserKeyId,
                        ReviewType      = articleCountEnum,
                        Title           = article.Title,
                        UserKeyId       = userKeyId,
                        PostTime        = DateTime.Now
                    }));
                }
            }

            return(new ReturnResult <bool>(ret));
        }