示例#1
0
        private PostCollectionV5 GetPosts(XSqlDataReader reader, bool isFirstRead)
        {
            PostCollectionV5 posts = new PostCollectionV5();

            List<int> replyIDs = new List<int>();

            if (isFirstRead)
            {
                while (reader.Read())
                {
                    PostV5 post = new PostV5(reader);
                    post.Attachments = new AttachmentCollection();
                    post.PostMarks = new PostMarkCollection();
                    posts.Add(post);
                    replyIDs.Add(post.PostID);
                }
            }
            else
            {
                if (reader.NextResult())
                {
                    while (reader.Read())
                    {
                        PostV5 post = new PostV5(reader);
                        post.Attachments = new AttachmentCollection();
                        post.PostMarks = new PostMarkCollection();
                        posts.Add(post);
                        replyIDs.Add(post.PostID);
                    }
                }
            }
            //读取下一个结果集
            if (reader.NextResult())
            {
                while (reader.Read()) //附件列表
                {
                    Attachment attachment = new Attachment(reader);
                    int replyIndex = replyIDs.IndexOf(attachment.PostID);
                    if (replyIndex != -1)
                    {
                        posts[replyIndex].Attachments.Add(attachment);
                    }
                }
            }
            //历史附件
            if (reader.NextResult())
            {
                while (reader.Read()) //附件列表
                {
                    Attachment attachment = new Attachment(reader);
                    attachment.AttachType = AttachType.History;
                    int hpostID = reader.Get<int>("HPostID");
                    int replyIndex = replyIDs.IndexOf(hpostID);
                    if (replyIndex != -1)
                    {
                        posts[replyIndex].Attachments.Add(attachment);
                    }
                }
            }
            if (reader.NextResult())//评分列表
            {
                while (reader.Read())
                {
                    PostMark postMark = new PostMark(reader);
                    int replyIndex = replyIDs.IndexOf(postMark.PostID);
                    if (replyIndex != -1)
                    {
                        posts[replyIndex].PostMarks.Add(postMark);
                    }
                }
            }
            if (reader.NextResult())
            {
                string s = null;
                while (reader.Read())
                {
                    s = reader.Get<string>(0);
                }

#if !Publish
                if (reader.SqlQuery.TempInfo != null)
                    reader.SqlQuery.TempInfo += "-----" + s;
                else
                    reader.SqlQuery.TempInfo = s;
#endif
            }

            return posts;
        }
示例#2
0
        public override int CreatePostMark(int postID, int userID, string username, DateTime createDate, int[] points, string reason, out PostMark postMark)
        {

            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_v5_CreatePostMark";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter<int>("@PostID", postID, SqlDbType.Int);
                query.CreateParameter<int>("@UserID", userID, SqlDbType.Int);
                query.CreateParameter<string>("@Username", username, SqlDbType.NVarChar, 50);
                query.CreateParameter<DateTime>("@CreateDate", createDate, SqlDbType.DateTime);
                query.CreateParameter<int>("@ExtendedPoints_1", points[0], SqlDbType.Int);
                query.CreateParameter<int>("@ExtendedPoints_2", points[1], SqlDbType.Int);
                query.CreateParameter<int>("@ExtendedPoints_3", points[2], SqlDbType.Int);
                query.CreateParameter<int>("@ExtendedPoints_4", points[3], SqlDbType.Int);
                query.CreateParameter<int>("@ExtendedPoints_5", points[4], SqlDbType.Int);
                query.CreateParameter<int>("@ExtendedPoints_6", points[5], SqlDbType.Int);
                query.CreateParameter<int>("@ExtendedPoints_7", points[6], SqlDbType.Int);
                query.CreateParameter<int>("@ExtendedPoints_8", points[7], SqlDbType.Int);
                query.CreateParameter<string>("@Reason", reason, SqlDbType.NText);
                SqlParameter errorCode = query.CreateParameter<int>("@ErrorCode", SqlDbType.Int, ParameterDirection.ReturnValue);

                postMark = null;
                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        postMark = new PostMark(reader);
                    }
                }

                return Convert.ToInt32(errorCode.Value);
            }
        }
示例#3
0
 public abstract int CreatePostMark(int postID, int userID, string username, DateTime createDate, int[] points, string reason, out PostMark postMark);