Esempio n. 1
0
        private void GetThread(int threadId)
        {
            using (IDataReader reader = DBForums.ForumThreadGetThread(threadId))
            {
                if (reader.Read())
                {
                    this.threadID = int.Parse(reader["ThreadID"].ToString());
                    if (reader["ForumID"] != DBNull.Value)
                    {
                        this.forumID     = Convert.ToInt32(reader["ForumID"]);
                        this.origForumID = forumID;
                    }
                    if (reader["ModuleID"] != DBNull.Value)
                    {
                        this.moduleID = Convert.ToInt32(reader["ModuleID"]);
                    }
                    if (reader["ThreadDate"] != DBNull.Value)
                    {
                        this.threadDate = Convert.ToDateTime(reader["ThreadDate"].ToString());
                    }
                    this.startedBy = reader["StartedBy"].ToString();
                    if (reader["StartedByUserID"] != DBNull.Value)
                    {
                        this.startedByUserID = int.Parse(reader["StartedByUserID"].ToString());
                    }

                    this.subject = reader["ThreadSubject"].ToString();
                    if (reader["TotalViews"] != DBNull.Value)
                    {
                        this.totalViews = Convert.ToInt32(reader["TotalViews"]);
                    }

                    if (reader["TotalReplies"] != DBNull.Value)
                    {
                        this.totalReplies = Convert.ToInt32(reader["TotalReplies"]);
                    }

                    if (reader["SortOrder"] != DBNull.Value)
                    {
                        this.sortOrder = Convert.ToInt32(reader["SortOrder"]);
                    }
                    if (reader["ForumSequence"] != DBNull.Value)
                    {
                        this.forumSequence = Convert.ToInt32(reader["ForumSequence"]);
                    }

                    if (reader["PostsPerPage"] != DBNull.Value)
                    {
                        this.postsPerPage = Convert.ToInt32(reader["PostsPerPage"]);
                    }

                    if (this.totalReplies + 1 > this.postsPerPage)
                    {
                        this.totalPages = this.totalReplies / this.postsPerPage;
                        int remainder = 0;
                        int pageCount = Math.DivRem(this.totalReplies + 1, this.postsPerPage, out remainder);
                        if ((remainder > 0) || (pageCount > this.totalPages))
                        {
                            this.totalPages += 1;
                        }
                    }
                    else
                    {
                        this.totalPages = 1;
                    }

                    // this is to support dbs that don't have bit data type
                    string locked = reader["IsLocked"].ToString();
                    this.isLocked = (locked == "True" || locked == "1");

                    if (reader["MostRecentPostDate"] != DBNull.Value)
                    {
                        this.mostRecentPostDate = Convert.ToDateTime(reader["MostRecentPostDate"]);
                    }

                    this.mostRecentPostUser = reader["MostRecentPostUser"].ToString();

                    if (reader["MostRecentPostUserID"] != DBNull.Value)
                    {
                        this.mostRecentPostUserID = Convert.ToInt32(reader["MostRecentPostUserID"]);
                    }

                    if (reader["ThreadGuid"] != DBNull.Value)
                    {
                        this.threadGuid = new Guid(reader["ThreadGuid"].ToString());
                    }

                    if (reader["IsQuestion"] != DBNull.Value)
                    {
                        this.isQuestion = Convert.ToBoolean(reader["IsQuestion"]);
                    }

                    if (reader["IncludeInSiteMap"] != DBNull.Value)
                    {
                        this.includeInSiteMap = Convert.ToBoolean(reader["IncludeInSiteMap"]);
                    }

                    if (reader["SetNoIndexMeta"] != DBNull.Value)
                    {
                        this.setNoIndexMeta = Convert.ToBoolean(reader["SetNoIndexMeta"]);
                    }

                    this.pageTitleOverride = reader["PTitleOverride"].ToString();

                    if (reader["ModStatus"] != DBNull.Value)
                    {
                        this.modStatus = Convert.ToInt32(reader["ModStatus"]);
                    }

                    if (reader["AssignedTo"] != DBNull.Value)
                    {
                        this.assignedTo = new Guid(reader["AssignedTo"].ToString());
                    }

                    if (reader["LockedBy"] != DBNull.Value)
                    {
                        this.lockedBy = new Guid(reader["LockedBy"].ToString());
                    }

                    this.threadType = reader["ThreadType"].ToString();

                    this.LockedReason = reader["LockedReason"].ToString();

                    if (reader["LockedUtc"] != DBNull.Value)
                    {
                        this.lockedUtc = Convert.ToDateTime(reader["LockedUtc"]);
                    }


                    //
                }
            }
        }