using System;
using System.Collections.Generic;
namespace Stat.web.v
{
    /// <summary>
    /// 
    /// </summary>
    /// <remarks>By ：Juju 2010-10-26</remarks>
    public partial class SEngine : Html.ReportPage
    {
        /// <summary>
        /// 
        /// </summary>
        protected Model.StatInfo statModel = new Stat.Model.StatInfo();
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            statModel.WebID = base.Webid;
            //
            Model.WebSites websiteModel = base.Website;
            if (websiteModel.WebId > 0)
            {
                this.Page.Title = "搜索引擎分析 " + websiteModel.WebName;
                statModel.GatherID = websiteModel.GatherServerID;
                statModel.StartTime = base.StartTime;
                statModel.EndTime = base.EndTime;
                //
                Show();
            }
            else
            {
                Response.Write("该站点不存在！");
                Response.End();
            }
        }

        /// <summary>
        /// 
        /// </summary>
        protected void Show()
        {
            IList<Model.StatItem> dtEngine = BLL.ViewEngine.GetList(statModel);
            ShowReport(dtEngine);
            ShowHtml(dtEngine);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dt"></param>
        protected void ShowHtml(IList<Model.StatItem> dt)
        {
            this.LtrEngineList.Text = Stat.Html.Engine.Get(dt, statModel.WebID, statModel.StartTime.ToShortDateString(), statModel.EndTime.ToShortDateString());
            Response.Flush();
        }

        /// <summary>
        /// 
        /// </summary>
        protected void ShowReport(IList<Model.StatItem> dt)
        {
            string strXML = Stat.Report.Rp_3_Pie3D.GetXML_Engine(dt, "搜索引擎", "(" + statModel.StartTime.ToLongDateString() + "--" + statModel.EndTime.AddDays(-1).ToLongDateString() + ")", 0, "PV");
            this.LtrRp_Engine.Text = BLL.StatCharts.RenderChart("../StatCharts/Pie3D.swf", "", strXML, "chartEngine", "99", "300", false, false);
            Response.Flush();
        }
    }
}
