/// <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); }
/// <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); } }
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); }
/// <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); }
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; }