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

        public IList<Stat.Model.ViewTop> Get(int webid)
        {
            SqlParameter parms=new SqlParameter("@Webid",SqlDbType.Int);
            parms.Value=webid;
           return GetList(Stat.DBUtility.SqlHelper.ExecuteDataTable(DBUtility.SqlHelper.ConnectionStringMaster,CommandType.StoredProcedure,"Stat_ViewTopLoadByWebid",parms));
           
        }
        #endregion

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        private List<Model.ViewTop> GetList(System.Data.DataTable table)
        {
            List<Model.ViewTop> list = new List<Model.ViewTop>();
            if (table != null)
            {
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    list.Add(GetModel(table.Rows[i]));
                }
            }
            return list;
        }
        /// <summary>
        /// 将记录集转为实体类
        /// </summary>
        /// <param name="dr">记录集</param> 
        /// <returns></returns>
        private Model.ViewTop GetModel(System.Data.DataRow dr)
        {
            Model.ViewTop nc = new Model.ViewTop();

            if (dr.Table.Columns.Contains("id") && !Convert.IsDBNull(dr["id"])) nc.id = Convert.ToInt32(dr["id"]); // id
            if (dr.Table.Columns.Contains("webid") && !Convert.IsDBNull(dr["webid"])) nc.webid = Convert.ToInt32(dr["webid"]); // webid
            if (dr.Table.Columns.Contains("pvCount") && !Convert.IsDBNull(dr["pvCount"])) nc.pvCount = Convert.ToInt64(dr["pvCount"]); // pvCount
            if (dr.Table.Columns.Contains("ipCount") && !Convert.IsDBNull(dr["ipCount"])) nc.ipCount = Convert.ToInt64(dr["ipCount"]); // ipCount
            if (dr.Table.Columns.Contains("uvCount") && !Convert.IsDBNull(dr["uvCount"])) nc.uvCount = Convert.ToInt64(dr["uvCount"]); // uvCount
            if (dr.Table.Columns.Contains("nuvCount") && !Convert.IsDBNull(dr["nuvCount"])) nc.nuvCount = Convert.ToInt64(dr["nuvCount"]); // nuvCount
            if (dr.Table.Columns.Contains("timeCount") && !Convert.IsDBNull(dr["timeCount"])) nc.timeCount = Convert.ToInt64(dr["timeCount"]); // timeCount
            if (dr.Table.Columns.Contains("otimeCount") && !Convert.IsDBNull(dr["otimeCount"])) nc.otimeCount = Convert.ToInt64(dr["otimeCount"]); // otimeCount
            if (dr.Table.Columns.Contains("PVtop") && !Convert.IsDBNull(dr["PVtop"])) nc.PVtop = Convert.ToInt32(dr["PVtop"]); // PVtop
            if (dr.Table.Columns.Contains("PVtime") && !Convert.IsDBNull(dr["PVtime"])) nc.PVtime = Convert.ToDateTime(dr["PVtime"]); // PVtime
            if (dr.Table.Columns.Contains("IPtop") && !Convert.IsDBNull(dr["IPtop"])) nc.IPtop = Convert.ToInt32(dr["IPtop"]); // IPtop
            if (dr.Table.Columns.Contains("IPtime") && !Convert.IsDBNull(dr["IPtime"])) nc.IPtime = Convert.ToDateTime(dr["IPtime"]); // IPtime
            if (dr.Table.Columns.Contains("UVtop") && !Convert.IsDBNull(dr["UVtop"])) nc.UVtop = Convert.ToInt32(dr["UVtop"]); // UVtop
            if (dr.Table.Columns.Contains("UVtime") && !Convert.IsDBNull(dr["UVtime"])) nc.UVtime = Convert.ToDateTime(dr["UVtime"]); // UVtime
            if (dr.Table.Columns.Contains("NuvTop") && !Convert.IsDBNull(dr["NuvTop"])) nc.NuvTop = Convert.ToInt32(dr["NuvTop"]); // NuvTop
            if (dr.Table.Columns.Contains("NuvTime") && !Convert.IsDBNull(dr["NuvTime"])) nc.NuvTime = Convert.ToDateTime(dr["NuvTime"]); // NuvTime
            if (dr.Table.Columns.Contains("timeTop") && !Convert.IsDBNull(dr["timeTop"])) nc.timeTop = Convert.ToInt32(dr["timeTop"]); // timeTop
            if (dr.Table.Columns.Contains("timeTime") && !Convert.IsDBNull(dr["timeTime"])) nc.timeTime = Convert.ToDateTime(dr["timeTime"]); // timeTime
            if (dr.Table.Columns.Contains("otimeTop") && !Convert.IsDBNull(dr["otimeTop"])) nc.otimeTop = Convert.ToInt32(dr["otimeTop"]); // otimeTop
            if (dr.Table.Columns.Contains("otimeTime") && !Convert.IsDBNull(dr["otimeTime"])) nc.otimeTime = Convert.ToDateTime(dr["otimeTime"]); // otimeTime
            return nc;
        }
    }
}
