Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string typeStr = Request.QueryString["type"];

            if (!string.IsNullOrEmpty(typeStr))
            {
                //识别分享类型
                ShareType type = ShareType.Unknown;
                switch (typeStr)
                {
                case "timeline":
                    type = ShareType.Timeline;
                    break;

                case "friend":
                    type = ShareType.Friend;
                    break;
                }
                //构造分享记录
                var pageShare = new PageShareEntity()
                {
                    Id  = Guid.NewGuid().ToString(),
                    Url = GetOrigenalUrl(System.Web.HttpContext.Current.Request.QueryString["url"]),
                    ParentShareOpenId = System.Web.HttpContext.Current.Request.QueryString["s"],
                    ShareOpenId       = System.Web.HttpContext.Current.Request.QueryString["u"],
                    From      = type,
                    ShareTime = DateTime.Now
                };
                //保存分享记录
                StatisticsBll.InsertPageShare(pageShare);
            }
        }
        /// <summary>
        /// 记录页面访问
        /// </summary>
        /// <param name="navOpenId">访问者微信openid</param>
        /// <param name="shareOpenId">当访问来源为朋友圈时的分享者微信openid</param>
        private void NavStatistics(string navOpenId, string shareOpenId)
        {
            //获取访问来源
            NavFrom fromType = GetNavFromType();
            //构造访问记录
            var pageNav = new PageNavEntity()
            {
                Id          = Guid.NewGuid().ToString(),
                Url         = GetOrigenalUrl(),
                NavOpenId   = navOpenId,
                ShareOpenId = shareOpenId,
                From        = fromType,
                VisitTime   = DateTime.Now
            };

            //访问记录写入数据库
            StatisticsBll.InsertPageNav(pageNav);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取页面分享统计信息
        /// </summary>
        /// <returns></returns>
        private ChartData GetPageShareStatistics()
        {
            //取过去两天的数据进行统计
            DateTime startTime                = DateTime.Now.AddDays(-3);
            DateTime endTime                  = DateTime.Now.AddDays(1);
            List <PageShareEntity> temp       = StatisticsBll.GetPageShareList();
            List <decimal>         statistics = new List <decimal>();
            //HighCharts时间轴的起始时间
            ChartData chartData = new ChartData
            {
                StartYear  = startTime.Year,
                StartDay   = startTime.Day,
                StartMonth = startTime.Month
            };

            //生成按小时统计的数据
            while (startTime < endTime)
            {
                statistics.Add(temp.FindAll(e => e.ShareTime >= startTime && e.ShareTime < startTime.AddHours(1)).Count());
                startTime = startTime.AddHours(1);
            }
            chartData.Statistics = statistics.ToArray();
            return(chartData);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     //传递给页面显示的记录列表
     ViewState["NavList"]   = StatisticsBll.GetPageNavList();
     ViewState["ShareList"] = StatisticsBll.GetPageShareList();
 }