Updated MiniProfiler to v2

pull/3113/head
Mark McDowall 12 years ago
parent 95cdaf25f6
commit 216bf08ced

@ -1,23 +1,25 @@
using System;
using System.Web; using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using System.Linq; using System.Linq;
using MvcMiniProfiler; using StackExchange.Profiling;
using MvcMiniProfiler.MVCHelpers; using StackExchange.Profiling.MVCHelpers;
using Microsoft.Web.Infrastructure;
using Microsoft.Web.Infrastructure.DynamicModuleHelper; using Microsoft.Web.Infrastructure.DynamicModuleHelper;
using NzbDrone.Common;
using NzbDrone.Web.Helpers;
//using System.Data; //using System.Data;
//using System.Data.Entity; //using System.Data.Entity;
//using System.Data.Entity.Infrastructure; //using System.Data.Entity.Infrastructure;
//using StackExchange.Profiling.Data.EntityFramework;
//using StackExchange.Profiling.Data.Linq2Sql;
//using MvcMiniProfiler.Data.Linq2Sql; [assembly: WebActivator.PreApplicationStartMethod(
typeof(NzbDrone.Web.App_Start.MiniProfilerPackage), "PreStart")]
[assembly: WebActivator.PreApplicationStartMethod(typeof(NzbDrone.Web.App_Start.MiniProfilerPackage), "PreStart")] [assembly: WebActivator.PostApplicationStartMethod(
[assembly: WebActivator.PostApplicationStartMethod(typeof(NzbDrone.Web.App_Start.MiniProfilerPackage), "PostStart")] typeof(NzbDrone.Web.App_Start.MiniProfilerPackage), "PostStart")]
namespace NzbDrone.Web.App_Start namespace NzbDrone.Web.App_Start
{ {
public static class MiniProfilerPackage public static class MiniProfilerPackage
{ {
@ -27,23 +29,37 @@ namespace NzbDrone.Web.App_Start
// Be sure to restart you ASP.NET Developement server, this code will not run until you do that. // Be sure to restart you ASP.NET Developement server, this code will not run until you do that.
//TODO: See - _MINIPROFILER UPDATED Layout.cshtml //TODO: See - _MINIPROFILER UPDATED Layout.cshtml
// For profiling to display in the UI you will have to include the line @MvcMiniProfiler.MiniProfiler.RenderIncludes() // For profiling to display in the UI you will have to include the line @StackExchange.Profiling.MiniProfiler.RenderIncludes()
// in your master layout // in your master layout
//TODO: Non SQL Server based installs can use other formatters like: new MvcMiniProfiler.SqlFormatters.InlineFormatter() //TODO: Non SQL Server based installs can use other formatters like: new StackExchange.Profiling.SqlFormatters.InlineFormatter()
MiniProfiler.Settings.SqlFormatter = new MvcMiniProfiler.SqlFormatters.SqlServerFormatter(); MiniProfiler.Settings.SqlFormatter = new StackExchange.Profiling.SqlFormatters.SqlServerFormatter();
//TODO: To profile a standard DbConnection: //TODO: To profile a standard DbConnection:
// var profiled = new ProfiledDbConnection(cnn, MiniProfiler.Current); // var profiled = new ProfiledDbConnection(cnn, MiniProfiler.Current);
//TODO: If you are profiling EF code first try: //TODO: If you are profiling EF code first try:
// MiniProfilerEF.Initialize(); // MiniProfilerEF.Initialize();
//Make sure the MiniProfiler handles BeginRequest and EndRequest //Make sure the MiniProfiler handles BeginRequest and EndRequest
DynamicModuleUtility.RegisterModule(typeof(MiniProfilerStartupModule)); DynamicModuleUtility.RegisterModule(typeof(MiniProfilerStartupModule));
//Setup profiler for Controllers via a Global ActionFilter //Setup profiler for Controllers via a Global ActionFilter
GlobalFilters.Filters.Add(new ProfilingActionFilter()); GlobalFilters.Filters.Add(new ProfilingActionFilter());
// You can use this to check if a request is allowed to view results
//MiniProfiler.Settings.Results_Authorize = (request) =>
//{
// you should implement this if you need to restrict visibility of profiling on a per request basis
// return !DisableProfilingResults;
//};
// the list of all sessions in the store is restricted by default, you must return true to alllow it
//MiniProfiler.Settings.Results_List_Authorize = (request) =>
//{
// you may implement this if you need to restrict visibility of profiling lists on a per request basis
//return true; // all requests are kosher
//};
} }
public static void PostStart() public static void PostStart()
@ -65,33 +81,28 @@ namespace NzbDrone.Web.App_Start
{ {
context.BeginRequest += (sender, e) => context.BeginRequest += (sender, e) =>
{ {
//var request = ((HttpApplication)sender).Request; var request = ((HttpApplication)sender).Request;
//TODO: By default only local requests are profiled, optionally you can set it up //TODO: By default only local requests are profiled, optionally you can set it up
// so authenticated users are always profiled // so authenticated users are always profiled
//if (request.IsLocal) { MiniProfiler.Start(); } if (request.IsLocal) { MiniProfiler.Start(); }
if (!EnvironmentProvider.IsProduction || ProfilerHelper.Enabled())
{
var requestPath = ((HttpApplication)sender).Request.AppRelativeCurrentExecutionFilePath.ToLower();
if (!requestPath.StartsWith("~/signalr") && !requestPath.EndsWith("notification/comet"))
{
MiniProfiler.Start();
}
}
}; };
// TODO: You can control who sees the profiling information // TODO: You can control who sees the profiling information
/* /*
context.AuthenticateRequest += (sender, e) => context.AuthenticateRequest += (sender, e) =>
{ {
if (!CurrentUserIsAllowedToSeeProfiler()) if (!CurrentUserIsAllowedToSeeProfiler())
{ {
MvcMiniProfiler.MiniProfiler.Stop(discardResults: true); StackExchange.Profiling.MiniProfiler.Stop(discardResults: true);
} }
}; };
*/ */
context.EndRequest += (sender, e) => MiniProfiler.Stop(); context.EndRequest += (sender, e) =>
{
MiniProfiler.Stop();
};
} }
public void Dispose() { } public void Dispose() { }

@ -1,4 +1,5 @@
using System.Web.Mvc; using System.Web.Mvc;
using StackExchange.Profiling;
namespace NzbDrone.Web.Controllers namespace NzbDrone.Web.Controllers
{ {
@ -7,7 +8,7 @@ namespace NzbDrone.Web.Controllers
[HttpGet] [HttpGet]
public JsonResult Index() public JsonResult Index()
{ {
MvcMiniProfiler.MiniProfiler.Stop(true); MiniProfiler.Stop(true);
return Json("OK", JsonRequestBehavior.AllowGet); return Json("OK", JsonRequestBehavior.AllowGet);
} }

@ -1,8 +1,8 @@
using System.Threading; using System.Threading;
using System.Web.Mvc; using System.Web.Mvc;
using System.Web.UI; using System.Web.UI;
using MvcMiniProfiler;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using StackExchange.Profiling;
namespace NzbDrone.Web.Controllers namespace NzbDrone.Web.Controllers
{ {

@ -4,7 +4,6 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Web.Mvc; using System.Web.Mvc;
using System.Web.Script.Serialization; using System.Web.Script.Serialization;
using MvcMiniProfiler;
using NzbDrone.Common.Model; using NzbDrone.Common.Model;
using NzbDrone.Core; using NzbDrone.Core;
using NzbDrone.Core.Helpers; using NzbDrone.Core.Helpers;
@ -14,6 +13,7 @@ using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Repository.Quality;
using NzbDrone.Web.Models; using NzbDrone.Web.Models;
using StackExchange.Profiling;
namespace NzbDrone.Web.Controllers namespace NzbDrone.Web.Controllers
{ {

@ -68,8 +68,8 @@
<Private>True</Private> <Private>True</Private>
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath> <HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference> </Reference>
<Reference Include="MvcMiniProfiler, Version=1.9.0.0, Culture=neutral, PublicKeyToken=b44f9351044011a3, processorArchitecture=MSIL"> <Reference Include="MiniProfiler">
<HintPath>..\packages\MiniProfiler.1.9\lib\net40\MvcMiniProfiler.dll</HintPath> <HintPath>..\packages\MiniProfiler.2.0.2\lib\net40\MiniProfiler.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
@ -148,6 +148,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="App_Start\DataTablesMvc.cs" /> <Compile Include="App_Start\DataTablesMvc.cs" />
<Compile Include="App_Start\MiniProfiler.cs" />
<Compile Include="Controllers\SearchHistoryController.cs" /> <Compile Include="Controllers\SearchHistoryController.cs" />
<Compile Include="Helpers\Validation\RequiredIfAnyAttribute.cs" /> <Compile Include="Helpers\Validation\RequiredIfAnyAttribute.cs" />
<Compile Include="Helpers\Validation\RequiredIfAttribute.cs" /> <Compile Include="Helpers\Validation\RequiredIfAttribute.cs" />
@ -220,7 +221,6 @@
</Compile> </Compile>
<Compile Include="App_Start\EntityFramework.SqlServerCompact.cs" /> <Compile Include="App_Start\EntityFramework.SqlServerCompact.cs" />
<Compile Include="App_Start\Logging.cs" /> <Compile Include="App_Start\Logging.cs" />
<Compile Include="App_Start\MiniProfiler.cs" />
<Compile Include="Filters\JsonErrorFilter.cs" /> <Compile Include="Filters\JsonErrorFilter.cs" />
<Compile Include="Controllers\CommandController.cs" /> <Compile Include="Controllers\CommandController.cs" />
<Compile Include="Controllers\DirectoryController.cs" /> <Compile Include="Controllers\DirectoryController.cs" />
@ -549,6 +549,9 @@
<ItemGroup> <ItemGroup>
<Content Include="Views\Settings\MetadataPartial.cshtml" /> <Content Include="Views\Settings\MetadataPartial.cshtml" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="Views\Shared\_MINIPROFILER UPDATED Layout.cshtml" />
</ItemGroup>
<PropertyGroup> <PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

@ -1,70 +1,71 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
@{ Layout = "~/Views/Shared/_ReferenceLayout.cshtml"; } @{ Layout = "~/Views/Shared/_ReferenceLayout.cshtml"; }
@using NzbDrone.Common @using NzbDrone.Common
@using NzbDrone.Web.Helpers @using NzbDrone.Web.Helpers
@section HeaderContent @using StackExchange.Profiling
{ @section HeaderContent
@if (string.IsNullOrWhiteSpace(ViewBag.Title) || String.Equals(ViewBag.Title, "NzbDrone", StringComparison.InvariantCultureIgnoreCase)) {
{ @if (string.IsNullOrWhiteSpace(ViewBag.Title) || String.Equals(ViewBag.Title, "NzbDrone", StringComparison.InvariantCultureIgnoreCase))
ViewBag.Title = "NzbDrone"; {
} ViewBag.Title = "NzbDrone";
else }
{ else
ViewBag.Title = String.Format("{0} - NzbDrone", ViewBag.Title); {
} ViewBag.Title = String.Format("{0} - NzbDrone", ViewBag.Title);
<title>@ViewBag.Title</title> }
@if (!EnvironmentProvider.IsProduction || ProfilerHelper.Enabled()) <title>@ViewBag.Title</title>
{ @if (!EnvironmentProvider.IsProduction || ProfilerHelper.Enabled())
@MvcMiniProfiler.MiniProfiler.RenderIncludes() {
} @MiniProfiler.RenderIncludes()
@Html.IncludeCss("Grid.css") }
@RenderSection("HeaderContent", required: false) @Html.IncludeCss("Grid.css")
} @RenderSection("HeaderContent", required: false)
<div id="centered"> }
<div id="menu"> <div id="centered">
<ul> <div id="menu">
@MvcHtmlString.Create(Html.CurrentActionLink("Series", "Index", "Series")) <ul>
@MvcHtmlString.Create(Html.CurrentActionLink("Upcoming", "Index", "Upcoming")) @MvcHtmlString.Create(Html.CurrentActionLink("Series", "Index", "Series"))
@MvcHtmlString.Create(Html.CurrentActionLink("History", "Index", "History")) @MvcHtmlString.Create(Html.CurrentActionLink("Upcoming", "Index", "Upcoming"))
@MvcHtmlString.Create(Html.CurrentActionLink("Missing", "Index", "Missing")) @MvcHtmlString.Create(Html.CurrentActionLink("History", "Index", "History"))
@MvcHtmlString.Create(Html.CurrentActionLink("Settings", "Index", "Settings")) @MvcHtmlString.Create(Html.CurrentActionLink("Missing", "Index", "Missing"))
@MvcHtmlString.Create(Html.CurrentActionLink("Logs", "Index", "Log")) @MvcHtmlString.Create(Html.CurrentActionLink("Settings", "Index", "Settings"))
</ul> @MvcHtmlString.Create(Html.CurrentActionLink("Logs", "Index", "Log"))
<input id="localSeriesLookup" type="text" /> </ul>
</div> <input id="localSeriesLookup" type="text" />
<div id="logo"> </div>
@ViewBag.Title <div id="logo">
</div> @ViewBag.Title
<div id="page"> </div>
@RenderSection("ActionMenu", required: false) <div id="page">
@RenderBody() @RenderSection("ActionMenu", required: false)
</div> @RenderBody()
<div id="footer"> </div>
@{Html.RenderAction("Footer", "Shared");} <div id="footer">
</div> @{Html.RenderAction("Footer", "Shared");}
</div> </div>
<div id="msgBox"> </div>
<span id="msgText">background notification</span> <div id="msgBox">
</div> <span id="msgText">background notification</span>
@section Scripts </div>
{ @section Scripts
@RenderSection("Scripts", required: false) {
@Html.IncludeScript("jquery.signalR.min.js") @RenderSection("Scripts", required: false)
<script src="@Url.Content("~/signalr/hubs")" type="text/javascript"></script> @Html.IncludeScript("jquery.signalR.min.js")
@if (EnvironmentProvider.IsProduction) <script src="@Url.Content("~/signalr/hubs")" type="text/javascript"></script>
{ @if (EnvironmentProvider.IsProduction)
<script type="text/javascript"> {
var _gaq = _gaq || []; <script type="text/javascript">
_gaq.push(['_setAccount', 'UA-8318723-7']); var _gaq = _gaq || [];
_gaq.push(['_setDomainName', 'none']); _gaq.push(['_setAccount', 'UA-8318723-7']);
_gaq.push(['_setAllowLinker', true]); _gaq.push(['_setDomainName', 'none']);
_gaq.push(['_trackPageview']); _gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; (function () {
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
})(); var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
</script> })();
} </script>
} }
}

@ -15,8 +15,8 @@
<package id="jQuery.Validation.Unobtrusive" version="2.0.20126.16343" /> <package id="jQuery.Validation.Unobtrusive" version="2.0.20126.16343" />
<package id="jQuery.vsdoc" version="1.6" /> <package id="jQuery.vsdoc" version="1.6" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" /> <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
<package id="MiniProfiler" version="1.9" /> <package id="MiniProfiler" version="2.0.2" />
<package id="MiniProfiler.MVC3" version="1.9.1" /> <package id="MiniProfiler.MVC3" version="2.0.2" />
<package id="Newtonsoft.Json" version="4.5.3" /> <package id="Newtonsoft.Json" version="4.5.3" />
<package id="Ninject" version="2.2.1.4" /> <package id="Ninject" version="2.2.1.4" />
<package id="Ninject.MVC3" version="2.2.2.0" /> <package id="Ninject.MVC3" version="2.2.2.0" />

File diff suppressed because it is too large Load Diff

@ -2,15 +2,15 @@
using System.Web; using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using System.Linq; using System.Linq;
using MvcMiniProfiler; using StackExchange.Profiling;
using MvcMiniProfiler.MVCHelpers; using StackExchange.Profiling.MVCHelpers;
using Microsoft.Web.Infrastructure; using Microsoft.Web.Infrastructure;
using Microsoft.Web.Infrastructure.DynamicModuleHelper; using Microsoft.Web.Infrastructure.DynamicModuleHelper;
//using System.Data; //using System.Data;
//using System.Data.Entity; //using System.Data.Entity;
//using System.Data.Entity.Infrastructure; //using System.Data.Entity.Infrastructure;
//using MvcMiniProfiler.Data.EntityFramework; //using StackExchange.Profiling.Data.EntityFramework;
//using MvcMiniProfiler.Data.Linq2Sql; //using StackExchange.Profiling.Data.Linq2Sql;
[assembly: WebActivator.PreApplicationStartMethod( [assembly: WebActivator.PreApplicationStartMethod(
typeof($rootnamespace$.App_Start.MiniProfilerPackage), "PreStart")] typeof($rootnamespace$.App_Start.MiniProfilerPackage), "PreStart")]
@ -29,11 +29,11 @@ namespace $rootnamespace$.App_Start
// Be sure to restart you ASP.NET Developement server, this code will not run until you do that. // Be sure to restart you ASP.NET Developement server, this code will not run until you do that.
//TODO: See - _MINIPROFILER UPDATED Layout.cshtml //TODO: See - _MINIPROFILER UPDATED Layout.cshtml
// For profiling to display in the UI you will have to include the line @MvcMiniProfiler.MiniProfiler.RenderIncludes() // For profiling to display in the UI you will have to include the line @StackExchange.Profiling.MiniProfiler.RenderIncludes()
// in your master layout // in your master layout
//TODO: Non SQL Server based installs can use other formatters like: new MvcMiniProfiler.SqlFormatters.InlineFormatter() //TODO: Non SQL Server based installs can use other formatters like: new StackExchange.Profiling.SqlFormatters.InlineFormatter()
MiniProfiler.Settings.SqlFormatter = new MvcMiniProfiler.SqlFormatters.SqlServerFormatter(); MiniProfiler.Settings.SqlFormatter = new StackExchange.Profiling.SqlFormatters.SqlServerFormatter();
//TODO: To profile a standard DbConnection: //TODO: To profile a standard DbConnection:
// var profiled = new ProfiledDbConnection(cnn, MiniProfiler.Current); // var profiled = new ProfiledDbConnection(cnn, MiniProfiler.Current);
@ -46,6 +46,20 @@ namespace $rootnamespace$.App_Start
//Setup profiler for Controllers via a Global ActionFilter //Setup profiler for Controllers via a Global ActionFilter
GlobalFilters.Filters.Add(new ProfilingActionFilter()); GlobalFilters.Filters.Add(new ProfilingActionFilter());
// You can use this to check if a request is allowed to view results
//MiniProfiler.Settings.Results_Authorize = (request) =>
//{
// you should implement this if you need to restrict visibility of profiling on a per request basis
// return !DisableProfilingResults;
//};
// the list of all sessions in the store is restricted by default, you must return true to alllow it
//MiniProfiler.Settings.Results_List_Authorize = (request) =>
//{
// you may implement this if you need to restrict visibility of profiling lists on a per request basis
//return true; // all requests are kosher
//};
} }
public static void PostStart() public static void PostStart()
@ -80,7 +94,7 @@ namespace $rootnamespace$.App_Start
{ {
if (!CurrentUserIsAllowedToSeeProfiler()) if (!CurrentUserIsAllowedToSeeProfiler())
{ {
MvcMiniProfiler.MiniProfiler.Stop(discardResults: true); StackExchange.Profiling.MiniProfiler.Stop(discardResults: true);
} }
}; };
*/ */

@ -1,16 +1,20 @@
<!DOCTYPE html> @* Required so you have extention methods for client timings *@
@using StackExchange.Profiling;
<!DOCTYPE html>
<html> <html>
<head> <head>
@* optional (enable client timing framework) *@
@this.InitClientTimings()
<meta charset="utf-8" /> <meta charset="utf-8" />
<title>@ViewBag.Title</title> <title>@ViewBag.Title</title>
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script> @* optional time scripts in the header *@
<script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script> @this.TimeScript("Content Site.css",
@<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />)
@* Make sure you've added this one line to your LAYOUT or MASTER PAGE *@ @this.TimeScript("jQuery 1.5.1",
@<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>)
@MvcMiniProfiler.MiniProfiler.RenderIncludes() @this.TimeScript("modernizr",
@<script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>)
</head> </head>
<body> <body>
@ -35,5 +39,7 @@
<footer> <footer>
</footer> </footer>
</div> </div>
@* Make sure you've added this one line to your LAYOUT or MASTER PAGE *@
@MiniProfiler.RenderIncludes()
</body> </body>
</html> </html>
Loading…
Cancel
Save