Example #1
0
        /// <summary>根据模型查找</summary>
        /// <param name="model"></param>
        /// <param name="cache"></param>
        /// <returns></returns>
        public static VisitStat FindByModel(VisitStatModel model, Boolean cache)
        {
            if (model == null)
            {
                return(null);
            }

            if (cache)
            {
                if (_cache.FindMethod == null)
                {
                    _cache.FindMethod = m => FindByModel(m, false);
                }

                return(_cache[model]);
            }

            var exp = new WhereExpression();

            exp &= _.Level == model.Level;
            if (model.Level > 0 && model.Time > DateTime.MinValue)
            {
                exp &= _.Time == model.GetDate(model.Level);
            }
            exp &= _.Page == model.Page;

            return(Find(exp));
        }
Example #2
0
        /// <summary>高级查询访问统计</summary>
        /// <param name="model"></param>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public static IList <VisitStat> Search(VisitStatModel model, DateTime start, DateTime end, PageParameter param)
        {
            var exp = new WhereExpression();

            if (model.Level >= 0)
            {
                exp &= _.Level == model.Level;
            }
            if (model.Level > 0 && model.Time > DateTime.MinValue)
            {
                exp &= _.Time == model.GetDate(model.Level);
            }
            if (!model.Page.IsNullOrEmpty())
            {
                exp &= _.Page == model.Page;
            }

            exp &= _.Time.Between(start, end);

            return(FindAll(exp, param));
        }