Ejemplo n.º 1
0
        void AddStatistic()
        {
            PageVisitor pv;

            if (Session[PageVisitorHelper.PageVisitorSessionKey] == null)
            {
                pv = PageVisitorHelper.AddPageVisitor(AccountID);
                Session[PageVisitorHelper.PageVisitorSessionKey] = pv;
            }
            else
            {
                pv = (PageVisitor)Session[PageVisitorHelper.PageVisitorSessionKey];
            }

            if (pv != null)
            {
                StatisticsHelper.AddStatistics(pv, ArticleID, ColumnID);
                TimeSpan ts = DateTime.Now - pv.OnlineTime;
                pv.Clicks += 1;
                if (ts.TotalSeconds > 10)//改为10秒 刷新在线时间
                {
                    pv.OnlineTime = DateTime.Now;
                    pv.LogoutDate = DateTime.Now;
                    PageVisitorHelper.UpdatePageVisitor(pv, new string[] { "OnlineTime", "LogoutDate", "Clicks" });
                }
            }
            else
            {
                Session[PageVisitorHelper.PageVisitorSessionKey] = null;
            }
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
0
 protected void Session_End(object sender, EventArgs e)
 {
     Application.Lock();
     Application[PageVisitorHelper.OnlinePeopleApplicationKey] = (int)Application[PageVisitorHelper.OnlinePeopleApplicationKey] - 1;
     Application.UnLock();
     if (GeneralConfigs.GetConfig().StartPageViewModule)
     {
         PageVisitorHelper.PageVisitorLeave();
     }
 }
Ejemplo n.º 4
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());
        }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
0
        OpenFlashChart.OpenFlashChart BuildChart()
        {
            OpenFlashChart.OpenFlashChart chart = new OpenFlashChart.OpenFlashChart();
            List <double> data1 = new List <double>();

            int maxDot = 0;

            for (double i = 0; i < Days; i++)
            {
                //data1.Add(rand.Next(30));
                DateTime startTime = BeginDate.AddDays(i);
                DateTime endTime   = startTime.AddDays(1);
                int      pv        = PageVisitorHelper.GetVisitorCountByTime(startTime, endTime);
                if (pv > maxDot)
                {
                    maxDot = pv;
                }
                data1.Add(pv);
            }

            OpenFlashChart.Area area = new Area();
            area.Values   = data1;
            area.HaloSize = 0;
            area.Width    = 4;
            //area.DotSize = 2;
            area.FontSize         = 12;
            area.DotStyleType.Tip = "#x_label#<br>访客数:#val#";
            //area.DotStyleType.Type = DotType.ANCHOR;
            area.DotStyleType.Type   = DotType.DOT;
            area.DotStyleType.Colour = "#0077CC";

            area.Tooltip   = "提示:#val#";
            area.Colour    = "#0077CC";
            area.FillColor = "#E6F2FA";
            area.FillAlpha = .5;
            Animation animation = new Animation();

            animation.Cascade    = 1;
            animation.Delay      = 0.5;
            animation.Type       = "pop-up";
            area.OnShowAnimation = animation;
            chart.AddElement(area);
            chart.Y_Legend                = new Legend("");
            chart.Title                   = new Title("");
            chart.Tooltip                 = new ToolTip("#x_label#<br>访客数:#val#");
            chart.Tooltip.MouseStyle      = ToolTipStyle.FOLLOW;
            chart.Tooltip.Shadow          = false;
            chart.Tooltip.BackgroundColor = "#ffffff";
            chart.Tooltip.Rounded         = 3;
            chart.Tooltip.Stroke          = 2;
            chart.Tooltip.Colour          = "#000000";
            chart.Tooltip.BodyStyle       = "color: #000000; font-weight: normal; font-size: 11;";

            maxDot = (int)(maxDot * 1.3);
            chart.Y_Axis.SetRange(0, maxDot, maxDot / 3);
            chart.X_Axis.GridColour = "#eeeeee";
            chart.Y_Axis.GridColour = "#eeeeee";
            chart.X_Axis.Colour     = "#333333";
            chart.Y_Axis.Colour     = "#333333";
            chart.Bgcolor           = "#fbfbfb";

            List <string> data2 = new List <string>();

            for (int i = 0; i < Days; i++)
            {
                data2.Add(BeginDate.AddDays(i).ToString("yyyy年MM月dd日"));
            }

            XAxis x = new XAxis();

            x.GridColour = "#eeeeee";
            x.Stroke     = 1;
            x.Steps      = Steps;
            XAxisLabels xlabels = new XAxisLabels();

            xlabels.Steps    = Steps;
            xlabels.Vertical = false;
            xlabels.SetLabels(data2);
            x.Labels     = xlabels;
            chart.X_Axis = x;

            chart.Tooltip            = new ToolTip("全局提示:#val#");
            chart.Tooltip.Shadow     = true;
            chart.Tooltip.Colour     = "#e43456";
            chart.Tooltip.MouseStyle = ToolTipStyle.CLOSEST;
            return(chart);
        }
Ejemplo n.º 7
0
        string GetChartXMLFile(string unit)
        {
            string filename = "chart_" + unit + "_" + BeginDate.ToString("yyyyMMdd") + "_" + EndDate.ToString("yyyyMMdd") + ".xml";
            string path     = Server.MapPath("~/_temp/chart");
            string fileUrl  = "";

            if (File.Exists(Path.Combine(path, filename)))
            {
                fileUrl = "/_temp/chart/" + filename;
            }
            else
            {
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                string strHead = @"<graph xaxisname=""{0}"" yaxisname=""访问量"" hovercapbg=""DEDEBE"" hovercapborder=""889E6D"" baseFontSize='12' rotateNames=""0""  numdivlines=""9"" divLineColor=""CCCCCC"" divLineAlpha=""80"" decimalPrecision=""0"" showAlternateHGridColor=""1"" AlternateHGridAlpha=""30"" AlternateHGridColor=""CCCCCC""  bgcolor='fbfbfb' caption=""{1}"" subcaption=""{2}"">";
                switch (unit)
                {
                case "hour":
                    using (FileStream fs = File.Open(Path.Combine(path, filename), FileMode.CreateNew, FileAccess.Write))
                    {
                        using (StreamWriter sw = new StreamWriter(fs, Encoding.UTF8))
                        {
                            sw.WriteLine(string.Format(strHead, "小时", BeginDate.ToString("yyyy-MM-dd") + "  24小时流量图", ""));
                            sw.WriteLine("<categories font=\"Arial\" fontSize=\"12\" fontColor=\"000000\">");
                            for (int i = 0; i <= 24; i++)
                            {
                                sw.WriteLine(string.Format("<category name=\"{0}\" hoverText=\"{0}点\"/>", i));
                            }
                            sw.WriteLine("</categories>");

                            sw.WriteLine("<dataset seriesname=\"访客数\" color=\"FDC12E\">");
                            for (int i = 0; i <= 24; i++)
                            {
                                DateTime startTime = BeginDate.AddDays(-1).AddHours(i);
                                DateTime endTime   = startTime.AddHours(1);
                                sw.WriteLine(string.Format("<set value=\"{0}\"/>", PageVisitorHelper.GetPVCountByTime(startTime, endTime)));
                            }
                            sw.WriteLine("</dataset>");

                            sw.WriteLine("<dataset seriesname=\"访客数\" color=\"56B9F9\">");
                            for (int i = 0; i <= 24; i++)
                            {
                                DateTime startTime = BeginDate.AddDays(-1).AddHours(i);
                                DateTime endTime   = startTime.AddHours(1);
                                sw.WriteLine(string.Format("<set value=\"{0}\"/>", PageVisitorHelper.GetVisitorCountByTime(startTime, endTime)));
                            }
                            sw.WriteLine("</dataset>");
                            sw.WriteLine("</graph>");
                            sw.Flush();
                        }
                    }
                    fileUrl = "/_temp/chart/" + filename;
                    break;

                case "day":
                    using (FileStream fs = File.Open(Path.Combine(path, filename), FileMode.CreateNew, FileAccess.Write))
                    {
                        using (StreamWriter sw = new StreamWriter(fs, Encoding.UTF8))
                        {
                            sw.WriteLine(string.Format(strHead, "天", "流量曲线图", BeginDate.ToString("yyyy-MM-dd") + "  到 " + EndDate.ToString("yyyy-MM-dd")));
                            sw.WriteLine("<categories font=\"Arial\" fontSize=\"11\" fontColor=\"000000\">");
                            TimeSpan ts   = EndDate - BeginDate;
                            int      days = ts.Days;
                            for (int i = 0; i <= days; i++)
                            {
                                sw.WriteLine(string.Format("<category name=\"{0}\" />", BeginDate.AddDays(i).Day));
                            }
                            sw.WriteLine("</categories>");

                            sw.WriteLine("<dataset seriesname=\"访客数\" color=\"FDC12E\">");
                            for (int i = 0; i <= days; i++)
                            {
                                DateTime startTime = BeginDate.AddDays(i);
                                DateTime endTime   = startTime.AddDays(1);
                                sw.WriteLine(string.Format("<set value=\"{0}\"/>", PageVisitorHelper.GetPVCountByTime(startTime, endTime)));
                            }
                            sw.WriteLine("</dataset>");

                            sw.WriteLine("<dataset seriesname=\"访客数\" color=\"56B9F9\">");
                            for (int i = 0; i <= days; i++)
                            {
                                DateTime startTime = BeginDate.AddDays(i);
                                DateTime endTime   = startTime.AddDays(1);
                                sw.WriteLine(string.Format("<set value=\"{0}\"/>", PageVisitorHelper.GetVisitorCountByTime(startTime, endTime)));
                            }
                            sw.WriteLine("</dataset>");
                            sw.WriteLine("</graph>");
                            sw.Flush();
                        }
                    }
                    fileUrl = "/_temp/chart/" + filename;
                    break;

                case "month":
                    using (FileStream fs = File.Open(Path.Combine(path, filename), FileMode.CreateNew, FileAccess.Write))
                    {
                        using (StreamWriter sw = new StreamWriter(fs, Encoding.UTF8))
                        {
                            sw.WriteLine(string.Format(strHead, "月", "流量曲线图", BeginDate.ToString("yyyy-MM") + "  到 " + EndDate.ToString("yyyy-MM")));
                            sw.WriteLine("<categories font=\"Arial\" fontSize=\"11\" fontColor=\"000000\">");
                            TimeSpan ts     = EndDate - BeginDate;
                            int      months = (int)(ts.TotalDays / 30);
                            for (int i = 0; i <= months; i++)
                            {
                                sw.WriteLine(string.Format("<category name=\"{0}\" hoverText=\"{0}月\"/>", BeginDate.AddMonths(i).Month));
                            }
                            sw.WriteLine("</categories>");

                            sw.WriteLine("<dataset seriesname=\"访客数\" color=\"FDC12E\">");
                            for (int i = 0; i <= months; i++)
                            {
                                DateTime startTime = BeginDate.AddMonths(i);
                                DateTime endTime   = startTime.AddMonths(1);
                                sw.WriteLine(string.Format("<set value=\"{0}\"/>", PageVisitorHelper.GetPVCountByTime(startTime, endTime)));
                            }
                            sw.WriteLine("</dataset>");

                            sw.WriteLine("<dataset seriesname=\"访客数\" color=\"56B9F9\">");
                            for (int i = 0; i <= months; i++)
                            {
                                DateTime startTime = BeginDate.AddMonths(i);
                                DateTime endTime   = startTime.AddMonths(1);
                                sw.WriteLine(string.Format("<set value=\"{0}\"/>", PageVisitorHelper.GetVisitorCountByTime(startTime, endTime)));
                            }
                            sw.WriteLine("</dataset>");
                            sw.WriteLine("</graph>");
                            sw.Flush();
                        }
                    }
                    fileUrl = "/_temp/chart/" + filename;
                    break;
                }
            }

            return(fileUrl);
        }
Ejemplo n.º 8
0
 void AddUserLoginStatistics()
 {
     PageVisitorHelper.AddPageVisitor(AccountID);
 }