Exemple #1
0
 /// <summary>
 /// 数据转换
 /// </summary>
 /// <param name="read"></param>
 /// <returns></returns>
 private List<CommentInfo> DataReaderToCommentList(OleDbDataReader read)
 {
     List<CommentInfo> list = new List<CommentInfo>();
     while (read.Read())
     {
         CommentInfo comment = new CommentInfo();
         comment.CommentId = Convert.ToInt32(read["CommentId"]);
         comment.ParentId = Convert.ToInt32(read["ParentId"]);
         comment.PostId = Convert.ToInt32(read["PostId"]);
         comment.UserId = Convert.ToInt32(read["UserId"]);
         comment.Name = Convert.ToString(read["Name"]);
         comment.Email = Convert.ToString(read["Email"]);
         comment.SiteUrl = Convert.ToString(read["SiteUrl"]);
         comment.Content = Convert.ToString(read["Content"]);
         comment.EmailNotify = Convert.ToInt32(read["EmailNotify"]);
         comment.IpAddress = Convert.ToString(read["IpAddress"]);
         comment.CreateDate = Convert.ToDateTime(read["CreateDate"]);
         comment.Approved = Convert.ToInt32(read["Approved"]);
         list.Add(comment);
     }
     read.Close();
     return list;
 }
Exemple #2
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="comment"></param>
        /// <returns></returns>
        public int UpdateComment(CommentInfo comment)
        {
            string cmdText = @"update [loachs_comments] set
                            PostId=@PostId,
                            ParentId=@ParentId,
                            UserId=@UserId,
                            Name=@Name,
                            Email=@Email,
                            SiteUrl=@SiteUrl,
                            Content=@Content,
                            EmailNotify=@EmailNotify,
                            IpAddress=@IpAddress,
                            CreateDate=@CreateDate,
                            Approved=@Approved
                            where CommentId=@CommentId ";

            OleDbParameter[] prams = {
                                        OleDbHelper.MakeInParam("@PostId", OleDbType.Integer,4, comment.PostId),
                                        OleDbHelper.MakeInParam("@ParentId", OleDbType.Integer,4, comment.ParentId),
                                        OleDbHelper.MakeInParam("@UserId", OleDbType.Integer,4, comment.UserId),
                                        OleDbHelper.MakeInParam("@Name", OleDbType.VarWChar,255, comment.Name),
                                        OleDbHelper.MakeInParam("@Email", OleDbType.VarWChar,255, comment.Email),
                                        OleDbHelper.MakeInParam("@SiteUrl", OleDbType.VarWChar,255, comment.SiteUrl),
                                        OleDbHelper.MakeInParam("@Content", OleDbType.VarWChar,255, comment.Content),
                                        OleDbHelper.MakeInParam("@EmailNotify", OleDbType.Integer,4 ,    comment.EmailNotify),
                                        OleDbHelper.MakeInParam("@IpAddress", OleDbType.VarWChar,255, comment.IpAddress),
                                        OleDbHelper.MakeInParam("@CreateDate", OleDbType.Date,8, comment.CreateDate),
                                        OleDbHelper.MakeInParam("@Approved", OleDbType.Integer,4 ,   comment.Approved),
                                        OleDbHelper.MakeInParam("@CommentId", OleDbType.Integer,4, comment.CommentId),

                                    };
            return OleDbHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams);
        }
Exemple #3
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="comment"></param>
        /// <returns></returns>
        public static int UpdateComment(CommentInfo comment)
        {
            _recentcomments = null;

            return dao.UpdateComment(comment);
        }
Exemple #4
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="comment"></param>
        /// <returns></returns>
        public int InsertComment(CommentInfo comment)
        {
            string cmdText = @"insert into [loachs_comments](
                            PostId, ParentId,UserId,Name,Email,SiteUrl,Content,EmailNotify,IpAddress,CreateDate,Approved)
                             values (
                            @PostId, @ParentId,@UserId,@Name,@Email,@SiteUrl,@Content,@EmailNotify,@IpAddress,@CreateDate,@Approved)";

            OleDbParameter[] prams = {
                                        OleDbHelper.MakeInParam("@PostId", OleDbType.Integer,4, comment.PostId),
                                        OleDbHelper.MakeInParam("@ParentId", OleDbType.Integer,4, comment.ParentId),
                                        OleDbHelper.MakeInParam("@UserId", OleDbType.Integer,4, comment.UserId),
                                        OleDbHelper.MakeInParam("@Name", OleDbType.VarWChar,255, comment.Name),
                                        OleDbHelper.MakeInParam("@Email", OleDbType.VarWChar,255, comment.Email),
                                        OleDbHelper.MakeInParam("@SiteUrl", OleDbType.VarWChar,255, comment.SiteUrl),
                                        OleDbHelper.MakeInParam("@Content", OleDbType.VarWChar,255, comment.Content),
                                        OleDbHelper.MakeInParam("@EmailNotify", OleDbType.Integer,4 ,    comment.EmailNotify),
                                        OleDbHelper.MakeInParam("@IpAddress", OleDbType.VarWChar,255, comment.IpAddress),
                                        OleDbHelper.MakeInParam("@CreateDate", OleDbType.Date,8, comment.CreateDate),
                                        OleDbHelper.MakeInParam("@Approved", OleDbType.Integer,4 ,   comment.Approved),
            };
            OleDbHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams);

            int newId = Convert.ToInt32(OleDbHelper.ExecuteScalar("select top 1 [CommentId] from [loachs_comments]  order by [CommentId] desc"));
            return newId;
        }
Exemple #5
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="comment"></param>
        /// <returns></returns>
        public static int InsertComment(CommentInfo comment)
        {
            int result = dao.InsertComment(comment);

            //统计
            StatisticsManager.UpdateStatisticsCommentCount(1);

            //用户
            UserManager.UpdateUserCommentCount(comment.UserId, 1);

            //文章
            PostManager.UpdatePostCommentCount(comment.PostId, 1);

            _recentcomments = null;

            return result;
        }