using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using JuSNS.Model;
using JuSNS.UI.Control;

namespace JuSNS.Web.home.mail
{
    public partial class notice : JuSNS.UI.Page.UserPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadList();
            if (!Page.IsPostBack)
            {
                JuSNS.Home.Mail Mail = new JuSNS.Home.Mail();
                Mail.UpdateNoticeMode(UserID);
            }
        }

        /// <summary>
        /// 加载分页
        /// </summary>
        /// <param name="PageIndex">当前页数</param>
        protected void LoadList()
        {
            DivPage.Visible = false;
            int r, p, PageIndex = 0;
            PageIndex = Convert.ToInt32(Request.QueryString["Page"]);
            SqlConditionInfo st = new SqlConditionInfo("@Receiver", UserID, TypeCode.Int32);

            DataTable dt = JuSNS.Home.UtilPage.GetPage("Notice_aspx", PageIndex, 30, out r, out p, st);
            if (dt != null)
            {
                Rpt_Notice.DataSource = dt;
                Rpt_Notice.DataBind();
                dt.Clear();
                dt.Dispose();
            }
            //判断是否调用分页
            if (r > 30)
            {
                DivPage.Visible = true;
                DivPage.InnerHtml = PageNavigator.Pagination(PageIndex, p, "notice.aspx");
            }
        }

        /// <summary>
        /// 取得未读通知样式
        /// </summary>
        /// <param name="isRead"></param>
        protected string getisNew(object isRead)
        {
            string s_Read = " class=\"pstr\"";
            if (Convert.ToBoolean(isRead) == false)
            {
                s_Read = " class=\"pstr bold\"";
            }
            return s_Read;
        }

        /// <summary>
        /// 取得详细内容
        /// </summary>
        /// <param name="nType">类型</param>
        /// <param name="cId">相关编号</param>
        /// <returns></returns>
        protected string getContent(object nType, object cId)
        {
            string s_Content = "";
            string CId = Convert.ToString(cId);

            switch ((EnumNotifyType)Convert.ToInt32(nType))
            {
                case EnumNotifyType.AgreeBeFriends:
                    s_Content = "同意与您成为好友。";
                    break;
                case EnumNotifyType.CommentBlog:
                    JuSNS.Home.Blog blog = new JuSNS.Home.Blog();
                    JuSNS.Model.BlogInfo bloginfo = blog.GetBlog(Convert.ToInt32(CId), false);
                    s_Content = "评论了你的日志 <a href=\"" + rooDir + "/home/blog/article.aspx?r=" + CId.ToString() + "\">" + bloginfo.Title + "</a>。";
                    break;
                case EnumNotifyType.ConfirmFriendDetail:
                    s_Content = "确认了你的好友描述。";
                    break;
                case EnumNotifyType.LassoOneself:
                    s_Content = "在<a href=\"" + rooDir + "/home/album/PhotoView.aspx?r[0]=" + CId + "\"> 照片</a> 中圈了自已。";
                    break;
                case EnumNotifyType.LassoOther:
                    s_Content = "在<a href=\"" + rooDir + "/home/album/PhotoView.aspx?r[0]=" + CId + "\"> 照片</a> 中把你圈了出来。";
                    break;
                case EnumNotifyType.Leaveword:
                    s_Content = "在你的 <a href=\"" + rooDir + "/home/gbook\"> 留言板</a> 留了言。";
                    break;
                case EnumNotifyType.PhotoComm:
                    s_Content = "在你的 <a href=\"" + rooDir + "/home/album/PhotoView.aspx?r[0]=" + CId + "\"> 相册</a> 发表了评论。";
                    break;
                case EnumNotifyType.GroupAdmin:
                    UserGroupInfo groupinfo = new UserGroupInfo();
                    JuSNS.Home.UserGroup usergroup = new JuSNS.Home.UserGroup();
                    groupinfo = usergroup.Info(Convert.ToInt32(cId));
                    s_Content = "在群 <a href=\"" + rooDir + "/home/group/group.aspx?groupid=" + CId + "\"> " + groupinfo.GroupName + "</a> 中把你设置成了管理员。";
                    break;
                case EnumNotifyType.MiniComment:
                    s_Content = "在你的 <a href=\"" + rooDir + "/home/mood/?mid=" + CId + "#re_" + CId + "\">心情日记</a> 发表了评论。";
                    break;
                case EnumNotifyType.SendGift:
                    s_Content = "给你送了一个 <a href=\"" + rooDir + "/home/gift/box.aspx?r=in\">礼物</a>。";
                    break;
                case EnumNotifyType.ToVote:
                    s_Content = "参与了你的 <a href=\"" + rooDir + "/home/vote/vote.aspx?r=" + CId + "\">投票</a>。";
                    break;
                case EnumNotifyType.VoteComment:
                    s_Content = "回复了你的 <a href=\"" + rooDir + "/home/vote/vote.aspx?r=" + CId + "\">投票</a>。";
                    break;
                case EnumNotifyType.ShareComment:
                    s_Content = "回复了你的 <a href=\"" + rooDir + "/home/share/?r=" + this.UserID + "\">分享</a>。";
                    break;
                case EnumNotifyType.ReplayAsk:
                    s_Content = "回复了你的 <a href=\"" + rooDir + "/ask/q" + CId + ".aspx\">问答</a>。";
                    break;
                case EnumNotifyType.AskBest:
                    s_Content = "把你的回复设置为了最佳答案，<a href=\"" + rooDir + "/ask/q" + CId + ".aspx\">查看</a>。";
                    break;
                case EnumNotifyType.ReGroupTopic:
                    JuSNS.Home.Group discuss = new JuSNS.Home.Group();
                    JuSNS.Model.GroupDiscussInfo discussinfo = new JuSNS.Model.GroupDiscussInfo();
                    discussinfo = discuss.Info(Convert.ToInt32(cId));
                    s_Content = "回复了你发表的群组主题 <a href=\""+rooDir+"/home/group/topic.aspx?DisID=" + CId + "\">" + discussinfo.Topic + "</a>。";
                    break;

            }
            return s_Content;
        }

        protected string getCss(object nType)
        {
            string s_Pic = string.Empty;
            switch ((EnumNotifyType)Convert.ToInt32(nType))
            {
                case EnumNotifyType.AgreeBeFriends:
                    s_Pic = "noti noti-friend";
                    break;
                case EnumNotifyType.CommentBlog:
                    s_Pic = "noti noti-blog";
                    break;
                case EnumNotifyType.ConfirmFriendDetail:
                    s_Pic = "noti noti-friend";
                    break;
                case EnumNotifyType.LassoOneself:
                    s_Pic = "noti noti-phototag";
                    break;
                case EnumNotifyType.LassoOther:
                    s_Pic = "noti noti-phototag";
                    break;
                case EnumNotifyType.Leaveword:
                    s_Pic = "noti noti-wall";
                    break;
                case EnumNotifyType.PhotoComm:
                    s_Pic = "noti noti-phototag";
                    break;
                case EnumNotifyType.GroupAdmin:
                    s_Pic = "noti noti-group";
                    break;
                case EnumNotifyType.MiniComment:
                    s_Pic = "noti noti-miniblog";
                    break;
                case EnumNotifyType.ReGroupTopic:
                    s_Pic = "noti noti-group";
                    break;
                case EnumNotifyType.SendGift:
                    s_Pic = "noti noti-gift";
                    break;
                case EnumNotifyType.ToVote:
                    s_Pic = "noti noti-vote";
                    break;
                case EnumNotifyType.VoteComment:
                    s_Pic = "noti noti-vote";
                    break;
                case EnumNotifyType.ShareComment:
                    s_Pic = "noti noti-share";
                    break;
                case EnumNotifyType.ReplayAsk:
                    s_Pic = "noti noti-ask";
                    break;
                case EnumNotifyType.AskBest:
                    s_Pic = "noti noti-ask";
                    break;
                    
            }
            return s_Pic;
        }
    }
}
