📄 forums.cs
字号:
forumsBelongingToGroup.Sort();
return forumsBelongingToGroup;
}
// *********************************************************************
// GetForumsByForumGroupId
//
/// <summary>
/// Used to return a narrow collection of forums that belong to a given forum id.
/// The username is provied for personalization, e.g. if the user has new
/// posts in the forum
/// </summary>
/// <param name="forumGroupId">Forum Group ID to retrieve forums for</param>
/// <param name="username">Username making the request</param>
///
// ***********************************************************************/
public ForumCollection GetForumsByForumGroupId(int forumGroupId, string username) {
return GetForumsByForumGroupId(forumGroupId, username, false);
}
// *********************************************************************
// GetForumInfo
//
/// <summary>
/// Returns information on a particular forum.
/// </summary>
/// <param name="ForumID">The ID of the Forum that you are interested in.</param>
/// <returns>A Forum object with information about the specified forum.</returns>
/// <remarks>If the passed in ForumID is not found, a ForumNotFoundException exception is
/// thrown.</remarks>
///
// ***********************************************************************/
public static Forum GetForumInfo(int ForumID) {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
//return dp.GetForumInfoByPostID(PostID);
return dp.GetForumInfo(ForumID, HttpContext.Current.User.Identity.Name);
}
// *********************************************************************
// GetTotalThreadsInForum
//
/// <summary>
/// Used in paging to return a count of the forums based on the query
/// </summary>
/// <param name="forumID">id of the forum</param>
/// <param name="maxDateTime">Datetime filter</param>
/// <param name="minDateTime">Datetime filter</param>
/// <param name="unreadThreadsOnly">Display threads that the user has not read</param>
/// <param name="username">User making the request</param>
///
// ***********************************************************************/
public static int GetTotalThreadsInForum(int forumID, DateTime maxDateTime, DateTime minDateTime, string username, bool unreadThreadsOnly) {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
return dp.GetTotalThreadsInForum(forumID, maxDateTime, minDateTime, username, unreadThreadsOnly);
}
// *********************************************************************
// GetForumInfoByPostID
//
/// <summary>
/// Returns information about the forum that a particular post exists in.
/// </summary>
/// <param name="PostID">The ID of the Post that exists in the forum you're interested in.</param>
/// <returns>A Forum object containing information about the forum the Post exists in.</returns>
/// <remarks>If the post is not found or does not contain a valid ForumID, a
/// ForumNotFoundException is thrown.</remarks>
///
// ***********************************************************************/
public static Forum GetForumInfoByPostID(int PostID) {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
return dp.GetForumInfoByPostID(PostID);
}
// *********************************************************************
// GetForumInfoByThreadID
//
/// <summary>
/// Returns information about the forum that a particular thread exists in.
/// </summary>
/// <param name="ThreadID">The ID of the Thread that exists in the forum you're interested in.</param>
/// <returns>A Forum object containing information about the forum the Thread exists in.</returns>
/// <remarks>If the thread is not found or does not contain a valid ForumID, a
/// ForumNotFoundException is thrown.</remarks>
///
// ***********************************************************************/
public static Forum GetForumInfoByThreadID(int ThreadID) {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
return dp.GetForumInfoByThreadID(ThreadID);
}
// *********************************************************************
// DeleteForum
//
/// <summary>
/// Deletes a forum and all of the posts in the forum.
/// </summary>
/// <param name="ForumID">The ID of the forum to delete.</param>
/// <remarks>Be very careful when using this method. The specified forum and ALL of its posts
/// will be deleted.</remarks>
///
// ***********************************************************************/
public static void DeleteForum(int forumID) {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
dp.DeleteForum(forumID);
}
// *********************************************************************
// AddForum
//
/// <summary>
/// Creates a new forum.
/// </summary>
/// <param name="forum">Specifies information about the forum to create.</param>
///
// ***********************************************************************/
public static void AddForum(Forum forum) {
// turn the description into a formatted version
forum.Description = ForumDescriptionFormattedToRaw(forum.Description);
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
dp.AddForum(forum);
}
// *********************************************************************
// UpdateForum
//
/// <summary>
/// Updates a particular forum.
/// </summary>
/// <param name="forum">Specifies information about the forum to update. The ForumID property
/// indicates what forum it is that you wish to update.</param>
///
// ***********************************************************************/
public static void UpdateForum(Forum forum) {
// turn the description into a formatted version
forum.Description = ForumDescriptionFormattedToRaw(forum.Description);
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
dp.UpdateForum(forum);
}
// *********************************************************************
// ForumDescriptionFormattedToRaw
//
/// <summary>
/// Converts the forum description from formatted text to raw text.
/// </summary>
/// <param name="Description">The formatted text forum description</param>
/// <returns>A raw text version of the forum's description.</returns>
/// <remarks>This function merely converts HTML newline tags to carraige returns.
/// This method only needs to be called editing an existing forum.
///
// ***********************************************************************/
public static String ForumDescriptionFormattedToRaw(String Description) {
// replace new line characters with \n
return Description.Replace(Globals.HtmlNewLine, "\n");
}
// *********************************************************************
// TotalNumberOfForums
//
/// <summary>
/// Returns the total number of forums that exist.
/// </summary>
/// <returns>The total number of forums.</returns>
///
// ***********************************************************************/
public static int TotalNumberOfForums() {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
return dp.TotalNumberOfForums();
}
// *********************************************************************
// ForumListStyle
//
/// <summary>
/// Used for displaying the forum group/forum relationship in dropdownlists
/// </summary>
///
// ***********************************************************************/
public enum ForumListStyle {
Flat,
Nested
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -