Esempio n. 1
0
        /// <summary>
        /// 添加访问信息
        /// </summary>
        /// <param name="AccountID"></param>
        /// <returns></returns>
        public PageVisitor AddPageVisitor(string AccountID)
        {
            HttpContext Context = HttpContext.Current;
            string      ip      = Context.Request.ServerVariables["REMOTE_ADDR"];
            PageVisitor s       = GetPageVisitorByIP(ip);

            if (s != null)
            {
                s.OnlineTime = DateTime.Now;
                Assistant.Update(s, new string[] { "OnlineTime" });
                return(s);
            }
            else
            {
                s = new PageVisitor();
                HttpBrowserCapabilities bc = Context.Request.Browser;
                s.TypeCode    = StatisticsHelper.TypeCode_User;
                s.VisitorIP   = ip;
                s.Url         = Context.Request.RawUrl;
                s.HttpReferer = Context.Request.ServerVariables["HTTP_REFERER"];
                SearchEngine se = new SearchEngine();
                s.Keyword      = se.SearchKey(s.HttpReferer);
                s.SearchEngine = se.EngineName;
                s.Platform     = GetPlatformInfo(Context);
                s.Screen       = bc.ScreenPixelsWidth.ToString() + "×" + bc.ScreenPixelsHeight.ToString();
                s.Browser      = bc.Browser + bc.Version;
                s.FromSite     = We7Helper.GetDomainFromUrl(s.HttpReferer);
                s.Clicks       = 1;
                AddPageVisitor(s);
                return(s);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 更新冗余字段
        /// </summary>
        public int FreshSumData(DateTime startTime)
        {
            Criteria c = new Criteria(CriteriaType.MoreThanEquals, "VisitDate", startTime);
            List <PageVisitorHistory> list = GetPageVisitores(c);
            int count = 0;

            foreach (PageVisitorHistory s in list)
            {
                bool needUpdate = false;
                if (s.Clicks <= 1)
                {
                    s.Clicks = GetStatisticsCount(s.ID);
                    if (s.Clicks > 1)
                    {
                        needUpdate = true;
                    }
                }
                s.PageView = s.Clicks;

                if (s.City == "" || s.City == null)
                {
                    string[] parts = We7Helper.GetCityNameByIP(s.VisitorIP).Split(' ');
                    if (parts.Length > 0)
                    {
                        s.Province = parts[0];
                    }
                    if (parts.Length > 1)
                    {
                        s.City = parts[1];
                    }
                    needUpdate = true;
                }
                if (s.FromSite == "" || s.FromSite == null)
                {
                    s.FromSite = We7Helper.GetDomainFromUrl(s.HttpReferer);
                    needUpdate = true;
                }
                if (s.VisitDate == s.LogoutDate)
                {
                    s.LogoutDate = GetLogoutDate(s.ID);
                    s.OnlineTime = s.LogoutDate;
                    needUpdate   = true;
                }

                if (needUpdate)
                {
                    try
                    {
                        UpdatePageVisitor(s, new string[] { "City", "Province", "FromSite", "Clicks", "LogoutDate", "OnlineTime" });
                    }
                    finally
                    {
                        count += 1;
                    }
                }
            }
            return(count);
        }
Esempio n. 3
0
        public void FreshSumData(DateTime startTime)
        {
            Criteria c = new Criteria(CriteriaType.MoreThanEquals, "VisitDate", startTime);
            List <PageVisitorHistory> list = GetPageVisitors(c);
            int count = 0;

            foreach (PageVisitorHistory pvh in list)
            {
                bool needUpdate = false;
                if (pvh.Clicks <= 1)
                {
                    pvh.Clicks = GetStatisticsCount(pvh.ID);
                    if (pvh.Clicks > 1)
                    {
                        needUpdate = true;
                    }
                }
                pvh.PageView = pvh.Clicks;
                if (string.IsNullOrEmpty(pvh.City))
                {
                    string[] parts = We7Helper.GetCityNameByIP(pvh.VisitorIP).Split(' ');
                    if (parts.Length > 0)
                    {
                        pvh.Province = parts[0];
                    }
                    if (parts.Length > 1)
                    {
                        pvh.City = parts[1];
                    }
                    needUpdate = true;
                }
                if (string.IsNullOrEmpty(pvh.FromSite))
                {
                    pvh.FromSite = We7Helper.GetDomainFromUrl(pvh.HttpReferer);
                    needUpdate   = true;
                }
                if (pvh.VisitDate == pvh.LogoutDate)
                {
                    pvh.LogoutDate = GetLogoutDate(pvh.ID);
                    pvh.OnlineTime = pvh.LogoutDate;
                    needUpdate     = true;
                }

                if (needUpdate)
                {
                    try
                    {
                        UpdatePageVisitor(pvh, new string[] { "City", "Province", "FromSite", "Clicks", "LogoutDate", "OnlineTime" });
                    }
                    finally
                    {
                        count += 1;
                    }
                }
            }
        }