using System;
using System.Collections.Generic;
using System.Web;

namespace Stat.BLL
{
    /// <summary>
    /// 
    /// </summary>
    public class ViewIP
    {

        static Stat.IDAL.IViewIP dal = Stat.DALFactory.AbstractFactory.GetInstance().CreateViewIP();

        /// <summary>
        /// IP Stat
        /// </summary>
        /// <param name="model"></param> 
        /// <returns></returns>
        internal static List<Model.ViewItem_String> GetItem(Model.StatInfo model)
        {
            return dal.GetItem(model);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="model"></param>
        /// <returns>暂时只查询 基础表</returns>
        /// <remarks>Juju 2011-11-2</remarks>
        public static List<Model.StatItem> Get(Model.StatInfo model)
        {
            string cacheName = "V_IP_" + model.WebID + "_" + model.StartTime + "_" + model.EndTime;
            if (HttpContext.Current.Cache.Get(cacheName) == null)
            {         
                List<Model.StatItem> list = new List<Model.StatItem>(); 
                //
                if (list == null || list.Count < 1)
                {
                    model.EndTime = model.StartTime.AddDays(1);                  
                    list = Report.Rp_String.SingleDay(GetItem(model));
                }    
                HttpContext.Current.Cache.Insert(cacheName, list, null, DateTime.MaxValue, TimeSpan.FromSeconds(10.0), System.Web.Caching.CacheItemPriority.Low, null);
                return list;
            }
            return (List<Model.StatItem>)HttpContext.Current.Cache.Get(cacheName);//从缓存中读取
        }
    }
}