Updated MiniProfiler to v2

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

@ -1,20 +1,22 @@
using System;
using System.Web;
using System.Web.Mvc;
using System.Linq;
using MvcMiniProfiler;
using MvcMiniProfiler.MVCHelpers;
using StackExchange.Profiling;
using StackExchange.Profiling.MVCHelpers;
using Microsoft.Web.Infrastructure;
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
using NzbDrone.Common;
using NzbDrone.Web.Helpers;
//using System.Data;
//using System.Data.Entity;
//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(typeof(NzbDrone.Web.App_Start.MiniProfilerPackage), "PostStart")]
[assembly: WebActivator.PostApplicationStartMethod(
typeof(NzbDrone.Web.App_Start.MiniProfilerPackage), "PostStart")]
namespace NzbDrone.Web.App_Start
@ -27,11 +29,11 @@ namespace NzbDrone.Web.App_Start
// Be sure to restart you ASP.NET Developement server, this code will not run until you do that.
//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
//TODO: Non SQL Server based installs can use other formatters like: new MvcMiniProfiler.SqlFormatters.InlineFormatter()
MiniProfiler.Settings.SqlFormatter = new MvcMiniProfiler.SqlFormatters.SqlServerFormatter();
//TODO: Non SQL Server based installs can use other formatters like: new StackExchange.Profiling.SqlFormatters.InlineFormatter()
MiniProfiler.Settings.SqlFormatter = new StackExchange.Profiling.SqlFormatters.SqlServerFormatter();
//TODO: To profile a standard DbConnection:
// var profiled = new ProfiledDbConnection(cnn, MiniProfiler.Current);
@ -44,6 +46,20 @@ namespace NzbDrone.Web.App_Start
//Setup profiler for Controllers via a Global ActionFilter
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()
@ -65,33 +81,28 @@ namespace NzbDrone.Web.App_Start
{
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
// so authenticated users are always profiled
//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();
}
}
if (request.IsLocal) { MiniProfiler.Start(); }
};
// TODO: You can control who sees the profiling information
/*
context.AuthenticateRequest += (sender, e) =>
{
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() { }

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

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

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

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

@ -2,6 +2,7 @@
@{ Layout = "~/Views/Shared/_ReferenceLayout.cshtml"; }
@using NzbDrone.Common
@using NzbDrone.Web.Helpers
@using StackExchange.Profiling
@section HeaderContent
{
@if (string.IsNullOrWhiteSpace(ViewBag.Title) || String.Equals(ViewBag.Title, "NzbDrone", StringComparison.InvariantCultureIgnoreCase))
@ -15,7 +16,7 @@
<title>@ViewBag.Title</title>
@if (!EnvironmentProvider.IsProduction || ProfilerHelper.Enabled())
{
@MvcMiniProfiler.MiniProfiler.RenderIncludes()
@MiniProfiler.RenderIncludes()
}
@Html.IncludeCss("Grid.css")
@RenderSection("HeaderContent", required: false)

@ -15,8 +15,8 @@
<package id="jQuery.Validation.Unobtrusive" version="2.0.20126.16343" />
<package id="jQuery.vsdoc" version="1.6" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
<package id="MiniProfiler" version="1.9" />
<package id="MiniProfiler.MVC3" version="1.9.1" />
<package id="MiniProfiler" version="2.0.2" />
<package id="MiniProfiler.MVC3" version="2.0.2" />
<package id="Newtonsoft.Json" version="4.5.3" />
<package id="Ninject" version="2.2.1.4" />
<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.Mvc;
using System.Linq;
using MvcMiniProfiler;
using MvcMiniProfiler.MVCHelpers;
using StackExchange.Profiling;
using StackExchange.Profiling.MVCHelpers;
using Microsoft.Web.Infrastructure;
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
//using System.Data;
//using System.Data.Entity;
//using System.Data.Entity.Infrastructure;
//using MvcMiniProfiler.Data.EntityFramework;
//using MvcMiniProfiler.Data.Linq2Sql;
//using StackExchange.Profiling.Data.EntityFramework;
//using StackExchange.Profiling.Data.Linq2Sql;
[assembly: WebActivator.PreApplicationStartMethod(
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.
//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
//TODO: Non SQL Server based installs can use other formatters like: new MvcMiniProfiler.SqlFormatters.InlineFormatter()
MiniProfiler.Settings.SqlFormatter = new MvcMiniProfiler.SqlFormatters.SqlServerFormatter();
//TODO: Non SQL Server based installs can use other formatters like: new StackExchange.Profiling.SqlFormatters.InlineFormatter()
MiniProfiler.Settings.SqlFormatter = new StackExchange.Profiling.SqlFormatters.SqlServerFormatter();
//TODO: To profile a standard DbConnection:
// var profiled = new ProfiledDbConnection(cnn, MiniProfiler.Current);
@ -46,6 +46,20 @@ namespace $rootnamespace$.App_Start
//Setup profiler for Controllers via a Global ActionFilter
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()
@ -80,7 +94,7 @@ namespace $rootnamespace$.App_Start
{
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>
<head>
@* optional (enable client timing framework) *@
@this.InitClientTimings()
<meta charset="utf-8" />
<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>
<script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
@* Make sure you've added this one line to your LAYOUT or MASTER PAGE *@
@MvcMiniProfiler.MiniProfiler.RenderIncludes()
@* optional time scripts in the header *@
@this.TimeScript("Content Site.css",
@<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />)
@this.TimeScript("jQuery 1.5.1",
@<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>)
@this.TimeScript("modernizr",
@<script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>)
</head>
<body>
@ -35,5 +39,7 @@
<footer>
</footer>
</div>
@* Make sure you've added this one line to your LAYOUT or MASTER PAGE *@
@MiniProfiler.RenderIncludes()
</body>
</html>
Loading…
Cancel
Save