Example #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            Counter = new VisiteCount();
            VisiteCount conter = AppCtx.Cache.RetrieveObject <VisiteCount>(PageVisitorHelper.VisiteCountCacheKey);

            if (conter == null)
            {
                conter = PageVisitorHelper.GetCurrentVisiteCount();
            }
            if (conter != null)
            {
                Counter.TotalPageView      = conter.TotalPageView + InitTotalPageView;
                Counter.TotalVisitors      = conter.TotalVisitors + InitTotalVisitors;
                Counter.YearVisitors       = conter.YearVisitors + InitYearVisitors;
                Counter.MonthVisitors      = conter.MonthVisitors + InitMonthVisitors;
                Counter.DayVisitors        = conter.DayVisitors + InitDayVisitors;
                Counter.YestodayVisitors   = conter.YestodayVisitors + InitYestodayVisitors;
                Counter.AverageDayVisitors = conter.AverageDayVisitors + InitAverageDayVisitors;
                Counter.YearPageview       = conter.YearPageview + InitYearPageview;
                Counter.MonthPageview      = conter.MonthPageview + InitMonthPageview;
                Counter.DayPageview        = conter.DayPageview + InitDayPageview;
                Counter.YestodayPageview   = conter.YestodayPageview + InitYestodayPageview;
                Counter.AverageDayPageview = conter.AverageDayPageview + InitAverageDayPageview;
                Counter.OnlineVisitors     = conter.OnlineVisitors + InitOnlineVisitors;
            }
        }
Example #2
0
        protected string GetVisitorCount()
        {
            PageVisitorHelper helper = ((HelperFactory)Application[Framework.HelperFactory.ApplicationID]).GetHelper <PageVisitorHelper>();
            VisiteCount       vc     = helper.GetCurrentVisiteCount();
            StringBuilder     sb     = new StringBuilder();

            sb.Append(@"    总访问量:" + vc.TotalVisitors + @"人次<br>
                            总浏览量:" + vc.TotalPageView + @"人次<br>
                            今日访问:" + vc.DayVisitors + @"人次<br>
                            日均访问:" + vc.AverageDayVisitors + "人次<br>");
            return(sb.ToString());
        }
Example #3
0
        private void BindCount()
        {
            VisiteCount vc = PageVisitorHelper.GetCurrentVisiteCount();

            LabelTotalVisitors.Text = vc.TotalPageView.ToString();
            TodayPVLabel.Text       = vc.DayPageview.ToString();

            StatisticsArticle sa = PageViewReportHelper.GetStatisticsArticleCount();

            LabelTotalArticles.Text = sa.TotalArticles.ToString();
            LabelTotalComments.Text = sa.TotalComments.ToString();
            LabelMonthArticles.Text = sa.MonthArticles.ToString();
            LabelMonthComments.Text = sa.MonthComments.ToString();
            LabelWeekArticles.Text  = sa.WeekArticles.ToString();
            LabelWeekComments.Text  = sa.WeekComments.ToString();
        }
Example #4
0
        /// <summary>
        /// 获取总体统计数据
        /// </summary>
        /// <returns></returns>
        public VisiteCount GetCurrentVisiteCount()
        {
            VisiteCount vc = AppCtx.Cache.RetrieveObject <VisiteCount>(VisiteCountCacheKey);

            if (vc != null && vc.CreateDate.Day != DateTime.Now.Day) //如果是第二天了就把前一天的记录给清除掉
            {
                vc = null;
                AppCtx.Cache.RemoveObject(VisiteCountCacheKey);
            }
            if (vc == null)
            {
                DateTime oldest = GetOldestTime();
                if (oldest < DateTime.Today)
                {
                    //MigrateToHistory();
                    //FreshSumData(oldest);
                }
                vc = new VisiteCount();
                //在线人数
                HttpContext Context = HttpContext.Current;
                //vc.OnlineVisitors = (int)Context.Application[PageVisitorHelper.OnlinePeopleApplicationKey];
                Criteria c = new Criteria(CriteriaType.MoreThanEquals, "OnlineTime", DateTime.Now.AddMinutes(-15));
                vc.OnlineVisitors = Assistant.Count <PageVisitor>(c);

                //今天访问量
                vc.DayVisitors = Assistant.Count <PageVisitor>(null);
                vc.DayPageview = Assistant.Count <Statistics>(null);

                //总访问数
                vc.TotalVisitors = Assistant.Count <PageVisitorHistory>(null) + vc.DayVisitors;
                //总浏览量
                vc.TotalPageView = Assistant.Count <StatisticsHistory>(null) + vc.DayPageview;
                //今年访问量
                int      year     = DateTime.Now.Year;
                DateTime thisYear = Convert.ToDateTime(year.ToString() + "-01-01");
                c = new Criteria(CriteriaType.MoreThanEquals, "VisitDate", thisYear);
                vc.YearVisitors = Assistant.Count <PageVisitorHistory>(c) + vc.DayVisitors;
                vc.YearPageview = Assistant.Count <StatisticsHistory>(c) + vc.DayPageview;
                //本月访问量
                int      month     = DateTime.Now.Month;
                DateTime thisMonth = Convert.ToDateTime(year.ToString() + "-" + month.ToString() + "-01");
                c = new Criteria(CriteriaType.MoreThanEquals, "VisitDate", thisMonth);
                vc.MonthVisitors = Assistant.Count <PageVisitorHistory>(c) + vc.DayVisitors;
                vc.MonthPageview = Assistant.Count <StatisticsHistory>(c) + vc.DayPageview;

                //昨天访问量
                c = new Criteria(CriteriaType.LessThan, "VisitDate", DateTime.Today);
                Criteria subc = new Criteria(CriteriaType.MoreThanEquals, "VisitDate", DateTime.Today.AddDays(-1));
                c.Criterias.Add(subc);
                vc.YestodayVisitors = Assistant.Count <PageVisitorHistory>(c);
                vc.YestodayPageview = Assistant.Count <StatisticsHistory>(c);

                //平均每天访问量
                Order[] o = new Order[] { new Order("VisitDate", OrderMode.Asc) };
                List <PageVisitorHistory> list = Assistant.List <PageVisitorHistory>(null, o, 0, 1);
                DateTime firstDay = list.Count > 0?list[0].VisitDate:DateTime.Now;
                vc.StartDate = firstDay;
                int days = ((TimeSpan)(DateTime.Today - firstDay.Date)).Days + 1;

                if (days > 0)
                {
                    vc.AverageDayVisitors = vc.TotalVisitors / days;
                    vc.AverageDayPageview = vc.TotalPageView / days;
                }
                AppCtx.Cache.AddObject(VisiteCountCacheKey, vc, ((int)CacheTime.Short) * 1000);
            }
            return(vc);
        }