⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 threadjoin.cs

📁 本系统是在asp版《在线文件管理器》的基础上设计制作
💻 CS
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using CommunityServer.Components;
using CommunityServer.Controls;
using CommunityServer.Discussions.Components;

namespace CommunityServer.Discussions.Controls 
{

    // *********************************************************************
    //  ThreadJoin
    //
    /// <summary>
    /// This sever control is used to join two threads into a single thread.
    /// </summary>
    /// 
    // ********************************************************************/ 
    public class ThreadJoin : SkinnedWebControl 
    {

        #region Member Variables & constructor
        CSContext csContext = CSContext.Current;
        string skinFilename = "Moderation\\View-ThreadJoin.ascx";
        HyperLink childThread;
        HyperLink parentThread;
        Button validateParent;
        CheckBox sendEmail;
        TextBox parentThreadID;
        HyperLink cancelMove;
        LinkButton move;
        CheckBox parentIsValid;
        ForumPost postToJoin;

        // *********************************************************************
        //  ThreadJoin
        //
        /// <summary>
        /// Constuctor
        /// </summary>
        /// 
        // ***********************************************************************/
        public ThreadJoin() : base() 
        {

            // Set the skin file
            if (SkinFilename == null)
                SkinFilename = skinFilename;

            if (csContext.ReturnUrl == null) 
            {
                throw new CSException(CSExceptionType.ReturnURLRequired);
            }
        }

        #endregion

        #region Initialize Skin
        // *********************************************************************
        //  InitializeSkin
        //
        /// <summary>
        /// Initialize the control template and populate the control with values
        /// </summary>
        /// <param name="skin">Control instance of the skin</param>
        /// 
        // ***********************************************************************/
        override protected void InitializeSkin(Control skin) 
        {

            // Get the post we want to move
            postToJoin = Posts.GetPost(csContext.PostID, csContext.User.UserID);

			// Do an access check
			Permissions.AccessCheck( postToJoin.Section, Permission.Moderate, CSContext.Current.User, postToJoin );

            // Find the parent threadid
            parentThreadID = (TextBox) skin.FindControl("ParentThreadID");

            // Display child thread
            childThread = (HyperLink) skin.FindControl("ChildThread");
            childThread.Text = postToJoin.Subject + " (" + postToJoin.ThreadID + ")";
            childThread.NavigateUrl = Globals.GetSiteUrls().Post(postToJoin.PostID);

            parentThread = (HyperLink) skin.FindControl("ParentThread");

            // Validate parent
            validateParent = (Button) skin.FindControl("ValidateParentThread");
            validateParent.Text = ResourceManager.GetString("ThreadJoin_ValidateButton");
            validateParent.Click += new EventHandler(ValidateThread_Click);
            
            parentIsValid = (CheckBox) skin.FindControl("ParentThreadIsValid");
            parentIsValid.Text = ResourceManager.GetString("ThreadJoin_IsValid");
            parentIsValid.Enabled = false;

            // Cancel
            cancelMove = (HyperLink) skin.FindControl("CancelMove");
            if (null != cancelMove) 
            {
                cancelMove.NavigateUrl = csContext.ReturnUrl;
                cancelMove.Text = ResourceManager.GetString("MovePost_CancelMove");
            }

            // Join threads
            move = (LinkButton) skin.FindControl("MovePost");
            if (null != move) 
            {
                move.Click += new System.EventHandler(SplitThread_Click);
                move.Text = ResourceManager.GetString("ThreadJoin_JoinThread");
				move.Enabled = false;
            }

            // Send email
            sendEmail = (CheckBox) skin.FindControl("SendUserEmail");
            sendEmail.Text = ResourceManager.GetString("ThreadJoin_SendUserEmail");
        }
        #endregion

        #region Move Event
        // *********************************************************************
        //  SplitThread_Click
        //
        /// <summary>
        /// Event handler for splitting a thread
        /// </summary>
        /// 
        // ***********************************************************************/
        private void SplitThread_Click(Object sender, EventArgs e) 
        {

            // Are we valid?
            Moderate.ThreadJoin ( Posts.GetPost(int.Parse(parentThreadID.Text), csContext.User.UserID), postToJoin, csContext.User.UserID, sendEmail.Checked);

            // Redirect the user to the return url.
            HttpContext.Current.Response.Redirect(csContext.ReturnUrl);
            HttpContext.Current.Response.End();
        }

        private void ValidateThread_Click (Object sender, EventArgs e) 
        {
            ForumPost p = null;

            // Check to ensure that a post exists
            try 
            {
                p = Posts.GetPost(int.Parse(parentThreadID.Text), csContext.User.UserID);
            } 
            catch 
            {
                return;
            }

            if (p == null)
                return;

            parentThreadID.Text = p.PostID.ToString();
            parentIsValid.Checked = true;
            parentThread.Text = p.Subject + " (" + p.ThreadID + ")";
            parentThread.NavigateUrl = Globals.GetSiteUrls().Post(p.PostID);

			move.Enabled = true;

        }

        #endregion
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -