1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-30 07:22:35 +01:00

Updated MiniProfiler to v2

This commit is contained in:
Mark McDowall 2012-07-27 14:31:33 -07:00
parent 95cdaf25f6
commit 216bf08ced
16 changed files with 2407 additions and 123 deletions

View File

@ -1,23 +1,25 @@
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
namespace NzbDrone.Web.App_Start
{
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.
//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);
//TODO: To profile a standard DbConnection:
// var profiled = new ProfiledDbConnection(cnn, MiniProfiler.Current);
//TODO: If you are profiling EF code first try:
// MiniProfilerEF.Initialize();
// MiniProfilerEF.Initialize();
//Make sure the MiniProfiler handles BeginRequest and EndRequest
DynamicModuleUtility.RegisterModule(typeof(MiniProfilerStartupModule));
//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() { }

View File

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

View File

@ -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
{

View File

@ -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
{

View File

@ -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>

View File

@ -1,70 +1,71 @@
<!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"; }
@using NzbDrone.Common
@using NzbDrone.Web.Helpers
@section HeaderContent
{
@if (string.IsNullOrWhiteSpace(ViewBag.Title) || String.Equals(ViewBag.Title, "NzbDrone", StringComparison.InvariantCultureIgnoreCase))
{
ViewBag.Title = "NzbDrone";
}
else
{
ViewBag.Title = String.Format("{0} - NzbDrone", ViewBag.Title);
}
<title>@ViewBag.Title</title>
@if (!EnvironmentProvider.IsProduction || ProfilerHelper.Enabled())
{
@MvcMiniProfiler.MiniProfiler.RenderIncludes()
}
@Html.IncludeCss("Grid.css")
@RenderSection("HeaderContent", required: false)
}
<div id="centered">
<div id="menu">
<ul>
@MvcHtmlString.Create(Html.CurrentActionLink("Series", "Index", "Series"))
@MvcHtmlString.Create(Html.CurrentActionLink("Upcoming", "Index", "Upcoming"))
@MvcHtmlString.Create(Html.CurrentActionLink("History", "Index", "History"))
@MvcHtmlString.Create(Html.CurrentActionLink("Missing", "Index", "Missing"))
@MvcHtmlString.Create(Html.CurrentActionLink("Settings", "Index", "Settings"))
@MvcHtmlString.Create(Html.CurrentActionLink("Logs", "Index", "Log"))
</ul>
<input id="localSeriesLookup" type="text" />
</div>
<div id="logo">
@ViewBag.Title
</div>
<div id="page">
@RenderSection("ActionMenu", required: false)
@RenderBody()
</div>
<div id="footer">
@{Html.RenderAction("Footer", "Shared");}
</div>
</div>
<div id="msgBox">
<span id="msgText">background notification</span>
</div>
@section Scripts
{
@RenderSection("Scripts", required: false)
@Html.IncludeScript("jquery.signalR.min.js")
<script src="@Url.Content("~/signalr/hubs")" type="text/javascript"></script>
@if (EnvironmentProvider.IsProduction)
{
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-8318723-7']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
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>
}
}
<!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"; }
@using NzbDrone.Common
@using NzbDrone.Web.Helpers
@using StackExchange.Profiling
@section HeaderContent
{
@if (string.IsNullOrWhiteSpace(ViewBag.Title) || String.Equals(ViewBag.Title, "NzbDrone", StringComparison.InvariantCultureIgnoreCase))
{
ViewBag.Title = "NzbDrone";
}
else
{
ViewBag.Title = String.Format("{0} - NzbDrone", ViewBag.Title);
}
<title>@ViewBag.Title</title>
@if (!EnvironmentProvider.IsProduction || ProfilerHelper.Enabled())
{
@MiniProfiler.RenderIncludes()
}
@Html.IncludeCss("Grid.css")
@RenderSection("HeaderContent", required: false)
}
<div id="centered">
<div id="menu">
<ul>
@MvcHtmlString.Create(Html.CurrentActionLink("Series", "Index", "Series"))
@MvcHtmlString.Create(Html.CurrentActionLink("Upcoming", "Index", "Upcoming"))
@MvcHtmlString.Create(Html.CurrentActionLink("History", "Index", "History"))
@MvcHtmlString.Create(Html.CurrentActionLink("Missing", "Index", "Missing"))
@MvcHtmlString.Create(Html.CurrentActionLink("Settings", "Index", "Settings"))
@MvcHtmlString.Create(Html.CurrentActionLink("Logs", "Index", "Log"))
</ul>
<input id="localSeriesLookup" type="text" />
</div>
<div id="logo">
@ViewBag.Title
</div>
<div id="page">
@RenderSection("ActionMenu", required: false)
@RenderBody()
</div>
<div id="footer">
@{Html.RenderAction("Footer", "Shared");}
</div>
</div>
<div id="msgBox">
<span id="msgText">background notification</span>
</div>
@section Scripts
{
@RenderSection("Scripts", required: false)
@Html.IncludeScript("jquery.signalR.min.js")
<script src="@Url.Content("~/signalr/hubs")" type="text/javascript"></script>
@if (EnvironmentProvider.IsProduction)
{
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-8318723-7']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
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>
}
}

View File

@ -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" />

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -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>

Binary file not shown.