using System;
using System.Collections.Generic;

namespace Stat.SQLServerDAL.ViewItems
{
    public class Online
    {
        /// <summary>
        /// 获取 列表
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public static List<Model.Online> GetPvIpUv(System.Data.DataTable table)
        {
            List<Model.Online> list = new List<Model.Online>();
            if (table != null)
            {
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    list.Add(GetOnline(table.Rows[i]));
                }
            }
            return list;
        }
        /// <summary>
        /// 获取实体
        /// </summary>
        ///<param name="row"></param>
        /// <returns></returns>
        private static Model.Online GetOnline(System.Data.DataRow row)
        {
            Model.Online model = new Model.Online();
            if (row != null)
            {
                if (row.Table.Columns.Contains("ipno") && !Convert.IsDBNull(row["ipno"])) model.Id = Convert.ToInt32(row["ipno"]);
                if (row.Table.Columns.Contains("IP") && !Convert.IsDBNull(row["IP"])) model.IP = row["IP"].ToString();
                if (row.Table.Columns.Contains("IPinfo") && !Convert.IsDBNull(row["IPinfo"])) model.Address = row["IPinfo"].ToString();
                if (row.Table.Columns.Contains("Area1") && !Convert.IsDBNull(row["Area1"])) model.Area = row["Area1"].ToString();
                if (row.Table.Columns.Contains("Tele") && !Convert.IsDBNull(row["Tele"])) model.ISP = row["Tele"].ToString();
                if (row.Table.Columns.Contains("Mac") && !Convert.IsDBNull(row["Mac"])) model.Mac = row["Mac"].ToString();
                if (row.Table.Columns.Contains("vMinute") && !Convert.IsDBNull(row["vMinute"])) model.vMinute = Convert.ToInt32(row["vMinute"]);
            }
            return model;
        }
    }
}