using System;
using System.Collections.Generic;
namespace Stat.web.v
{
    /// <summary>
    /// 
    /// </summary>
    /// <remarks>By : Juju 2010-12-11</remarks>
    public partial class SAlexa : System.Web.UI.Page
    {
        /// <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 = Plugin.Common.Rq_Int("wid");
            IList<Model.WebSites> website = Stat.Cache.CacheFatory.CreateWebSite().Get(statModel.WebID);
            if (website.Count > 0)
            {
                this.Page.Title = "Alexa安装情况 " + website[0].WebName;
                //
                statModel.StartTime = Plugin.Common.Rq_DateTime("st");
                statModel.EndTime = Plugin.Common.Rq_DateTime("et");
                //
                DateTime dtNow = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                statModel.EndTime = statModel.EndTime > dtNow ? dtNow : statModel.EndTime;
                statModel.StartTime = statModel.StartTime > statModel.EndTime ? statModel.EndTime : statModel.StartTime;
                //
                Show();
            }
        }

        /// <summary>
        /// 
        /// </summary>
        protected void Show()
        {
            List<Model.StatItem> list = Stat.Items.Alexa.Get(BLL.ViewAlexa.Get(statModel));
            ShowReport(list);
            ShowHtml(list);
        }
        /// <summary>
        /// 
        /// </summary>
        protected void ShowHtml(List<Model.StatItem> list)
        {
            this.LtrAlexaList.Text = Html.ItemList.Get(list, statModel.WebID, "Alexa插件安装", "ax", statModel.StartTime.ToShortDateString(), statModel.EndTime.ToShortDateString());
            Response.Flush();
        }

        /// <summary>
        /// 获取数据
        /// </summary>
        protected void ShowReport(List<Model.StatItem> list)
        {
            //生成报表
            string strXML = Stat.Report.Rp_3_Pie3D.GetXML(list, "Alexa插件安装情况", "(" + statModel.StartTime.ToLongDateString() + "--" + statModel.EndTime.ToLongDateString() + ")", 0, "PV");
            this.LtrRp_Alexa.Text = BLL.StatCharts.RenderChart("../StatCharts/Pie3D.swf", "", strXML, "chartBrows", "99", "300", false, false);
            Response.Flush();
        }
    }
}
