示例#1
0
        private static void CommitMonitorData()
        {
            if (PerformanceMonitorHelper.ExistsMonitor(MonitorName))
            {
                MonitorData md = PerformanceMonitorHelper.GetMonitor("WfServerContextInvoker");

                md.Stopwatch.Stop();

                if (md.EnableLogging)
                {
                    md.LogWriter.WriteLine("请求{0}的结束时间: {1:yyyy-MM-dd HH:mm:ss.fff},经过{2:#,##0}毫秒",
                                           md.MonitorName, SNTPClient.AdjustedTime, md.Stopwatch.ElapsedMilliseconds);

                    CommitLogging(md);
                }

                if (md.EnablePFCounter)
                {
                    SetCountersValues(md, md.HasErrors);
                }

                PerformanceMonitorHelper.RemoveMonitor(MonitorName);
                PerformanceMonitorHelper.DefaultMonitorName = "DefaultMonitor";
            }
        }
        private void context_Error(object sender, EventArgs e)
        {
            if (PerformanceMonitorHelper.ExistsMonitor(PageMonitorModule.MonitorDataKey))
            {
                MonitorData md = PerformanceMonitorHelper.GetMonitor(PageMonitorModule.MonitorDataKey);

                md.HasErrors = true;
            }
        }
        private void context_EndRequestExecute(object sender, EventArgs e)
        {
            if (PerformanceMonitorHelper.ExistsMonitor(PageMonitorModule.MonitorDataKey))
            {
                if (HttpContext.Current.Response.StatusCode != 302)
                {
                    MonitorData md = PerformanceMonitorHelper.GetMonitor(PageMonitorModule.MonitorDataKey);

                    md.Stopwatch.Stop();

                    if (md.EnableLogging)
                    {
                        md.LogWriter.WriteLine("请求{0}的结束时间: {1:yyyy-MM-dd HH:mm:ss.fff},经过{2:#,##0}毫秒",
                                               md.MonitorName, SNTPClient.AdjustedTime, md.Stopwatch.ElapsedMilliseconds);
                    }

                    CommitLogging(md);
                    SetCountersValue(md);

                    PerformanceMonitorHelper.RemoveMonitor(PageMonitorModule.MonitorDataKey);
                    PerformanceMonitorHelper.DefaultMonitorName = "DefaultMonitor";
                }
            }
        }