using System;
using System.Collections.Generic;
using System.Data;
namespace Stat.web.v
{
    /// <summary>
    /// 
    /// </summary>
    public partial class SNReferer : System.Web.UI.Page
    {
        /// <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 = 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("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();
            }
        }
        /// <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.ViewOnClick> list = BLL.ViewUrlFrom.GetNItem(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();
            }
        }
    }
}
