diff --git a/NzbDrone.Web/App_Start/EntityFramework.SqlServerCompact.cs b/NzbDrone.Web/App_Start/EntityFramework.SqlServerCompact.cs new file mode 100644 index 000000000..a579f7479 --- /dev/null +++ b/NzbDrone.Web/App_Start/EntityFramework.SqlServerCompact.cs @@ -0,0 +1,12 @@ +using System.Data.Entity; +using System.Data.Entity.Infrastructure; + +[assembly: WebActivator.PreApplicationStartMethod(typeof(NzbDrone.Web.App_Start.EntityFramework_SqlServerCompact), "Start")] + +namespace NzbDrone.Web.App_Start { + public static class EntityFramework_SqlServerCompact { + public static void Start() { + Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0"); + } + } +} diff --git a/NzbDrone.Web/App_Start/MiniProfiler.cs b/NzbDrone.Web/App_Start/MiniProfiler.cs new file mode 100644 index 000000000..11f7c4410 --- /dev/null +++ b/NzbDrone.Web/App_Start/MiniProfiler.cs @@ -0,0 +1,95 @@ +using System.Web; +using System.Web.Mvc; +using System.Linq; +using MvcMiniProfiler; +using MvcMiniProfiler.MVCHelpers; +using Microsoft.Web.Infrastructure.DynamicModuleHelper; +//using System.Data; +//using System.Data.Entity; +//using System.Data.Entity.Infrastructure; + +//using MvcMiniProfiler.Data.Linq2Sql; + +[assembly: WebActivator.PreApplicationStartMethod( + typeof(NzbDrone.Web.App_Start.MiniProfilerPackage), "PreStart")] + +[assembly: WebActivator.PostApplicationStartMethod( + typeof(NzbDrone.Web.App_Start.MiniProfilerPackage), "PostStart")] + + +namespace NzbDrone.Web.App_Start +{ + public static class MiniProfilerPackage + { + public static void PreStart() + { + + // 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() + // 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: To profile a standard DbConnection: + // var profiled = new ProfiledDbConnection(cnn, MiniProfiler.Current); + + //TODO: If you are profiling EF code first try: + // 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()); + } + + public static void PostStart() + { + // Intercept ViewEngines to profile all partial views and regular views. + // If you prefer to insert your profiling blocks manually you can comment this out + var copy = ViewEngines.Engines.ToList(); + ViewEngines.Engines.Clear(); + foreach (var item in copy) + { + ViewEngines.Engines.Add(new ProfilingViewEngine(item)); + } + } + } + + public class MiniProfilerStartupModule : IHttpModule + { + public void Init(HttpApplication context) + { + context.BeginRequest += (sender, e) => + { + 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(); } + }; + + + // TODO: You can control who sees the profiling information + /* + context.AuthenticateRequest += (sender, e) => + { + if (!CurrentUserIsAllowedToSeeProfiler()) + { + MvcMiniProfiler.MiniProfiler.Stop(discardResults: true); + } + }; + */ + + context.EndRequest += (sender, e) => + { + MiniProfiler.Stop(); + }; + } + + public void Dispose() { } + } +} + diff --git a/NzbDrone.Web/Global.asax.cs b/NzbDrone.Web/Global.asax.cs index b1919b223..b8c7a200e 100644 --- a/NzbDrone.Web/Global.asax.cs +++ b/NzbDrone.Web/Global.asax.cs @@ -4,18 +4,14 @@ using System.Linq; using System.Reflection; using System.Threading; using System.Web; -using System.Web.Caching; using System.Web.Mvc; using System.Web.Routing; -using MvcMiniProfiler; using NLog.Config; using Ninject; using Ninject.Web.Mvc; using NLog; using NzbDrone.Common; using NzbDrone.Core; -using NzbDrone.Core.Instrumentation; -using Telerik.Web.Mvc; namespace NzbDrone.Web { @@ -99,13 +95,11 @@ namespace NzbDrone.Web protected void Application_BeginRequest() { - Thread.CurrentThread.Name = "UI"; - MiniProfiler.Start(); + Thread.CurrentThread.Name = "WEB_THREAD"; } protected void Application_EndRequest() { - MiniProfiler.Stop(); } } } \ No newline at end of file diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 86c876b5b..be31737e8 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -46,23 +46,20 @@ - False ..\packages\EntityFramework.4.2.0.0\lib\net40\EntityFramework.dll + - False - ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll True + ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll - - False ..\packages\MiniProfiler.1.9\lib\net40\MvcMiniProfiler.dll ..\packages\Ninject.2.2.1.4\lib\net40-Full\Ninject.dll - + ..\packages\Ninject.MVC3.2.2.2.0\lib\net40-Full\Ninject.Web.Mvc.dll @@ -118,6 +115,10 @@ False ..\Libraries\TvdbLib.dll + + False + ..\packages\WebActivator.1.5\lib\net40\WebActivator.dll + @@ -174,6 +175,8 @@ True UploadLocalization.en-US.resx + + @@ -486,9 +489,6 @@ - - - diff --git a/NzbDrone.Web/Views/Log/Index.cshtml b/NzbDrone.Web/Views/Log/Index.cshtml index 2e3f5b9b1..dcae34133 100644 --- a/NzbDrone.Web/Views/Log/Index.cshtml +++ b/NzbDrone.Web/Views/Log/Index.cshtml @@ -24,7 +24,11 @@ Logs } @section ActionMenu{ - @{Html.RenderPartial("SubMenu");} + + @Ajax.ActionLink("Clear Logs", "Clear", "Log", new AjaxOptions { OnSuccess = "reloadGrid" }) + + + } @section MainContent{ @{Html.Telerik().Grid().Name("logsGrid") @@ -32,7 +36,7 @@ Logs .Columns(columns => { columns.Bound(c => c.Time).Title("Time").Width(170); - columns.Bound(c => c.Level).Title("Level"); + columns.Bound(c => c.Level).Title("Level").Width(70); columns.Bound(c => c.Logger).Title("Source"); columns.Bound(c => c.Message); }) @@ -41,15 +45,12 @@ Logs "<#= ExceptionType #>" + "<#= Exception #>" )) - .DataBinding(data => - { - data.Server().Select("AjaxBinding", "Log", new { ajax = true }); - data.Ajax().Select("AjaxBinding", "Log").Enabled(true); - }) + .DataBinding(data => data.Ajax().Select("AjaxBinding", "Log").Enabled(true)) .Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.Time).Descending()).Enabled(true)) - .Pageable(c => c.PageSize(50).Position(GridPagerPosition.Bottom).Style(GridPagerStyles.NextPrevious)) + .Pageable(paging => paging.Style(GridPagerStyles.Status).PageOnScroll(true).PageSize(100)) .Filterable() .ClientEvents(c => c.OnRowDataBound("onRowDataBound")) + .Scrollable(c=>c.Height(500)) .Render();} } + + + @* Make sure you've added this one line to your LAYOUT or MASTER PAGE *@ + + @MvcMiniProfiler.MiniProfiler.RenderIncludes() + + + + + + + + My MVC Application + + + @Html.Partial("_LogOnPartial") + + + + @Html.ActionLink("Home", "Index", "Home") + @Html.ActionLink("About", "About", "Home") + + + + + @RenderBody() + + + + +