Пример #1
0
 /// <summary>
 ///  文章点赞数与评论数
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public OperationResult <ReviewCommonEntity> ReviewCommon_Get(EventItemCommentEntity entity)
 {
     try
     {
         ReviewCommonEntity rcEntity = new ReviewCommonEntity();
         SqlParameter[]     commPrms =
         {
             new SqlParameter("@EventItemID", entity.EventItemID),
             new SqlParameter("@UserID",      entity.UserID)
         };
         DataTable table = SQlHelper.ExecuteDataset(SQlHelper.MyConnectStr, CommandType.StoredProcedure, "M_ReviewCommon_Get", commPrms).Tables[0];
         if (table != null && table.Rows.Count != 0)
         {
             rcEntity.ReviewCount      = table.Rows[0]["ReviewCount"].ToInt();
             rcEntity.ArticleLikeCount = table.Rows[0]["ArticleLikeCount"].ToInt();
             rcEntity.IsArticleLike    = table.Rows[0]["IsArticleLike"].ToInt() == 0 ? false : true;
         }
         return(new OperationResult <ReviewCommonEntity>(OperationResultType.Success, "评论和点赞数抓取完成!", rcEntity));
     }
     catch (Exception ex)
     {
         LogUtil.WriteLog(ex);
         return(new OperationResult <ReviewCommonEntity>(OperationResultType.NoConnection, Description.EnumDescription(OperationResultType.NoConnection)));
     }
 }
Пример #2
0
        /// <summary>
        ///  添加文章评论
        /// </summary>
        /// <returns></returns>
        public OperationResult <ReviewCommonEntity> ArticleComments_Insert(EventItemCommentEntity entity)
        {
            try
            {
                ReviewCommonEntity rcEntity = new ReviewCommonEntity();
                SqlParameter[]     prms     =
                {
                    new SqlParameter("@EventItemID",    entity.EventItemID),
                    new SqlParameter("@UserID",         entity.UserID),
                    new SqlParameter("@IsAnonymous",    entity.IsAnonymous),
                    new SqlParameter("@CommentContent", entity.CommentContent),
                    new SqlParameter("@CommentTime",    entity.CommentTime == null ? DateTime.Now:entity.CommentTime),
                    new SqlParameter("@CheckTypeID",    entity.CheckTypeID),
                    new SqlParameter("@ViewStateID",    entity.ViewStateID)
                };
                DataTable table = SQlHelper.ExecuteDataset(SQlHelper.MyConnectStr, CommandType.StoredProcedure, "M_EventItemComments_Insert", prms).Tables[0];

                if (table != null && table.Rows.Count != 0)
                {
                    rcEntity.ReviewCount      = table.Rows[0]["ReviewCount"].ToInt();
                    rcEntity.ArticleLikeCount = table.Rows[0]["ArticleLikeCount"].ToInt();
                    rcEntity.IsArticleLike    = table.Rows[0]["IsArticleLike"].ToInt() == 0 ? false : true;
                }
                return(new OperationResult <ReviewCommonEntity>(OperationResultType.Success, "添加文章评论完成!", rcEntity));
            }
            catch (Exception ex)
            {
                LogUtil.WriteLog(ex);
                return(new OperationResult <ReviewCommonEntity>(OperationResultType.NoConnection, Description.EnumDescription(OperationResultType.NoConnection)));
            }
        }
Пример #3
0
 /// <summary>
 ///  文章点赞插入
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public OperationResult <ReviewCommonEntity> ArticleLike_Insert(EventItemLikeEntity entity)
 {
     try
     {
         ReviewCommonEntity rcEntity = new ReviewCommonEntity();
         using (SqlConnection con = new SqlConnection(SQlHelper.MyConnectStr))
         {
             SqlTransaction trans = null;
             con.Open();
             trans = con.BeginTransaction();
             SqlParameter[] prms =
             {
                 new SqlParameter("@EventItemID", entity.EventItemID),
                 new SqlParameter("@UserID",      entity.UserID),
                 new SqlParameter("@LikeCnt",     entity.LikeCnt),
                 new SqlParameter("@LikeTime",    entity.LikeTime == null ? DateTime.Now :entity.LikeTime)
             };
             SqlParameter[] commPrms =
             {
                 new SqlParameter("@EventItemID", entity.EventItemID),
                 new SqlParameter("@UserID",      entity.UserID)
             };
             int state = SQlHelper.ExecuteNonQuery(trans, CommandType.StoredProcedure, "M_EventItem_Like_Insert", prms);
             trans.Commit();
             DataTable table = SQlHelper.ExecuteDataset(SQlHelper.MyConnectStr, CommandType.StoredProcedure, "M_ReviewCommon_Get", commPrms).Tables[0];
             if (table != null && table.Rows.Count != 0)
             {
                 rcEntity.ReviewCount      = table.Rows[0]["ReviewCount"].ToInt();
                 rcEntity.ArticleLikeCount = table.Rows[0]["ArticleLikeCount"].ToInt();
                 rcEntity.IsArticleLike    = table.Rows[0]["IsArticleLike"].ToInt() == 0 ? false : true;
             }
             if (state == 1)
             {
                 return(new OperationResult <ReviewCommonEntity>(OperationResultType.Success, "文章点赞成功!", rcEntity));
             }
             else
             {
                 return(new OperationResult <ReviewCommonEntity>(OperationResultType.NoChanged, "您已点过赞了!", rcEntity));
             }
         }
     }
     catch (Exception ex)
     {
         LogUtil.WriteLog(ex);
         return(new OperationResult <ReviewCommonEntity>(OperationResultType.NoConnection, Description.EnumDescription(OperationResultType.NoConnection)));
     }
 }