using System;
using System.Collections.Generic;
using System.Data;
namespace Stat.web.v
{
    /// <summary>
    /// 
    /// </summary>
    public partial class SOnLinePage : 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("page");
                pageModel.PageIndex = pageModel.PageIndex < 1 ? 1 : pageModel.PageIndex;
                statModel.CurrentUrl = Plugin.Common.Rq("pUrl");
                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;
            /*-------------------------------------------------------------------------------------*/
            DataTable dtPage = BLL.ViewPage.GetSItem(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();
            }
        }
    }
}
