using System;
using System.Collections.Generic;
using System.Text;
using JuSNS.Factory;
using JuSNS.Model;
using System.Data.SqlClient;
using System.Data;
using JuSNS.Profile;
using JuSNS.Common;
using System.Reflection;

namespace JuSNS.SQLServer
{
    /// <summary>
    /// 解析用户动作
    /// </summary>
    public class ParseUserLog:DbBase,IParseUserLog
    {
        private string rootDir;
        private string SiteName;

        public ParseUserLog()
        {
            rootDir = Public.rootDir;
            SiteName = JuSNS.Config.UiConfig.SiteName;
        }
        public string Parse(UserLogInfo info,int currentUserID)
        {
            MethodInfo method = this.GetType().GetMethod(info.DynType, BindingFlags.Instance | BindingFlags.IgnoreCase | BindingFlags.NonPublic);
            object str = string.Empty;
            try
            {
                str = method.Invoke(this, new object[] { info, currentUserID });
            }
            catch(Exception e){ }
            return str.ToString();
        }
        /// <summary>
        /// 公共替换
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        protected string ComParse(UserLogInfo info,int currentUserID)
        {
            string s = JuSNS.Config.DynConfig.Config[info.DynType];
            string username = "<a href=\"" + JuSNS.Config.UiConfig.spaceDir + "/" + JuSNS.Common.Public.URLWrite("", "r", info.User.UserID.ToString()) + "\">" + GetUserName(info.User.UserID) + "</a>";
            SiteName = JuSNS.Config.UiConfig.SiteName;
            string PostTime = JuSNS.Common.Public.getTimeSpan(info.LogTime);
            s = s.Replace("{UserName}", username);
            s = s.Replace("{SiteName}", SiteName);
            s = s.Replace("{root}", rootDir);
            s = s.Replace("{PostTime}", PostTime);
            s = s.Replace("{UserID}", info.User.UserID.ToString());
            s = s.Replace("{ID}", info.cID.ToString());
            if (info.bUserID.UserID!=0)
            {
                string namestr = "<b>你</b>";
                if (currentUserID != info.bUserID.UserID)
                {
                    namestr = GetUserName(info.bUserID.UserID);
                }
                username = "<a href=\"" + JuSNS.Config.UiConfig.spaceDir + "/" + JuSNS.Common.Public.URLWrite("", "r", info.bUserID.UserID.ToString()) + "\">" + namestr + "</a>";
                s = s.Replace("{bUserName}", username);
            }
            return s;
        }

        protected string AddApp(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            string title = string.Empty;
            SqlParameter param = new SqlParameter("@AppID", info.cID);
            string sql = "select AppName from App_App where AppID=@AppID";
            try
            {
                title = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
            }
            catch { }
            s = s.Replace("{title}", title);
            return s;
        }

        protected string OutApp(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            string title = string.Empty;
            SqlParameter param = new SqlParameter("@AppID", info.cID);
            string sql = "select AppName from App_App where AppID=@AppID";
            try
            {
                title = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
            }
            catch { }
            s = s.Replace("{title}", title);
            return s;
        }

        protected string App(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            string title = string.Empty;
            JuSNS.SQLServer.ApiInterface.Activity active=new JuSNS.SQLServer.ApiInterface.Activity();
            JuSNS.Model.ApiInterface.AppActiveInfo activeinfo = active.GetInfo(info.cID);
            title = activeinfo.ParseContent;
            s = s.Replace("{title}", title);
            return s;
        }

        protected string Login(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            return s;
        }

        protected string Info(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            return s;
        }

        protected string InfoLink(UserLogInfo info, int currentUserID)
        {
            string s = ComParse(info, currentUserID);
            return s;

        }

        protected string vEmail(UserLogInfo info, int currentUserID)
        {
            string s = ComParse(info, currentUserID);
            return s;
        }

        protected string InfoFav(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            return s;
        }

        protected string InfoName(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            string namestr = "你";
            if (currentUserID != info.User.UserID)
            {
                namestr = GetUserName(info.User.UserID);
            }
            string username = "<a href=\"" + JuSNS.Config.UiConfig.spaceDir + "/" + JuSNS.Common.Public.URLWrite("", "r", info.User.UserID.ToString()) + "\">" + namestr + "</a>";
            s = s.Replace("{Content}", info.Description);
            s = s.Replace("{UserName}", username);
            return s;
        }

        protected string InfoAddress(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            return s;
        }

        protected string HeadPic(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            SqlParameter param = new SqlParameter("@pID", Convert.ToInt32(info.infoarr));
            string Sql = "select FilePath from NT_Photo where PhotoID=@pID";
            string filepath = string.Empty ;
            try{
                filepath = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, param));
            }
            catch { return string.Empty; }
            s = s.Replace("{title}", "<a href=\"" + rootDir + "/user/" + Public.URLWrite("", "r", info.User.UserID.ToString()) + "\"><img src=\"" + JuSNS.Common.Public.GetSmallHeadPic(filepath, 1) + "\" style=\"height:48px;\" /></a>");
            return s;
        }

        protected string Mood(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            SqlParameter param = new SqlParameter("@ID", info.cID);
            DataTable dt = DbHelper.ExecuteTable(CommandType.StoredProcedure, "JuSNS_GetTopIDMood", param);
            if (dt != null && dt.Rows.Count > 0)
            {
                string mInfo = dt.Rows[0]["Content"].ToString();
                if (!string.IsNullOrEmpty(mInfo))
                {
                    mInfo = JuSNS.Common.Public.CheckSma(mInfo) + "<br /><a href=\"mood/?mid=" + dt.Rows[0]["ID"].ToString() + "#re_" + dt.Rows[0]["ID"].ToString() + "\">详情</a> <a href=\"javascript:void(0);\" onclick=\"showCommentJS('" + info.cID + "','mini_ID_" + info.cID + "','1');//showdynMoodComment('" + info.ID + "','" + info.cID + "',0);\">回复(" + dt.Rows[0]["ReplayNum"].ToString() + ")</a><div style=\"display:none;\" id=\"mini_ID_" + info.cID + "\">loading...</div>";
                    s = s.Replace("{Content}", mInfo);
                }
            }
            else
            {
                s = string.Empty;
            }
            dt.Dispose();
            return s;
        }


        protected string Blog(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            SqlParameter param = new SqlParameter("@ID", info.cID);
            DataTable dt = DbHelper.ExecuteTable(CommandType.StoredProcedure, "JuSNS_GetTopIDBlog", param);
            string bTitle = string.Empty;
            string ReplayStr = string.Empty;
            string mInfo = string.Empty;
            if (dt != null && dt.Rows.Count > 0)
            {
                mInfo = dt.Rows[0]["Content"].ToString();
                bTitle = dt.Rows[0]["title"].ToString();
                ReplayStr = "<a href=\"" + rootDir + "/blog/b" + info.cID + ".aspx\">详情</a> <a href=\"" + rootDir + "/blog/b" + info.cID + ".aspx#addcomment\">评论(" + dt.Rows[0]["ReplayNum"].ToString() + ")</a><div style=\"display:none;\" id=\"blog_dyn_" + info.ID + "\"></div>";
                s = s.Replace("{title}", Input.GetSubString(bTitle, 46));
                s = s.Replace("{Content}", Input.GetSubString(Input.FilterHTML(mInfo), 300));
                s = s.Replace("{bID}", "b"+info.cID.ToString());
                s += ReplayStr;
            }
            else
            {
                s = string.Empty;
            }
            dt.Clear(); dt.Dispose();
            return s;
        }


        protected string BlogComment(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            SqlParameter param = new SqlParameter("@ID", info.infoarr);
            DataTable dt = DbHelper.ExecuteTable(CommandType.StoredProcedure, "JuSNS_GetTopIDBlog", param);
            string sbTitle = string.Empty;
            string sReplayStr = string.Empty;
            string mInfo = string.Empty;
            if (dt != null && dt.Rows.Count > 0)
            {
                mInfo = dt.Rows[0]["Content"].ToString();
                mInfo=Input.GetSubString(Input.FilterHTML(mInfo),200);
                sbTitle = dt.Rows[0]["title"].ToString();
                sReplayStr = "<a href=\"" + rootDir + "/blog/b" + info.infoarr + ".aspx\">查看日志</a> <a href=\"" + rootDir + "/blog/b" + info.infoarr + ".aspx#addcomment\">评论(" + dt.Rows[0]["ReplayNum"].ToString() + ")</a>";
                s = s.Replace("{title}", sbTitle);
                s = s.Replace("{Content}", mInfo + "<div class=\"quote\"><span class=\"q\">" + Public.CheckSma(Input.FilterHTML(DbHelper.ExecuteScalar(CommandType.Text, "select Content from NT_blogcomment where id=" + info.cID, null).ToString())) + "</span></div>");
                s = s.Replace("{bID}", "b" + info.infoarr.ToString());
                s += sReplayStr;
            }
            else
            {
                s = string.Empty;
            }
            dt.Clear(); dt.Dispose();
            return s;
        }

        protected string Creatlbum(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            SqlParameter[] param = new SqlParameter[2];
            param[0] = new SqlParameter("@ID", SqlDbType.Int, 4);
            param[0].Value = info.cID;
            param[1] = new SqlParameter("@Flg", SqlDbType.Int, 4);
            param[1].Value = 0;
            DataTable dt= DbHelper.ExecuteTable(CommandType.StoredProcedure, "JuSNS_GetDynInfoId", param);
            string abumtitle = string.Empty;
            string Desc = string.Empty;
            if (dt != null && dt.Rows.Count > 0)
            {
                abumtitle = dt.Rows[0]["title"].ToString();
                Desc = dt.Rows[0]["Description"].ToString();
                s = s.Replace("{title}", abumtitle);
                s = s.Replace("{Content}", Input.FilterHTML(Desc));
                s = s.Replace("{ID}", info.cID.ToString());
                s = s.Replace("{UserID}", info.User.UserID.ToString());
            }
            else
            {
                s = string.Empty;
            }
            dt.Clear(); dt.Dispose();
            return s;
        }

        protected string Dellbum(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            return s;
        }

        protected string UpdateAlbum(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            string Content = string.Empty;
            int AlbumID = 0;
            StringBuilder sb = new StringBuilder();
            SqlParameter param = new SqlParameter("@PhotoID", info.cID);
            try
            {                
                string sql = "select AlbumID from Nt_Photo where PhotoID=@PhotoID";
                AlbumID = Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
            }
            catch { }
            string title = "暂无名称";
            try
            {
                param = new SqlParameter("@AlbumID", AlbumID);
                string sql = "select Title from NT_Album where AlbumID=@AlbumID";
                title = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
            }
            catch { }
            foreach (int id in info.aboutID)
            {
                string sql = "select FilePath from Nt_Photo where PhotoID="+id;
                string str = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, null));
                str = "<a href=\"" + rootDir + "/home/album/photoview.aspx?r[0]=" + id + "" + "\"><img src=\"" + JuSNS.Common.Public.GetSmallPic(str, 0) + "\" /></a>";
                sb.Append(str);
                sb.Append("&nbsp;&nbsp;");
            }

            s = s.Replace("{title}", title);
            s = s.Replace("{AlbumID}", AlbumID.ToString());
            s = s.Replace("{Content}", sb.ToString());
            return s;
        }


        protected string Quanren(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            string Content = string.Empty;
            SqlParameter param = new SqlParameter("@PhotoID", info.cID);
            string title = "暂无名称";
            try
            {
                string sql = "select Description from NT_Photo where PhotoID=@PhotoID";
                title = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
            }
            catch { }
            try
            {
                string sql = "select FilePath from NT_Photo where PhotoID=@PhotoID";
                Content = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
                Content = "<a href=\"" + rootDir + "/home/album/photoview.aspx?r[0]=" + info.cID + "" + "\"><img src=\"" + JuSNS.Common.Public.GetSmallPic(Content, 0) + "\" /></a>";
                
            }
            catch { }
            s = s.Replace("{title}", title);
            s = s.Replace("{Content}", Content);
            return s;
        }

        protected string CreatGroup(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            SqlParameter param = new SqlParameter("@GroupID", info.cID);
            string title = string.Empty;
            try
            {
                string sql = "select GroupName from NT_UserGroup where GroupID=@GroupID";
                title = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
            }
            catch { }
            s = s.Replace("{title}", title);
            return s;
        }

        protected string JoinGroup(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            StringBuilder sb = new StringBuilder();
            foreach (int id in info.aboutID)
            {
                SqlParameter param = new SqlParameter("@GroupID", id);
                string sql = "select GroupName from Nt_UserGroup where GroupID=@GroupID";
                string tempname = string.Empty;
                try
                {
                    tempname = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
                }
                catch { }
                tempname = "<a href=\"" + Public.rootDir + "/home/group/group.aspx?GroupID="+id+"\">"+tempname+"</a>";
                sb.Append(tempname);
                sb.Append(",");
            }
            string GroupInfo = sb.ToString();
            if (GroupInfo.EndsWith(","))
            {
                GroupInfo = GroupInfo.Substring(0,GroupInfo.Length - 1);
            }
            s = s.Replace("{GroupInfo}", GroupInfo);
            return s;
        }

        protected string OutGroup(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            StringBuilder sb = new StringBuilder();
            foreach (int id in info.aboutID)
            {
                SqlParameter param = new SqlParameter("@GroupID", id);
                string sql = "select GroupName from Nt_UserGroup where GroupID=@GroupID";
                string tempname = string.Empty;
                try
                {
                    tempname = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
                }
                catch { }
                tempname = "<a href=\"" + Public.rootDir + "/home/group/group.aspx?GroupID=" + id + "\">" + tempname + "</a>";
                sb.Append(tempname);
                sb.Append(",");
            }
            string GroupInfo = sb.ToString();
            if (GroupInfo.EndsWith(","))
            {
                GroupInfo = GroupInfo.Substring(0,GroupInfo.Length - 1);
            }
            s = s.Replace("{GroupInfo}", GroupInfo);
            return s;
        }

        protected string PostTopic(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            string groupName = string.Empty;
            string GroupID = string.Empty;
            string Content = string.Empty;
            string title = string.Empty;
            SqlParameter param = new SqlParameter("@ID", info.cID);
            string sql = "select Content from NT_groupdiscuss where ID=@ID";
            try
            {
                Content = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
            }
            catch { }
            sql = "select Topic from NT_groupdiscuss where ID=@ID";
            try
            {
                title = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
                title = "<a href=\"" + rootDir + "/home/group/Topic.aspx?DisID=" + info.cID + "\">" + title + "</a>";
            }
            catch { }
            sql = "Select GroupID from NT_groupdiscuss where ID=@ID";
            try
            {
                GroupID = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
            }
            catch{ }
            sql = "select GroupName from Nt_UserGroup where GroupID=(Select GroupID from NT_groupdiscuss where ID=@ID)";
            try
            {
                groupName = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
            }
            catch { }
            string img = string.Empty;
            string text = string.Empty;
            Input.splitImgAndText(Input.ToshowTxt(Content), out img, out text);
            Content = img + Input.GetSubString(Input.FilterHTML(text), 200);
            s = s.Replace("{groupName}", "<a href=\"" + rootDir + "/home/group/group.aspx?GroupID=" + GroupID + "\">" + groupName + "</a>");
            s = s.Replace("{Content}", "<div class=\"quote\"><span class=\"q\">"+Content+"</span></div>");
            s = s.Replace("{title}", title);
            return s;
        }


        protected string ReplyTopic(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            string groupName = string.Empty;
            string Content = string.Empty;
            string title = string.Empty;
            string TopicID = "0";
            string GroupID = string.Empty;
            SqlParameter param = new SqlParameter("@ID", info.cID);
            string sql = "select belongTopic from NT_groupdiscuss where ID=@ID";
            try
            {
                TopicID = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param)) ;
            }
            catch { }
            sql = "select Topic from NT_groupdiscuss where ID=" + TopicID + "";
            try
            {
                title = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
            }
            catch { }
            sql = "select Content from NT_groupdiscuss where ID=@ID";
            try
            {
                Content = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
            }
            catch { }
            sql = "select GroupName from Nt_UserGroup where GroupID=(Select GroupID from NT_groupdiscuss where ID=@ID)";
            try
            {
                groupName = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
            }
            catch { }
            sql = "Select GroupID from NT_groupdiscuss where ID=@ID";
            try
            {
                GroupID = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
            }
            catch { }
            string img = string.Empty;
            string text = string.Empty;
            Input.splitImgAndText(Input.ToshowTxt(Content), out img, out text);
            Content = img + Input.GetSubString(Input.FilterHTML(text), 200);
            s = s.Replace("{groupName}", "<a href=\"" + rootDir + "/home/group/group.aspx?GroupID=" + GroupID + "\">" + groupName + "</a>");
            s = s.Replace("{TopicID}", TopicID);
            s = s.Replace("{title}", title);
            s = s.Replace("{Content}", "<div class=\"quote\"><span class=\"q\">" + Content + "</span></div>");
            return s;
        }

        protected string GroupAdmin(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            string GroupName = string.Empty;
            SqlParameter param = new SqlParameter("@GroupID", info.cID);
            string sql = "Select GroupName from Nt_UserGroup where GroupID=@GroupID";
            try
            {
                GroupName = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
            }
            catch { }
            s = s.Replace("{groupName}", "<a href=\"" + rootDir + "/home/group/group.aspx?GroupID=" + info.cID + "\">" + GroupName + "</a>");
            return s;
        }

        protected string Poke(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            string Content = string.Empty;
            SqlParameter param = new SqlParameter("@ID", info.cID);
            string gStr = string.Empty;
            string from = string.Empty;
            string to = string.Empty;
            string sql = string.Empty;
            if (info.infoarr == "-1")
            {
                sql = "select pokefrom from NT_Greet where ID=@ID ";
                try
                {
                    from = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
                }
                catch { }
                sql = "select poketo from NT_Greet where ID=@ID ";
                try
                {
                    to = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
                }
                catch { }
            }
            gStr = JuSNS.Common.Public.GetAction(Convert.ToInt32(info.infoarr), from, to, "1");
            if (currentUserID != info.bUserID.UserID)
            {
                gStr = gStr.Replace("你", "<a href=\"" + JuSNS.Common.Public.rootDir + "/user/" + JuSNS.Common.Public.URLWrite("", "r", info.bUserID.UserID.ToString()) + "\">" + GetUserName(info.bUserID.UserID) + "</a>");
            }
            s = s.Replace("{Content}", gStr + " <a href=\""+rootDir+"/home/poke\"><img src=\"" + JuSNS.Common.Public.rootDir + "/template/" + JuSNS.Config.UiConfig.SkinStyle + "/images/poke/pokeact_" + info.infoarr.Replace("-", "_") + ".gif\" align=\"absmiddle\" /></a>");
            return s;
        }

        protected string Gift(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            string Content = string.Empty;
            SqlParameter param = new SqlParameter("@id", info.cID);
            string picid = string.Empty;
            string giftName = string.Empty;
            string gContent = string.Empty;
            string sql = "select Picture from NT_Gift where ID=@id";
            try
            {
                picid = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param)); 
            }
            catch{ }
            sql = "select GName from NT_Gift where ID=@id";
            try
            {
                giftName = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
            }
            catch { }
            sql = "select Content from NT_GiftUser where ID=" + Convert.ToInt32(info.infoarr);
            try
            {
                gContent = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, null));
            }
            catch { }
            if (!string.IsNullOrEmpty(gContent))
            {
                gContent = "<div class=\"quote\"><span class=\"q\">" + gContent + "</span></div>";
            }
            Content = "<a href=\"" + rootDir + "/home/gift\"><img src=\"" + rootDir + "/template/images/gift/" + picid + "\" style=\"border:0;\" alt=\"" + giftName + "\" /></a>";
            s = s.Replace("{Content}", "<div class=\"nl\">" + Content + "</div><div class=\"nl\" style=\"margin-left:10px\">"+gContent+"</div>");
            s = s.Replace("{title}", giftName);
            return s;
        }

        protected string InviteJoin(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            return s;
        }

        protected string ShareAlbum(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info, currentUserID);
            string ShareURL = string.Empty;
            string Content = string.Empty;
            string title = string.Empty;
            ShareURL = rootDir + "/home/album/AlbumView.aspx?r[1]=" + info.infoarr + "";
            SqlParameter param = new SqlParameter("@AlbumID", Convert.ToInt32(info.infoarr));
            string sql = "select Title from Nt_Album where AlbumID=@AlbumID";
            try
            {
                title = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));               
            }
            catch { }
            sql = "select filepath from Nt_Photo where AlbumID=@AlbumID and IsCover=(1)";
            try
            {
                string filepath = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
                Content = "<img src=\"" + JuSNS.Common.Public.GetSmallPic(filepath, 0) + "\" alt=\"" + title + "\"></img>";
                Content = "<a href=\"" + ShareURL + "\">" + Content + "</a>";
            }
            catch { }
            s = s.Replace("{ShareURL}", ShareURL);
            s = s.Replace("{Content}", Content);
            s = s.Replace("{title}", title);
            return s;
        }

        protected string ShareBlog(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            string ShareURL = string.Empty;
            string Content = string.Empty;
            string title = string.Empty;
            ShareURL = rootDir + "/home/blog/article.aspx?r=" + info.infoarr + "";
            SqlParameter param = new SqlParameter("@ID", Convert.ToInt32(info.infoarr));
            string sql = "select title from NT_blog where ID=@ID";
            try
            {
                title = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
                title = "<a href=\"" + ShareURL + "\">" + title + "</a>";
            }
            catch { }
            sql = "select Content from Nt_Blog where ID=@ID ";
            try
            {
                Content = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
                Content = Input.GetSubString(Input.FilterHTML(Content), 240) + "...";
            }
            catch { }
            if (string.IsNullOrEmpty(title))
            {
                return string.Empty;
            }
            s = s.Replace("{ShareURL}", ShareURL);
            s = s.Replace("{Content}", Content + "<div><a href=\"" + ShareURL + "\">阅读全文</a> <a href=\"" + ShareURL + "#addcomment\">查看评论</a></div>");
            s = s.Replace("{title}", title);
            return s;

        }

        protected string SharePhoto(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            string ShareURL = string.Empty;
            string Content = string.Empty;
            string title = string.Empty;
            ShareURL = rootDir + "/home/album/photoview.aspx?r[0]=" + info.infoarr + "";
            SqlParameter param = new SqlParameter("@PhotoID", Convert.ToInt32(info.infoarr));
            //得到相册
            string sql = "Select FilePath,UploadUser,(select Title from NT_album where NT_album.AlbumID=Nt_photo.AlbumID) as AlbumName,(select UserName from NT_User where NT_User.UserID=Nt_photo.UploadUser) as UserName,AlbumID from Nt_photo where PhotoID=@PhotoID";
            try
            {
                string filepath=string.Empty;
                string albumName = string.Empty;
                string userName = string.Empty;
                string uID = string.Empty;
                string albumID = string.Empty;
                DataTable dt = DbHelper.ExecuteTable(CommandType.Text, sql, param);
                if (dt != null && dt.Rows.Count > 0)
                {
                    filepath = dt.Rows[0]["FilePath"].ToString();
                    albumName = dt.Rows[0]["AlbumName"].ToString();
                    userName = dt.Rows[0]["UserName"].ToString();
                    uID = dt.Rows[0]["UploadUser"].ToString();
                    albumID = dt.Rows[0]["albumID"].ToString();
                    dt.Clear(); dt.Dispose();
                }
                else
                {   
                    dt.Clear(); dt.Dispose();
                    return string.Empty;
                }
                Content = "<a href=\"" + ShareURL + "\"><img src=\"" + JuSNS.Common.Public.GetSmallPic(filepath, 0) + "\" alt=\"" + title + "\" align=\"left\"></img></a> <span class=\"padding10\">来自<a href=\"../user/" + JuSNS.Common.Public.URLWrite("", "r", uID) + "\">" + userName + "</a>的相册【<a href=\"Album/AlbumView.aspx?r[0]=" + uID + "&r[1]=" + albumID + "\">" + albumName + "</a>】</span>";
            }
            catch { }
            s = s.Replace("{ShareURL}", ShareURL);
            s = s.Replace("{Content}", Content);
            s = s.Replace("{title}", string.Empty);
            return s;
        }

        protected string ShareViode(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            string ShareURL = string.Empty;
            string title = string.Empty;
            string Content = string.Empty;
            SqlParameter param = new SqlParameter("@ID", info.cID);
            string sql = "select Url from NT_Share where ID=@ID";
            try
            {
                ShareURL = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
            }
            catch { }
            sql = "select title from NT_Share where ID=@ID";
            try
            {
                title = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
            }
            catch { }
            Content = "<embed src=\"" + ShareURL + "\" width=\"100\" height=\"80\" autostart=\"false\"></embed>";
            s = s.Replace("{Content}", Content);
            s = s.Replace("{ShareURL}", ShareURL);
            s = s.Replace("{title}", title);
            return s;
        }

        protected string ShareWeb(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            string ShareURL = string.Empty;
            string Content = string.Empty;
            string title = string.Empty;
            SqlParameter param = new SqlParameter("@ID", info.cID);
            string sql = "select URL,Description,title from NT_Share where ID=@ID";
            IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, sql, param);
            if (dr.Read())
            {
                ShareURL = dr.GetString(0);
                Content = dr.GetString(1);
                Content = Input.GetSubString(Content, 200);
                title = dr.GetString(2);
            }
            dr.Close();
            s = s.Replace("{ShareURL}", rootDir + "/home/url.aspx?url=" + JuSNS.Common.Input.URLEncode(ShareURL));
            s = s.Replace("{ShareWebURL}", ShareURL.Replace("http://",string.Empty));
            s = s.Replace("{Content}", Content);
            s = s.Replace("{title}", title);
            return s;
        }

        protected string ShareNews(UserLogInfo info,int currentUserID)
        {
            try
            {
                string s = ComParse(info, currentUserID);
                string Content = string.Empty;
                string title = string.Empty;
                string PicSTR = string.Empty;
                SqlParameter param = new SqlParameter("@ID", info.cID);
                string sql = "select URL,Description,title,(select pic from NT_News where NT_News.ID=NT_Share.CaseID) as pic,(select Title from NT_News where NT_News.ID=NT_Share.CaseID) as Title from NT_Share where ID=@ID";
                IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, sql, param);
                if (dr.Read())
                {
                    Content = Input.ForTXT(Input.FilterHTML(dr["Description"].ToString()));
                    PicSTR = dr["Pic"].ToString();
                    Content = Input.GetSubString(Content, 200) + "<div><a href=\"" + rootDir + "/news/n" + info.infoarr + ".aspx\">阅读全文</a> <a href=\"" + rootDir + "/news/n" + info.infoarr + ".aspx#Form1\">评论</a></div>";
                    title = dr["Title"].ToString();
                }
                dr.Close(); dr.Dispose();
                s = s.Replace("{ShareURL}", rootDir+"/news/n"+info.infoarr+".aspx");
                if (!string.IsNullOrEmpty(PicSTR))
                {
                    PicSTR = "<div class=\"nr image\" style=\"margin-left:10px;\"><a href=\"" + rootDir + "/news/n" + info.cID + ".aspx\"><img src=\"" + rootDir + "/" + PicSTR + "\" style=\"width:70px;\" /></a></div>";
                }
                s = s.Replace("{Content}", PicSTR + "<div class=\"nl\">" + Content+ "</div>");
                s = s.Replace("{title}", title);
                return s;
            }
            catch (Exception e)
            {
                return string.Empty;
            }
        }

        protected string ShareFriend(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info, currentUserID);
            string Content = string.Empty;
            string title = string.Empty;
            SqlParameter param = new SqlParameter("@ID", info.cID);
            string sql = "select Description,title from NT_Share where ID=@ID";
            IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, sql, param);
            if (dr.Read())
            {
                Content = dr.GetString(0);
                Content = Input.GetSubString(Content, 240);
                title = dr.GetString(1);
            }
            dr.Close();
            string ShareURL = rootDir + "/user/?r=" + info.infoarr;
            s = s.Replace("{ShareURL}", ShareURL);
            s = s.Replace("{Content}", Content);
            s = s.Replace("{title}", title);
            return s;
        }

        protected string ShareMusic(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info, currentUserID);
            string ShareURL = string.Empty;
            string Content = string.Empty;
            string title = string.Empty;
            SqlParameter param = new SqlParameter("@ID", info.cID);
            string sql = "select URL,Description,title from NT_Share where ID=@ID";
            IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, sql, param);
            ShareURL = dr.GetString(0);           
            title = dr.GetString(2);
            dr.Dispose();
            Content = "<embed src=\"" + ShareURL + "\" width=\"100px\" height=\"50px\" autostart=\"false\"></embed>";
            s = s.Replace("{ShareURL}", ShareURL);
            s = s.Replace("{Content}", Content);
            s = s.Replace("{title}", title);
            return s;
        }

        protected string ShareOther(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info, currentUserID);
            string ShareURL = string.Empty;
            string Content = string.Empty;
            string title = string.Empty;
            SqlParameter param = new SqlParameter("@ID", info.cID);
            string sql = "select URL,Description,title from NT_Share where ID=@ID";
            IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, sql, param);
            ShareURL = dr.GetString(0);
            Content = dr.GetString(1);
            Content = Input.GetSubString(Content, 50) ;
            title = dr.GetString(2);
            dr.Dispose();
            s = s.Replace("{ShareURL}", ShareURL);
            s = s.Replace("{Content}", Content);
            s = s.Replace("{title}", title);
            return s;
        }

        protected string CommentShare(UserLogInfo info,int currentUserID)
        {
            try
            {
                string s = ComParse(info, currentUserID);
                SqlParameter[] Param = new SqlParameter[1];
                Param[0] = new SqlParameter("@ID", SqlDbType.Int, 4);
                Param[0].Value = info.cID;
                string sql = "select UserID,Title,Description,ShareType,CaseID,(select Content from NT_Sharecomment where ID=" + Convert.ToInt32(info.infoarr) + ") as content from NT_Share where ID=@ID";
                DataTable dt = DbHelper.ExecuteTable(CommandType.Text, sql, Param);
                string sReplayStr = string.Empty;
                string mInfo = string.Empty;
                if (dt != null && dt.Rows.Count > 0)
                {
                    string sbTitle = dt.Rows[0]["Title"].ToString();
                    mInfo = dt.Rows[0]["content"].ToString();
                    sReplayStr = "<a href=\"" + rootDir + "/home/share/?r=" + dt.Rows[0]["UserID"].ToString() + "\">更多分享</a>";
                    s = s.Replace("{title}", "<a href=\"" + rootDir + "/home/share/links.aspx?ID=" + dt.Rows[0]["CaseID"].ToString() + "&type=" + dt.Rows[0]["ShareType"].ToString() + "&userid=" + dt.Rows[0]["UserID"].ToString() + "\">" + sbTitle + "</a>");
                    s = s.Replace("{Content}", "<div class=\"quote\"><span class=\"q\">" + Input.FilterHTML(mInfo) + "</span></div>" + sReplayStr + "");
                    s = s.Replace("{ID}", info.cID.ToString());
                }
                else
                {
                    s = string.Empty;
                }
                dt.Clear(); dt.Dispose();
                return s;
            }
            catch
            {
                return string.Empty;
            }
        }

        protected string AddMovie(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            string Content = string.Empty;
            SqlParameter param = new SqlParameter("@MovieID", info.cID);
            string sql = "select Gut from NT_Movie where MovieID=@MovieID";
            try
            {
                Content = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
            }
            catch { }
            Content = Input.GetSubString(Content, 50) ;
            s = s.Replace("{Content}", Content);
            return s;
        }

        protected string CommentMovie(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            int MovieID = 0;
            string Content = string.Empty;
            string title = string.Empty;
            SqlParameter param = new SqlParameter("@ID", info.cID);
            string sql = "select MovieID,Comment from NT_movieComment where ID=@ID";
            IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, sql, param);
            if (dr.Read())
            {
                MovieID = dr.GetInt32(0);
                Content = dr.GetString(1);
                Content = Input.GetSubString(Content, 50) ;
            }
            dr.Dispose();
            param = new SqlParameter("@MovieID", MovieID);
            sql = "Select Title from Nt_Movie where MovieID=@MovieID";
            try
            {
                title = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
            }
            catch { }
            s = s.Replace("{title}", title);
            s = s.Replace("{Content}", Content);
            s = s.Replace("{MovieID}", MovieID.ToString());
            return s;
        }

        protected string Bill(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info, currentUserID);
            string sql = "select bName from NT_Bill where ID=" + info.cID + " and UserID=" + info.User.UserID + "";
            string title = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, null));
            if (!string.IsNullOrEmpty(title))
            {
                s = s.Replace("{title}", title);
            }
            else
            {
                s = string.Empty;
            }
            return s;
        }

        protected string CommentBill(UserLogInfo info,int currentUserID)
        {
             
             string s = ComParse(info, currentUserID);
             int BillID = 0;
             string title = string.Empty;
             string Content = string.Empty;
             SqlParameter param = new SqlParameter("@ID", info.cID);
             string sql = "select bID,Title from NT_billcomment where ID=@ID";
             IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, sql, param);
             if (dr.Read())
             {
                 Content = dr.GetString(1);
                 BillID = dr.GetInt32(0);
             }
             dr.Dispose();
             param = new SqlParameter("@ID", BillID);
             sql = "select bName from Nt_Bill where ID=@ID";
             try
             {
                 title = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
             }
             catch { }
             s = s.Replace("{title}", title);
             s = s.Replace("{Content}", Content);
             s = s.Replace("{BillID}", BillID.ToString());
             return s;
        }

        protected string Friend(UserLogInfo info,int currentUserID)
        {
            string s = ComParse(info,currentUserID);
            string Content = string.Empty;
            StringBuilder sb = new StringBuilder();
            foreach (int id in info.aboutID)
            {
                string namestr = "你";
                if (id != currentUserID)
                {
                    namestr = GetUserName(id);
                }
                string str = "<a href=\"" + JuSNS.Config.UiConfig.spaceDir + "/" + JuSNS.Common.Public.URLWrite("", "r", id.ToString()) + "\" title=\"" + namestr + "\">" + namestr + "</a>";
                sb.Append(str);
                sb.Append("、");
            }
            Content = sb.ToString();
            if (Content.EndsWith("、"))
            {
                Content = Content.Substring(0,Content.Length - 1);
            }
            s = s.Replace("{Content}", Content);
            return s;
        }

        protected string CommentNews(UserLogInfo info,int currentUserID)
        {
            try
            {
                string s = ComParse(info, currentUserID);
                SqlParameter[] Param = new SqlParameter[2];
                Param[0] = new SqlParameter("@ID", SqlDbType.Int, 4);
                Param[0].Value = Convert.ToInt32(info.infoarr);
                Param[1] = new SqlParameter("@NewsID", SqlDbType.Int, 4);
                Param[1].Value = info.cID;

                DataTable dt = DbHelper.ExecuteTable(CommandType.StoredProcedure, "JuSNS_GetNewsCommentID", Param);
                string sReplayStr = string.Empty;
                string mInfo = string.Empty;
                if (dt != null && dt.Rows.Count > 0)
                {
                    string sbTitle = dt.Rows[0]["Title"].ToString();
                    string PicSTR = string.Empty;
                    mInfo = dt.Rows[0]["Content"].ToString();
                    sReplayStr = "<a href=\"" + rootDir + "/news/n" + info.cID + ".aspx\">查看热文</a> <a href=\"" + rootDir + "/news/n" + info.cID + ".aspx#Form1\">评论(" + dt.Rows[0]["ReplayNum"].ToString() + ")</a>";
                    s = s.Replace("{title}", sbTitle);
                    if (!string.IsNullOrEmpty(PicSTR) && PicSTR.Length>5)
                    {
                        PicSTR = "<div class=\"nr image\" style=\"margin-left:10px;\"><a href=\"" + rootDir + "/news/n" + info.cID + ".aspx\"><img src=\"" + rootDir + "/" + dt.Rows[0]["Pic"].ToString() + "\" style=\"width:70px;\" /></a></div>";
                    }
                    s = s.Replace("{Content}", PicSTR + "<div class=\"nl\">" + Public.CheckSma(Input.FilterHTML(mInfo))) + "</div>";
                    s = s.Replace("{ID}", info.cID.ToString());
                    s += sReplayStr;
                }
                else
                {
                    s = string.Empty;
                }
                dt.Clear(); dt.Dispose();
                return s;
            }
            catch 
            {
                return string.Empty;
            }
        }

        protected string addvote(UserLogInfo info, int currentUserID)
        {
            string s = ComParse(info, currentUserID);
            string title = string.Empty;
            string content = string.Empty;
            string sql = "select Title,Mode from NT_Vote where ID=" + info.cID;
            try
            {
                string mode = "0";
                IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, sql, null);
                if (dr.Read())
                {
                    title = dr["Title"].ToString();
                    mode = dr["Mode"].ToString();
                }
                else
                {
                    return string.Empty;
                }
                dr.Close();
                StringBuilder sb = new StringBuilder();
                List<VoteOptionInfo> list = OptionList(info.cID);

                for (int i = 0; i < list.Count && i < 2; i++)
                {
                    string o = "";
                    if (mode == "1")
                    {
                        o = "<img src=\"" + Public.rootDir + "/template/" + JuSNS.Config.UiConfig.SkinStyle + "/images/site/dyn/radio.gif\" align=\"absmiddle\" /> ";
                        sb.Append(o + Input.HtmlDecode(list[i].OptionName) + "<br />");
                    }
                    else
                    {
                        o = "<img src=\"" + Public.rootDir + "/template/" + JuSNS.Config.UiConfig.SkinStyle + "/images/site/dyn/checkbox.gif\" align=\"absmiddle\" /> ";
                        sb.Append(o + Input.HtmlDecode(list[i].OptionName) + "<br />");
                    }
                }
                content = sb.ToString();
            }
            catch
            {
                return string.Empty;
            }
            s = s.Replace("{title}", title);
            s = s.Replace("{Content}", content);            
            return s;
        }


        protected string joinvote(UserLogInfo info, int currentUserID)
        {
            string s = ComParse(info, currentUserID);
            string title = string.Empty;
            string content = string.Empty;
            string sql = "select Title,Mode from NT_Vote where ID=" + info.cID;
            try
            {
                string mode = "0";
                IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, sql, null);
                if (dr.Read())
                {
                    title=dr["Title"].ToString();
                    mode=dr["Mode"].ToString();
                }
                else
                {
                    return string.Empty;
                }
                dr.Close();
                StringBuilder sb = new StringBuilder();
                List<VoteOptionInfo> list = OptionList(info.cID);

                for (int i = 0; i < list.Count && i < 2; i++)
                {
                    string o = "";
                    if (mode == "1")
                    {
                        o = "<img src=\""+Public.rootDir+"/template/"+JuSNS.Config.UiConfig.SkinStyle+"/images/site/dyn/radio.gif\" align=\"absmiddle\" /> ";
                        sb.Append(o + Input.HtmlDecode(list[i].OptionName) + "<br />");
                    }
                    else
                    {
                        o = "<img src=\"" + Public.rootDir + "/template/" + JuSNS.Config.UiConfig.SkinStyle + "/images/site/dyn/checkbox.gif\" align=\"absmiddle\" /> ";
                        sb.Append(o + Input.HtmlDecode(list[i].OptionName) + "<br />");
                    }
                }
                content = sb.ToString();
            }
            catch
            {
                return string.Empty;
            }
            s = s.Replace("{title}", title);
            s = s.Replace("{Content}", content);
            return s;
        }

        protected string Creatask(UserLogInfo info, int currentUserID)
        {
            string s = ComParse(info, currentUserID);
            string sql = "select Title,Content from NT_ask where ID=" + info.cID + "";
            IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, sql, null);
            string Title = string.Empty;
            string id = info.cID.ToString();
            string ContentStr = string.Empty;
            if (dr.Read())
            {
                Title = dr["title"].ToString();
                ContentStr = dr["Content"].ToString();
            }
            dr.Close();
            s = s.Replace("{title}", Title);
            s = s.Replace("{ID}", id);
            s = s.Replace("{Content}", Input.GetSubString(Input.FilterHTML(ContentStr), 140));
            return s;
        }

        protected string ReplayAsk(UserLogInfo info, int currentUserID)
        {
            string s = ComParse(info, currentUserID);
            string sql = "select a.Title,a.Content from NT_ask a where a.ID=" + info.cID + "";
            IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, sql, null);
            string Title = string.Empty;
            string id = info.cID.ToString();
            string ContentStr = string.Empty;
            if (dr.Read())
            {
                Title = dr["title"].ToString();
                ContentStr = "<div class=\"quote\"><span class=\"q\">" + Input.GetSubString(Input.FilterHTML(DbHelper.ExecuteScalar(CommandType.Text, "select Content from NT_ask where ID=" + Convert.ToInt32(info.infoarr) + "", null).ToString()), 140) + "</span></div>";
            }
            dr.Close();
            s = s.Replace("{title}", Title);
            s = s.Replace("{sID}", id);
            s = s.Replace("{Content}",ContentStr);
            return s;
        }

        protected string askBest(UserLogInfo info, int currentUserID)
        {
            string s = ComParse(info, currentUserID);
            string sql = "select a.Title,a.Content from NT_ask a where a.ID=" +Convert.ToInt32(info.infoarr) + "";
            IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, sql, null);
            string Title = string.Empty;
            string ContentStr = string.Empty;
            if (dr.Read())
            {
                Title = dr["title"].ToString();
                ContentStr = "<div class=\"quote\"><span class=\"q\">" + Input.GetSubString(Input.FilterHTML(DbHelper.ExecuteScalar(CommandType.Text, "select Content from NT_ask where ID=" +info.cID + "", null).ToString()), 140) + "</span></div>";
            }
            dr.Close();
            s = s.Replace("{title}", Title);
            s = s.Replace("{sID}", info.infoarr);
            s = s.Replace("{Content}", ContentStr);
            return s;
        }

        public List<VoteOptionInfo> OptionList(int VoteID)
        {
            List<VoteOptionInfo> list = new List<VoteOptionInfo>();
            string Sql = "Select [ID],[VoteID],[OptionName],[Cnt] From [NT_VoteOption] Where [VoteID]=" + VoteID;
            IDataReader rd = DbHelper.ExecuteReader(CommandType.Text, Sql, null);
            while (rd.Read())
            {
                VoteOptionInfo info = new VoteOptionInfo();
                info.ID = Convert.ToInt32(rd["ID"].ToString());
                info.VoteID = Convert.ToInt32(rd["VoteID"].ToString());
                if (rd["OptionName"] != DBNull.Value) info.OptionName = rd["OptionName"].ToString();
                info.Cnt = Convert.ToInt32(rd["Cnt"].ToString());
                list.Add(info);
            }
            rd.Close();
            return list;
        }


        private string GetUserName(int userid)
        {
            SqlParameter param = new SqlParameter("@UserID", userid);
            string sql = "select UserName from Nt_User where UserID=@UserID";
            string str = string.Empty;
            try
            {
                str = Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, sql, param));
            }
            catch { }
            return str;
        }
    }
}
