using System;
using System.Collections.Generic;
using System.Data;
namespace Stat.web.v
{
    /// <summary>
    /// 
    /// </summary>
    /// <remarks>Juju 2011-10-26</remarks>
    public partial class SNReferer : Html.ReportPage
    {
        /// <summary>
        /// 
        /// </summary>
        protected Model.StatInfo statModel = new Stat.Model.StatInfo();
        Model.PageInfo pageModel = new Stat.Model.PageInfo(50);

        /// <summary>
        /// 
        /// </summary>
        protected Int64 totaliPV = 0, totaliIP = 0, totaliUV = 0;
        /// <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;
                //
                pageModel.PageIndex = Plugin.Common.Rq_Int("cp");
                pageModel.PageIndex = pageModel.PageIndex < 1 ? 1 : pageModel.PageIndex;
                statModel.LastUrl = Plugin.Common.Rq("fUrl");
                statModel.IP = Plugin.Common.Rq("ip");
                //
                statModel.StartTime = DateTime.Now.AddMinutes(-20);  //赋值到文本框 
                statModel.EndTime = DateTime.Now;
                //
                Show();
            }
            else
            {
                Response.Write("该站点不存在！");
                Response.End();
            }
        }
        /// <summary>
        /// 获取数据
        /// </summary>
        protected void Show()
        {
            List<Model.StatItem> listOnLine = BLL.ViewOnLine.Get(statModel);
            string strOnLineXML = Stat.Report.Rp_3_MSLine.GetXML_OnLine(listOnLine, "当前用户活动情况", "", 0);
            this.LtrRp_Online.Text = BLL.StatCharts.RenderChart("../StatCharts/MSLine.swf", "", strOnLineXML, "chartOnline", "99", "220", false, false);
            Response.Flush();
            totaliPV = listOnLine[0].PvCount;
            totaliIP = listOnLine[0].IpCount;
            totaliUV = listOnLine[0].UvCount;
            /*----------------------------------------------------------------------------------*/
            List<Model.ViewClick> list = BLL.ViewOnLine.GetReferer(statModel);
            this.LtrOnRefererList.Text = Stat.Html.OnReferer.Get(list, statModel.WebID, pageModel.PageIndex, pageModel.PageSize);
            Response.Flush();
            if (list != null && list.Count > 0)
            {
                string par = "wid=" + statModel.WebID + "&ip=" + statModel.IP + "&fUrl=" + statModel.LastUrl;
                this.LtrOnRefererPageIndex.Text = JPageIndex.GetIndex.Get(list.Count, pageModel.PageIndex, pageModel.PageSize, par, 1, 0, 1, 5);
                Response.Flush();
            }
        }
    }
}
