Beispiel #1
0
        void OnPost(Object sender, EventArgs e)
        {
            if (!WebOnline && !WebBehavior && !WebStatistics)
            {
                return;
            }

            var ctx = HttpContext.Current;

            if (ctx == null)
            {
                return;
            }

            var req = ctx.Request;

            if (req == null)
            {
                return;
            }

            var user = ctx.User?.Identity as IManageUser ?? ManageProvider.User as IManageUser;

            var sid = ctx.Session?.SessionID;
            var ip  = WebHelper.UserHost;

            var page  = GetPage(req);
            var title = GetTitle(ctx, req);
            var msg   = GetMessage(ctx, req, title);

            TaskEx.Run(() =>
            {
                try
                {
                    // 统计网页状态
                    if (WebOnline && !sid.IsNullOrEmpty())
                    {
                        UserOnline.SetWebStatus(sid, page, msg, user, ip);
                    }

                    // 记录用户访问的Url
                    if (WebBehavior)
                    {
                        SaveBehavior(user, ip, page, msg);
                    }

                    // 每个页面的访问统计
                    if (WebStatistics)
                    {
                        SaveStatistics(ctx, user, ip, page, title);
                    }
                }
                catch (Exception ex)
                {
                    XTrace.WriteException(ex);
                }
            });
        }
Beispiel #2
0
        /// <summary>输出运行时间</summary>
        void OnPost(Object sender, EventArgs e)
        {
            try
            {
                //var set = Setting.Current;

                // 统计网页状态
                if (WebOnline)
                {
                    UserOnline.SetWebStatus();
                }

                // 记录用户访问的Url
                if (WebBehavior)
                {
                    SaveBehavior();
                }
            }
            catch (Exception ex)
            {
                XTrace.WriteException(ex);
            }
        }
Beispiel #3
0
        void OnPost(Object sender, EventArgs e)
        {
            if (!WebOnline && !WebBehavior && !WebStatistics)
            {
                return;
            }

            var ctx = HttpContext.Current;

            if (ctx == null)
            {
                return;
            }

            var req = ctx.Request;

            if (req == null)
            {
                return;
            }

            var user = ctx.User?.Identity as IManageUser ?? ManageProvider.User as IManageUser;

            var sid = ctx.Session?.SessionID;
            var ip  = GetIP();

            var page = GetPage(req);

            // 过滤后缀
            //var ext = Path.GetExtension(page);
            //if (!ext.IsNullOrEmpty() && ExcludeSuffixes.Contains(ext)) return;
            if (page.EndsWithIgnoreCase(ExcludeSuffixes))
            {
                return;
            }

            var title = GetTitle(ctx, req);
            var msg   = GetMessage(ctx, req, title);

            ThreadPoolX.QueueUserWorkItem(() =>
            {
                try
                {
                    // 统计网页状态
                    if (WebOnline && !sid.IsNullOrEmpty())
                    {
                        UserOnline.SetWebStatus(sid, page, msg, user, ip);
                    }

                    // 记录用户访问的Url
                    if (WebBehavior)
                    {
                        SaveBehavior(user, ip, page, msg, GetError(ctx) == null);
                    }

                    // 每个页面的访问统计
                    if (WebStatistics)
                    {
                        SaveStatistics(ctx, user, ip, page, title);
                    }
                }
                catch (Exception ex)
                {
                    XTrace.WriteException(ex);
                }
            });
        }