using System.Collections.Generic;

namespace Stat.Html
{
    public class DayList
    {
        /// <summary>
        /// 每日数据列表（HTML）
        /// </summary>
        /// <param name="list"></param>
        /// <param name="cPage"></param>
        /// <returns></returns>
        public static string Get(List<Model.ViewDay> list, int pageIndex, int pageSize, int webid)
        {

            int st = (pageIndex - 1) * pageSize;
            st = st > list.Count ? list.Count : st;
            int et = st + pageSize;
            et = et > list.Count ? list.Count : et;

            System.Text.StringBuilder tep = new System.Text.StringBuilder();
            if (list != null && list.Count > 0)
            {
                tep.Append(" <table bgcolor=\"#cedfef\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"100%\" class=\"padding\">");
                tep.Append(" <tr>");
                tep.Append("   <td bgcolor=\"#e9f1fa\" width=\"13%\" align=\"center\"  height=\"25\">&nbsp;<strong>日 期</strong></td>");
                tep.Append("   <td bgcolor=\"#e9f1fa\" width=\"10%\" align=\"right\" ><strong>PV</strong>&nbsp;</td>");
                tep.Append("   <td bgcolor=\"#e9f1fa\" width=\"10%\" align=\"right\" ><strong>IP</strong>&nbsp;</td>");
                tep.Append("   <td bgcolor=\"#e9f1fa\" width=\"10%\" align=\"right\" ><strong>独立访客</strong>&nbsp;</td>");
                tep.Append("   <td bgcolor=\"#e9f1fa\" width=\"10%\" align=\"right\" ><strong>新访客</strong>&nbsp;</td>");
                tep.Append("   <td bgcolor=\"#e9f1fa\" width=\"10%\" align=\"right\" ><strong>访问次数</strong>&nbsp;</td>");
                tep.Append("   <td bgcolor=\"#e9f1fa\" width=\"10%\" align=\"right\" ><strong>回访次数</strong>&nbsp;</td>");
                tep.Append("   <td bgcolor=\"#e9f1fa\" width=\"10%\" align=\"right\" ><strong>人均PV</strong>&nbsp;</td>");
                tep.Append("    <td bgcolor=\"#e9f1fa\" width=\"*\" align=\"left\"  >&nbsp;<strong>PV比例</strong></td>");
                tep.Append("  </tr>");


                for (int i = st; i < et; i++)
                {
                    if (pageIndex == 1 && i == 0 && list.Count > 1)
                    {
                        tep.Append("<tr bgcolor=\"#FFFFFF\" onmouseover=\"this.style.backgroundColor='#EEF3F9';\" onmouseout=\"this.style.backgroundColor='#FFFFFF';\">");
                        tep.Append(" <td align=\"center\" height=23 class=\"blud14\">&nbsp;总&nbsp;&nbsp;计&nbsp;</td>");
                        tep.Append(" <td align=\"right\"><a href=\"Vpage.aspx?wid=" + webid + "&st=" + list[1].vYear + "-" + list[1].vMonth + "-" + list[1].vDay + "&et=" + list[et - 1].vYear + "-" + list[et - 1].vMonth + "-" + list[et - 1].vDay + "\" title=\"查看\"><span class=\"blud14\">" + list[0].pvCount + "</span></a></td>");
                        tep.Append(" <td align=\"right\"><a href=\"vIP.aspx?wid=" + webid + "&st=" + list[1].vYear + "-" + list[1].vMonth + "-" + list[1].vDay + "&et=" + list[et - 1].vYear + "-" + list[et - 1].vMonth + "-" + list[et - 1].vDay + "\" title=\"查看\"><span class=\"blud14\">" + list[0].ipCount + "</span></a></td>");
                        tep.Append(" <td align=\"right\"><span class=\"blud14\">" + list[0].cusCount + "</span></td>");
                        tep.Append(" <td align=\"right\"><span class=\"blud14\">" + list[0].newCount + "</span></td>");
                        tep.Append(" <td align=\"right\"><span class=\"blud14\">" + list[0].timCount + "</span></td>");
                        tep.Append(" <td align=\"right\"><span class=\"blud14\">" + list[0].otimCount + "</span></td>");
                        tep.Append(" <td align=\"right\"><span class=\"blud14\">" + list[0].AVG.ToString("0.0") + "</span></td>");
                        tep.Append(" <td align=\"left\" >&nbsp;-</td>");
                        tep.Append("</tr>");
                    }
                    else
                    {
                        tep.Append("<tr bgcolor=\"#FFFFFF\" onmouseover=\"this.style.backgroundColor='#EEF3F9';\" onmouseout=\"this.style.backgroundColor='#FFFFFF';\">");
                        tep.Append(" <td align=\"center\" height=23>" + list[i].vYear + "年" + list[i].vMonth + "月" + list[i].vDay + "日</td>");
                        tep.Append(" <td align=\"right\" height=20><a href=\"Vpage.aspx?wid=" + webid + "&st=" + list[i].vYear + "-" + list[i].vMonth + "-" + list[i].vDay + "&et=" + list[i].vYear + "-" + list[i].vMonth + "-" + list[i].vDay + "\" title=\"查看\"><span class=\"red14\">" + list[i].pvCount + "</span></a></td>");
                        tep.Append(" <td align=\"right\" height=20><a href=\"vIP.aspx?wid=" + webid + "&st=" + list[i].vYear + "-" + list[i].vMonth + "-" + list[i].vDay + "&et=" + list[i].vYear + "-" + list[i].vMonth + "-" + list[i].vDay + "\" title=\"查看\"><span class=\"red14\">" + list[i].ipCount + "</span></a></td>");
                        tep.Append(" <td align=\"right\" height=20><span class=\"red14\">" + list[i].cusCount + "</span></td>");
                        tep.Append(" <td align=\"right\" height=20>" + list[i].newCount + "</td>");
                        tep.Append(" <td align=\"right\">" + list[i].timCount + "</td>");
                        tep.Append(" <td align=\"right\">" + list[i].otimCount + "</td>");
                        tep.Append(" <td align=\"right\" height=20>" + list[i].AVG.ToString("0.0") + "</td>");
                        tep.Append(" <td align=\"left\" height=20><img src=\"Images/bar1.gif\" height=\"10\" width=\"" + list[i].Percent.ToString("0") + "\" />" + list[i].Percent.ToString("0.00") + "%</td>");
                        tep.Append("</tr>");
                    }
                }
                /*--------------------------------------------------------*/
                tep.Append("</table>");
            }
            return tep.ToString();
        }       
    }
}
