using System;
using System.Data;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
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.Home;
using JuSNS.Model;
using JuSNS.Common;

namespace JuSNS.Web.home
{
    public partial class index : JuSNS.UI.Page.UserPage
    {
        JUser us = new JUser();
        User usr = new User();
        Friend frd = new Friend();
        UserInfo mdl = new UserInfo();
        HomeIndex uHome = new HomeIndex();
        protected string isHeadPic = string.Empty;
        protected string GetTiShiDivStr = string.Empty;
        protected int integral = 0;
        protected int integralyb = 0;
        protected int Click = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            mdl = usr.GetUserInfo(this.UserID);
            integral = mdl.integral;
            integralyb = mdl.inteyb;
            Click = mdl.Click;
            this.ptitle.InnerText = this.UserName + "@" + JuSNS.Config.UiConfig.SiteName + "首页";
            isHeadPic = this.GetHeadImage(this.UserID, 1);
            string HeadSTR = this.GetHeadPath(this.UserID);
            string ErrSTR = string.Empty;
            if (mdl.State != EnumUserState.Normal)
            {
                ErrSTR += "您的帐户未激活电子邮件，<a href=\""+rooDir+"/EmailActive.aspx?email="+mdl.Email+"&r="+this.UserID+"\">激活电子邮件将获得积分</a>。";
            }
            if (mdl.LoginTimes < 2 && string.IsNullOrEmpty(HeadSTR))
            {
                Response.Redirect(rooDir + "/home/space/edit.aspx?f=1");
            }
            if (string.IsNullOrEmpty(HeadSTR))
            {
                string errorStr = "您需要上传了头像后，才能正常浏览！";
                if (JuSNS.Config.UiConfig.isUpHeadPic == "1")
                {
                    Response.Redirect(rooDir + "/home/space/userheadphoto.aspx?h=1&Err=" + Input.URLEncode(errorStr) + "");
                }
                else
                {
                    ErrSTR += "您还没上传头像！为方便朋友找到您！请及时<a href=\"" + rooDir + "/home/space/userHeadPhoto.aspx\">上传头像</a>。";
                }
            }

            if (!string.IsNullOrEmpty(ErrSTR))
            {
                bool isShow = false;
                HttpCookie SNSMessageCookie = Request.Cookies["SNSShowIndexMessage"];
                if (SNSMessageCookie != null && !string.IsNullOrEmpty(SNSMessageCookie["ShowIndexMessage"]))
                {
                    if (SNSMessageCookie["ShowIndexMessage"] == "1")
                    {
                        isShow = true;
                    }
                }
                if (!isShow)
                {
                    this.ErrDiv.Visible = true;
                    this.ErrDiv.InnerHtml = "<span class=\"nl\">" + ErrSTR + "</span><span class=\"nr\"><a href=\"javascript:void(0);\" onclick=\"NoShowMessage('ShowIndexMessage','ErrDiv');\"><img src=\"" + rooDir + "/template/" + JuSNS.Config.UiConfig.SkinStyle + "/images/closedyn.gif\" align=\"absmiddle\" />不在显示</a> &nbsp; </span>";
                }
            }
            string a = Request.QueryString["a"];
            if (!string.IsNullOrEmpty(a))
            {
                Response.Write(DynList());
                Response.End();
            }
            else
            {
                GetReqNew(); MoodInfo(); LoadVisitorList(); ShowFindFriends(); LoadSFriendList(); Giftslist(); PokeList();
                if (Public.GetXMLValue("isOpenAlbum") == "1")
                {
                    albumPhotosList();
                    this.showAlbumDivVisiable.Visible = true;
                }
                else
                {
                    this.showAlbumDivVisiable.Visible = false;
                }
                this.dnynews.InnerHtml = DynList();
                if (Public.GetXMLValue("isShowNewReg") == "1")
                {
                    LoadnewRegList();
                    this.newReg.Visible = true;
                }
                else
                {
                    this.newReg.Visible = true;
                }
                if (Public.GetXMLValue("isShowBirthday") == "1")
                {
                    BirthList();
                }
                else
                {
                    this.birthdayIDVisiable.Visible = false;
                }
            }
        }

        /// <summary>
        /// 最新请求，通知，邀请
        /// </summary>
        protected void GetReqNew()
        {
            string listStr = string.Empty;
            int reqNumber = us.FriendRequest(UserID, 1);
            string reqStyle = reqNumber.ToString() + "个好友请求";
            if (reqNumber > 0) { reqStyle = "<span class=\"bold reshow\">" + reqNumber + "个好友请求</span>"; }
            listStr += "<li><div class=\"req-friend-add\"><a href=\"" + rooDir + "/home/friend/req.aspx\" title=\"有" + reqNumber + "个好友请求\">" + reqStyle + "</a></div></li>";

            int groupNumber = us.FriendRequest(UserID, 3);
            string groupStyle = groupNumber.ToString() + "个群组邀请";
            if (groupNumber > 0) { groupStyle = "<span class=\"bold reshow\">" + groupNumber + "个群组邀请</span>"; }
            listStr += "<li><div class=\"req-group-add\"><a href=\"" + rooDir + "/home/group/req.aspx\" title=\"有" + groupNumber + "个群组邀请\">" + groupStyle + "</a></div></li>";
           
            int SysNote = 0;
            JuSNS.Home.Mail Mail = new JuSNS.Home.Mail();
            SysNote = Mail.InBoxCount(UserID);
            string SysNoteSTR = SysNote.ToString() + "个短信";
            if (SysNote > 0) { SysNoteSTR = "<span class=\"bold reshow\">" + SysNote + "个短信</span>"; }
            listStr += "<li><div class=\"req-sys-add\"><a href=\"" + rooDir + "/home/mail\" title=\"有" + SysNote + "个短信\">" + SysNoteSTR + "</a></div></li>";

            string NoteStr = string.Empty;
            int NoteNumber = us.GetNoteNumber(UserID);
            string NoteStyle = NoteNumber.ToString() + "个事件提醒";
            if (NoteNumber > 0) { NoteStyle = "<span class=\"bold reshow\">" + NoteNumber + "个事件提醒</span>"; }

            listStr += "<li><div class=\"req-note-add\"><a href=\"" + rooDir + "/home/note\" title=\"有" + NoteNumber + "个事件提醒\">" + NoteStyle + "</a></div></li>";

            
            this.messageBox.InnerHtml = listStr;
        }

        /// <summary>
        /// 最新心情
        /// </summary>
        protected void MoodInfo()
        {
            string mInfo = string.Empty;
            string resultStr = string.Empty;
            IDataReader dr = us.GetMoodInfo(UserID);
            if (dr.Read())
            {
                mInfo = dr["Content"].ToString() + " <span class=\"time\">" + Public.getTimeEXSpan(DateTime.Parse(dr["PostTime"].ToString())) + "</span>";
            }
            if (mInfo != string.Empty)
            {
                resultStr = Public.CheckSma(mInfo) + " <a href=\"mood/?mid=" + dr["ID"].ToString() + "#re_" + dr["ID"].ToString() + "\">回复(" + dr["ReplayNum"].ToString() + ")</a>";
            }
            else
            {
                resultStr = "你可以更新状态，让朋友们知道你在做什么... ";
            }
            dr.Close();
            this.newmood_index.InnerHtml = "<span id=\"myNewMoodTopDiv\">" + resultStr + " <a href=\"javascript:void(0);\" onclick=\"changemood('" + UserID + "')\">编辑</a></span>";
        }

        /// <summary>
        /// 寻找同城好友，随机好友，推荐好友
        /// </summary>
        protected void ShowFindFriends()
        {
            UserBasicInfo mdlbase = new UserBasicInfo();
            mdlbase = usr.GetUserBasic(this.UserID);
            List<UserInfo>[] list =null;
            if (Public.GetXMLValue("Matchfriend") == "1")
            {
                list = uHome.FindFriend(UserID, mdlbase.Sex);
            }
            else
            {
                list = uHome.FindFriend(UserID, 10);
            }
            this.cityFriend.InnerHtml = TheSameCity(list[0], 1);
        }

        /// <summary>
        /// 同城好友
        /// </summary>
        /// <returns></returns>
        protected string TheSameCity(List<UserInfo> list,int f)
        {
            string listStr = string.Empty;
            string bnnl = string.Empty;
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            System.Text.StringBuilder sb1 = new System.Text.StringBuilder();
            if (f == 0)
            {
                bnnl = "style=\"margin-top:4px;\"";
            }
            if (list != null && list.Count > 0)
            {
                foreach (UserInfo us in list)
                {
                    string uname = us.Username;
                    string headpic = us.PortraitDir;
                    int num = 12;
                    if (f != 1)
                    {
                        num = 8;
                    }
                    listStr += "<li><div class=\"imageq\"><a href=\"../user/" + Public.URLWrite("", "r", us.UserID.ToString()) + "\"><img src=\"" + this.GetHeadImage(us.UserID) + "\" style=\"width:48px;height:48px;\" alt=\"" + uname + "\" /></a></div><div " + bnnl + "><a href=\"../user/" + Public.URLWrite("", "r", us.UserID.ToString()) + "\">" + Input.GetSubString(uname, num) + "</a></div></li>";
                }
            }
            else
            {
                if (f == 1)
                {
                    listStr = "<div style=\"height:30px;\"> 没有找出同城网友！或许是你没创建城市信息！<a href=\"base/network.aspx\">点这里更新</a></div>";
                }
            }
            return "<ul>" + listStr + "</ul>";
        }

        protected void LoadnewRegList()
        {
            UserBasicInfo mdlbase = new UserBasicInfo();
            mdlbase = usr.GetUserBasic(this.UserID);
            List<UserInfo>[] list = null;
            if (Public.GetXMLValue("Matchfriend") == "1")
            {
                list = uHome.FindNewReg(UserID, mdlbase.Sex,3);
            }
            else
            {
                list = uHome.FindNewReg(UserID, 10,3);
            }
            string listSTR = TheSameCity(list[0], 0);
            if (listSTR.Length>10)
            {
                this.nUserRegList.InnerHtml = listSTR;
            }
            else
            {
                this.newReg.Visible = false;
            }
        }

        protected string NewUserReg()
        {
            return string.Empty;
        }

        protected void BirthList()
        {
            string ListSTR = string.Empty;
            DataTable dt = uHome.FriendBirthday(this.UserID);
            string gDateSTR = string.Empty;
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DateTime nday = DateTime.Now;
                    string ShowDateSTR = dt.Rows[i]["date1"].ToString();
                    if (gDateSTR != dt.Rows[i]["date1"].ToString())
                    {
                        if (dt.Rows[i]["date1"].ToString() == nday.ToString("MM-dd"))
                        {
                            ShowDateSTR = "<span class=\"reshow bold\">今天</span>";
                        }
                        else if (dt.Rows[i]["date1"].ToString() == (nday.AddDays(-1)).ToString("MM-dd"))
                        {
                            ShowDateSTR = "昨天";
                        }
                        else if (dt.Rows[i]["date1"].ToString() == (nday.AddDays(1)).ToString("MM-dd"))
                        {
                            ShowDateSTR = "明天";
                        }
                    }
                    else
                    {
                        ShowDateSTR = "&nbsp;";
                    }
                    ListSTR += "<li><label>" + ShowDateSTR + "</label> <a href=\"../user/" + Public.URLWrite("", "r", dt.Rows[i]["UserID"].ToString()) + "\">" + dt.Rows[i]["uName"].ToString() + "</a><a href=\"" + rooDir + "/home/gift/?r=" + dt.Rows[i]["UserID"].ToString() + "&uName=" + Input.URLEncode(dt.Rows[i]["uName"].ToString()) + "\"><img src=\"../template/" + JuSNS.Config.UiConfig.SkinStyle + "/images/site/ico/s/gift.gif\" title=\"给Ta送礼物。\" align=\"absmiddle\" /></a><a href=\"javascript:void(0);\" onclick=\"mailto('" + dt.Rows[i]["UserID"].ToString() + "','生日快乐')\"><img src=\"../template/" + JuSNS.Config.UiConfig.SkinStyle + "/images/site/ico/s/mail.gif\" title=\"给他消息祝福Ta。\" align=\"absmiddle\" /></a><a href=\"javascript:void(0);\" onclick=\"javascript:Greet('" + dt.Rows[i]["UserID"].ToString() + "','" + dt.Rows[i]["uName"].ToString() + "','" + GetHeadImage(Convert.ToInt32(dt.Rows[i]["UserID"].ToString()), 2) + "');\"><img src=\"../template/" + JuSNS.Config.UiConfig.SkinStyle + "/images/site/ico/s/diag.gif\"  align=\"absmiddle\" title=\"给他打招呼祝福Ta。\" /></a></li>";
                    gDateSTR = dt.Rows[i]["date1"].ToString();
                }
            }
            else
            {
                this.birthdayIDVisiable.Visible = false;
            }
            dt.Clear(); dt.Dispose();
            this.BirthdayContent.InnerHtml = ListSTR;
        }

        /// <summary>
        /// 来访者绑定数据
        /// </summary>
        protected void LoadVisitorList()
        {
            int ReCount, PgCount;
            int PageIndex = 1;
            DataTable dt = UtilPage.GetPage("GetVisitList_In_aspx", PageIndex, 12, out ReCount, out PgCount, new SqlConditionInfo("@UserID", this.UserID, TypeCode.Int32));
            DataTable data = new DataTable();
            data.Columns.Add("VColum", typeof(string));
            bool isValue = false;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                isValue = true;
                StringBuilder sb = new StringBuilder();
                DataRow dr = data.NewRow();
                string reshowStr = string.Empty;
                sb.Append("<li>");
                string isOnline = string.Empty;
                if (dt.Rows[i]["isOnline"].ToString() != "0")
                {
                    isOnline = "<img src=\"" + rooDir + "/template/" + JuSNS.Config.UiConfig.SkinStyle + "/images/site/online.gif\" align=\"absmiddle\" title=\"在线\" />";
                }
                sb.Append("<div class=\"imageq\"><a  title=\"" + this.GetUserName(Convert.ToInt32(dt.Rows[i]["VisitorID"].ToString())) + "\" href=\"../user/" + Public.URLWrite("", "r", dt.Rows[i]["VisitorID"].ToString()) + "\"><img style=\"width:48px;height:48px;\" src=\"" + GetHeadImage(Convert.ToInt32(dt.Rows[i]["VisitorID"].ToString()), 1) + "\" /></a></div>\n");
                sb.Append("<div style=\"margin-top:4px;\">" + isOnline + "<a href=\"../user/" + Public.URLWrite("", "r", dt.Rows[i]["VisitorID"].ToString()) + "\" title=\"" + this.GetUserName(Convert.ToInt32(dt.Rows[i]["VisitorID"].ToString())) + "\">" + Input.GetSubString(this.GetUserName(Convert.ToInt32(dt.Rows[i]["VisitorID"].ToString())), 8) + "</a></div>\n");
                sb.Append("<div class=\"time\">" + Public.getTimeEXTSpan(DateTime.Parse(dt.Rows[i]["LastVisitTime"].ToString())) + "</div>\n");
                sb.Append("</li>\n");
                dr["VColum"] = sb.ToString();
                data.Rows.Add(dr);
            }
            if (!isValue)
            {
                this.showVisitorDivVisiable.Visible = false;
            }
            this.VisitInList.Visible = true;
            this.VisitInList.DataSource = data;
            this.VisitInList.DataBind();
        }

        /// <summary>
        /// 你可能认识的好友绑定数据
        /// </summary>
        protected void LoadSFriendList()
        {
            int ReCount, PgCount;
            int PageIndex = 1;
            DataTable dt = UtilPage.GetPage("GetSFriendList_aspx", PageIndex, 9, out ReCount, out PgCount, new SqlConditionInfo("@UserID", this.UserID, TypeCode.Int32));
            DataTable data = new DataTable();
            data.Columns.Add("SFColum", typeof(string));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                StringBuilder sb = new StringBuilder();
                DataRow dr = data.NewRow();
                string reshowStr = string.Empty;
                sb.Append("<li>");
                string isOnline = string.Empty;
                if (dt.Rows[i]["isOnline"].ToString() != "0")
                {
                    isOnline = "<img src=\"" + rooDir + "/template/" + JuSNS.Config.UiConfig.SkinStyle + "/images/site/online.gif\" align=\"absmiddle\" title=\"在线\" />";
                }
                sb.Append("<div class=\"imageq\"><a  title=\"" + this.GetUserName(Convert.ToInt32(dt.Rows[i]["UserID"].ToString())) + "\" href=\"../user/" + Public.URLWrite("", "r", dt.Rows[i]["UserID"].ToString()) + "\"><img style=\"width:48px;height:48px;\" src=\"" + GetHeadImage(Convert.ToInt32(dt.Rows[i]["UserID"].ToString()), 1) + "\" /></a></div>\n");
                sb.Append("<div style=\"margin-top:4px;\">" + isOnline + "<a href=\"../user/" + Public.URLWrite("", "r", dt.Rows[i]["UserID"].ToString()) + "\" title=\"" + this.GetUserName(Convert.ToInt32(dt.Rows[i]["UserID"].ToString())) + "\">" + Input.GetSubString(this.GetUserName(Convert.ToInt32(dt.Rows[i]["UserID"].ToString())), 16) + "</a></div>\n");
                sb.Append("</li>\n");
                dr["SFColum"] = sb.ToString();
                data.Rows.Add(dr);
            }
            this.SFriendList.Visible = true;
            this.SFriendList.DataSource = data;
            this.SFriendList.DataBind();
        }

        protected void Giftslist()
        {
            Gift gt = new Gift();
            int ReCount, PgCount;
            int PageIndex = 1;
            DataTable dt = gt.ShowGiftList("in", UserID, PageIndex, 10, out ReCount, out PgCount);
            DataTable data = new DataTable();
            data.Columns.Add("GColum", typeof(string));
            bool isValue = false;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                isValue = true;
                StringBuilder sb = new StringBuilder();
                DataRow dr = data.NewRow();
                string sendUid = dt.Rows[i]["SendUserID"].ToString();
                mdl = us.GetUserInfo(Convert.ToInt32(sendUid));
                sb.Append("<li>\n");
                sb.Append("<div><a href=\"gift/box.aspx?r=in\"><img src=\"" + rooDir + "/template/images/gift/" + dt.Rows[i]["pic"].ToString() + "\" title=\"" + dt.Rows[i]["gName"].ToString() + "\" /></a></div>\n");
                if (dt.Rows[i]["ptype"].ToString() == "2")
                {
                    sb.Append("<div>某人(匿名)赠送</div>\n");
                }
                else if (dt.Rows[i]["ptype"].ToString() == "1")
                {
                    sb.Append("<div>【<span class=\"reshow\">悄</span>】<a href=\"../user/" + Public.URLWrite("", "r", sendUid) + "\">" + mdl.Username + "</a>赠送</div>\n");
                }
                else
                {
                    sb.Append("<div><a href=\"../user/" + Public.URLWrite("", "r", sendUid) + "\">" + mdl.Username + "</a>赠送</div>\n");
                }
                sb.Append("</li>\n");
                dr["GColum"] = sb.ToString();
                data.Rows.Add(dr);
            }
            if (!isValue)
            {
                this.GiftVisiable.Visible = false;
            }
            this.glistc.Visible = true;
            this.glistc.DataSource = data;
            this.glistc.DataBind();
            dt.Clear(); data.Clear();
        }

        protected void PokeList()
        {
            string listStr = string.Empty;
            IDataReader dr = uHome.GetPoke(this.UserID);
            while (dr.Read())
            {
                string gPT = string.Empty;
                if (dr["gType"].ToString() == "-1")
                {
                    gPT = "_1";
                }
                else
                {
                    gPT = dr["gType"].ToString();
                }
                listStr += "<li id=\"Poke_li_" + dr["ID"].ToString() + "\"><span><img align=\"absmiddle\" src=\"../template/" + JuSNS.Config.UiConfig.SkinStyle + "/images/poke/pokeact_" + gPT + ".gif\"/></span> <a href=\"../user/" + Public.URLWrite("", "r", dr["UserID"].ToString()) + "\"><strong>" + this.GetUserName(Convert.ToInt32(dr["UserID"].ToString())) + "</strong></a> " + Public.GetAction(Convert.ToInt32(dr["gType"].ToString()), dr["pokefrom"].ToString(), dr["poketo"].ToString(), dr["isPub"].ToString()) + "<div class=\"padding30\"><a href=\"javascript:void(0);\" onclick=\"SendPoke('" + dr["UserID"].ToString() + "','" + dr["UserName"].ToString() + "','" + GetHeadImage(Convert.ToInt32(dr["UserID"].ToString()), 2) + "','" + dr["ID"].ToString() + "')\">回应</a><span class=\"pike\">|</span><a href=\"javascript:void(0);\" onclick=\"deletePoke('" + dr["ID"].ToString() + "','" + dr["ID"].ToString() + "')\">忽略</a></div></li>\r\n";
            }
            dr.Close();
            if (listStr != string.Empty)
            {
                this.showPokeDivVisiable.Visible = true;
                string glistStr = "<ul>" + listStr + "</ul>";
                this.showPokeDivVisiable.InnerHtml = glistStr.Replace("xx", "你");
            }
            else
            {
                this.showPokeDivVisiable.Visible = false;
                this.titlePoke.Visible = false;
            }
        }

        /// <summary>
        /// 读取动态
        /// </summary>
        protected string  DynList()
        {
            List<UserLogInfo> list = null;
            string a = Request.QueryString["a"];
            if (!string.IsNullOrEmpty(a))
            {
                list = uHome.DynList(UserID, a);
            }
            else
            {
                list = uHome.DynList(UserID);
            }
            string UserDynStr = string.Empty;
            string rStr = string.Empty;
            string nStr = string.Empty;
            bool isShow = false;
            HttpCookie SNSMessageCookie = Request.Cookies["SNSmessage_News"];
            if (SNSMessageCookie != null && !string.IsNullOrEmpty(SNSMessageCookie["message_News"]))
            {
                if (SNSMessageCookie["message_News"] == "1")
                {
                    isShow = true;
                }
            }
            if (!isShow)
            {
                News ns = new News(); DataTable dt = ns.GetSysNews(1, 1);
                if (dt != null && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        nStr += "<li class=\"ico-sys\" id=\"message_" + dt.Rows[i]["ID"].ToString() + "\">";
                        nStr += "<div class=\"dyntitle\">";
                        nStr += "<div class=\"dynlinetitle\">";
                        nStr += "<span class=\"bold reshow\"><a href=\"" + rooDir + "/news/n" + dt.Rows[i]["ID"].ToString() + ".aspx\" title=\"系统消息：" + dt.Rows[i]["title"].ToString() + "\">" + dt.Rows[i]["title"].ToString() + "</a></span>";
                        nStr += "</div><div class=\"dyntime\">" + DateTime.Parse(dt.Rows[i]["CreatTime"].ToString()).ToString("MM-dd") + " <a title=\"忽略\" href=\"javascript:void(0);\" onclick=\"NoShowMessage('message_News','message_" + dt.Rows[i]["ID"].ToString() + "');\"><img src=\"" + rooDir + "/template/" + Config.UiConfig.SkinStyle + "/images/settingicon.gif\" align=\"absmiddle\" /></a></div>";
                        nStr += "</div>";
                        string PicSTR = string.Empty;
                        if (!string.IsNullOrEmpty(dt.Rows[i]["Pic"].ToString()) && dt.Rows[i]["Pic"].ToString().Length>5)
                        {
                            PicSTR = "<div class=\"nl image\" style=\"margin-right:8px\"><a href=\"" + rooDir + "/news/n" + dt.Rows[i]["ID"].ToString() + ".aspx\" title=\"系统消息：" + dt.Rows[i]["title"].ToString() + "\"><img src=\"" + rooDir + "/" + dt.Rows[i]["Pic"].ToString() + "\" style=\"width:70px;\" align=\"absmiddle\" /></a></div>";
                        }
                        nStr += "<div class=\"dyncontent\">" + PicSTR + "<div class=\"nl\">" + JuSNS.Common.Input.GetSubString(JuSNS.Common.Input.LostHTML(dt.Rows[i]["Content"].ToString()), 300) + "</div></div>";
                        nStr += "</li>";
                    }
                }
                dt.Clear(); dt.Dispose();
            }
            if (list == null || list.Count < 1)
            {
                rStr = "<ul>" + nStr + "</ul>\r";
            }
            else
            {
                string gDateSTR = string.Empty;
                bool isZ = false;
                foreach (UserLogInfo info in list)
                {
                    string TmpUserLogStr = ParseUserLog.Parse(info,this.UserID);
                    if (TmpUserLogStr != string.Empty)
                    {
                        DateTime nday = DateTime.Now;
                        string ShowDateSTR = string.Empty;
                        if (gDateSTR != info.LogTime.ToString("MM-dd"))
                        {
                            if (info.LogTime.ToString("MM-dd") == nday.ToString("MM-dd")) {ShowDateSTR = "<li class=\"dyncli\"><span class=\"legend\">今天</span></li>";}
                            else if (info.LogTime.ToString("MM-dd") == (nday.AddDays(-1)).ToString("MM-dd")){ShowDateSTR = "<li class=\"dyncli\"><span class=\"legend\">昨天</span></li>";}
                            else if (info.LogTime.ToString("MM-dd") == (nday.AddDays(-2)).ToString("MM-dd")){ShowDateSTR = "<li class=\"dyncli\"><span class=\"legend\">前天</span></li>";}
                            else
                            {
                                if (!isZ)
                                {
                                    ShowDateSTR = "<li class=\"dyncli\"><span class=\"legend\">以前的动态</span></li>";
                                    isZ = true;
                                }
                            }
                        }
                        else
                        {
                            ShowDateSTR = string.Empty;
                        }
                        UserDynStr += ShowDateSTR;
                        UserDynStr += "<li class=\"ico-" + info.DynType + "\">" + TmpUserLogStr + "</li>\r";
                        if (UserDynStr.IndexOf("{UserHeadPic}") > -1)
                        {
                            UserDynStr = UserDynStr.Replace("{UserHeadPic}", "<a href=\"../user/" + Public.URLWrite("", "r", info.infoarr) + "\"><img src=\"" + GetHeadImage(Convert.ToInt32(info.infoarr), 1) + "\" style=\"width:48px;\" /></a>");
                        }
                        if (UserDynStr.IndexOf("{CloseDyn}") > -1)
                        {
                            UserDynStr = UserDynStr.Replace("{CloseDyn}", " <a href=\"javascript:void(0);\" onclick=\"closedyn('"+info.User.UserID+"',this)\"><img src=\"" + rooDir + "/template/" + JuSNS.Config.UiConfig.SkinStyle + "/images/closedyn.gif\" align=\"absmiddle\" title=\"屏蔽此用户的动态\" /></a>");
                        }
                        gDateSTR = info.LogTime.ToString("MM-dd");
                    }
                }
                rStr = "<ul>" + nStr + UserDynStr + "</ul>\r";
                rStr = rStr.Replace("{Email}", "");
                rStr = rStr.Replace("{sUserID}", UserID.ToString());
            }
            return rStr;
        }

        protected void albumPhotosList()
        {
            int ReCount, PgCount;
            int PageIndex = 1;
            DataTable dt = UtilPage.GetPage("photos_aspx", PageIndex, 6, out ReCount, out PgCount, new SqlConditionInfo("@UserID", this.UserID, TypeCode.Int32));
            DataTable data = new DataTable();
            data.Columns.Add("d", typeof(string));
            bool isValue = false;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                isValue = true;
                StringBuilder sb = new StringBuilder();
                DataRow dr = data.NewRow();
                sb.Append("<li>");
                sb.Append("<div><a href=\"album/photoview.aspx?r[0]=" + dt.Rows[i]["PhotoID"].ToString() + "\" title=\"" + Input.GetSubString(dt.Rows[i]["Description"].ToString(),50) + "\"><img src=\"" + this.GetSmallPic(dt.Rows[i]["FilePath"].ToString(), 0) + "\" /></a></div>");
                sb.Append("<div><a href=\"../../user/" + Public.URLWrite("", "r", dt.Rows[i]["UploadUser"].ToString()) + "\">" + dt.Rows[i]["UserName"].ToString() + "</a></div>");
                sb.Append("</li>");
                dr["d"] = sb.ToString();
                data.Rows.Add(dr);
            }
            this.PhotosList.Visible = true;
            this.PhotosList.DataSource = data;
            this.PhotosList.DataBind();
            if (isValue)
            {
                this.showAlbumDivVisiable.Visible = true;
            }
            else
            {
                this.showAlbumDivVisiable.Visible = false;
            }
        }

    }
}
