/// <summary> /// 统计Html /// </summary> /// <param name="options"></param> /// <param name="path"></param> /// <returns></returns> public static string ResultStatListHtml(MiniProfilerBaseOptions options, string path, string queryString = null) { var version = options.VersionHash; return($@"<html> <head> <title>List of profiling sessions</title> <script id=""mini-profiler"" data-ids="""" src=""{path}includes.min.js?v={version}""></script> <link href=""{path}includes.min.css?v={version}"" rel=""stylesheet"" /> <script>MiniProfiler.listInitStat({{path: '{path}', version: '{version}',queryString: '{queryString}'}});</script> </head> <body> <table class=""mp-results-index""> <thead> <tr> <th>Name</th> <th>Total Count</th> <th>Max Duration(ms)</th> <th>Min Duration(ms)</th> <th>Avg Duration(ms)</th> </tr> </thead> <tbody></tbody> </table> </body> </html>"); }
/// <summary> /// Synchronously gets unviewed profiles for the user, /// expiring any above the <see cref="MiniProfilerBaseOptions.MaxUnviewedProfiles"/> count. /// </summary> /// <param name="options">The options to operate against on.</param> /// <param name="user">The user to get profiler IDs for.</param> /// <returns>The list of IDs</returns> public static List <Guid> ExpireAndGetUnviewed(this MiniProfilerBaseOptions options, string user) { var ids = options.Storage?.GetUnviewedIds(user); if (ids?.Count > options.MaxUnviewedProfiles) { for (var i = 0; i < ids.Count - options.MaxUnviewedProfiles; i++) { options.Storage.SetViewedAsync(user, ids[i]); } } return(ids); }
/// <summary> /// Asynchronously gets unviewed profiles for the user, /// expiring any above the <see cref="MiniProfilerBaseOptions.MaxUnviewedProfiles"/> count. /// </summary> /// <param name="options">The options to operate against on.</param> /// <param name="user">The user to get profiler IDs for.</param> /// <returns>The list of IDs</returns> public static async Task <List <Guid> > ExpireAndGetUnviewedAsync(this MiniProfilerBaseOptions options, string user) { if (options.Storage == null) { return(null); } var ids = await options.Storage.GetUnviewedIdsAsync(user).ConfigureAwait(false); if (ids?.Count > options.MaxUnviewedProfiles) { for (var i = 0; i < ids.Count - options.MaxUnviewedProfiles; i++) { await options.Storage.SetViewedAsync(user, ids[i]).ConfigureAwait(false); } } return(ids); }