Пример #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);
            }
        }
Пример #2
0
        /// <summary>
        /// 删除一条统计信息
        /// </summary>
        /// <param name="id"></param>
        public void DeletePageVisitor(string id)
        {
            PageVisitor s = GetPageVisitor(id);

            if (s != null)
            {
                Assistant.Delete(s);
            }
        }
Пример #3
0
 /// <summary>
 /// 新增一条统计信息
 /// </summary>
 /// <param name="s"></param>
 /// <param name="type"></param>
 public void AddPageVisitor(PageVisitor s)
 {
     s.ID         = We7Helper.CreateNewID();
     s.VisitDate  = DateTime.Now;
     s.LogoutDate = DateTime.Now;
     s.OnlineTime = DateTime.Now;
     s.Updated    = DateTime.Now;
     s.Created    = DateTime.Now;
     Assistant.Insert(s);
 }
Пример #4
0
        /// <summary>
        /// 更新退出时间
        /// </summary>
        public void UpdateLogoutTime()
        {
            HttpContext Context = HttpContext.Current;

            if (Context.Session[PageVisitorHelper.PageVisitorSessionKey] != null)
            {
                PageVisitor pv = (PageVisitor)Context.Session[PageVisitorHelper.PageVisitorSessionKey];
                pv.LogoutDate = DateTime.Now;
                Assistant.Update(pv, new string[] { "LogoutDate" });
            }
        }
Пример #5
0
        /// <summary>
        /// 添加统计信息
        /// </summary>
        /// <param name="pv">点击量</param>
        /// <param name="ArticleID">文章ID</param>
        /// <param name="ColumnID">栏目ID</param>
        public void AddStatistics(PageVisitor pv, string ArticleID, string ColumnID)
        {
            HttpContext Context = HttpContext.Current;
            Statistics  s       = new Statistics();

            s.VisitorID = pv.ID;
            s.ArticleID = ArticleID;
            s.ChannelID = ColumnID;
            s.Url       = Context.Request.RawUrl;
            AddStatistics(s);
        }
Пример #6
0
 /// <summary>
 /// 访客离开,在session结束时调用
 /// </summary>
 public void PageVisitorLeave()
 {
     if (HttpContext.Current != null)
     {
         HttpSessionState Session = HttpContext.Current.Session;
         if (Session[PageVisitorHelper.PageVisitorSessionKey] != null)
         {
             PageVisitor pv = (PageVisitor)Session[PageVisitorHelper.PageVisitorSessionKey];
             pv.OnlineTime = DateTime.Now;
             Assistant.Update(pv, new string[] { "OnlineTime" });
         }
     }
 }
Пример #7
0
 public void UpdatePageVisitor(PageVisitor pv, string[] fields)
 {
     Assistant.Update(pv, fields);
 }