Beispiel #1
0
        /// <summary>
        /// Renders a full HTML page for the share link in MiniProfiler.
        /// </summary>
        /// <param name="options">The options to render for.</param>
        /// <param name="path">The root path that MiniProfiler is being served from.</param>
        /// <returns>A full HTML page for this MiniProfiler.</returns>
        public static string ResultListHtml(MiniProfilerBaseOptions options, string path)
        {
            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.listInit({{path: '{path}', version: '{version}', colorScheme: '{options.ColorScheme.ToString()}'}});</script>
  </head>
  <body>
    <table class=""mp-results-index"">
      <thead>
        <tr>
          <th>Name</th>
          <th>Server</th>
          <th>Started</th>
          <th>Total Duration</th>
          <th>Request Start</th>
          <th>Response Start</th>
          <th>Dom Complete</th>
        </tr>
      </thead>
      <tbody></tbody>
    </table>
  </body>
</html>");
        }
        /// <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 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);
        }