privatemessageview.cs

来自「community server 源码」· CS 代码 · 共 126 行

CS
126
字号
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

// TODO: Remove code that display help...

using System.Collections;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

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

namespace CommunityServer.Discussions.Controls 
{
    // *********************************************************************
    //  PrivateMessageView
    //
    /// <summary>
    /// This server control is used to display private messages to a user
    /// </summary>
    /// 
    // ********************************************************************/
    public class PrivateMessageView : ThreadView 
    {
        #region Member variables and constructor

        string skinFilename = "View-PrivateMessages.ascx";
        
        // *********************************************************************
        //  PrivateMessageView
        //
        /// <summary>
        /// The constructor simply checks for a ForumID value passed in via the
        /// HTTP POST or GET.
        /// properties.
        /// </summary>
        /// 
        // ********************************************************************/
        public PrivateMessageView() 
        {
            base.ThreadViewMode = ThreadViewMode.PrivateMessages;

            SkinName = skinFilename;
        }

        #endregion

        #region Skin

        // *********************************************************************
        //  Initializeskin
        //
        /// <summary>
        /// Initializes the user control loaded in CreateChildControls. Initialization
        /// consists of finding well known control names and wiring up any necessary events.
        /// </summary>
        /// 
        // ********************************************************************/ 
        protected override void AttachChildControls() 
        {
            base.AttachChildControls();
            
            if (base.announcements != null)
                base.announcements.ItemCommand += new RepeaterCommandEventHandler( Messages_ItemCommand );

            if (base.threads != null)
                base.threads.ItemCommand += new RepeaterCommandEventHandler( Messages_ItemCommand );

            //DataBind();
        }

        #endregion

        #region Events

        public void Messages_ItemCommand(object sender, RepeaterCommandEventArgs e)
        {
            ArrayList deleteList = new ArrayList();
            Repeater source = sender as Repeater;
            
            if (source == null)
                return;

            if (source.ID.ToLower() == "announcements")
            {
                foreach (RepeaterItem i in announcements.Items) 
                {
                    CheckBox c = i.FindControl("BulkEdit") as CheckBox;

                    if (c.Checked) 
                    {
                        HtmlGenericControl d = i.FindControl("ThreadID") as HtmlGenericControl;
                        deleteList.Add( int.Parse(d.InnerText) );
                    }
                }
            }

            if (source.ID.ToLower() == "threads")
            {
                foreach (RepeaterItem i in threads.Items) 
                {
                    CheckBox c = i.FindControl("BulkEdit") as CheckBox;

                    if (c.Checked) 
                    {
                        HtmlGenericControl d = i.FindControl("ThreadID") as HtmlGenericControl;
                        deleteList.Add( int.Parse(d.InnerText) );
                    }
                }
            }

			int user = CSContext.Current.User.UserID;
            PrivateMessages.DeletePrivateMessages( user, deleteList );

			UserMessages.InvalidateMessageCount( user);

            DataBind();
        }

        #endregion
    }
}

⌨️ 快捷键说明

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