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;

namespace JuSNS.Web.user
{
    public partial class index : JuSNS.UI.Page.BasePage
    {
        public int uID = 0;
        public string r = string.Empty;
        public string userName = string.Empty;
        public string Photo = string.Empty;
        public string Photo1 = string.Empty;
        public string Network = string.Empty;//网络
        public string Province = string.Empty;//所在省
        public int Click = 0;//点击次数
        public string integral = "0";//积分
        public string inteyb = "0";//元宝
        public int IsFriend = 0;//是否是好朋友
        public int FriendNum = 0;//好朋友个数 
        public int BlogNum = 0;//心情日记数量ShareNum
        public int AlbumListCount = 0;//相册数量
        public int ShareCount = 0;//分享数量
        public int MovieCount = 0;//电影数量
        public int GroupCount = 0;//群组数量
        public int BlogCount = 0;//日志数量
        public string LastMini = string.Empty;//最新的心情日志

        Friend frd = new Friend();
        User us = new User();
        JuSNS.Home.Space sp = new JuSNS.Home.Space();
        UserInfo mdl = new JuSNS.Model.UserInfo();
        HomeIndex uHome = new HomeIndex();
        protected void Page_Load(object sender, EventArgs e)
        {
            r = Request.QueryString["r"];
            if (JuSNS.Common.Input.IsInteger(r) && r!="0")
            {
                uID = Convert.ToInt32(r);
            }
            else
            {
                uID = this.GetUserID();
            }
            if (uID == 0)
            {
                PageError("需要登录！", rooDir + "/home", true);
            }

            if (!us.CheckUser(uID))
            {
                PageError("访问发生了错误", rooDir + "/home");
            }
            if (uID != this.GetUserID())
            {
                string isHeadPic = this.GetHeadPath(this.GetUserID());
                if (string.IsNullOrEmpty(isHeadPic))
                {
                    string errorStr = "您需要上传了头像后，才能正常浏览 <b>朋友空间</b>！";
                    if (JuSNS.Config.UiConfig.isUpHeadPic == "1" && !JuSNS.Common.Public.GetHeadLimite(0))
                    {
                        Response.Redirect(rooDir + "/home/space/userheadphoto.aspx?h=1&Err=" + JuSNS.Common.Input.URLEncode(errorStr) + "");
                    }
                }
            }

            IsFriends();//判断是否是好友

            if (this.GetUserID() != uID)
            {
                if (this.GetUserID() > 0)
                {
                    sp.InserVisit(uID, this.GetUserID()); //记录访问者信息
                }
                #region 进入别人的空间隐私判断
                JuSNS.Model.PrivacyInfo info = us.GetPrivacy(uID);

                if (!CheckSpace((int)info.PrivacySpace))//空间隐私
                {
                    Response.Redirect(rooDir + "/user/Search.aspx?a=uid&r=" + uID);
                }
                #endregion
            }
            GetUserInfo();
            sp.InsertClick(uID, (Click + 1));//记录空间被查看次数

            #region 读取模板内容替换标签
            string TemplateContent = string.Empty;
            string userXML = rooDir + "/user/config/xml/" + uID + ".xml";
            string GetTemplatePath = JuSNS.Common.Public.getXML(userXML, "stylename", "default", 1);
            if (!string.IsNullOrEmpty(GetTemplatePath))
            {
                TemplateContent = GetTemplet("" + rooDir + "/template/space/" + GetTemplatePath + "/index.html");
            }
            else
            {
                GetTemplatePath = "default";
                TemplateContent = GetTemplet("" + rooDir + "/template/space/default/index.html");
            }
            Response.Write(ReplaceLabel(TemplateContent, GetTemplatePath));
            Response.End();
         
            #endregion
        }

        /// <summary>
        /// 得到模板路径
        /// </summary>
        /// <param name="tPath"></param>
        /// <returns></returns>
        protected string GetTemplet(string tPath)
        {
            return JuSNS.Common.Public.GetTempleContent(tPath);
        }

        /// <summary>
        /// 替换标签
        /// </summary>
        /// <param name="TemplateContent">模板内容</param>
        /// <param name="uid">用户编号</param>
        /// <returns></returns>
        protected string ReplaceLabel(string TemplateContent, string getTemplatePath)
        {
            string ContentStr = TemplateContent;
            if (TemplateContent.IndexOf("{UserItem}") > -1)
            {
                ContentStr = ContentStr.Replace("{UserItem}", GetItem());
            }
            if (TemplateContent.IndexOf("{ThisUserID}") > -1)
            {
                ContentStr = ContentStr.Replace("{ThisUserID}", GetUserID().ToString());
            }
            if (TemplateContent.IndexOf("{Bind}") > -1)
            {
                ContentStr = ContentStr.Replace("{Bind}", Bind());
            }

            if (TemplateContent.IndexOf("{rootDir}") > -1)
            {
                ContentStr = ContentStr.Replace("{rootDir}", this.rooDir);
            }
            if (TemplateContent.IndexOf("{ShortMenu}") > -1)
            {
                ContentStr = ContentStr.Replace("{ShortMenu}", this.GetHtmlShort());
            }
            if (TemplateContent.IndexOf("{Head}") > -1)
            {
                ContentStr = ContentStr.Replace("{Head}", this.GetHtmlHead());
            }
            if (TemplateContent.IndexOf("{Foot}") > -1)
            {
                ContentStr = ContentStr.Replace("{Foot}", this.GetHtmlFoot());
            }
            if (TemplateContent.IndexOf("{sysDefaultCSS}") > -1)
            {
                ContentStr = ContentStr.Replace("{sysDefaultCSS}", JuSNS.Config.UiConfig.SkinStyle);
            }

            if (TemplateContent.IndexOf("{SpaceCSSSKin}") > -1)
            {
                ContentStr = ContentStr.Replace("{SpaceCSSSKin}", getTemplatePath);
            }

            if (TemplateContent.IndexOf("{UserID}") > -1)
            {//用户UserID
                ContentStr = ContentStr.Replace("{UserID}", uID.ToString());
            }

            if (TemplateContent.IndexOf("{CSSPath}") > -1)
            {//CSS目录
                string TMPCssPath = rooDir+ "/template/space/" + getTemplatePath + "/style.css";
                ContentStr = ContentStr.Replace("{CSSPath}", TMPCssPath);
            }

            if (TemplateContent.IndexOf("{defineBGPIC}") > -1)
            {//CSS自定义背景图片
                ContentStr = ContentStr.Replace("{defineBGPIC}", uID.ToString());
            }

            if (TemplateContent.IndexOf("{SpaceURL}") > -1)
            {//空间实际网络地址

                ContentStr = ContentStr.Replace("{SpaceURL}", "http://" + JuSNS.Config.UiConfig.URL + rooDir + "/user/" + JuSNS.Common.Public.URLWrite("", "r", uID.ToString()));
            }

            if (TemplateContent.IndexOf("{HeadPic}") > -1)
            {//个人图片(大)
                ContentStr = ContentStr.Replace("{HeadPic}", Photo);
            }
            if (TemplateContent.IndexOf("{HeadPicSmall}") > -1)
            {//个人图片(小)
                ContentStr = ContentStr.Replace("{HeadPicSmall}", Photo1);
            }

            if (TemplateContent.IndexOf("{UserName}") > -1)
            {//个人姓名
                ContentStr = ContentStr.Replace("{UserName}", userName);
            }

            if (TemplateContent.IndexOf("{Network}") > -1)
            {//网络
                ContentStr = ContentStr.Replace("{Network}", Network);
            }

            if (TemplateContent.IndexOf("{Info}") > -1 || TemplateContent.IndexOf("{InfoDisplay}") > -1)
            {// 基本信息
                string uInfos = GetUserInfo();
                if (!string.IsNullOrEmpty(uInfos))
                {
                    ContentStr = ContentStr.Replace("{InfoDisplay}", "block");
                    ContentStr = ContentStr.Replace("{Info}", uInfos);
                }
                else
                {
                    ContentStr = ContentStr.Replace("{InfoDisplay}", "none");
                    ContentStr = ContentStr.Replace("{Info}", uInfos);
                }
            }

            if (TemplateContent.IndexOf("{DongZhuo}") > -1)
            {//动作
                ContentStr = ContentStr.Replace("{DongZhuo}", GetDZ());
            }

            if (TemplateContent.IndexOf("{FriendCount}") > -1 || TemplateContent.IndexOf("{FriendList}") > -1)
            {//好友列表/好友数量
                string FriendList = GetFriendInfo();
                if (FriendList == string.Empty)
                {
                    if (TemplateContent.IndexOf("{FriendDisplay}") > -1) { ContentStr = ContentStr.Replace("{FriendDisplay}", "none"); }
                    if (TemplateContent.IndexOf("{FriendCount}") > -1) { ContentStr = ContentStr.Replace("{FriendCount}", "0"); }
                    if (TemplateContent.IndexOf("{FriendList}") > -1) { ContentStr = ContentStr.Replace("{FriendList}", ""); }
                }
                else
                {
                    if (TemplateContent.IndexOf("{FriendDisplay}") > -1) { ContentStr = ContentStr.Replace("{FriendDisplay}", ""); }
                    if (TemplateContent.IndexOf("{FriendCount}") > -1) { ContentStr = ContentStr.Replace("{FriendCount}", FriendNum.ToString()); }
                    if (TemplateContent.IndexOf("{FriendList}") > -1) { ContentStr = ContentStr.Replace("{FriendList}", FriendList); }
                }
            }

            if (TemplateContent.IndexOf("{MiniList}") > -1 || TemplateContent.IndexOf("{MinCount}") > -1 || TemplateContent.IndexOf("{LastMini}") > -1 || TemplateContent.IndexOf("{moodDisplay}") > -1)
            {//心情日记列表/数量
                string MiniList = GetBlogInfo();
                ////最新心情日记
                if (MiniList=="1")
                {
                    if (TemplateContent.IndexOf("{moodDisplay}") > -1) { ContentStr = ContentStr.Replace("{moodDisplay}", "none"); }
                    if (TemplateContent.IndexOf("{LastMini}") > -1) { ContentStr = ContentStr.Replace("{LastMini}", ""); }
                    if (TemplateContent.IndexOf("{MinCount}") > -1) { ContentStr = ContentStr.Replace("{MinCount}", ""); }
                    if (TemplateContent.IndexOf("{MiniList}") > -1) { ContentStr = ContentStr.Replace("{MiniList}", ""); }
                }
                else
                {
                    if (TemplateContent.IndexOf("{moodDisplay}") > -1) { ContentStr = ContentStr.Replace("{moodDisplay}", ""); }
                    if (TemplateContent.IndexOf("{LastMini}") > -1) { ContentStr = ContentStr.Replace("{LastMini}", LastMini); }
                    if (TemplateContent.IndexOf("{MinCount}") > -1) { ContentStr = ContentStr.Replace("{MinCount}", BlogNum.ToString()); }
                    if (TemplateContent.IndexOf("{MiniList}") > -1) { ContentStr = ContentStr.Replace("{MiniList}", MiniList); }
                }
            }

            if (TemplateContent.IndexOf("{ShareList}") > -1 || TemplateContent.IndexOf("{ShareCount}") > -1)
            {//分享列表/数量
                string ShareList = GetShareInfo();
                if (ShareList == string.Empty)
                {
                    if (TemplateContent.IndexOf("{ShareDisplay}") > -1){ContentStr = ContentStr.Replace("{ShareDisplay}","none");}
                    if (TemplateContent.IndexOf("{ShareCount}") > -1){ContentStr = ContentStr.Replace("{ShareCount}", "0"); }
                    if (TemplateContent.IndexOf("{ShareList}") > -1){ContentStr = ContentStr.Replace("{ShareList}", "");}
                }
                else
                {
                    if (TemplateContent.IndexOf("{ShareDisplay}") > -1) {ContentStr = ContentStr.Replace("{ShareDisplay}", "");}
                    if (TemplateContent.IndexOf("{ShareCount}") > -1){ContentStr = ContentStr.Replace("{ShareCount}", ShareCount.ToString());}
                    if (TemplateContent.IndexOf("{ShareList}") > -1){ContentStr = ContentStr.Replace("{ShareList}", ShareList);}
                }
            }

            if (TemplateContent.IndexOf("{MovieList}") > -1 || TemplateContent.IndexOf("{MovieCount}") > -1)
            {//电影列表/数量
                string MovieList = GetMovieInfo();
                if (MovieList == string.Empty)
                {
                    if (TemplateContent.IndexOf("{MovieDisplay}") > -1){ContentStr = ContentStr.Replace("{MovieDisplay}", "none");}
                    if (TemplateContent.IndexOf("{MovieCount}") > -1){ContentStr = ContentStr.Replace("{MovieCount}", "0");}
                    if (TemplateContent.IndexOf("{MovieList}") > -1){ ContentStr = ContentStr.Replace("{MovieList}", "");}
                }
                else
                {
                    if (TemplateContent.IndexOf("{MovieDisplay}") > -1){ContentStr = ContentStr.Replace("{MovieDisplay}", "");}
                    if (TemplateContent.IndexOf("{MovieCount}") > -1){ContentStr = ContentStr.Replace("{MovieCount}", MovieCount.ToString());}
                    if (TemplateContent.IndexOf("{MovieList}") > -1){ContentStr = ContentStr.Replace("{MovieList}", MovieList);}
                }
            }

            if (TemplateContent.IndexOf("{GroupList}") > -1 || TemplateContent.IndexOf("{GroupCount}") > -1)
            {//群组列表/群组数量
                string GroupList = GetGroupInfo();
                if (GroupList != string.Empty)
                {
                    if (TemplateContent.IndexOf("{GroupDisplay}") > -1) { ContentStr = ContentStr.Replace("{GroupDisplay}", ""); }
                    if (TemplateContent.IndexOf("{GroupCount}") > -1) { ContentStr = ContentStr.Replace("{GroupCount}", GroupCount.ToString()); }
                    if (TemplateContent.IndexOf("{GroupList}") > -1) { ContentStr = ContentStr.Replace("{GroupList}", GroupList); }
                }
                else
                {
                    if (TemplateContent.IndexOf("{GroupDisplay}") > -1) { ContentStr = ContentStr.Replace("{GroupDisplay}", "none"); }
                    if (TemplateContent.IndexOf("{GroupCount}") > -1) { ContentStr = ContentStr.Replace("{GroupCount}", "0"); }
                    if (TemplateContent.IndexOf("{GroupList}") > -1) { ContentStr = ContentStr.Replace("{GroupList}", ""); }
                }
            }

            if (TemplateContent.IndexOf("{PreNews}") > -1)
            {
                //个人动态
                ContentStr = ContentStr.Replace("{PreNews}", DynList(Convert.ToInt32(JuSNS.Common.Public.GetXMLValue("HomedynNumber"))));
            }
            if (TemplateContent.IndexOf("{PreNewsCount}") > -1)
            {//个人动态数目
                ContentStr = ContentStr.Replace("{PreNewsCount}", GetLeaveNum(false));
            }

            if (TemplateContent.IndexOf("{AlbumList}") > -1 || TemplateContent.IndexOf("{AlbumListCount}") > -1)
            {//相册列表/相册数量
                string AlbumList = GetAlbumInfo();
                if (AlbumList == string.Empty)
                {
                    if (TemplateContent.IndexOf("{AlbumDisplay}") > -1) { ContentStr = ContentStr.Replace("{AlbumDisplay}", "none"); }
                    if (TemplateContent.IndexOf("{AlbumListCount}") > -1) { ContentStr = ContentStr.Replace("{AlbumListCount}", AlbumListCount.ToString()); }
                    if (TemplateContent.IndexOf("{AlbumList}") > -1) { ContentStr = ContentStr.Replace("{AlbumList}", AlbumList); }
                }
                else
                {
                    if (TemplateContent.IndexOf("{AlbumDisplay}") > -1) { ContentStr = ContentStr.Replace("{AlbumDisplay}", ""); }
                    if (TemplateContent.IndexOf("{AlbumListCount}") > -1) { ContentStr = ContentStr.Replace("{AlbumListCount}", AlbumListCount.ToString()); }
                    if (TemplateContent.IndexOf("{AlbumList}") > -1) { ContentStr = ContentStr.Replace("{AlbumList}", AlbumList); }
                }
            }

            if (TemplateContent.IndexOf("{BlogList}") > -1 || TemplateContent.IndexOf("{BlogCount}") > -1)
            {//日志列表/日志数量
                string BlogList = GetUserBlogInfo();
                if (BlogList == string.Empty)
                {
                    if (TemplateContent.IndexOf("{BlogDisplay}") > -1) { ContentStr = ContentStr.Replace("{BlogDisplay}", "none"); }
                    if (TemplateContent.IndexOf("{BlogCount}") > -1) { ContentStr = ContentStr.Replace("{BlogCount}", "0"); }
                    if (TemplateContent.IndexOf("{BlogList}") > -1) { ContentStr = ContentStr.Replace("{BlogList}", ""); }
                }
                else
                {
                    if (TemplateContent.IndexOf("{BlogDisplay}") > -1) { ContentStr = ContentStr.Replace("{BlogDisplay}", ""); }
                    if (TemplateContent.IndexOf("{BlogCount}") > -1) { ContentStr = ContentStr.Replace("{BlogCount}", BlogCount.ToString()); }
                    if (TemplateContent.IndexOf("{BlogList}") > -1) { ContentStr = ContentStr.Replace("{BlogList}", BlogList); }
                }
            }

            if (TemplateContent.IndexOf("{VoteList}") > -1 || TemplateContent.IndexOf("{VoteCount}") > -1)
            {//投票列表/投票数量
                string VoteList = GetUserVoteInfo();
                if (VoteList == string.Empty)
                {
                    if (TemplateContent.IndexOf("{VoteDisplay}") > -1) { ContentStr = ContentStr.Replace("{VoteDisplay}", "none"); }
                    if (TemplateContent.IndexOf("{VoteList}") > -1) { ContentStr = ContentStr.Replace("{VoteList}", ""); }
                }
                else
                {
                    if (TemplateContent.IndexOf("{VoteDisplay}") > -1) { ContentStr = ContentStr.Replace("{VoteDisplay}", ""); }
                    if (TemplateContent.IndexOf("{VoteList}") > -1) { ContentStr = ContentStr.Replace("{VoteList}", VoteList); }
                }
            }

            if (TemplateContent.IndexOf("{UserInfo}") > -1)
            {//个人资料信息
                string job = GetCareerInfo();//工作信息
                string shool = GetShoolInfo();//学校信息
                string Lx = GetLXInfo();//联系信息和个人爱好
                string userContent = job + shool + Lx;
                if (userContent != string.Empty)
                {
                    ContentStr = ContentStr.Replace("{LianDisplay}", "");
                    ContentStr = ContentStr.Replace("{UserInfo}", userContent);
                }
                else
                {
                    ContentStr = ContentStr.Replace("{LianDisplay}", "none");
                    ContentStr = ContentStr.Replace("{UserInfo}", "");
                }
            }

            if (TemplateContent.IndexOf("{GuestBook}") > -1 || TemplateContent.IndexOf("{GuestDisplay}") > -1)
            {//留言板
                string gbookContent = GetMsgInfo();
                ContentStr = ContentStr.Replace("{GuestDisplay}", "");
                ContentStr = ContentStr.Replace("{GuestBook}", gbookContent);
            }

            if (this.GetUserID() == 0)
            {
                ContentStr = ContentStr.Replace("{BookFormDisplay}", "none");
            }
            else
            {
                ContentStr = ContentStr.Replace("{BookFormDisplay}", "block");
            }

            if (TemplateContent.IndexOf("{GuestCount}") > -1)
            {//留言板
                ContentStr = ContentStr.Replace("{GuestCount}", GetLeaveNum(true));
            }

            if (TemplateContent.IndexOf("{DeleteFriend}") > -1)
            {//删除好友
                ContentStr = ContentStr.Replace("{DeleteFriend}", DeShareFriend(true));
            }

            if (TemplateContent.IndexOf("{ShareFriend}") > -1)
            {//分享好友
                ContentStr = ContentStr.Replace("{ShareFriend}", DeShareFriend(false));
            }

            if (TemplateContent.IndexOf("{Click}") > -1)
            {//点击次数
                ContentStr = ContentStr.Replace("{Click}", Click.ToString());
            }

            if (TemplateContent.IndexOf("{integral}") > -1)
            {//积分
                ContentStr = ContentStr.Replace("{integral}", integral);
            }

            if (TemplateContent.IndexOf("{LoginUserID}") > -1)
            {//登录者会员编号
                ContentStr = ContentStr.Replace("{LoginUserID}", Request.QueryString["r"]);
            }
            return ContentStr;
        }

        protected string Bind()
        {
            string bstr = string.Empty;
            UserBasicInfo ub = us.GetUserBasic(this.GetUserID());
            if (!string.IsNullOrEmpty(ub.MSN))
            {
                bstr += "<a href=\"" + rooDir + "/home/base/msn.aspx\" title=\"捆绑了MSN\"><img src=\"/template/images/msn.gif\" align=\"absmiddle\" /></a>&nbsp;";
            }
            if (!string.IsNullOrEmpty(ub.GTalk))
            {
                bstr += "<a href=\"" + rooDir + "/home/base/msn.aspx\" title=\"捆绑了GTalk\"><img src=\"/template/images/gtalk.gif\" align=\"absmiddle\" /></a>&nbsp;";
            }

            if (!string.IsNullOrEmpty(ub.Mobile))
            {
                bstr += "<a href=\"" + rooDir + "/home/base/mobile.aspx\" title=\"捆绑了手机\"><img src=\"/template/images/mobile.gif\" align=\"absmiddle\" /></a>";
            }
            return bstr;
        }

        #region  隐私判断
        public bool CheckSpace(int Privacy)
        {
            bool Privacyflag = false;
            switch (Privacy)
            {
                case 0://全站用户可见
                    Privacyflag = true;
                    break;
                case 1://相同网络用户及好友可见
                    if (IsFriend == 2 || sp.CheckSameNet(this.GetUserID(), uID))
                    {
                        Privacyflag = true;
                    }
                    break;
                case 2://仅好友可见
                    if (IsFriend == 2 || uID == this.GetUserID())
                    {
                        Privacyflag = true;
                    }
                    break;
                case 3://仅自己可见
                    if (uID == this.GetUserID())
                    {
                        Privacyflag = true;
                    }
                    break;
            }
            return Privacyflag;
        }
        #endregion

        #region 看别人是不是自己的好友
        protected void IsFriends()
        {
            if (this.GetUserID() != uID)
            {
                JuSNS.Home.Friend frd = new JuSNS.Home.Friend();
                IsFriend = frd.GetRelation(this.GetUserID(), uID);
            }
        }
        #endregion


        #region 读取会员基本信息
        public string GetUserInfo()
        {
            string strInfo = string.Empty;
            DataTable dt = sp.getUserInfo(uID, 0);
            if (dt != null && dt.Rows.Count > 0)
            {
                userName = dt.Rows[0]["UserName"].ToString();
                Photo = this.GetHeadImage(uID,3);
                Photo1 = this.GetHeadImage(uID,2);
                if (JuSNS.Common.Input.IsInteger(dt.Rows[0]["Click"].ToString()))
                {
                    Click = Convert.ToInt32(dt.Rows[0]["Click"].ToString());
                }

                if (JuSNS.Common.Input.IsInteger(dt.Rows[0]["integral"].ToString()))
                {
                    integral = dt.Rows[0]["integral"].ToString();
                }
                if (JuSNS.Common.Input.IsInteger(dt.Rows[0]["inteyb"].ToString()))
                {
                    inteyb = dt.Rows[0]["inteyb"].ToString();
                }
                dt.Columns.Add("Info", typeof(string));
                if (dt.Rows[0]["Province"].ToString() != "")
                {
                    Network = "<a href=\"" + rooDir + "/network/?r=" + dt.Rows[0]["Pro"].ToString() + "\">" + dt.Rows[0]["Province"].ToString() + "</a>";
                    Province = dt.Rows[0]["Province"].ToString();
                }
                if (dt.Rows[0]["Sex"].ToString() != "")
                {
                    strInfo += "<div class=\"baseuserinfo\"><label class=\"f-info\">性别：</label>" + dt.Rows[0]["Sex"].ToString() + "</div>";
                }
                if (dt.Rows[0]["Constellation"].ToString() != "")
                {
                    strInfo += "<div class=\"baseuserinfo\"><label class=\"f-info\">星座：</label>" + dt.Rows[0]["Constellation"].ToString() + "</div>";
                }
                string birthStr = string.Empty;
                if (!string.IsNullOrEmpty(dt.Rows[0]["Birthday"].ToString()) && JuSNS.Common.Input.IsDate(dt.Rows[0]["Birthday"].ToString()))
                {
                    DateTime gBirthDay = DateTime.Parse(dt.Rows[0]["Birthday"].ToString());
                    switch (dt.Rows[0]["BirthidayDisplay"].ToString())
                    {
                        case "0":
                            birthStr = gBirthDay.Year + "年" + gBirthDay.Month + "月"+gBirthDay.Day+"日";
                            break;
                        case "1":
                            birthStr = gBirthDay.Month + "月" + gBirthDay.Day + "日";
                            break;
                        case "2":
                            birthStr = gBirthDay.Year + "年";
                            break;
                    }
                }
                if (birthStr != string.Empty)
                {
                    strInfo += "<div class=\"baseuserinfo\"><label class=\"f-info\">生日：</label>" + birthStr + "</div>";
                }

                if (dt.Rows[0]["Province"].ToString() != "")
                {
                    strInfo += "<div class=\"baseuserinfo\"><label class=\"f-info\">所在地：</label>" + dt.Rows[0]["Province"].ToString() + " " + dt.Rows[0]["City"].ToString() + "</div>";
                }
                if (dt.Rows[0]["HomeProv"].ToString() != "")
                {
                    strInfo += "<div class=\"baseuserinfo\"><label class=\"f-info\">家乡：</label>" + dt.Rows[0]["HomeProv"].ToString() + " " + dt.Rows[0]["HomeCity"].ToString() + "</div>";
                }
                if (dt.Rows[0]["VocName"].ToString() != "")
                {
                    strInfo += "<div class=\"baseuserinfo\"><label class=\"f-info\">行业：</label>" + dt.Rows[0]["VocName"].ToString() + "</div>";
                }
                if (dt.Rows[0]["integral"].ToString() != "")
                {
                    strInfo += "<div class=\"baseuserinfo\"><label class=\"f-info\">积分：</label>" + dt.Rows[0]["integral"].ToString() + "</div>";
                }
                if (dt.Rows[0]["inteyb"].ToString() != "")
                {
                    strInfo += "<div class=\"baseuserinfo\"><label class=\"f-info\">"+JuSNS.Config.UiConfig.gName+"：</label>" + dt.Rows[0]["inteyb"].ToString() + "</div>";
                }
            }
            dt.Clear(); dt.Dispose();
            if (uID != this.GetUserID())
            {
                JuSNS.Model.PrivacyInfo info = us.GetPrivacy(uID);
                if (!CheckSpace((int)info.PrivacyFavourite))//好友隐私
                {
                    return string.Empty;
                }
            }
            return strInfo;
        }
        #endregion

        #region 动作
        public string GetDZ()
        {
            string strDZ = string.Empty;
            string quanR = string.Empty;
            if (uID != this.GetUserID())
            {
                JuSNS.Model.PrivacyInfo info = us.GetPrivacy(uID);
                if (CheckSpace((int)info.PrivacyLasso))//照片圈圈隐私
                {
                    strDZ = this.quanR();
                    strDZ += "<li><a href=\"" + rooDir + "/home/mail/to.aspx?userid=" + uID + "\">发送私信</a></li>";
                    strDZ += "<li><a href=\"javascript:\" onclick=\"javascript:Greet('" + uID + "','" + userName + "','" + Photo1 + "');\">打招呼</a></li>";
                    string userXML = "~/user/config/xml/" + uID.ToString() + ".xml";
                    if (JuSNS.Common.Public.getXML(userXML, "isOpenGift", "0", 1) == "1")
                    {
                        strDZ += "<li><a href=\"" + rooDir + "/home/gift?r=" + uID.ToString() + "&uName=" + JuSNS.Common.Input.URLEncode(userName) + "\">给他送礼物</a></li>";
                    }
                    if (IsFriend == 0)
                    {
                        strDZ += "<li><a href=\"javascript:;\" onclick=\"javascript:AddFrd(" + uID + ",'" + userName + "','" + Photo1 + "','addok(" + uID + ")');\" id=\"add_as_friend\">加为好友</a></li>";
                    }
                    else if (IsFriend == 3)
                    {
                        strDZ += "<li>等待好友验证</li>";
                    }
                    else if (IsFriend == 4)
                    {
                        strDZ += "<li><a href=\"" + rooDir + "/home/friend/req.aspx\">处理好友请求</a></li>";
                    }
                }
                else
                {
                    strDZ = "该好友已设置隐私！";
                }
            }
            else
            {
                strDZ = this.quanR() + "<li><a href=\"" + rooDir + "/home/Space/edit.aspx\">编辑我的资料</a></li>";
            }
            return strDZ;
        }
        #endregion


        #region  圈的照片数
        public string quanR()
        {
            //读取被我圈的照片数
            DataTable nu = sp.getUserInfo(uID, 23);
            string Number = "0";
            if (nu != null)
            {
                if (nu.Rows.Count > 0)
                {
                    Number = nu.Rows[0]["number"].ToString();
                }
            }

            if (uID == this.GetUserID())
            {
                Number = "<li><a href=\""+rooDir+"/home/album/Quan.aspx?r=" + uID + "\">我被圈的照片(" + Number + ")</a></li>";
            }
            else
            {
                Number = "<li><a href=\"" + rooDir + "/home/album/Quan.aspx?r=" + uID + "\">" + userName + "被圈的照片" + "(" + Number + ")</a></li>";
            }
            return Number;
        }
        #endregion


        #region 读取会员的好友
        public string GetFriendInfo()
        {
            if (uID != this.GetUserID())
            {
                JuSNS.Model.PrivacyInfo info = us.GetPrivacy(uID);
                if (!CheckSpace((int)info.PrivacyFriends))//好友隐私
                {
                    return string.Empty;
                }
            }

            string str = string.Empty;
            DataTable dt = sp.getUserInfo(uID, 1);
            if (dt != null && dt.Rows.Count > 0)
            {
                FriendNum = dt.Rows.Count;
                int n = dt.Rows.Count;
                if (n > 24)
                {
                    n = 24;
                }

                for (int i = 0; i < n; i++)
                {
                    dt.Rows[i]["FilePath"] = this.GetHeadImage(int.Parse(dt.Rows[i]["UserID"].ToString()));
                    str += "<li><div class=\"imageq\"><a href=\"" + rooDir + "/user/" + JuSNS.Common.Public.URLWrite("", "r", dt.Rows[i]["UserID"].ToString()) + "\"><img src=\"" + dt.Rows[i]["FilePath"].ToString() + "\" style=\"width:48px;height:48px;\" alt=\"" + dt.Rows[i]["UserName"].ToString() + "\"/></div><div style=\"margin-top:5px;\">" + dt.Rows[i]["UserName"].ToString() + "</div></a></li>";
                }
            }
            dt.Clear(); dt.Dispose();
            return str;
        }
        #endregion

        #region 读取会员心情日记
        public string GetBlogInfo()
        {
            if (uID != this.GetUserID())
            {
                JuSNS.Model.PrivacyInfo info = us.GetPrivacy(uID);
                if (!CheckSpace((int)info.PrivacyMiniBlog))//迷你隐私
                {
                    return "1";
                }
            }
            string strBlog = "还没有心情日志";
            DataTable dt = sp.getUserInfo(uID, 2);
            if (dt != null && dt.Rows.Count > 0)
            {
                BlogNum = dt.Rows.Count;
                dt.Columns.Add("Time", typeof(string));
                int n = dt.Rows.Count;
                strBlog = string.Empty;
                if (n > 4){n = 4;}
                string imgStr = string.Empty;
                string textStr = string.Empty;
                for (int i = 0; i < n; i++)
                {
                    string GetContent = JuSNS.Common.Public.CheckSma(dt.Rows[i]["Content"].ToString());
                    if (i == 0)
                    {
                        LastMini = GetContent + " <a id=\"addcomment\"  href=\"" + rooDir + "/home/mood/?mid=" + dt.Rows[i]["ID"].ToString() + "#re_" + dt.Rows[i]["ID"].ToString() + "\">回复(" + dt.Rows[i]["MCount"].ToString() + ")</a>"; //最新的第一条心情日记
                        continue;
                    }
                    dt.Rows[i]["Time"] = JuSNS.Common.Public.getTimeSpan(Convert.ToDateTime(dt.Rows[i]["PostTime"].ToString()));
                    strBlog += "<li>" + GetContent + " <a id=\"addcomment\"  href=\"" + rooDir + "/home/mood/?mid=" + dt.Rows[i]["ID"].ToString() + "#re_" + dt.Rows[i]["ID"].ToString() + "\">回复(" + dt.Rows[i]["MCount"].ToString() + ")</a>  <span class=\"time\">" + dt.Rows[i]["Time"].ToString() + "</span></li>";
                }
            }
            dt.Clear(); dt.Dispose();
            return strBlog;
        }
        #endregion

        #region 读取留言条数和动态条数
        public string GetLeaveNum(bool fg)
        {
            string str = "0";
            DataTable dt = null;
            if (fg)
            {//留言数目
                dt = sp.getUserInfo(uID, 12);
            }
            else
            {//动态数目
                dt = sp.getUserInfo(uID, 13);
            }

            if (dt != null && dt.Rows.Count > 0)
            {
                str = dt.Rows.Count.ToString();
            }
            dt.Clear(); dt.Dispose();
            return str;
        }
        #endregion

        #region 读取会员相册
        public string GetAlbumInfo()
        {
            string strAlbum = string.Empty;
            DataTable dt = sp.getUserInfo(uID, 6);
            if (dt != null && dt.Rows.Count > 0)
            {
                JuSNS.Home.Album ab = new JuSNS.Home.Album();
                AlbumListCount = dt.Rows.Count;
                dt.Columns.Add("FilePath", typeof(string));
                dt.Columns.Add("Time", typeof(string));
                int n = dt.Rows.Count;

                if (n > 3){n = 3;}

                for (int i = 0; i < n; i++)
                {
                    bool fg = false;
                    if (uID != this.GetUserID())
                    {
                        if (CheckSpace(int.Parse(dt.Rows[i]["Privacy"].ToString())))//相册隐私
                        {
                            fg = true;
                        }
                    }
                    if (fg == true || uID == this.GetUserID())
                    {
                        dt.Rows[i]["FilePath"] = this.GetSmallPic(ab.CoverPath(int.Parse(dt.Rows[i]["AlbumID"].ToString())), 1);

                        if (dt.Rows[i]["LastUploadTime"].ToString() != "")
                        {
                            dt.Rows[i]["Time"] = "更新于 " + JuSNS.Common.Public.getTimeSpan(Convert.ToDateTime(dt.Rows[i]["LastUploadTime"].ToString()));
                        }
                        strAlbum += "<li class=\"sp_nl\">";
                        strAlbum += "<div class=\"sp_nl images\"><a href=\"" + rooDir + "/home/Album/AlbumView.aspx?r[0]=" + uID + "&r[1]=" + dt.Rows[i]["AlbumID"].ToString() + "\"><img src=\"" + dt.Rows[i]["FilePath"].ToString() + "\" style=\"width:80px;\" /></a></div>";
                        strAlbum += "<div class=\"sp_nr title\">";
                        strAlbum += "<span class=\"sp_bold\"><a href=\"" + rooDir + "/home/Album/AlbumView.aspx?r[0]=" + uID + "&r[1]=" + dt.Rows[i]["AlbumID"].ToString() + "\">" + dt.Rows[i]["Title"].ToString() + "</a></span>";
                        strAlbum += "<span>" + dt.Rows[i]["ImagesCount"].ToString() + "张照片</span>";
                        strAlbum += "<span>" + dt.Rows[i]["Time"].ToString() + "</span></li>";
                        strAlbum += "</div></li>";
                    }
                }
            }
            dt.Clear(); dt.Dispose();
            return strAlbum;
        }
        #endregion

        #region 读取会员分享
        public string GetShareInfo()
        {
            if (uID != this.GetUserID())
            {
                JuSNS.Model.PrivacyInfo info = us.GetPrivacy(uID);
                if (!CheckSpace((int)info.PrivacyShare))//分享隐私
                {
                    return string.Empty;
                }
            }
            string strShare = string.Empty;
            DataTable dt = sp.getUserInfo(uID, 3);
            if (dt != null && dt.Rows.Count > 0)
            {
                int type = 0;
                ShareCount = Convert.ToInt32(dt.Rows[0]["Num"].ToString());
                dt.Columns.Add("Css", typeof(string));
                dt.Columns.Add("Time", typeof(string));

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    #region
                    bool fg = false;
                    if (uID != this.GetUserID())
                    {
                        if (sp.CheckPar(int.Parse(dt.Rows[i]["Privacy"].ToString()), uID, this.GetUserID()))
                        {
                            fg = true;
                        }
                    }

                    if (fg == true || uID == this.GetUserID())
                    {
                        type = int.Parse(dt.Rows[i]["ShareType"].ToString());
                        if (type == (int)EnumShareType.ShareWeb)
                        {//分享网址
                            dt.Rows[i]["Css"] = "ShareWeb";
                        }
                        else if (type == (int)EnumShareType.SharePhoto)
                        {//分享相片
                            dt.Rows[i]["Css"] = "SharePhoto";
                        }
                        else if (type == (int)EnumShareType.ShareFriend)
                        {//分享朋友
                            dt.Rows[i]["Css"] = "ShareFriend";
                        }
                        else if (type == (int)EnumShareType.ShareAlbum)
                        {//相册
                            dt.Rows[i]["Css"] = "ShareAlbum";
                        }
                        else if (type == (int)EnumShareType.ShareNews)
                        {//热文
                            dt.Rows[i]["Css"] = "ShareNews";
                        }
                        else if (type == (int)EnumShareType.ShareMusic)
                        {//热文
                            dt.Rows[i]["Css"] = "ShareMusic";
                        }
                        else if (type == (int)EnumShareType.ShareBlog)
                        {//分享日志
                            dt.Rows[i]["Css"] = "ShareBlog";
                        }
                        dt.Rows[i]["Title"] = JuSNS.Common.Input.GetSubString(dt.Rows[i]["Title"].ToString(), 30);
                        dt.Rows[i]["Time"] = JuSNS.Common.Public.getTimeSpan(Convert.ToDateTime(dt.Rows[i]["PostTime"].ToString()));
                        strShare += "<li class=\"share-" + dt.Rows[i]["Css"].ToString() + "\"><a href=\"" + rooDir + "/home/share/?r=" + uID + "\">" + dt.Rows[i]["Title"].ToString() + "</a><div>" + dt.Rows[i]["Time"].ToString() + "</div></li>";
                    }
                    #endregion
                }
            }
            dt.Clear(); dt.Dispose();
            return strShare;
        }
        #endregion

        public string GetUserVoteInfo()
        {
            string Rss = string.Empty;
            string strRss = string.Empty;
            DataTable dt = sp.getUserInfo(uID, 29);
            if (dt != null && dt.Rows.Count > 0)
            {
                BlogCount = dt.Rows.Count;
                dt.Columns.Add("Time", typeof(string));
                dt.Columns.Add("Comment", typeof(string));
                int n = dt.Rows.Count;
                if (n > 5)
                {
                    n = 5;
                }

                for (int i = 0; i < n; i++)
                {
                    dt.Rows[i]["Time"] = JuSNS.Common.Public.getTimeSpan(Convert.ToDateTime(dt.Rows[i]["AddTime"].ToString()));
                    if (dt.Rows[i]["Comments"].ToString() == "0")
                    {
                        dt.Rows[i]["Comment"] = "";
                    }
                    else
                    {
                        dt.Rows[i]["Comment"] = "<span class=\"sp_pipe\">|</span> <a href=\"" + rooDir + "/home/vote/vote.aspx?r=" + dt.Rows[i]["ID"].ToString() + "\">" + dt.Rows[i]["Comments"].ToString() + "&nbsp;个评论</a>";
                    }

                    strRss += "<li><a href=\"" + rooDir + "/home/vote/vote.aspx?r=" + dt.Rows[i]["ID"].ToString() + "\">" + dt.Rows[i]["Title"].ToString() + "</a>";
                    strRss += " <span class=\"sp_time\">" + dt.Rows[i]["Time"] + "</span>";
                    strRss += dt.Rows[i]["Comment"].ToString() + "</li>";
                }
            }
            dt.Clear(); dt.Dispose();
            return Rss + strRss;
        }

        #region 读取会员日志
        public string GetUserBlogInfo()
        {
            JuSNS.Model.PrivacyInfo info = us.GetPrivacy(uID);
            if (!CheckSpace((int)info.PrivacyMiniBlog))//分享隐私
            {
                return string.Empty;
            }
            string Rss = string.Empty;
            string strRss = string.Empty;
            DataTable dt = sp.getUserInfo(uID, 8);
            if (dt != null && dt.Rows.Count > 0)
            {
                BlogCount = dt.Rows.Count;
                dt.Columns.Add("Time", typeof(string));
                dt.Columns.Add("Comment", typeof(string));
                int n = dt.Rows.Count;
                if (n > 5)
                {
                    n = 5;
                }

                for (int i = 0; i < n; i++)
                {
                    bool fg = false;
                    if (uID != this.GetUserID())
                    {
                        if (CheckSpace(int.Parse(dt.Rows[i]["Privacy"].ToString())))//日志隐私
                        {
                            fg = true;
                        }
                    }

                    if (fg == true || uID == this.GetUserID())
                    {
                        dt.Rows[i]["PicPath"] = JuSNS.Config.PicConfig.BlogOrigDir + dt.Rows[i]["PicPath"].ToString();
                        dt.Rows[i]["Time"] = JuSNS.Common.Public.getTimeSpan(Convert.ToDateTime(dt.Rows[i]["LastModTime"].ToString()));
                        if (dt.Rows[i]["Comments"].ToString() == "0")
                        {
                            dt.Rows[i]["Comment"] = "";
                        }
                        else
                        {
                            dt.Rows[i]["Comment"] = "<span class=\"sp_pipe\">|</span> <a href=\"" + rooDir + "/home/blog/article.aspx?r=" + dt.Rows[i]["ID"].ToString() + "#comment\">" + dt.Rows[i]["Comments"].ToString() + "&nbsp;个评论</a>";
                        }

                        if (i == 0)
                        {
                            dt.Rows[i]["Content"] = JuSNS.Common.Input.FilterLogHTML(dt.Rows[i]["Content"].ToString()).Trim();
                            if (dt.Rows[i]["Content"].ToString().Length > 50)
                            {
                                dt.Rows[i]["Content"] = dt.Rows[i]["Content"].ToString().Substring(0, 50);
                            }
                            Rss = "<li><div class=\"sp_bold\"><a href=\"" + rooDir + "/home/blog/article.aspx?r=" + dt.Rows[i]["ID"].ToString() + "\">" + dt.Rows[i]["Title"].ToString() + "</a></div>";
                            Rss += dt.Rows[i]["Content"].ToString();
                            Rss += "<div><a href=\"" + rooDir + "/home/blog/article.aspx?r=" + dt.Rows[i]["ID"].ToString() + "\">阅读全文</a> <span class=\"sp_time\">" + dt.Rows[i]["Time"].ToString() + "</span> " + dt.Rows[i]["Comment"].ToString() + "</div></li>";
                        }
                        else
                        {
                            strRss += "<li><div class=\"bloglist\"><span class=\"sp_bold\"><a href=\"" + rooDir + "/home/blog/article.aspx?r=" + dt.Rows[i]["ID"].ToString() + "\">" + dt.Rows[i]["Title"].ToString() + "</a></span>";
                            strRss += " <span class=\"sp_time\">" + dt.Rows[i]["Time"].ToString() + "</span>";
                            strRss +=  dt.Rows[i]["Comment"].ToString() + "</div></li>";
                        }
                    }
                }
            }
            dt.Clear(); dt.Dispose();
            return Rss + strRss;
        }
        #endregion


        #region 读取会员工作信息
        public string GetCareerInfo()
        {
            string strCareer = "";
            DataTable dt = sp.getUserInfo(uID, 9);
            if (dt != null && dt.Rows.Count > 0)
            {
                dt.Columns.Add("Career", typeof(string));
                dt.Columns.Add("Time", typeof(string));
                dt.Columns.Add("Temp", typeof(string));
                if (uID == this.GetUserID())
                {
                    strCareer += "<div class=\"sp_bold height25\">工作信息<a href=\"" + rooDir + "/home/space/edit-work.aspx\">(编辑)</a></div>";
                }
                else
                {
                    strCareer += "<div class=\"sp_bold height25\">工作信息</div>";
                }


                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (i == 0)
                    {
                        dt.Rows[0]["Career"] = "公司:";
                    }
                    else
                    {
                        dt.Rows[0]["Career"] = "";
                    }

                    if (dt.Rows[i]["JoinYear"].ToString() == "" || dt.Rows[i]["JoinMonth"].ToString() == "" || dt.Rows[i]["JoinYear"].ToString() == "0" || dt.Rows[i]["JoinMonth"].ToString() == "0")
                    {
                        dt.Rows[i]["Time"] = "";
                    }
                    else
                    {
                        if (dt.Rows[i]["LeaveYear"].ToString() == "" || dt.Rows[i]["LeaveMonth"].ToString() == "" || dt.Rows[i]["LeaveYear"].ToString() == "0" || dt.Rows[i]["LeaveMonth"].ToString() == "0")
                        {
                            dt.Rows[i]["Time"] = "(" + dt.Rows[i]["JoinYear"].ToString() + "-" + dt.Rows[i]["JoinMonth"].ToString() + "  -  现在)";
                        }
                        else
                        {
                            dt.Rows[i]["Time"] = "(" + dt.Rows[i]["JoinYear"].ToString() + "-" + dt.Rows[i]["JoinMonth"].ToString() + "  -  " + dt.Rows[i]["LeaveYear"].ToString() + "-" + dt.Rows[i]["LeaveMonth"].ToString() + ")";
                        }
                    }

                    strCareer += "<p><label class=\"f-content\">" + dt.Rows[0]["Career"].ToString() + "</label><a href=\""+rooDir+"/home/Space/Search.aspx?r[0]=Company&r[1]=" + JuSNS.Common.Input.URLEncode(dt.Rows[i]["Company"].ToString()) + "\">" + dt.Rows[i]["Company"].ToString() + "</a> " + dt.Rows[i]["Time"].ToString() + "</p>";
                    strCareer += "<p><label class=\"f-content\">&nbsp;</label>" + dt.Rows[i]["Description"].ToString() + "</p>";
                }
            }
            return strCareer;
        }
        #endregion

        #region 读取会员学校信息
        public string GetShoolInfo()
        {
            JuSNS.Model.PrivacyInfo info = us.GetPrivacy(uID);
            if (!CheckSpace((int)info.PrivacyEducate))//分享隐私
            {
                return string.Empty;
            }

            string Result = "";
            DataTable dt = sp.getUserInfo(uID, 10);
            if (dt != null && dt.Rows.Count > 0)
            {
                int DegreeID = 0;
                string str_JuniorHigh = "";
                string str_SeniorHigh = "";
                string str_College = "";
                string str_Master = "";
                string str_Doctor = "";
                string Year = "";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string labelstr = string.Empty;
                    if ((i+1) != dt.Rows.Count)
                    {
                        labelstr = "<label class=\"f-content\">&nbsp;</label>";
                    }
                    #region 教育程度
                    DegreeID = int.Parse(dt.Rows[i]["DegreeID"].ToString());

                    if (dt.Rows[i]["MatriculationYear"].ToString() != "0")
                    {
                        Year = "(" + dt.Rows[i]["MatriculationYear"].ToString() + " 年入学)";
                    }
                    if (DegreeID == (int)EnumStudyGrade.JuniorHigh)
                    {//初中
                        str_JuniorHigh += "<a href=\"" + rooDir + "/home/space/Search.aspx?r[0]=SchoolID&r[1]=" + dt.Rows[i]["SchoolID"].ToString()+ "\">" + dt.Rows[i]["SchoolName"].ToString() + " </a> - " + dt.Rows[i]["Name"].ToString() + "" + Year + "<br/>" + labelstr + "";
                    }
                    else if (DegreeID == (int)EnumStudyGrade.SeniorHigh)
                    {//高中
                        str_SeniorHigh += "<a href=\"" + rooDir + "/home/space/Search.aspx?r[0]=SchoolID&r[1]=" + dt.Rows[i]["SchoolID"].ToString() + "\">" + dt.Rows[i]["SchoolName"].ToString() + " </a> - " + dt.Rows[i]["Name"].ToString() + "" + Year + "<br/>" + labelstr + "";
                    }
                    else if (DegreeID == (int)EnumStudyGrade.College)
                    {//大学
                        str_College += "<a href=\"" + rooDir + "/home/space/Search.aspx?r[0]=SchoolID&r[1]=" + dt.Rows[i]["SchoolID"].ToString() + "\">" + dt.Rows[i]["SchoolName"].ToString() + " </a>- " + dt.Rows[i]["Name"].ToString() + "" + Year + "<br/>" + labelstr + "";
                    }
                    else if (DegreeID == (int)EnumStudyGrade.Master)
                    {//研究生
                        str_Master += "<a href=\"" + rooDir + "/home/space/Search.aspx?r[0]=SchoolID&r[1]=" + dt.Rows[i]["SchoolID"].ToString() + "\">" + dt.Rows[i]["SchoolName"].ToString() + " </a> - " + dt.Rows[i]["Name"].ToString() + "" + Year + "<br/>" + labelstr + "";
                    }
                    else if (DegreeID == (int)EnumStudyGrade.Doctor)
                    {//博士
                        str_Doctor += "<a href=\"" + rooDir + "/home/space/Search.aspx?r[0]=SchoolID&r[1]=" + dt.Rows[i]["SchoolID"].ToString() + "\">" + dt.Rows[i]["SchoolName"].ToString() + " </a> - " + dt.Rows[i]["Name"].ToString() + "" + Year + "<br/>" + labelstr + "";
                    }
                    #endregion
                }

                if (!string.IsNullOrEmpty(str_JuniorHigh))
                {
                    Result += "<div class=\"c\"></div><p><label class=\"f-content\">初中：</label>" + str_JuniorHigh + "</p>";
                }
                if (!string.IsNullOrEmpty(str_SeniorHigh))
                {
                    Result += "<div class=\"c\"></div><p><label class=\"f-content\">高中：</label>" + str_SeniorHigh + "</p>";
                }
                if (!string.IsNullOrEmpty(str_College))
                {
                    Result += "<div class=\"c\"></div><p><label class=\"f-content\">大学：</label>" + str_College + "</p>";
                }
                if (!string.IsNullOrEmpty(str_Master))
                {
                    Result += "<div class=\"c\"></div><p><label class=\"f-content\">研究生：</label>" + str_Master + "</p>";
                }
                if (!string.IsNullOrEmpty(str_Doctor))
                {
                    Result += "<div class=\"c\"></div><p><label class=\"f-content\">博士：</label>" + str_Doctor + "</p>";
                }

                if (!string.IsNullOrEmpty(Result))
                {
                    if (uID == this.GetUserID())
                    {
                        Result = "<div class=\"c\"></div><p  class=\"sp_bold\" height25>学校信息<a href=\"" + rooDir + "/home/space/edit-edu.aspx\">(编辑)</a></p>" + Result;
                    }
                    else
                    {
                        Result = "<div class=\"c\"></div><p  class=\"sp_bold\" height25>学校信息</p>" + Result;
                    }
                }
            }
            dt.Clear(); dt.Dispose();
            return Result;
        }
        #endregion

        #region 读取会员联系信息和个人爱好
        public string GetLXInfo()
        {
            string strinfo = string.Empty;
            DataTable dt = sp.getUserInfo(uID, 11);
            if (dt != null && dt.Rows.Count > 0)
            {
                dt.Columns.Add("Career", typeof(string));
                dt.Columns.Add("Contact", typeof(string));
                string Career = string.Empty;
                string Contact = string.Empty;

                //判断是否有权限看
                JuSNS.Model.UserBasicInfo info = us.GetUserBasic(uID);

                Career += ChecPrivacy(info.EmailPrivacy, dt.Rows[0]["Email"].ToString(), "Email", true, "");
                Career += ChecPrivacy(info.MSNPrivacy, dt.Rows[0]["MSN"].ToString(), "MSN", true, "");
                Career += ChecPrivacy(info.GTalkPrivacy, dt.Rows[0]["GTalk"].ToString(), "GTalk", true, "");
                Career += ChecPrivacy(info.QQPrivacy, dt.Rows[0]["QQ"].ToString(), "QQ", true, "");
                Career += ChecPrivacy(info.SkypePrivacy, dt.Rows[0]["Skype"].ToString(), "Skype", true, "");
                Career += ChecPrivacy(info.MobilePrivacy, dt.Rows[0]["Mobile"].ToString(), "手机", true, "");
                Career += ChecPrivacy(info.TelPrivacy, dt.Rows[0]["Tel"].ToString(), "电话", true, "");
                Career += ChecPrivacy(info.AddrPrivacy, dt.Rows[0]["Addr"].ToString(), "住址", true, "");

                if (dt.Rows[0]["WebSite"].ToString().Trim() != "")
                {
                    Career += ChecPrivacy(info.WebSitePrivacy, "<a href='"+rooDir+"/home/url.aspx?url=" + dt.Rows[0]["WebSite"].ToString() + "' target='_blank'>" + dt.Rows[0]["WebSite"].ToString() + "</a>", "网站", true, "");
                }
                Contact += ChecPrivacy(0, dt.Rows[0]["Favourite"].ToString(), "兴趣爱好", false, "Favourite");
                Contact += ChecPrivacy(0, dt.Rows[0]["FavMusics"].ToString(), "喜欢的音乐", false, "FavMusics");
                Contact += ChecPrivacy(0, dt.Rows[0]["FavMovies"].ToString(), "喜欢的电影", false, "FavMovies");
                Contact += ChecPrivacy(0, dt.Rows[0]["FavCartoons"].ToString(), "喜欢的动漫", false, "FavCartoons");
                Contact += ChecPrivacy(0, dt.Rows[0]["FavGames"].ToString(), "喜欢的游戏", false, "FavGames");
                Contact += ChecPrivacy(0, dt.Rows[0]["FavSports"].ToString(), "喜欢的运动", false, "FavSports");
                Contact += ChecPrivacy(0, dt.Rows[0]["FavBooks"].ToString(), "喜欢的书", false, "FavBooks");
                Contact += ChecPrivacy(0, dt.Rows[0]["AppreciateMen"].ToString(), "欣赏的人", false, "AppreciateMen");
                Contact += ChecPrivacy(0, dt.Rows[0]["FavAdages"].ToString(), "喜欢的格言", false, "FavAdages");
                Contact += ChecPrivacy(0, dt.Rows[0]["Presentation"].ToString(), "自述", false, "Presentation");

                if (Career != string.Empty)
                {
                    if (uID == this.GetUserID())
                    {
                        strinfo += "<div class=\"c\"></div><p class=\"sp_bold height25\">联系信息<a href=\""+rooDir+"/home/space/edit-link.aspx\">(编辑)</a></p>";
                    }
                    else
                    {
                        strinfo += "<div class=\"c\"></div><p class=\"sp_bold height25\">联系信息</p>";
                    }

                    strinfo += Career;
                }
                if (Contact != string.Empty)
                {
                    if (uID == this.GetUserID())
                    {
                        strinfo += "<p class=\"sp_bold height25\">个人爱好<a href=\""+rooDir+"/home/space/edit-like.aspx\">(编辑)</a></p>";
                    }
                    else
                    {
                        strinfo += "<p class=\"sp_bold height25\">个人爱好</p>";
                    }
                    strinfo += Contact;
                }
            }
            return strinfo;
        }
        #endregion

        #region 联系信息和个人爱好权限判断
        public string ChecPrivacy(int IPrivacy, string Content, string title, bool flag, string hrefTitle)
        {
            string Result =string.Empty;

            if (!string.IsNullOrEmpty(Content))
            {
                if (flag)//联系信息
                {
                    switch (IPrivacy)
                    {
                        case 0://全站用户可见
                            Result = "<p><label class=\"f-content\">" + title + "：</label>" + Content + "</p>";
                            break;
                        case 1://相同网络用户及好友可见
                            if (IsFriend == 2 || sp.CheckSameNet(this.GetUserID(), uID))
                            {
                                Result = "<p><label class=\"f-content\">" + title + "：</label>" + Content + "</p>";
                            }
                            break;
                        case 2://仅好友可见
                            if (IsFriend == 2 || uID == this.GetUserID())
                            {
                                Result = "<p><label class=\"f-content\">" + title + "：</label>" + Content + "</p>";
                            }
                            break;
                        case 3://仅自己可见
                            if (uID == this.GetUserID())
                            {
                                Result = "<p><label class=\"f-content\">" + title + "：</label>" + Content + "</p>";
                            }
                            break;
                    }
                }
                else//个人爱好
                {
                    Result = string.Empty;

                    if (title == "喜欢的格言" || title == "自述")
                    {
                        Result = "<p class=\"c\"><label class=\"f-content1\">" + title + "</label>：" + Content + "</p>";
                    }
                    else
                    {
                        string[] str = Content.Split(',');
                        string mystr = string.Empty;
                        for (int i = 0; i < str.Length; i++)
                        {
                            if (str[i].ToString().Trim() != "")
                            {
                                mystr += "<a href=\""+rooDir+"/home/space/Search.aspx?r[0]=" + hrefTitle + "&r[1]=" + JuSNS.Common.Input.URLEncode(str[i].ToString()) + "\">" + str[i].ToString() + "</a>  ";
                            }
                        }
                        Result = "<p class=\"c\"><label class=\"f-content1\">" + title + "</label>：" + mystr + "</p>";
                    }
                }
            }
            return Result;
        }
        #endregion

        #region 读取会员留言
        public string GetMsgInfo()
        {
            string strMsg = string.Empty;
            PrivacyInfo info = us.GetPrivacy(uID);
            if (CheckSpace((int)info.PrivacyLeaveWord))//留言板隐私
            {
                int ReCount, PgCount;
                int PageIndex = 1;
                DataTable dt = UtilPage.GetPage("leaveword_aspx", PageIndex, 6, out ReCount, out PgCount, new SqlConditionInfo("@Receiver", uID, TypeCode.Int32));
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    strMsg += "<li class=\"nl\"  id=\"book_li_" + dt.Rows[i]["ID"].ToString() + "\">";
                    strMsg += "<div  class=\"nl body-m-left image\">";
                    strMsg += "<a href=\"../user/" + JuSNS.Common.Public.URLWrite("", "r", dt.Rows[i]["SendID"].ToString()) + "\"><img style=\"width:48px;height:48px;\" src=\"" + GetHeadImage(Convert.ToInt32(dt.Rows[i]["SendID"].ToString()), 1) + "\" /> </a>";
                    strMsg += "</div>";
                    strMsg += "<div class=\"nl body-m-right\">";
                    strMsg += "<div class=\"nl hdtitle s97\">";
                    string DelStr = string.Empty;
                    string repSTR = string.Empty;
                    string mess = string.Empty;
                    if (this.GetUserID() == uID)
                    {
                        DelStr = "<a href=\"javascript:void(0);\" onclick=\"javascript:Confirm(this,'<ul><li>确定要删除留言吗？删除留言将删除回复！</li></ul>','删除留言',function(){delbook('" + dt.Rows[i]["ID"].ToString() + "','" + dt.Rows[i]["RecID"].ToString() + "')})\">删除</a>";
                        repSTR = "<a href=\"" + rooDir + "/home/gbook?r=" + dt.Rows[i]["SendID"].ToString() + "\">回复(" + dt.Rows[i]["ReplayCount"].ToString() + ")</a>&nbsp;";
                        mess = "<a href=\"javascript:void(0);\" onclick=\"mailto('" + dt.Rows[i]["SendID"].ToString() + "','')\">发消息</a>&nbsp;";
                    }
                    strMsg += "  <a href=\"../user/" + JuSNS.Common.Public.URLWrite("", "r", dt.Rows[i]["SendID"].ToString()) + "\">" + dt.Rows[i]["UserName"].ToString() + "</a><span class=\"tshow\">(" + dt.Rows[i]["Name"].ToString() + ")</span>  "+repSTR+" "+mess+" " + DelStr + " <a href=\"../home/gbook?s=" + dt.Rows[i]["SendID"].ToString() + "&r=" + dt.Rows[i]["RecID"].ToString() + "&a=record\">对话录</a> <span class=\"tshow\">" + JuSNS.Common.Public.getTimeEXPINSpan(DateTime.Parse(dt.Rows[i]["PostTime"].ToString())) + "</span>";
                    strMsg += "</div>";
                    strMsg += "<div class=\"nl content s97\" style=\"padding:6px;\">";
                    strMsg += "" + JuSNS.Common.Public.CheckSma(dt.Rows[i]["Content"].ToString()) + "";
                    strMsg += "</div>";
                    strMsg += "<div class=\"repbook\" id=\"repay_book_" + dt.Rows[i]["ID"].ToString() + "\" style=\"display:none;\"></div>";
                    strMsg += "</div>";
                    strMsg += "</li>";
                }
            }
            return strMsg;
        }
        #endregion

        #region 删除分享好友
        public string DeShareFriend(bool fg)
        {
            string restr = string.Empty;
            if (fg)
            {//删除
                if (IsFriend == 2)
                {
                    restr += "<span class=\"delb\"><a href=\"javaScript:DelFriend(" + uID + ");\">删除</a></span>";
                }
            }
            else
            {//分享
                if (this.GetUserID() != uID)
                {
                    if (IsFriend == 2)
                    {
                        restr += "<span class=\"share\"><a href=\"javascript:ShowShareDiv(6," + uID + ",'" + userName + "','','','" + this.GetUserID() + "');\">分享</a></span>";
                    }
                }
            }
            return restr;
        }
        #endregion


        #region 读取电影
        public string GetMovieInfo()
        {
            if (uID != this.GetUserID())
            {
                JuSNS.Model.PrivacyInfo info = us.GetPrivacy(uID);
                if (!CheckSpace((int)info.PrivacyMovies))//电影隐私
                {
                    return string.Empty;
                }
            }

            string strMovie = string.Empty;
            DataTable dt = sp.getUserInfo(uID, 5);
            if (dt != null && dt.Rows.Count > 0)
            {
                JuSNS.Home.Movie movie = new JuSNS.Home.Movie();
                MovieCount = dt.Rows.Count;
                dt.Columns.Add("Type", typeof(string));

                int n = dt.Rows.Count;

                if (n > 5){n = 5;}
                for (int i = 0; i < n; i++)
                {
                    strMovie += "<li class=\"sp_nl\"><div class=\"sp_m1_nl\"><a  href=\"" + rooDir + "/home/movie/movie.aspx?ID=" + dt.Rows[i]["MovieID"].ToString() + "\"><img src=\""+rooDir+"/" + dt.Rows[i]["PosterFile"].ToString() + "\" alt=\"" + dt.Rows[i]["Title"].ToString() + "\" align=\"left\" style=\"width:70px;height:100px\" /></a></div>";
                    strMovie += "<div class=\"sp_m1_nr\"><div class=\"sp_bold\"><a href=\"" + rooDir + "/home/movie/movie.aspx?Id=" + dt.Rows[i]["MovieID"].ToString() + "\">" + dt.Rows[i]["title"].ToString() + "</a> </div>";
                    strMovie += "<div class=\"film_content\">" + JuSNS.Common.Input.GetSubString(dt.Rows[i]["gut"].ToString(), 50) + " <a href=\"" + rooDir + "/home/movie/movie.aspx?Id=" + dt.Rows[i]["MovieID"].ToString() + "#comment\">评论</a></div></div></li>";
                }
            }
            dt.Clear(); dt.Dispose();
            return strMovie;
        }
        #endregion

        #region 取得想看/不想看/以及看过对此的星级评价样式
        /// <summary>
        /// 取得想看/不想看/以及看过对此的星级评价样式
        /// </summary>
        /// <param name="type">类型</param>
        /// <returns>返回样式</returns>
        protected string GetCSS(object type)
        {
            string s_CSS = "";
            switch (type.ToString())
            {
                case "-1":
                    s_CSS = "<span class=\"movie-notinterested\"></span>";
                    break;
                case "0":
                    s_CSS = "<span class=\"movie-wannasee\"></span>";
                    break;
                case "1":
                    s_CSS = "<span class=\"rate-star rate-star1\"></span>";
                    break;
                case "2":
                    s_CSS = "<span class=\"rate-star rate-star2\"></span>";
                    break;
                case "3":
                    s_CSS = "<span class=\"rate-star rate-star3\"></span>";
                    break;
                case "4":
                    s_CSS = "<span class=\"rate-star rate-star4\"></span>";
                    break;
                case "5":
                    s_CSS = "<span class=\"rate-star rate-star5\"></span>";
                    break;
            }
            return s_CSS;
        }
        #endregion

        #region 读取会员组群
        public string GetGroupInfo()
        {
            if (uID != this.GetUserID())
            {
                JuSNS.Model.PrivacyInfo info = us.GetPrivacy(uID);
                if (!CheckSpace((int)info.PrivacyGroup))//组群隐私
                {
                    return string.Empty;
                }
            }

            string strGroup = string.Empty;
            DataTable dt = sp.getUserInfo(uID, 4);
            if (dt != null && dt.Rows.Count > 0)
            {
                GroupCount = dt.Rows.Count;
                int n = dt.Rows.Count;
                if (n > 30)
                {
                    n = 30;
                }
                strGroup += "<p class=\"qunzu\">";
                for (int i = 0; i < n; i++)
                {
                    if ((i + 1) != n)
                    {
                        strGroup += "<a href=\""+rooDir+"/home/group/group.aspx?GroupID=" + dt.Rows[i]["GroupID"].ToString() + "\">" + dt.Rows[i]["GroupName"].ToString() + "</a>，";
                    }
                    else
                    {
                        strGroup += "<a href=\"" + rooDir + "/home/group/group.aspx?GroupID=" + dt.Rows[i]["GroupID"].ToString() + "\">" + dt.Rows[i]["GroupName"].ToString() + "</a>";
                    }
                }
                strGroup += "</p>";
            }
            dt.Clear();dt.Dispose();
            return strGroup;
        }
        #endregion

        /// <summary>
        /// 读取动态
        /// </summary>
        protected string DynList(int Num)
        {
            List<UserLogInfo> list = null;
            list = uHome.DynlistID(uID, Num,string.Empty);
            string UserDynStr = string.Empty;
            string rStr = string.Empty;
            if (list == null || list.Count < 1)
            {
                rStr = "<ul></ul>\r";
            }
            else
            {
                string gDateSTR = string.Empty;
                bool isZ = false;
                foreach (UserLogInfo info in list)
                {
                    string TmpUserLogStr = ParseUserLog.Parse(info, this.GetUserID());
                    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/" + JuSNS.Common.Public.URLWrite("", "r", info.infoarr) + "\"><img src=\"" + GetHeadImage(Convert.ToInt32(info.infoarr), 1) + "\" style=\"width:48px;\" /></a>");
                        }
                        UserDynStr = UserDynStr.Replace("{CloseDyn}", string.Empty);
                        gDateSTR = info.LogTime.ToString("MM-dd");
                    }
                }
                rStr = "<ul>" + UserDynStr + "</ul>\r";
                rStr = rStr.Replace("{Email}", "");
                rStr = rStr.Replace("{sUserID}", this.GetUserID().ToString());
            }
            return JuSNS.Common.Public.CheckSma(rStr);
        }

        protected string GetItem()
        {
            string itemSTR = string.Empty;
            itemSTR += "<li><a href=\"" + this.rooDir + "/home/mood?r=" + uID + "\" target=\"_blank\">心情</a></li>";
            itemSTR += "<li><a href=\"" + this.rooDir + "/home/blog?r=" + uID + "\" target=\"_blank\">日记</a></li>";
            itemSTR += "<li><a href=\"" + this.rooDir + "/home/album?r=" + uID + "\" target=\"_blank\">相册</a></li>";
            itemSTR += "<li><a href=\"" + this.rooDir + "/home/group/my.aspx?r=" + uID + "&a=creat\" target=\"_blank\">群组</a></li>";
            itemSTR += "<li><a href=\"" + this.rooDir + "/home/share?r=" + uID + "\" target=\"_blank\">分享</a></li>";
            itemSTR += "<li><a href=\"" + this.rooDir + "/home/bill?r=" + uID + "\" target=\"_blank\">账本</a></li>";
            itemSTR += "<li><a href=\"" + this.rooDir + "/home/movie?r=" + uID + "\" target=\"_blank\">电影</a></li>";
            itemSTR += "<li><a href=\"" + this.rooDir + "/home/vote?r=" + uID + "\" target=\"_blank\">投票</a></li>";
            itemSTR += "<li><a href=\"" + this.rooDir + "/home/gbook?r=" + uID + "\" target=\"_blank\">留言</a></li>";
            itemSTR += "<li><a href=\"" + this.rooDir + "/home/friend?r=" + uID + "\" target=\"_blank\">朋友</a></li>";
            return itemSTR;
        }
    }
}
