From fd32a04d45c7def0844da46d3af90853d02385a8 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Fri, 22 Apr 2011 10:09:06 -0700 Subject: [PATCH] Attach to debugger is a lot more reliable. Added system/config ui rss job only runs enabled jobs fixed wrong mappings for indexers in settingscontroller --- .../Providers/Core/ConfigProvider.cs | 7 +++ .../Providers/Indexer/IndexerProviderBase.cs | 2 +- NzbDrone.Core/Providers/Jobs/RssSyncJob.cs | 2 +- .../Controllers/SettingsController.cs | 18 ++++---- NzbDrone.Web/Controllers/SystemController.cs | 11 ++++- NzbDrone.Web/NzbDrone.Web.csproj | 1 + NzbDrone.Web/Views/System/Config.cshtml | 9 ++++ NzbDrone/ProcessAttacher.cs | 28 +++++------ NzbDrone/Program.cs | 46 +++++++++++++++---- 9 files changed, 86 insertions(+), 38 deletions(-) create mode 100644 NzbDrone.Web/Views/System/Config.cshtml diff --git a/NzbDrone.Core/Providers/Core/ConfigProvider.cs b/NzbDrone.Core/Providers/Core/ConfigProvider.cs index be928d4aa..c124a966e 100644 --- a/NzbDrone.Core/Providers/Core/ConfigProvider.cs +++ b/NzbDrone.Core/Providers/Core/ConfigProvider.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Linq; using NLog; using NzbDrone.Core.Repository; using SubSonic.Repository; @@ -15,6 +17,11 @@ namespace NzbDrone.Core.Providers.Core _sonicRepo = dataRepository; } + public IList All() + { + return _sonicRepo.All().ToList(); + } + public ConfigProvider() { } diff --git a/NzbDrone.Core/Providers/Indexer/IndexerProviderBase.cs b/NzbDrone.Core/Providers/Indexer/IndexerProviderBase.cs index be09fa51a..ebe41399f 100644 --- a/NzbDrone.Core/Providers/Indexer/IndexerProviderBase.cs +++ b/NzbDrone.Core/Providers/Indexer/IndexerProviderBase.cs @@ -44,7 +44,7 @@ namespace NzbDrone.Core.Providers.Indexer protected abstract string[] Urls { get; } - protected IndexerSetting Settings + public IndexerSetting Settings { get { diff --git a/NzbDrone.Core/Providers/Jobs/RssSyncJob.cs b/NzbDrone.Core/Providers/Jobs/RssSyncJob.cs index cb56934ec..5b5e61e03 100644 --- a/NzbDrone.Core/Providers/Jobs/RssSyncJob.cs +++ b/NzbDrone.Core/Providers/Jobs/RssSyncJob.cs @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Providers.Jobs public void Start(ProgressNotification notification, int targetId) { - foreach (var indexer in _indexers) + foreach (var indexer in _indexers.Where(i => i.Settings.Enable)) { indexer.Fetch(); } diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index 7505c71f5..62c0efec9 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -66,11 +66,11 @@ namespace NzbDrone.Web.Controllers NzbMatrixApiKey = _configProvider.GetValue("NzbMatrixApiKey", String.Empty, true), - NzbsrusUId = _configProvider.GetValue("NzbsrusUId", String.Empty, true), - NzbsrusHash = _configProvider.GetValue("NzbsrusHash", String.Empty, true), + NzbsrusUId = _configProvider.NzbsrusUId, + NzbsrusHash = _configProvider.NzbsrusHash, - NzbsOrgHash = _configProvider.NzbsrusHash, - NzbsOrgUId = _configProvider.NzbsrusUId, + NzbsOrgHash = _configProvider.NzbsOrgHash, + NzbsOrgUId = _configProvider.NzbsOrgUId, NewzbinUsername = _configProvider.NewzbinUsername, NewzbinPassword = _configProvider.NewzbinPassword, @@ -214,7 +214,7 @@ namespace NzbDrone.Web.Controllers { Name = "New Profile", UserProfile = true, - Allowed = new List {QualityTypes.Unknown}, + Allowed = new List { QualityTypes.Unknown }, Cutoff = QualityTypes.Unknown, }; @@ -272,7 +272,7 @@ namespace NzbDrone.Web.Controllers { return new JsonResult { Data = "failed" }; } - + return new JsonResult { Data = "ok" }; } @@ -333,14 +333,14 @@ namespace NzbDrone.Web.Controllers newzbinSettings.Enable = data.NewzbinEnabled; _indexerProvider.SaveSettings(newzbinSettings); - _configProvider.NzbsrusHash = data.NzbsOrgHash; _configProvider.NzbsOrgUId = data.NzbsOrgUId; + _configProvider.NzbsOrgHash = data.NzbsOrgHash; _configProvider.NzbMatrixUsername = data.NzbMatrixUsername; _configProvider.NzbMatrixApiKey = data.NzbMatrixApiKey; _configProvider.NzbsrusUId = data.NzbsrusUId; - _configProvider.NzbsOrgUId = data.NzbsrusHash; + _configProvider.NzbsrusHash = data.NzbsrusHash; _configProvider.NewzbinUsername = data.NewzbinUsername; _configProvider.NewzbinPassword = data.NewzbinPassword; @@ -402,7 +402,7 @@ namespace NzbDrone.Web.Controllers return Content("Error Saving Settings, please fix any errors"); //profile.Cutoff = profile.Allowed.Last(); - _qualityProvider.Update(profile); + _qualityProvider.Update(profile); } return Content(SETTINGS_SAVED); } diff --git a/NzbDrone.Web/Controllers/SystemController.cs b/NzbDrone.Web/Controllers/SystemController.cs index dd0dfb69f..692f995cd 100644 --- a/NzbDrone.Web/Controllers/SystemController.cs +++ b/NzbDrone.Web/Controllers/SystemController.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Web; using System.Web.Mvc; using NzbDrone.Core.Providers; +using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Jobs; namespace NzbDrone.Web.Controllers @@ -12,11 +13,13 @@ namespace NzbDrone.Web.Controllers { private readonly JobProvider _jobProvider; private readonly IndexerProvider _indexerProvider; + private readonly ConfigProvider _configProvider; - public SystemController(JobProvider jobProvider, IndexerProvider indexerProvider) + public SystemController(JobProvider jobProvider, IndexerProvider indexerProvider, ConfigProvider configProvider) { _jobProvider = jobProvider; _indexerProvider = indexerProvider; + _configProvider = configProvider; } public ActionResult Jobs() @@ -30,5 +33,11 @@ namespace NzbDrone.Web.Controllers } + public ActionResult Config() + { + return View(_configProvider.All()); + } + + } } diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 478023e0a..a5b6f7678 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -683,6 +683,7 @@ + diff --git a/NzbDrone.Web/Views/System/Config.cshtml b/NzbDrone.Web/Views/System/Config.cshtml new file mode 100644 index 000000000..3515402d8 --- /dev/null +++ b/NzbDrone.Web/Views/System/Config.cshtml @@ -0,0 +1,9 @@ +@model IEnumerable +@section TitleContent{ +Config +} +@section MainContent{ + @{Html.Telerik().Grid(Model).Name("Grid") + .TableHtmlAttributes(new { @class = "Grid" }) + .Render();} +} diff --git a/NzbDrone/ProcessAttacher.cs b/NzbDrone/ProcessAttacher.cs index dc7432576..a1b7a4e56 100644 --- a/NzbDrone/ProcessAttacher.cs +++ b/NzbDrone/ProcessAttacher.cs @@ -10,31 +10,27 @@ using System.Collections.Generic; using System.Runtime.InteropServices; using EnvDTE; using EnvDTE80; +using NLog; using Thread = System.Threading.Thread; namespace NzbDrone { public class ProcessAttacher { + + private static readonly Logger Logger = LogManager.GetLogger("Application"); + + public static void Attach() { - for (int i = 0; i < 10; i++) - { - try - { - DTE2 dte2; - dte2 = (DTE2)Marshal. - GetActiveObject("VisualStudio.DTE.10.0"); + DTE2 dte2; + dte2 = (DTE2)Marshal. + GetActiveObject("VisualStudio.DTE.10.0"); + + var pa = new ProcessAttacher(dte2, "iisexpress", 10); + pa.PessimisticAttachManaged(); + return; - var pa = new ProcessAttacher(dte2, "iisexpress", 10); - pa.PessimisticAttachManaged(); - return; - } - catch - { - Thread.Sleep(500); - } - } // Get an instance of the currently running Visual Studio IDE. } diff --git a/NzbDrone/Program.cs b/NzbDrone/Program.cs index 536f47efc..6645bbebf 100644 --- a/NzbDrone/Program.cs +++ b/NzbDrone/Program.cs @@ -30,28 +30,54 @@ namespace NzbDrone IISController.StopServer(); IISController.StartServer(); - Process.Start(IISController.AppUrl); + #if DEBUG - //Manually Attach debugger to IISExpress - if (Debugger.IsAttached) + Attach(); +#endif + + Process.Start(IISController.AppUrl); + + IISController.IISProcess.WaitForExit(); + + } + catch (Exception e) + { + AppDomainException(e); + } + + } + + private static void Attach() + { + if (Debugger.IsAttached) + { + Logger.Info("Trying to attach to debugger"); + + var count = 0; + + while (true) { try { ProcessAttacher.Attach(); + Logger.Info("Debugger Attached"); + return; } catch (Exception e) { - Logger.Warn("Unable to attach to debugger", e); + count++; + if (count > 20) + { + Logger.WarnException("Unable to attach to debugger", e); + return; + } + + Thread.Sleep(100); + } } -#endif - } - catch (Exception e) - { - AppDomainException(e); } - }