From 8779a37f7fe58134f8244b6f11ae4950924f11ff Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 13 Nov 2011 22:01:51 -0800 Subject: [PATCH] UI for automatic update. --- NzbDrone.Common/ExceptioneerTarget.cs | 2 +- NzbDrone.Update/Program.cs | 27 ++++++++++++++--- NzbDrone.Web/Controllers/UpdateController.cs | 32 ++++++++++++++++++++ NzbDrone.Web/NzbDrone.Web.csproj | 5 +++ NzbDrone.Web/Views/Update/Index.cshtml | 16 ++++++++++ 5 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 NzbDrone.Web/Controllers/UpdateController.cs create mode 100644 NzbDrone.Web/Views/Update/Index.cshtml diff --git a/NzbDrone.Common/ExceptioneerTarget.cs b/NzbDrone.Common/ExceptioneerTarget.cs index 600f4c93d..51883b907 100644 --- a/NzbDrone.Common/ExceptioneerTarget.cs +++ b/NzbDrone.Common/ExceptioneerTarget.cs @@ -14,7 +14,7 @@ namespace NzbDrone.Common if (logEvent == null || logEvent.Exception == null) return; if (Debugger.IsAttached || Process.GetCurrentProcess().ProcessName.Contains("JetBrains")) return; - Logger.Trace("Sending Exception to Exceptioneer. {0}", Process.GetCurrentProcess().ProcessName); + Logger.Trace("Sending Exception to Exceptioneer. Process Name: {0}", Process.GetCurrentProcess().ProcessName); logEvent.Exception.Data.Add("Message", logEvent.Message); diff --git a/NzbDrone.Update/Program.cs b/NzbDrone.Update/Program.cs index ed3cf0f34..bddb8221e 100644 --- a/NzbDrone.Update/Program.cs +++ b/NzbDrone.Update/Program.cs @@ -2,6 +2,8 @@ using System.IO; using System.Linq; using NLog; +using NLog.Config; +using NLog.Targets; using NzbDrone.Common; using NzbDrone.Update.Providers; @@ -26,10 +28,7 @@ namespace NzbDrone.Update { Console.WriteLine("Starting NzbDrone Update Client"); - LogConfiguration.RegisterConsoleLogger(LogLevel.Trace); - LogConfiguration.RegisterUdpLogger(); - LogConfiguration.RegisterExceptioneer(); - LogConfiguration.Reload(); + InitLoggers(); logger.Info("Initializing update application"); @@ -48,6 +47,26 @@ namespace NzbDrone.Update } } + private static void InitLoggers() + { + LogConfiguration.RegisterConsoleLogger(LogLevel.Trace); + LogConfiguration.RegisterUdpLogger(); + LogConfiguration.RegisterExceptioneer(); + + var fileTarget = new FileTarget(); + fileTarget.AutoFlush = true; + fileTarget.ConcurrentWrites = false; + fileTarget.DeleteOldFileOnStartup = true; + fileTarget.FileName = "upgrade.log"; + fileTarget.KeepFileOpen =false; + + fileTarget.Layout = "${logger}: ${message} ${exception}"; + LogManager.Configuration.AddTarget(fileTarget.GetType().Name, fileTarget); + LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, fileTarget)); + + LogConfiguration.Reload(); + } + public void Start(string[] args) { VerfityArguments(args); diff --git a/NzbDrone.Web/Controllers/UpdateController.cs b/NzbDrone.Web/Controllers/UpdateController.cs new file mode 100644 index 000000000..bb0b39722 --- /dev/null +++ b/NzbDrone.Web/Controllers/UpdateController.cs @@ -0,0 +1,32 @@ +using System.Linq; +using System.Web.Mvc; +using NzbDrone.Core.Providers; +using NzbDrone.Core.Providers.Jobs; +using NzbDrone.Web.Models; + +namespace NzbDrone.Web.Controllers +{ + public class UpdateController : Controller + { + private readonly UpdateProvider _updateProvider; + private readonly JobProvider _jobProvider; + + public UpdateController(UpdateProvider updateProvider, JobProvider jobProvider) + { + _updateProvider = updateProvider; + _jobProvider = jobProvider; + } + + public ActionResult Index() + { + return View(_updateProvider.GetAvilableUpdate()); + } + + public ActionResult StartUpdate() + { + _jobProvider.QueueJob(typeof(AppUpdateJob), 0, 0); + + return Json(new NotificationResult() { Title = "Update will begin shortly", NotificationType = NotificationType.Info, Text = "NzbDrone will restart automatically."}); + } + } +} diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 7962bd742..ac9fd1fa6 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -45,6 +45,7 @@ x86 + False ..\packages\MiniProfiler.1.9\lib\net40\MvcMiniProfiler.dll @@ -448,6 +449,7 @@ + Global.asax @@ -922,6 +924,9 @@ + + +