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

namespace Stat.BLL
{
    /// <summary>
    /// 
    /// </summary>
    public class ViewJavaApplet
    {
        static Stat.IDAL.IViewJavaApplet dal = Stat.DALFactory.AbstractFactory.GetInstance().CreateViewJavaApplet();
        /// <summary>
        /// IsJava
        /// </summary>
        /// <param name="model"></param> 
        /// <returns></returns>
        internal static List<Model.ViewItem_Int> GetItem(Model.StatInfo model)
        {
            return dal.GetItem(model);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static List<Model.StatItem> Get(Model.StatInfo model)
        {
            string cName = "V_JavaApplet_" + model.WebID + "_" + model.StartTime + "_" + model.EndTime;
            if (HttpContext.Current.Cache.Get(cName) == null)
            {
                List<Model.StatItem> list = dal.GetList(model);
                //
                if (list == null || list.Count < 1)
                {
                    //详细数据
                    list = Report.Rp_Int.SingleDay(GetItem(model), Items.JavaApplet.Get());
                }
                else
                {
                    //过往数据
                    list = Report.Rp_Int.MultiDay(list);
                }
                //
                HttpContext.Current.Cache.Insert(cName, list, null, DateTime.MaxValue, TimeSpan.FromSeconds(3.0), System.Web.Caching.CacheItemPriority.Low, null);
                return list;
            }
            return (List<Model.StatItem>)HttpContext.Current.Cache.Get(cName);//从缓存中读取

        }
    }
}
