using System;
using System.Collections.Generic;
using System.Data;
namespace Stat.web.v
{
    /// <summary>
    /// 
    /// </summary>
    /// <remarks>Juju 2011-10-26</remarks>
    public partial class SOnLinePage : 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 = base.PageIndex;
                statModel.CurrentUrl = Plugin.Common.Rq("pUrl");
                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;
            /*-------------------------------------------------------------------------------------*/
            DataTable dtPage = BLL.ViewOnLine.GetStayPage(statModel);
            this.LtrOnPageList.Text = Stat.Html.OnPage.Get(dtPage, statModel.WebID, pageModel.PageIndex, pageModel.PageSize);
            Response.Flush();
            if (dtPage != null && dtPage.Rows.Count > 0)
            {
                string urlPar = "wid=" + statModel.WebID + "&ip=" + statModel.IP + "&pUrl=" + statModel.CurrentUrl;
                this.LtrOnPagePageIndex.Text = JPageIndex.GetIndex.Get(dtPage.Rows.Count, pageModel.PageIndex, pageModel.PageSize, urlPar, 1, 0, 1, 6);
                Response.Flush();
            }
        }
    }
}
