using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using Stat.SQLServerDAL.CommonParmeters;
using Stat.DBUtility;
namespace Stat.SQLServerDAL
{
    class ViewUrlPage : IDAL.IViewUrlPage
    {
        #region IViewUrlPage 成员

        /// <summary>
        /// 
        /// </summary>
        /// <param name="model"></param>
        /// <returns>Juju 2011-10-27</returns>
        public List<Model.StatItem> GetList(Stat.Model.StatInfo model)
        {
            model.TableName = "ViewUrlPage";
            model.Cells = "UrlPage,pvCount,ipCount,uvCount,nuvCount,timCount,otimCount,vYear,vMonth,vDay";
            return StatItem.GetList(Common.GetViewItemData(model), "UrlPage", 1);
        }
        #endregion
        #region IViewOnClick 成员 ：PV STAT
        public List<Model.ViewItem_String> GetItem(global::Stat.Model.StatInfo model)
        {
            model.TableName = "View_" + model.StartTime.Year + "_" + model.StartTime.Month + "_" + model.StartTime.Day;
            model.Cells = "top 10000 [id],IP,Mac,UrlPage,View_Alone";
            SqlParameter[] parms = ViewItemParmeters.SetSqlParmeter(model);
            DataTable dt = SqlHelper.ExecuteDataTable(SqlHelper.ConnectionStringGather(model.GatherID), CommandType.StoredProcedure, "Stat_ViewClickLoadUrlPageByRandom", parms);
            return ViewItems.GetString.GetList(dt, "UrlPage");
        }

        #endregion

        /// <summary>
        /// 已经过时
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        /// <remarks>Juju 2011-10-24</remarks>
        [System.Obsolete("The method is obsolete will be remove", true)]
        public DataTable GetNUrlPage(global::Stat.Model.StatInfo model)
        {
            model.Cells = "top 10000 IP,ViewTime,UrlPage,UrlFrom";
            SqlParameter[] parms = ViewItemParmeters.SetSqlParmeter(model);
            parms[5].Value = model.CurrentUrl ?? "";
            return SqlHelper.ExecuteDataTable(SqlHelper.ConnectionStringGather(model.GatherID), CommandType.StoredProcedure, "Stat_ViewClickLoadPageByWebid", parms);
        }

    }
}
