using System;
using System.Collections;
using System.Collections.Generic;
namespace Stat.web.v
{
    /// <summary>
    /// 
    /// </summary>
    public partial class Hour : System.Web.UI.Page
    {
        Stat.Cache.IConfig config = Stat.Cache.CacheFatory.CreateConfig();
        /// <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");
            //
            Stat.Security.ISecurity security = Stat.Security.DataFatory.CreateSecurity();
            security.CheckReportPower(statModel.WebID);
            //
            IList<Model.WebSites> website = Stat.Cache.CacheFatory.CreateWebSite().Get(statModel.WebID);
            if (website.Count > 0)
            {
                this.Page.Title = "小时统计 " + 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()
        {
            int hourBreak = config.GetStatHourPostpone();
            //小时数据
            List<Model.ViewDay> list = BLL.ViewHour.Get24Hour(statModel, hourBreak);
            //报表
            string strSubTitle = "(" + statModel.StartTime.ToShortDateString() + "- -" + statModel.EndTime.ToShortDateString() + ")";
            string strHourXML = Stat.Report.Rp_3_MSLine.GetXML_vHour(list, "24小时访问分布图", strSubTitle, 0);
            this.LtrRp_Hour.Text = BLL.StatCharts.RenderChart("../StatCharts/MSLine.swf", "", strHourXML, "chartHour", "99", "280", false, false);
            Response.Flush();
            //Html
            this.LtrHourList.Text = Stat.Html.HourList.Get(list);
            Response.Flush();
        }
    }
}
