using System.Data;

namespace Stat.Html
{
   public class OnPage
    {
        /// <summary>
        /// 用户停留页面数据列表（HTML）
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="cPage"></param>
        /// <param name="pSize"></param>
        /// <returns></returns>
        public static string Get(DataTable dt,int webid, int cPage, int pSize)
        {
            System.Text.StringBuilder tep = new System.Text.StringBuilder();
            if (dt != null && dt.Rows.Count > 0)
            {
                /*--------------------------------------------------------*/
                int st = (cPage - 1) * pSize;
                st = st > dt.Rows.Count ? dt.Rows.Count : st;
                int et = st + pSize;
                et = et > dt.Rows.Count ? dt.Rows.Count : et;
                /*--------------------------------------------------------*/

                for (int i = st; i < et; i++)
                {
                    tep.Append(" <table bgcolor=\"#cedfef\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"100%\" class=\"padding\">");
                    tep.Append(" <tr>");
                    tep.Append("   <td bgcolor=\"#e9f1fa\" width=\"60\" align=\"left\"  height=\"25\"><strong>用户</strong></td>");
                    tep.Append("   <td bgcolor=\"#e9f1fa\" width=\"120\" align=\"left\"><strong>I P</strong></td>");
                    tep.Append("   <td bgcolor=\"#e9f1fa\" width=\"120\" align=\"left\" ><strong>访问时间</strong></td>");
                    tep.Append("   <td bgcolor=\"#e9f1fa\" width=\"*\" align=\"left\" class=\"zdhh\"><strong>来源：" + dt.Rows[i]["UrlFrom"] + "</strong></td>");
                    tep.Append("  </tr>");

                    tep.Append("<tr bgcolor=\"#FFFFFF\" onmouseover=\"this.style.backgroundColor='#EEF3F9';\" onmouseout=\"this.style.backgroundColor='#FFFFFF';\">");

                    tep.Append(" <td align=\"left\" height=25>&nbsp;" + (i + 1) + "</td>");
                    tep.Append(" <td align=\"left\" ><a href=\"Vpage.aspx?wid=" + webid + "&ip=" + dt.Rows[i]["IP"] +"\" title=\"追踪该IP\"><span class=\"red14\">" + dt.Rows[i]["IP"] + "</span></a></td>");
                    tep.Append(" <td align=\"left\" ><span >" + dt.Rows[i]["ViewTime"] + "</span></td>");
                    tep.Append(" <td align=\"left\" class=\"zdhh\">停留：<a href=\"" + dt.Rows[i]["UrlPage"] + "\" target=\"_blank\"><span class=\"red14\">" + dt.Rows[i]["UrlPage"] + "</span></a></td>");


                    tep.Append("</tr>");

                    /*--------------------------------------------------------*/
                    tep.Append("</table><br>");
                }

            }



            return tep.ToString();
        }
    }
}
