diff --git a/NzbDrone.App.Test/CentralDispatchTests.cs b/NzbDrone.App.Test/CentralDispatchTests.cs index b27dac6c2..2093f28a6 100644 --- a/NzbDrone.App.Test/CentralDispatchTests.cs +++ b/NzbDrone.App.Test/CentralDispatchTests.cs @@ -11,14 +11,14 @@ namespace NzbDrone.App.Test [Test] public void Kernel_can_get_kernel() { - CentralDispatch.Container.Should().NotBeNull(); + NzbDroneBootstrapper.Container.Should().NotBeNull(); } [Test] public void Kernel_should_return_same_kernel() { - var firstKernel = CentralDispatch.Container; - var secondKernel = CentralDispatch.Container; + var firstKernel = NzbDroneBootstrapper.Container; + var secondKernel = NzbDroneBootstrapper.Container; firstKernel.Should().BeSameAs(secondKernel); } @@ -26,7 +26,7 @@ namespace NzbDrone.App.Test [Test] public void Kernel_should_be_able_to_resolve_ApplicationServer() { - var appServer = CentralDispatch.Container.Resolve(); + var appServer = NzbDroneBootstrapper.Container.Resolve(); appServer.Should().NotBeNull(); } @@ -34,8 +34,8 @@ namespace NzbDrone.App.Test [Test] public void Kernel_should_resolve_same_ApplicationServer_instance() { - var appServer1 = CentralDispatch.Container.Resolve(); - var appServer2 = CentralDispatch.Container.Resolve(); + var appServer1 = NzbDroneBootstrapper.Container.Resolve(); + var appServer2 = NzbDroneBootstrapper.Container.Resolve(); appServer1.Should().BeSameAs(appServer2); } diff --git a/NzbDrone.App.Test/MonitoringProviderTest.cs b/NzbDrone.App.Test/MonitoringProviderTest.cs index 615d4101f..3954d299b 100644 --- a/NzbDrone.App.Test/MonitoringProviderTest.cs +++ b/NzbDrone.App.Test/MonitoringProviderTest.cs @@ -7,7 +7,6 @@ using Moq; using NUnit.Framework; using NzbDrone.Common; using NzbDrone.Common.Model; -using NzbDrone.Providers; using NzbDrone.Test.Common; namespace NzbDrone.App.Test @@ -24,14 +23,14 @@ namespace NzbDrone.App.Test Mocker.GetMock().Setup(c => c.GetProcessById(It.IsAny())).Returns((ProcessInfo)null); - Mocker.Resolve().EnsurePriority(null); + Mocker.Resolve().EnsurePriority(null); } [Test] public void Ensure_should_log_warn_exception_rather_than_throw() { Mocker.GetMock().Setup(c => c.GetCurrentProcess()).Throws(); - Mocker.Resolve().EnsurePriority(null); + Mocker.Resolve().EnsurePriority(null); ExceptionVerification.ExpectedWarns(1); } diff --git a/NzbDrone.App.Test/RouterTest.cs b/NzbDrone.App.Test/RouterTest.cs index b458a46f2..640838b6f 100644 --- a/NzbDrone.App.Test/RouterTest.cs +++ b/NzbDrone.App.Test/RouterTest.cs @@ -1,12 +1,9 @@ -using System.IO; -using System.ServiceProcess; +using System.ServiceProcess; using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Common; -using NzbDrone.Model; using NzbDrone.Test.Common; -using NzbDrone.Test.Common.AutoMoq; namespace NzbDrone.App.Test { @@ -14,34 +11,34 @@ namespace NzbDrone.App.Test public class RouterTest : TestBase { - [TestCase(null, ApplicationMode.Console)] - [TestCase("", ApplicationMode.Console)] - [TestCase("1", ApplicationMode.Help)] - [TestCase("ii", ApplicationMode.Help)] - [TestCase("uu", ApplicationMode.Help)] - [TestCase("i", ApplicationMode.InstallService)] - [TestCase("I", ApplicationMode.InstallService)] - [TestCase("/I", ApplicationMode.InstallService)] - [TestCase("/i", ApplicationMode.InstallService)] - [TestCase("-I", ApplicationMode.InstallService)] - [TestCase("-i", ApplicationMode.InstallService)] - [TestCase("u", ApplicationMode.UninstallService)] - [TestCase("U", ApplicationMode.UninstallService)] - [TestCase("/U", ApplicationMode.UninstallService)] - [TestCase("/u", ApplicationMode.UninstallService)] - [TestCase("-U", ApplicationMode.UninstallService)] - [TestCase("-u", ApplicationMode.UninstallService)] - public void GetApplicationMode_single_arg(string arg, ApplicationMode mode) + [TestCase(null, ApplicationModes.Console)] + [TestCase("", ApplicationModes.Console)] + [TestCase("1", ApplicationModes.Help)] + [TestCase("ii", ApplicationModes.Help)] + [TestCase("uu", ApplicationModes.Help)] + [TestCase("i", ApplicationModes.InstallService)] + [TestCase("I", ApplicationModes.InstallService)] + [TestCase("/I", ApplicationModes.InstallService)] + [TestCase("/i", ApplicationModes.InstallService)] + [TestCase("-I", ApplicationModes.InstallService)] + [TestCase("-i", ApplicationModes.InstallService)] + [TestCase("u", ApplicationModes.UninstallService)] + [TestCase("U", ApplicationModes.UninstallService)] + [TestCase("/U", ApplicationModes.UninstallService)] + [TestCase("/u", ApplicationModes.UninstallService)] + [TestCase("-U", ApplicationModes.UninstallService)] + [TestCase("-u", ApplicationModes.UninstallService)] + public void GetApplicationMode_single_arg(string arg, ApplicationModes modes) { - Router.GetApplicationMode(new[] { arg }).Should().Be(mode); + Router.GetApplicationMode(new[] { arg }).Should().Be(modes); } - [TestCase("", "", ApplicationMode.Console)] - [TestCase("", null, ApplicationMode.Console)] - [TestCase("i", "n", ApplicationMode.Help)] - public void GetApplicationMode_two_args(string a, string b, ApplicationMode mode) + [TestCase("", "", ApplicationModes.Console)] + [TestCase("", null, ApplicationModes.Console)] + [TestCase("i", "n", ApplicationModes.Help)] + public void GetApplicationMode_two_args(string a, string b, ApplicationModes modes) { - Router.GetApplicationMode(new[] { a, b }).Should().Be(mode); + Router.GetApplicationMode(new[] { a, b }).Should().Be(modes); } [Test] @@ -53,7 +50,7 @@ namespace NzbDrone.App.Test serviceProviderMock.Setup(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME)); Mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true); - Mocker.Resolve().Route(ApplicationMode.InstallService); + Mocker.Resolve().Route(ApplicationModes.InstallService); serviceProviderMock.Verify(c => c.Install(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once()); } @@ -67,7 +64,7 @@ namespace NzbDrone.App.Test Mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true); serviceProviderMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(true); - Mocker.Resolve().Route(ApplicationMode.UninstallService); + Mocker.Resolve().Route(ApplicationModes.UninstallService); serviceProviderMock.Verify(c => c.UnInstall(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once()); } @@ -81,17 +78,17 @@ namespace NzbDrone.App.Test appServerProvider.Setup(c => c.Start()); Mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true); - Mocker.Resolve().Route(ApplicationMode.Console); + Mocker.Resolve().Route(ApplicationModes.Console); consoleProvider.Verify(c => c.WaitForClose(), Times.Once()); appServerProvider.Verify(c => c.Start(), Times.Once()); } - [TestCase(ApplicationMode.Console)] - [TestCase(ApplicationMode.InstallService)] - [TestCase(ApplicationMode.UninstallService)] - [TestCase(ApplicationMode.Help)] - public void Route_should_call_service_start_when_run_in_service_more(ApplicationMode applicationMode) + [TestCase(ApplicationModes.Console)] + [TestCase(ApplicationModes.InstallService)] + [TestCase(ApplicationModes.UninstallService)] + [TestCase(ApplicationModes.Help)] + public void Route_should_call_service_start_when_run_in_service_more(ApplicationModes applicationModes) { var envMock = Mocker.GetMock(); var serviceProvider = Mocker.GetMock(); @@ -100,7 +97,7 @@ namespace NzbDrone.App.Test serviceProvider.Setup(c => c.Run(It.IsAny())); - Mocker.Resolve().Route(applicationMode); + Mocker.Resolve().Route(applicationModes); serviceProvider.Verify(c => c.Run(It.IsAny()), Times.Once()); } @@ -116,7 +113,7 @@ namespace NzbDrone.App.Test consoleMock.Setup(c => c.PrintServiceAlreadyExist()); serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(true); - Mocker.Resolve().Route(ApplicationMode.InstallService); + Mocker.Resolve().Route(ApplicationModes.InstallService); Mocker.VerifyAllMocks(); } @@ -131,7 +128,7 @@ namespace NzbDrone.App.Test consoleMock.Setup(c => c.PrintServiceDoestExist()); serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(false); - Mocker.Resolve().Route(ApplicationMode.UninstallService); + Mocker.Resolve().Route(ApplicationModes.UninstallService); Mocker.VerifyAllMocks(); } diff --git a/NzbDrone.Common/HostController.cs b/NzbDrone.Common/HostController.cs index a9cb2ead2..0aa18e9f1 100644 --- a/NzbDrone.Common/HostController.cs +++ b/NzbDrone.Common/HostController.cs @@ -35,11 +35,12 @@ namespace NzbDrone.Common public void StartServer() { _host = new NancyHost(new Uri(AppUrl), _bootstrapper); + _host.Start(); } public string AppUrl { - get { return string.Format("http://localhost:{0}/", _configFileProvider.Port); } + get { return string.Format("http://localhost:{0}", _configFileProvider.Port); } } diff --git a/NzbDrone.Console/AppMain.cs b/NzbDrone.Console/AppMain.cs new file mode 100644 index 000000000..573b9fdad --- /dev/null +++ b/NzbDrone.Console/AppMain.cs @@ -0,0 +1,24 @@ +using System; + +namespace NzbDrone.Console +{ + public static class AppMain + { + public static void Main(string[] args) + { + try + { + + NzbDrone.AppMain.Main(args); + + } + catch(Exception e) + { + System.Console.WriteLine(e.ToString()); + } + + System.Console.WriteLine("Press enter to exit..."); + System.Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/NzbDrone/NzbDrone.Console.csproj b/NzbDrone.Console/NzbDrone.Console.csproj similarity index 60% rename from NzbDrone/NzbDrone.Console.csproj rename to NzbDrone.Console/NzbDrone.Console.csproj index d06c1fce9..ff57da500 100644 --- a/NzbDrone/NzbDrone.Console.csproj +++ b/NzbDrone.Console/NzbDrone.Console.csproj @@ -8,7 +8,7 @@ {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976} Exe Properties - NzbDrone + NzbDrone.Console NzbDrone.Console v4.0 512 @@ -36,7 +36,7 @@ true full false - bin\Debug\ + ..\NzbDrone\bin\Debug\ DEBUG;TRACE prompt 4 @@ -55,75 +55,35 @@ C:\Users\Mark\AppData\Local\Temp\vs1A55.tmp\x86\Release\ - NzbDrone.ico + + - NzbDrone.AppMain + NzbDrone.Console.AppMain OnOutputUpdated - - False - ..\packages\Autofac.3.0.1\lib\net40\Autofac.dll - - - False - ..\packages\Autofac.3.0.1\lib\net40\Autofac.Configuration.dll - - - False - ..\packages\Exceptron.Client.1.0.20\lib\net20\Exceptron.Client.dll - - - ..\packages\Exceptron.Nlog.1.0.11\lib\net20\Exceptron.NLog.dll - - - False - ..\packages\Nancy.0.16.1\lib\net40\Nancy.dll - - - False - ..\packages\Nancy.Bootstrappers.Autofac.0.16.1\lib\net40\Nancy.Bootstrappers.Autofac.dll - - - False - ..\packages\Nancy.Hosting.Self.0.16.1\lib\net40\Nancy.Hosting.Self.dll - - - ..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll - - Properties\SharedAssemblyInfo.cs - - Component - - - - - - - - Always - - + + NLog.config + + + NLog.xsd Designer - - - - + @@ -148,19 +108,16 @@ - - {fd286df8-2d3a-4394-8ad5-443fade55fb2} - NzbDrone.Api - - - {F2BE0FDF-6E47-4827-A420-DD4EF82407F8} - NzbDrone.Common - - - {FF5EE3B6-913B-47CE-9CEB-11C51B4E1205} - NzbDrone.Core + + {d12f7f2f-8a3c-415f-88fa-6dd061a84869} + NzbDrone + + + NzbDrone.ico + + diff --git a/NzbDrone.Console/Properties/AssemblyInfo.cs b/NzbDrone.Console/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..be9ef8d74 --- /dev/null +++ b/NzbDrone.Console/Properties/AssemblyInfo.cs @@ -0,0 +1,15 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +[assembly: AssemblyTitle("NzbDrone.exe")] +[assembly: Guid("67AADCD9-89AA-4D95-8281-3193740E70E5")] + +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.0.*")] +[assembly: AssemblyFileVersion("1.0.0.*")] \ No newline at end of file diff --git a/NzbDrone.Console/app.config b/NzbDrone.Console/app.config new file mode 100644 index 000000000..46c4e347d --- /dev/null +++ b/NzbDrone.Console/app.config @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/NzbDrone.Core/Datastore/SiaqodbProxy.cs b/NzbDrone.Core/Datastore/SiaqodbProxy.cs index 067f28e96..89ca2ee07 100644 --- a/NzbDrone.Core/Datastore/SiaqodbProxy.cs +++ b/NzbDrone.Core/Datastore/SiaqodbProxy.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using Sqo; @@ -16,6 +17,37 @@ namespace NzbDrone.Core.Datastore void DeleteMany(IEnumerable objects) where T : ModelBase; } + public static class SiaqodbLogger + { + public static void ListenTo(Siaqodb db) + { + db.DeletedObject += OnDeletedObject; + db.LoadingObject +=OnLoadingObject; + db.LoadedObject +=OnLoadedObject; + } + + private static void OnLoadedObject(object sender, LoadedObjectEventArgs e) + { + Write("Loaded", e.Object.GetType(), e.OID); + } + + private static void OnLoadingObject(object sender, LoadingObjectEventArgs e) + { + Write("Loading", e.ObjectType, e.OID); + } + + static void OnDeletedObject(object sender, DeletedEventsArgs e) + { + Write("Deleted", e.ObjectType, e.OID); + } + + private static void Write(string operation, Type modelType, int id) + { + var message = string.Format("{0} {1}[{2}]", operation, modelType.Name, id); + Trace.WriteLine(message, "Siaqodb"); + } + } + public class SiaqodbProxy : IObjectDatabase { private readonly Siaqodb _db; @@ -23,8 +55,11 @@ namespace NzbDrone.Core.Datastore public SiaqodbProxy(Siaqodb db) { _db = db; + //SiaqodbConfigurator.SetRaiseLoadEvents(true); + //SiaqodbLogger.ListenTo(_db); } + public void Dispose() { @@ -32,7 +67,7 @@ namespace NzbDrone.Core.Datastore public IEnumerable AsQueryable() { - return _db.Cast(); + return _db.LoadAllLazy(); } public T Insert(T obj) where T : ModelBase diff --git a/NzbDrone.Core/Instrumentation/LogInjectionModule.cs b/NzbDrone.Core/Instrumentation/LogInjectionModule.cs index 4d7ace9d5..e7f2407d4 100644 --- a/NzbDrone.Core/Instrumentation/LogInjectionModule.cs +++ b/NzbDrone.Core/Instrumentation/LogInjectionModule.cs @@ -23,15 +23,7 @@ namespace NzbDrone.Core.Instrumentation private static object GetLogger(Type type) { - const string STRING_TO_REMOVE = "NzbDrone"; - - var loggerName = type.FullName; - if (loggerName.StartsWith(STRING_TO_REMOVE)) - { - loggerName = loggerName.Substring(STRING_TO_REMOVE.Length + 1); - } - - return LogManager.GetLogger(loggerName); + return LogManager.GetLogger(type.Name); } } } \ No newline at end of file diff --git a/NzbDrone.Core/Properties/AssemblyInfo.cs b/NzbDrone.Core/Properties/AssemblyInfo.cs index 3e61062d3..da8c7d45b 100644 --- a/NzbDrone.Core/Properties/AssemblyInfo.cs +++ b/NzbDrone.Core/Properties/AssemblyInfo.cs @@ -12,7 +12,6 @@ using System.Runtime.InteropServices; [assembly: Guid("3C29FEF7-4B07-49ED-822E-1C29DC49BFAB")] [assembly: InternalsVisibleTo("NzbDrone.Core.Test")] -[assembly: InternalsVisibleTo("NzbDrone.Web")] // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: diff --git a/NzbDrone.sln b/NzbDrone.sln index 588843591..8a3b10af3 100644 --- a/NzbDrone.sln +++ b/NzbDrone.sln @@ -40,8 +40,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{1E6B3C EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NzbDrone.Api", "NzbDrone.Api\NzbDrone.Api.csproj", "{FD286DF8-2D3A-4394-8AD5-443FADE55FB2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NzbDrone.Console", "NzbDrone\NzbDrone.Console.csproj", "{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E0BC607C-90DC-4B3B-A2FB-7DC5B45338A4}" ProjectSection(SolutionItems) = preProject JSLintOptions.xml = JSLintOptions.xml @@ -53,6 +51,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NzbDrone.Backbone", "NzbDro EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Autofac.Integration.Mvc", "Autofac.Integration.Mvc\Autofac.Integration.Mvc.csproj", "{DD874E64-C7EC-464D-925F-CF4A709EDEEF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NzbDrone.Console", "NzbDrone.Console\NzbDrone.Console.csproj", "{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -320,24 +320,6 @@ Global {FD286DF8-2D3A-4394-8AD5-443FADE55FB2}.Services|Mixed Platforms.Build.0 = Release|Any CPU {FD286DF8-2D3A-4394-8AD5-443FADE55FB2}.Services|x64.ActiveCfg = Release|Any CPU {FD286DF8-2D3A-4394-8AD5-443FADE55FB2}.Services|x86.ActiveCfg = Release|Any CPU - {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|Any CPU.ActiveCfg = Debug|x86 - {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|x64.ActiveCfg = Debug|x86 - {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|x86.ActiveCfg = Debug|x86 - {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|x86.Build.0 = Debug|x86 - {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|Any CPU.ActiveCfg = Release|x86 - {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|Mixed Platforms.Build.0 = Release|x86 - {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|x64.ActiveCfg = Release|x86 - {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|x86.ActiveCfg = Release|x86 - {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|x86.Build.0 = Release|x86 - {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|Any CPU.ActiveCfg = Release|x86 - {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|Mixed Platforms.ActiveCfg = Release|x86 - {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|Mixed Platforms.Build.0 = Release|x86 - {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|x64.ActiveCfg = Release|x86 - {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|x86.ActiveCfg = Release|x86 - {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|x86.Build.0 = Release|x86 {64E5482F-0C4F-46C6-9377-699D3EADBA9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {64E5482F-0C4F-46C6-9377-699D3EADBA9E}.Debug|Any CPU.Build.0 = Debug|Any CPU {64E5482F-0C4F-46C6-9377-699D3EADBA9E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -389,6 +371,24 @@ Global {DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Services|Mixed Platforms.Build.0 = Release|Any CPU {DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Services|x64.ActiveCfg = Release|Any CPU {DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Services|x86.ActiveCfg = Release|Any CPU + {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|Any CPU.ActiveCfg = Debug|x86 + {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|x64.ActiveCfg = Debug|x86 + {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|x86.ActiveCfg = Debug|x86 + {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|x86.Build.0 = Debug|x86 + {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|Any CPU.ActiveCfg = Release|x86 + {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|Mixed Platforms.Build.0 = Release|x86 + {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|x64.ActiveCfg = Release|x86 + {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|x86.ActiveCfg = Release|x86 + {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|x86.Build.0 = Release|x86 + {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|Any CPU.ActiveCfg = Release|x86 + {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|Mixed Platforms.ActiveCfg = Release|x86 + {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|Mixed Platforms.Build.0 = Release|x86 + {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|x64.ActiveCfg = Release|x86 + {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|x86.ActiveCfg = Release|x86 + {3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/NzbDrone/AppMain.cs b/NzbDrone/AppMain.cs index 8176cc2ac..50cf33f21 100644 --- a/NzbDrone/AppMain.cs +++ b/NzbDrone/AppMain.cs @@ -1,18 +1,23 @@ using System; using System.Diagnostics; using System.Reflection; -using NzbDrone.Providers; using Autofac; +using NLog; namespace NzbDrone { public static class AppMain { + private static readonly Logger logger = LogManager.GetLogger("AppMain"); + + public static void Main(string[] args) { try { - Console.WriteLine("Starting NzbDrone Console. Version " + Assembly.GetExecutingAssembly().GetName().Version); + logger.Info("Starting NzbDrone Console. Version {0}", Assembly.GetExecutingAssembly().GetName().Version); + + AppDomain.CurrentDomain.UnhandledException += ((s, e) => AppDomainException(e.ExceptionObject as Exception)); //Check if full version .NET is installed. try @@ -21,29 +26,35 @@ namespace NzbDrone } catch (Exception) { - Console.WriteLine("It looks like you don't have full version of .NET Framework installed. Press any key and you will be directed to the download page."); + logger.Error("It looks like you don't have full version of .NET Framework installed. Press any key and you will be directed to the download page."); Console.Read(); try { Process.Start("http://www.microsoft.com/download/en/details.aspx?id=17851"); } - catch (Exception) + catch (Exception e) { - Console.WriteLine("Opps. can't start default browser. Please visit http://www.microsoft.com/download/en/details.aspx?id=17851 to download .NET Framework 4."); + logger.Warn("Oops. can't start default browser. Please visit http://www.microsoft.com/download/en/details.aspx?id=17851 to download .NET Framework 4."); Console.ReadLine(); } - + return; } - CentralDispatch.Container.Resolve().Route(args); + NzbDroneBootstrapper.Container.Resolve().Route(args); } catch (Exception e) { - MonitoringProvider.AppDomainException(e); + AppDomainException(e); } } + + public static void AppDomainException(Exception exception) + { + Console.WriteLine("EPIC FAIL: {0}", exception); + logger.FatalException("EPIC FAIL: " + exception.Message, exception); + } } } \ No newline at end of file diff --git a/NzbDrone/Model/ApplicationMode.cs b/NzbDrone/ApplicationMode.cs similarity index 60% rename from NzbDrone/Model/ApplicationMode.cs rename to NzbDrone/ApplicationMode.cs index 541b3b270..a92579385 100644 --- a/NzbDrone/Model/ApplicationMode.cs +++ b/NzbDrone/ApplicationMode.cs @@ -1,12 +1,11 @@ -namespace NzbDrone.Model +namespace NzbDrone { - public enum ApplicationMode + public enum ApplicationModes { Console, Help, InstallService, UninstallService, Service, - Nancy } } diff --git a/NzbDrone/ApplicationServer.cs b/NzbDrone/ApplicationServer.cs index 5c9c4044b..4af1cd262 100644 --- a/NzbDrone/ApplicationServer.cs +++ b/NzbDrone/ApplicationServer.cs @@ -1,10 +1,7 @@ using System; -using System.IO; -using System.Runtime.InteropServices; using System.ServiceProcess; using NLog; using NzbDrone.Common; -using NzbDrone.Providers; namespace NzbDrone @@ -17,22 +14,20 @@ namespace NzbDrone private readonly EnvironmentProvider _environmentProvider; private readonly IHostController _hostController; private readonly ProcessProvider _processProvider; - private readonly MonitoringProvider _monitoringProvider; + private readonly PriorityMonitor _priorityMonitor; private readonly SecurityProvider _securityProvider; - private readonly DiskProvider _diskProvider; public ApplicationServer(ConfigFileProvider configFileProvider, IHostController hostController, EnvironmentProvider environmentProvider, - ProcessProvider processProvider, MonitoringProvider monitoringProvider, - SecurityProvider securityProvider, DiskProvider diskProvider) + ProcessProvider processProvider, PriorityMonitor priorityMonitor, + SecurityProvider securityProvider) { _configFileProvider = configFileProvider; _hostController = hostController; _environmentProvider = environmentProvider; _processProvider = processProvider; - _monitoringProvider = monitoringProvider; + _priorityMonitor = priorityMonitor; _securityProvider = securityProvider; - _diskProvider = diskProvider; } public ApplicationServer() @@ -47,19 +42,9 @@ namespace NzbDrone public virtual void Start() { - _hostController.StopServer(); _securityProvider.MakeAccessible(); - if(_securityProvider.IsCurrentUserAdmin()) - { - var tempFiles = Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), "Temporary ASP.NET Files"); - logger.Debug("Creating Temporary ASP.Net folder: {0}", tempFiles); - _diskProvider.CreateDirectory(tempFiles); - } - _hostController.StartServer(); - //Todo: verify that IIS is actually started - if (_environmentProvider.IsUserInteractive && _configFileProvider.LaunchBrowser) { @@ -74,7 +59,7 @@ namespace NzbDrone } } - _monitoringProvider.Start(); + _priorityMonitor.Start(); } protected override void OnStop() diff --git a/NzbDrone/NzbDrone.csproj b/NzbDrone/NzbDrone.csproj index 935b5f5d3..616286378 100644 --- a/NzbDrone/NzbDrone.csproj +++ b/NzbDrone/NzbDrone.csproj @@ -68,6 +68,12 @@ False ..\packages\Autofac.3.0.1\lib\net40\Autofac.dll + + ..\packages\Exceptron.Client.1.0.20\lib\net20\Exceptron.Client.dll + + + ..\packages\Exceptron.Nlog.1.0.11\lib\net20\Exceptron.NLog.dll + ..\packages\Nancy.0.16.1\lib\net40\Nancy.dll @@ -92,15 +98,21 @@ Component - - + + - + + + Always + + + Designer + diff --git a/NzbDrone/NzbDrone.ncrunchproject b/NzbDrone/NzbDrone.ncrunchproject deleted file mode 100644 index 73e1ebbb9..000000000 --- a/NzbDrone/NzbDrone.ncrunchproject +++ /dev/null @@ -1,21 +0,0 @@ - - false - false - false - true - false - false - false - false - true - true - false - true - true - 60000 - - - - AutoDetect - PostBuildEventDisabled - \ No newline at end of file diff --git a/NzbDrone/CentralDispatch.cs b/NzbDrone/NzbDroneBootstrapper.cs similarity index 91% rename from NzbDrone/CentralDispatch.cs rename to NzbDrone/NzbDroneBootstrapper.cs index 5268090a5..16aed3210 100644 --- a/NzbDrone/CentralDispatch.cs +++ b/NzbDrone/NzbDroneBootstrapper.cs @@ -7,12 +7,12 @@ using NzbDrone.Core.Instrumentation; namespace NzbDrone { - public static class CentralDispatch + public static class NzbDroneBootstrapper { private static readonly IContainer container; - private static readonly Logger logger = LogManager.GetLogger("Host.CentralDispatch"); + private static readonly Logger logger = LogManager.GetLogger("NzbDroneBootstrapper"); - static CentralDispatch() + static NzbDroneBootstrapper() { var builder = new ContainerBuilder(); BindKernel(builder); diff --git a/NzbDrone/Providers/MonitoringProvider.cs b/NzbDrone/PriorityMonitor.cs similarity index 67% rename from NzbDrone/Providers/MonitoringProvider.cs rename to NzbDrone/PriorityMonitor.cs index 1a6a8e03e..018a8980c 100644 --- a/NzbDrone/Providers/MonitoringProvider.cs +++ b/NzbDrone/PriorityMonitor.cs @@ -1,29 +1,27 @@ -using System; +using System.Linq; +using System; using System.Diagnostics; using System.Threading; using NLog; using NzbDrone.Common; -namespace NzbDrone.Providers +namespace NzbDrone { - public class MonitoringProvider + public class PriorityMonitor { - private static readonly Logger logger = LogManager.GetLogger("Host.MonitoringProvider"); - private readonly ProcessProvider _processProvider; + private readonly Logger _logger; private Timer _processPriorityCheckTimer; - public MonitoringProvider(ProcessProvider processProvider) + public PriorityMonitor(ProcessProvider processProvider, Logger logger) { _processProvider = processProvider; + _logger = logger; } public void Start() { - AppDomain.CurrentDomain.UnhandledException += ((s, e) => AppDomainException(e.ExceptionObject as Exception)); - - _processPriorityCheckTimer = new Timer(EnsurePriority); _processPriorityCheckTimer.Change(TimeSpan.FromSeconds(15), TimeSpan.FromMinutes(30)); @@ -48,14 +46,8 @@ namespace NzbDrone.Providers } catch (Exception e) { - logger.WarnException("Unable to verify priority", e); + _logger.WarnException("Unable to verify priority", e); } } - - public static void AppDomainException(Exception excepion) - { - Console.WriteLine("EPIC FAIL: {0}", excepion); - logger.FatalException("EPIC FAIL: " + excepion.Message, excepion); - } } } \ No newline at end of file diff --git a/NzbDrone/Router.cs b/NzbDrone/Router.cs index e25c0ae3e..0996b128b 100644 --- a/NzbDrone/Router.cs +++ b/NzbDrone/Router.cs @@ -2,34 +2,29 @@ using System.Collections.Generic; using System.Linq; using NLog; -using Nancy.Hosting.Self; -using NzbDrone.Api; using NzbDrone.Common; using NzbDrone.Common.SysTray; -using NzbDrone.Model; namespace NzbDrone { public class Router { - private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - private readonly ApplicationServer _applicationServer; private readonly ServiceProvider _serviceProvider; private readonly ConsoleProvider _consoleProvider; private readonly EnvironmentProvider _environmentProvider; private readonly SysTrayProvider _sysTrayProvider; - private readonly ProcessProvider _processProvider; + private readonly Logger _logger; public Router(ApplicationServer applicationServer, ServiceProvider serviceProvider, - ConsoleProvider consoleProvider, EnvironmentProvider environmentProvider, SysTrayProvider sysTrayProvider, ProcessProvider processProvider) + ConsoleProvider consoleProvider, EnvironmentProvider environmentProvider, SysTrayProvider sysTrayProvider, Logger logger) { _applicationServer = applicationServer; _serviceProvider = serviceProvider; _consoleProvider = consoleProvider; _environmentProvider = environmentProvider; _sysTrayProvider = sysTrayProvider; - _processProvider = processProvider; + _logger = logger; } public void Route(IEnumerable args) @@ -37,41 +32,27 @@ namespace NzbDrone Route(GetApplicationMode(args)); } - public void Route(ApplicationMode applicationMode) + public void Route(ApplicationModes applicationModes) { if (!_environmentProvider.IsUserInteractive) { - applicationMode = ApplicationMode.Service; + applicationModes = ApplicationModes.Service; } - logger.Info("Application mode: {0}", applicationMode); + _logger.Info("Application mode: {0}", applicationModes); - switch (applicationMode) + switch (applicationModes) { - case ApplicationMode.Nancy: - { - - var nancyHost = new NancyHost(new Uri("http://localhost:8282"), new NancyBootstrapper()); - nancyHost.Start(); - - - _processProvider.Start("http://localhost:8282"); - - _consoleProvider.WaitForClose(); - - break; - } - - case ApplicationMode.Service: + case ApplicationModes.Service: { - logger.Trace("Service selected"); + _logger.Trace("Service selected"); _serviceProvider.Run(_applicationServer); break; } - case ApplicationMode.Console: + case ApplicationModes.Console: { - logger.Trace("Console selected"); + _logger.Trace("Console selected"); _applicationServer.Start(); if (ConsoleProvider.IsConsoleApplication) _consoleProvider.WaitForClose(); @@ -83,9 +64,9 @@ namespace NzbDrone break; } - case ApplicationMode.InstallService: + case ApplicationModes.InstallService: { - logger.Trace("Install Service selected"); + _logger.Trace("Install Service selected"); if (_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)) { _consoleProvider.PrintServiceAlreadyExist(); @@ -97,9 +78,9 @@ namespace NzbDrone } break; } - case ApplicationMode.UninstallService: + case ApplicationModes.UninstallService: { - logger.Trace("Uninstall Service selected"); + _logger.Trace("Uninstall Service selected"); if (!_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)) { _consoleProvider.PrintServiceDoestExist(); @@ -119,21 +100,20 @@ namespace NzbDrone } } - public static ApplicationMode GetApplicationMode(IEnumerable args) + public static ApplicationModes GetApplicationMode(IEnumerable args) { - if (args == null) return ApplicationMode.Console; + if (args == null) return ApplicationModes.Console; var cleanArgs = args.Where(c => c != null && !String.IsNullOrWhiteSpace(c)).ToList(); - if (cleanArgs.Count == 0) return ApplicationMode.Console; - if (cleanArgs.Count != 1) return ApplicationMode.Help; + if (cleanArgs.Count == 0) return ApplicationModes.Console; + if (cleanArgs.Count != 1) return ApplicationModes.Help; var arg = cleanArgs.First().Trim('/', '\\', '-').ToLower(); - if (arg == "i") return ApplicationMode.InstallService; - if (arg == "u") return ApplicationMode.UninstallService; - if (arg == "n") return ApplicationMode.Nancy; + if (arg == "i") return ApplicationModes.InstallService; + if (arg == "u") return ApplicationModes.UninstallService; - return ApplicationMode.Help; + return ApplicationModes.Help; } } }