Esempio n. 1
0
        /// <summary>
        /// Stores <param name="profiler"/> to MongoDB under its <see cref="MiniProfiler.Id"/>;
        /// stores all child Timings and SqlTimings to their respective tables.
        /// </summary>
        public override void Save(MiniProfiler profiler)
        {
            var miniProfilerPoco = new MiniProfilerPoco
            {
                Id                          = profiler.Id,
                RootTimingId                = profiler.Root != null ? profiler.Root.Id : (Guid?)null,
                Name                        = profiler.Name,
                Started                     = profiler.Started,
                DurationMilliseconds        = (double)profiler.DurationMilliseconds,
                User                        = profiler.UserName,
                HasUserViewed               = profiler.HasUserViewed,
                MachineName                 = profiler.MachineName,
                CustomLinksJson             = profiler.CustomLinksJson,
                ClientTimingsRedirectCounts = profiler.ClientTimings != null ? profiler.ClientTimings.RedirectCount : (int?)null
            };

            var result = Profilers.Save(miniProfilerPoco, WriteConcern.Acknowledged);

            if (!result.UpdatedExisting)
            {
                SaveTiming(profiler.Root);
            }

            SaveClientTimings(profiler);
        }
Esempio n. 2
0
        /// <summary>
        /// Stores <param name="profiler"/> to MongoDB under its <see cref="MiniProfiler.Id"/>;
        /// stores all child Timings and SqlTimings to their respective tables.
        /// </summary>
        public override void Save(MiniProfiler profiler)
        {
            var profilerPoco = new MiniProfilerPoco
            {
                Id                                   = profiler.Id.ToString(),
                Name                                 = Truncate(profiler.Name, 200),
                Started                              = profiler.Started,
                MachineName                          = Truncate(profiler.MachineName, 100),
                User                                 = Truncate(profiler.User, 100),
                Level                                = profiler.Level,
                RootTimingId                         = profiler.Root.Id,
                DurationMilliseconds                 = (double)profiler.DurationMilliseconds,
                DurationMillisecondsInSql            = (double)profiler.DurationMillisecondsInSql,
                HasSqlTimings                        = profiler.HasSqlTimings,
                HasDuplicateSqlTimings               = profiler.HasDuplicateSqlTimings,
                HasTrivialTimings                    = profiler.HasTrivialTimings,
                HasAllTrivialTimings                 = profiler.HasAllTrivialTimings,
                TrivialDurationThresholdMilliseconds = (double)profiler.TrivialDurationThresholdMilliseconds,
                HasUserViewed                        = profiler.HasUserViewed
            };

            var result = Profilers.Save(profilerPoco, SafeMode.True);

            if (result.UpdatedExisting == false)
            {
                //Save Root Timing
                SaveTiming(profiler, profiler.Root);
            }

            // we may have a missing client timing - re save
            if (profiler.ClientTimings != null)
            {
                SaveClientTiming(profiler);
            }
        }
Esempio n. 3
0
        private static MiniProfiler ProfilerPocoToProfiler(MiniProfilerPoco profilerPoco)
        {
            if (profilerPoco == null)
            {
                return(null);
            }

#pragma warning disable 618
            var miniProfiler = new MiniProfiler
#pragma warning restore 618
            {
                Id                   = profilerPoco.Id,
                MachineName          = profilerPoco.MachineName,
                UserName             = profilerPoco.User,
                HasUserViewed        = profilerPoco.HasUserViewed,
                Name                 = profilerPoco.Name,
                Started              = profilerPoco.Started,
                RootTimingId         = profilerPoco.RootTimingId,
                DurationMilliseconds = (decimal)profilerPoco.DurationMilliseconds
            };

            return(miniProfiler);
        }
Esempio n. 4
0
        /// <summary>
        /// Stores <param name="profiler"/> to MongoDB under its <see cref="MiniProfiler.Id"/>; 
        /// stores all child Timings and SqlTimings to their respective tables.
        /// </summary>
        public override void Save(MiniProfiler profiler)
        {
            var profilerPoco = new MiniProfilerPoco
            {
                Id = profiler.Id.ToString(),
                Name = Truncate(profiler.Name, 200),
                Started = profiler.Started,
                MachineName = Truncate(profiler.MachineName, 100),
                User = Truncate(profiler.User, 100),
                Level = profiler.Level,
                RootTimingId = profiler.Root.Id,
                DurationMilliseconds = (double)profiler.DurationMilliseconds,
                DurationMillisecondsInSql = (double)profiler.DurationMillisecondsInSql,
                HasSqlTimings = profiler.HasSqlTimings,
                HasDuplicateSqlTimings = profiler.HasDuplicateSqlTimings,
                HasTrivialTimings = profiler.HasTrivialTimings,
                HasAllTrivialTimings = profiler.HasAllTrivialTimings,
                TrivialDurationThresholdMilliseconds = (double)profiler.TrivialDurationThresholdMilliseconds,
                HasUserViewed = profiler.HasUserViewed
            };

            var result = Profilers.Save(profilerPoco, SafeMode.True);

            if (result.UpdatedExisting == false)
            {
                //Save Root Timing
                SaveTiming(profiler, profiler.Root);
            }

            // we may have a missing client timing - re save
            if (profiler.ClientTimings != null)
            {
                SaveClientTiming(profiler);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Stores <param name="profiler"/> to MongoDB under its <see cref="MiniProfiler.Id"/>; 
        /// stores all child Timings and SqlTimings to their respective tables.
        /// </summary>
        public override void Save(MiniProfiler profiler)
        {
            var miniProfilerPoco = new MiniProfilerPoco
            {
                Id = profiler.Id,
                RootTimingId = profiler.Root != null ? profiler.Root.Id : (Guid?) null,
                Name = profiler.Name,
                Started = profiler.Started,
                DurationMilliseconds = (double) profiler.DurationMilliseconds,
                User = profiler.User,
                HasUserViewed = profiler.HasUserViewed,
                MachineName = profiler.MachineName,
                CustomLinksJson = profiler.CustomLinksJson,
                ClientTimingsRedirectCounts = profiler.ClientTimings != null ? profiler.ClientTimings.RedirectCount : (int?) null
            };

            var result = Profilers.Save(miniProfilerPoco, WriteConcern.Acknowledged);

            if (!result.UpdatedExisting)
            {
                SaveTiming(profiler.Root);
            }

            SaveClientTimings(profiler);
        }
Esempio n. 6
0
        private static MiniProfiler ProfilerPocoToProfiler(MiniProfilerPoco profilerPoco)
        {
            if (profilerPoco == null)
                return null;

#pragma warning disable 618
            var miniProfiler = new MiniProfiler
#pragma warning restore 618
            {
                Id = profilerPoco.Id,
                MachineName = profilerPoco.MachineName,
                User = profilerPoco.User,
                HasUserViewed = profilerPoco.HasUserViewed,
                Name = profilerPoco.Name,
                Started = profilerPoco.Started,
                RootTimingId = profilerPoco.RootTimingId,
                DurationMilliseconds = (decimal) profilerPoco.DurationMilliseconds
            };

            return miniProfiler;
        }