using System.Collections.Generic;

namespace Stat.Html
{
   public class OnReferer
    {
        /// <summary>
        /// 来源页面数据列表（HTML）
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="cPage"></param>
        /// <param name="pSize"></param>
        /// <returns></returns>
       public static string Get(List<Model.ViewOnClick> list, int webid, int cPage, int pSize)
        {
            System.Text.StringBuilder tep = new System.Text.StringBuilder();
            if (list != null && list.Count > 0)
            {
                int st = (cPage - 1) * pSize;
                st = st > list.Count ? list.Count : st;
                int et = st + pSize;
                et = et > list.Count ? list.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=\"40\" 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>站内入口：" + list[i].CurrentUrl+ "</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=" + list[i].IP + "\" title=\"追踪该IP\" > <span class=\"red14\">" + list[i].IP + "</span></a></td>");
                    tep.Append(" <td align=\"left\" ><span >" + list[i].ViewTime + "</span></td>");
                    tep.Append(" <td align=\"left\" class=\"zdhh\">外部来源：<a href=\"" + list[i].LastUrl + "\" target=\"_blank\"><span class=\"red14\">" + GetFrom(list[i].LastUrl) + "</span></a></td>");


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

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

            }



            return tep.ToString();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        private static string GetFrom(string o)
        {
            if (o == null || o == "")
            {
                return "用户直接输入网址 or 书签";
            }
            else
            {
                return o;
            }
        }
    }
}
