using System.Collections.Generic;
using System.Text;

namespace Stat.Report
{
    /// <summary>
    /// 多线性报表
    /// </summary>
    public class Rp_3_MSLine
    {
        /// <summary>
        /// 小时流量分布
        /// </summary>
        /// <param name="list">数据源</param>
        /// <param name="caption">标题</param>
        /// <param name="subcaption">副标题</param>
        /// <param name="showValues"></param>
        /// <returns></returns>
        public static string GetXML_vHour(List<Model.ViewDay> list, string caption, string subcaption, int showValues)
        {

            StringBuilder strXML = new System.Text.StringBuilder();

            strXML.Append("<chart caption='" + caption + "' subcaption='" + subcaption + "' lineThickness='2' showValues='" + showValues + "' formatNumberScale='0' anchorRadius='2'");
            strXML.Append(" divLineIsDashed='1' showAlternateHGridColor='1'");
            strXML.Append(" shadowAlpha='40' labelStep='1' numvdivlines='5' bgColor='FFFFFF' bgAngle='270' bgAlpha='10,10'");
            strXML.Append(" alternateHGridAlpha='5' alternateHGridColor='CC3300' divLineColor='CC3300' divLineAlpha='20' ");
            strXML.Append(" captionPadding='3' chartTopMargin='5' chartBottomMargin='10' chartLeftMargin='10' chartRightMargin='10'");

            strXML.Append(" canvasBorderColor='FFCEBD' baseFontColor='000000' bgColor='FFFFFF' showBorder='0'>");
            if (list != null && list.Count > 23)
            {
                /*------------------------------------------------*/
                strXML.Append("<categories >");
                for (int i = 0; i < 24; i++)
                {
                    strXML.Append("<category label='" + i.ToString() + "时' />");
                }
                strXML.Append("</categories>");
                /*------------------------------------------------*/
                strXML.Append("<dataset seriesName='P V' color='1D8BD1' anchorBorderColor='1D8BD1' anchorBgColor='1D8BD1'>");
                for (int i = 0; i < 24; i++)
                {
                    strXML.Append("	<set value='" + list[i].pvCount + "'");
                    strXML.Append(" toolText='" + i + "时：共 " + list[i].pvCount + " PV' />");
                }
                strXML.Append("	</dataset>");
                /*------------------------------------------------*/
                strXML.Append("<dataset seriesName='I P' color='F1683C' anchorBorderColor='F1683C' anchorBgColor='F1683C'>");
                for (int i = 0; i < 24; i++)
                {
                    strXML.Append("	<set value='" + list[i].ipCount + "'");
                    strXML.Append(" toolText='" + i + "时：共 " + list[i].ipCount + " IP' />");
                }
                strXML.Append("</dataset>");
                /*------------------------------------------------*/
                //strXML.Append("<dataset seriesName='独立访客' color='2AD62A' anchorBorderColor='2AD62A' anchorBgColor='2AD62A'>");
                //for (int i = 0; i < 24; i++)
                //{
                //    strXML.Append("	<set value='" + list[i].cusCount + "'");
                //    strXML.Append(" toolText='" + i + "时：共 " + list[i].cusCount + " 独立访客，其中 " + list[i].newCount + " 位是新访客' />");
                //}
                //strXML.Append("</dataset>");

                /*------------------------------------------------*/
                strXML.Append("<dataset seriesName='来访次数' color='DBDC25' anchorBorderColor='DBDC25' anchorBgColor='DBDC25'>");
                for (int i = 0; i < 24; i++)
                {
                    strXML.Append("	<set value='" + list[i].timCount + "'");
                    strXML.Append(" toolText='" + i + "时：共 " + list[i].timCount + " 次来访，其中 " + list[i].otimCount + " 次是回访' />");
                }
                strXML.Append("</dataset>");
            }
            /*------------------------------------------------*/
            strXML.Append("	<styles>  ");
            strXML.Append("		<definition>");
            strXML.Append("			<style name='CaptionFont' type='font' size='14'/>");
            strXML.Append("		</definition>");
            strXML.Append("		<application>");
            strXML.Append("			<apply toObject='CAPTION' styles='CaptionFont' />");
            strXML.Append("			<apply toObject='SUBCAPTION' styles='CaptionFont' />");
            strXML.Append("		</application>");
            strXML.Append("	</styles>");
            /*------------------------------------------------*/
            strXML.Append("</chart>");

            return strXML.ToString();

        }
        /*---------------------------------------------------------------------------------------*/
        /// <summary>
        /// 在线流量分布
        /// </summary>
        /// <param name="dt">数据源</param>
        /// <param name="caption">标题</param>
        /// <param name="subcaption">副标题</param>
        /// <param name="showValues">（0）</param>
        /// <returns></returns>
        public static string GetXML_OnLine(List<Model.StatItem> list, string caption, string subcaption, int showValues)
        {

            StringBuilder strXML = new System.Text.StringBuilder();

            strXML.Append("<chart caption='" + caption + "' subcaption='" + subcaption + "' lineThickness='2' showValues='" + showValues + "' formatNumberScale='0' anchorRadius='2'");
            strXML.Append(" divLineIsDashed='1' showAlternateHGridColor='1'");
            strXML.Append(" shadowAlpha='40' labelStep='1' numvdivlines='5' bgColor='FFFFFF' bgAngle='270' bgAlpha='10,10'");
            strXML.Append(" alternateHGridAlpha='5' alternateHGridColor='CC3300' divLineColor='CC3300' divLineAlpha='20' ");
            strXML.Append(" captionPadding='3' chartTopMargin='5' chartBottomMargin='10' chartLeftMargin='10' chartRightMargin='10'");

            strXML.Append(" canvasBorderColor='FFCEBD' baseFontColor='000000' bgColor='FFFFFF' showBorder='0'>");
            if (list != null && list.Count > 1)
            {
                /*------------------------------------------------*/
                strXML.Append("<categories >");
                for (int i = 1; i < list.Count; i++)
                {
                    strXML.Append("<category label='" + list[i].Name + "' />");
                }
                strXML.Append("</categories>");
                /*------------------------------------------------*/
                strXML.Append("<dataset seriesName='P V' color='1D8BD1' anchorBorderColor='1D8BD1' anchorBgColor='1D8BD1'>");
                for (int i = 1; i < list.Count; i++)
                {
                    strXML.Append("	<set value='" + list[i].PvCount + "'");
                    strXML.Append(" toolText='" + list[i].Name + "：共 " + list[i].PvCount + " PV' />");
                }
                strXML.Append("	</dataset>");
                /*------------------------------------------------*/
                strXML.Append("<dataset seriesName='I P' color='F1683C' anchorBorderColor='F1683C' anchorBgColor='F1683C'>");
                for (int i = 1; i < list.Count; i++)
                {
                    strXML.Append("	<set value='" + list[i].IpCount + "'");
                    strXML.Append(" toolText='" + list[i].Name + "：共 " + list[i].IpCount + " IP' />");
                }
                strXML.Append("</dataset>");
                /*------------------------------------------------*/
                strXML.Append("<dataset seriesName='U V' color='2AD62A' anchorBorderColor='2AD62A' anchorBgColor='2AD62A'>");
                for (int i = 1; i < list.Count; i++)
                {
                    strXML.Append("	<set value='" + list[i].UvCount + "'");
                    strXML.Append(" toolText='" + list[i].Name + "：共 " + list[i].UvCount + " 独立访客' />");
                }
                strXML.Append("</dataset>");
            }
            /*------------------------------------------------*/
            strXML.Append("	<styles>  ");
            strXML.Append("		<definition>");
            strXML.Append("			<style name='CaptionFont' type='font' size='12'/>");
            strXML.Append("		</definition>");
            strXML.Append("		<application>");
            strXML.Append("			<apply toObject='CAPTION' styles='CaptionFont' />");
            strXML.Append("			<apply toObject='SUBCAPTION' styles='CaptionFont' />");
            strXML.Append("		</application>");
            strXML.Append("	</styles>");
            /*------------------------------------------------*/
            strXML.Append("</chart>");

            return strXML.ToString();

        }

    }
}
