using System;
using System.Collections.Generic;
namespace Stat.web.v
{
    /// <summary>
    /// 
    /// </summary>
    /// <remarks>By ： Juju 2010-12-11</remarks>
    public partial class SRPage : System.Web.UI.Page
    {
        Model.PageInfo pageModel = new Stat.Model.PageInfo(100);
        /// <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;
                pageModel.PageIndex = Plugin.Common.Rq_Int("page");
                pageModel.PageIndex = pageModel.PageIndex < 1 ? 1 : pageModel.PageIndex;
                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()
        {
            ShowHtml(BLL.ViewUrlFrom.Get(statModel));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="list"></param>
        protected void ShowHtml(List<Model.StatItem> list)
        {
            string strdtRPageList = Stat.Html.RPage.GetList(list, pageModel.PageIndex, pageModel.PageSize);
            this.LtrRPageList.Text = strdtRPageList;
            Response.Flush();
            if (list.Count > pageModel.PageSize)
            {
                string urlPar = "wid=" + statModel.WebID + "&st=" + statModel.strStartTime + "&et=" + statModel.strEndTime;
                this.LtrRpagePageIndex.Text = JPageIndex.GetIndex.Get(list.Count, pageModel.PageIndex, pageModel.PageSize, urlPar, 1, 0, 1, 6);

                Response.Flush();
            }
        }
    }
}
