aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.ServerApplication
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.ServerApplication')
-rw-r--r--MediaBrowser.ServerApplication/App.xaml15
-rw-r--r--MediaBrowser.ServerApplication/App.xaml.cs326
-rw-r--r--MediaBrowser.ServerApplication/Controls/ItemUpdateNotification.xaml.cs3
-rw-r--r--MediaBrowser.ServerApplication/Controls/MultiItemUpdateNotification.xaml.cs3
-rw-r--r--MediaBrowser.ServerApplication/Logging/LogWindow.xaml8
-rw-r--r--MediaBrowser.ServerApplication/Logging/LogWindow.xaml.cs128
-rw-r--r--MediaBrowser.ServerApplication/Logging/WindowTraceListener.cs75
-rw-r--r--MediaBrowser.ServerApplication/MainWindow.xaml.cs4
-rw-r--r--MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj18
-rw-r--r--MediaBrowser.ServerApplication/MediaBrowser.ServerApplication_TemporaryKey.pfxbin0 -> 1676 bytes
-rw-r--r--MediaBrowser.ServerApplication/packages.config1
11 files changed, 541 insertions, 40 deletions
diff --git a/MediaBrowser.ServerApplication/App.xaml b/MediaBrowser.ServerApplication/App.xaml
index 6b7f6c38f..3729dc7b6 100644
--- a/MediaBrowser.ServerApplication/App.xaml
+++ b/MediaBrowser.ServerApplication/App.xaml
@@ -1,8 +1,7 @@
-<z:BaseApplication x:Class="MediaBrowser.ServerApplication.App"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:z="clr-namespace:MediaBrowser.Common.UI;assembly=MediaBrowser.Common">
- <Application.Resources>
-
- </Application.Resources>
-</z:BaseApplication>
+<Application x:Class="MediaBrowser.ServerApplication.App"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+ <Application.Resources>
+
+ </Application.Resources>
+</Application>
diff --git a/MediaBrowser.ServerApplication/App.xaml.cs b/MediaBrowser.ServerApplication/App.xaml.cs
index 4da5c39fe..cc6367127 100644
--- a/MediaBrowser.ServerApplication/App.xaml.cs
+++ b/MediaBrowser.ServerApplication/App.xaml.cs
@@ -1,23 +1,31 @@
using MediaBrowser.Common.Kernel;
-using MediaBrowser.Common.Logging;
-using MediaBrowser.Common.UI;
+using MediaBrowser.Common.Updates;
using MediaBrowser.Controller;
using MediaBrowser.IsoMounter;
+using MediaBrowser.Logging.Nlog;
using MediaBrowser.Model.Logging;
using MediaBrowser.Server.Uninstall;
using MediaBrowser.ServerApplication.Implementations;
+using Microsoft.Win32;
using System;
-using System.Collections.Generic;
+using System.Deployment.Application;
using System.Diagnostics;
+using System.IO;
using System.Linq;
+using System.Net.Cache;
+using System.Threading;
+using System.Threading.Tasks;
using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
namespace MediaBrowser.ServerApplication
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
- public partial class App : BaseApplication, IApplication
+ public partial class App : Application, IApplicationHost
{
/// <summary>
/// Defines the entry point of the application.
@@ -25,8 +33,7 @@ namespace MediaBrowser.ServerApplication
[STAThread]
public static void Main()
{
- var application = new App(LogManager.GetLogger("App"));
- application.InitializeComponent();
+ var application = new App(new NLogger("App"));
application.Run();
}
@@ -44,20 +51,44 @@ namespace MediaBrowser.ServerApplication
}
/// <summary>
+ /// The single instance mutex
+ /// </summary>
+ private Mutex SingleInstanceMutex;
+
+ /// <summary>
+ /// Gets or sets the kernel.
+ /// </summary>
+ /// <value>The kernel.</value>
+ protected IKernel Kernel { get; set; }
+
+ /// <summary>
+ /// Gets or sets the logger.
+ /// </summary>
+ /// <value>The logger.</value>
+ protected ILogger Logger { get; set; }
+
+ /// <summary>
+ /// Gets or sets the log file path.
+ /// </summary>
+ /// <value>The log file path.</value>
+ private string LogFilePath { get; set; }
+
+ /// <summary>
/// Initializes a new instance of the <see cref="App" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
public App(ILogger logger)
- : base(logger)
{
-
+ Logger = logger;
+
+ InitializeComponent();
}
/// <summary>
/// Gets the name of the product.
/// </summary>
/// <value>The name of the product.</value>
- protected override string ProductName
+ protected string ProductName
{
get { return Globals.ProductName; }
}
@@ -66,7 +97,7 @@ namespace MediaBrowser.ServerApplication
/// Gets the name of the publisher.
/// </summary>
/// <value>The name of the publisher.</value>
- protected override string PublisherName
+ protected string PublisherName
{
get { return Globals.PublisherName; }
}
@@ -75,7 +106,7 @@ namespace MediaBrowser.ServerApplication
/// Gets the name of the suite.
/// </summary>
/// <value>The name of the suite.</value>
- protected override string SuiteName
+ protected string SuiteName
{
get { return Globals.SuiteName; }
}
@@ -84,21 +115,180 @@ namespace MediaBrowser.ServerApplication
/// Gets the name of the uninstaller file.
/// </summary>
/// <value>The name of the uninstaller file.</value>
- protected override string UninstallerFileName
+ protected string UninstallerFileName
{
get { return "MediaBrowser.Server.Uninstall.exe"; }
}
/// <summary>
- /// Called when [second instance launched].
+ /// Gets or sets a value indicating whether [last run at startup value].
/// </summary>
- /// <param name="args">The args.</param>
- protected override void OnSecondInstanceLaunched(IList<string> args)
+ /// <value><c>null</c> if [last run at startup value] contains no value, <c>true</c> if [last run at startup value]; otherwise, <c>false</c>.</value>
+ private bool? LastRunAtStartupValue { get; set; }
+
+ /// <summary>
+ /// Raises the <see cref="E:System.Windows.Application.Startup" /> event.
+ /// </summary>
+ /// <param name="e">A <see cref="T:System.Windows.StartupEventArgs" /> that contains the event data.</param>
+ protected override void OnStartup(StartupEventArgs e)
{
- base.OnSecondInstanceLaunched(args);
+ bool createdNew;
+ SingleInstanceMutex = new Mutex(true, @"Local\" + GetType().Assembly.GetName().Name, out createdNew);
+ if (!createdNew)
+ {
+ SingleInstanceMutex = null;
+ Shutdown();
+ return;
+ }
- OpenDashboard();
- InitializeComponent();
+ AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
+ LoadKernel();
+
+ SystemEvents.SessionEnding += SystemEvents_SessionEnding;
+ }
+
+ /// <summary>
+ /// Handles the UnhandledException event of the CurrentDomain control.
+ /// </summary>
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="e">The <see cref="UnhandledExceptionEventArgs" /> instance containing the event data.</param>
+ void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
+ {
+ var exception = (Exception)e.ExceptionObject;
+
+ Logger.ErrorException("UnhandledException", exception);
+
+ MessageBox.Show("Unhandled exception: " + exception.Message);
+ }
+
+ /// <summary>
+ /// Handles the SessionEnding event of the SystemEvents control.
+ /// </summary>
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="e">The <see cref="SessionEndingEventArgs" /> instance containing the event data.</param>
+ void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
+ {
+ // Try to shut down gracefully
+ Shutdown();
+ }
+
+ /// <summary>
+ /// Loads the kernel.
+ /// </summary>
+ protected async void LoadKernel()
+ {
+ Kernel = new Kernel(this, new PismoIsoManager(Logger), new DotNetZipClient(), new BdInfoExaminer(), Logger);
+
+ try
+ {
+ new MainWindow(Logger).Show();
+
+ var now = DateTime.UtcNow;
+
+ await Kernel.Init();
+
+ var done = (DateTime.UtcNow - now);
+ Logger.Info("Kernel.Init completed in {0}{1} minutes and {2} seconds.", done.Hours > 0 ? done.Hours + " Hours " : "", done.Minutes, done.Seconds);
+
+ await OnKernelLoaded();
+ }
+ catch (Exception ex)
+ {
+ Logger.ErrorException("Error launching application", ex);
+
+ MessageBox.Show("There was an error launching Media Browser: " + ex.Message);
+
+ // Shutdown the app with an error code
+ Shutdown(1);
+ }
+ }
+
+ /// <summary>
+ /// Called when [kernel loaded].
+ /// </summary>
+ /// <returns>Task.</returns>
+ protected Task OnKernelLoaded()
+ {
+ return Task.Run(() =>
+ {
+ Kernel.ConfigurationUpdated += Kernel_ConfigurationUpdated;
+
+ ConfigureClickOnceStartup();
+ });
+ }
+
+ /// <summary>
+ /// Handles the ConfigurationUpdated event of the Kernel control.
+ /// </summary>
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
+ void Kernel_ConfigurationUpdated(object sender, EventArgs e)
+ {
+ if (!LastRunAtStartupValue.HasValue || LastRunAtStartupValue.Value != Kernel.Configuration.RunAtStartup)
+ {
+ ConfigureClickOnceStartup();
+ }
+ }
+
+ /// <summary>
+ /// Configures the click once startup.
+ /// </summary>
+ private void ConfigureClickOnceStartup()
+ {
+ if (!ApplicationDeployment.IsNetworkDeployed)
+ {
+ return;
+ }
+
+ try
+ {
+ var clickOnceHelper = new ClickOnceHelper(PublisherName, ProductName, SuiteName);
+
+ if (Kernel.Configuration.RunAtStartup)
+ {
+ clickOnceHelper.UpdateUninstallParameters(UninstallerFileName);
+ clickOnceHelper.AddShortcutToStartup();
+ }
+ else
+ {
+ clickOnceHelper.RemoveShortcutFromStartup();
+ }
+
+ LastRunAtStartupValue = Kernel.Configuration.RunAtStartup;
+ }
+ catch (Exception ex)
+ {
+ Logger.ErrorException("Error configuring ClickOnce", ex);
+ }
+ }
+
+ /// <summary>
+ /// Raises the <see cref="E:System.Windows.Application.Exit" /> event.
+ /// </summary>
+ /// <param name="e">An <see cref="T:System.Windows.ExitEventArgs" /> that contains the event data.</param>
+ protected override void OnExit(ExitEventArgs e)
+ {
+ ReleaseMutex();
+
+ base.OnExit(e);
+
+ Kernel.Dispose();
+ }
+
+ /// <summary>
+ /// Releases the mutex.
+ /// </summary>
+ private void ReleaseMutex()
+ {
+ if (SingleInstanceMutex == null)
+ {
+ return;
+ }
+
+ SingleInstanceMutex.ReleaseMutex();
+ SingleInstanceMutex.Close();
+ SingleInstanceMutex.Dispose();
+ SingleInstanceMutex = null;
}
/// <summary>
@@ -179,21 +369,105 @@ namespace MediaBrowser.ServerApplication
}
/// <summary>
- /// Instantiates the kernel.
+ /// Restarts this instance.
+ /// </summary>
+ /// <exception cref="System.NotImplementedException"></exception>
+ public void Restart()
+ {
+ Dispatcher.Invoke(ReleaseMutex);
+
+ Kernel.Dispose();
+
+ System.Windows.Forms.Application.Restart();
+
+ Dispatcher.Invoke(Shutdown);
+ }
+
+ /// <summary>
+ /// Reloads the logger.
+ /// </summary>
+ /// <exception cref="System.NotImplementedException"></exception>
+ public void ReloadLogger()
+ {
+ LogFilePath = Path.Combine(Kernel.ApplicationPaths.LogDirectoryPath, "Server-" + DateTime.Now.Ticks + ".log");
+
+ NlogManager.AddFileTarget(LogFilePath, Kernel.Configuration.EnableDebugLevelLogging);
+ }
+
+ /// <summary>
+ /// Gets the image.
+ /// </summary>
+ /// <param name="uri">The URI.</param>
+ /// <returns>Image.</returns>
+ /// <exception cref="System.ArgumentNullException">uri</exception>
+ public Image GetImage(string uri)
+ {
+ if (string.IsNullOrEmpty(uri))
+ {
+ throw new ArgumentNullException("uri");
+ }
+
+ return GetImage(new Uri(uri));
+ }
+
+ /// <summary>
+ /// Gets the image.
+ /// </summary>
+ /// <param name="uri">The URI.</param>
+ /// <returns>Image.</returns>
+ /// <exception cref="System.ArgumentNullException">uri</exception>
+ public Image GetImage(Uri uri)
+ {
+ if (uri == null)
+ {
+ throw new ArgumentNullException("uri");
+ }
+
+ return new Image { Source = GetBitmapImage(uri) };
+ }
+
+ /// <summary>
+ /// Gets the bitmap image.
/// </summary>
- /// <returns>IKernel.</returns>
- protected override IKernel InstantiateKernel()
+ /// <param name="uri">The URI.</param>
+ /// <returns>BitmapImage.</returns>
+ /// <exception cref="System.ArgumentNullException">uri</exception>
+ public BitmapImage GetBitmapImage(string uri)
{
- return new Kernel(new PismoIsoManager(Logger), new DotNetZipClient(), new BdInfoExaminer(), Logger);
+ if (string.IsNullOrEmpty(uri))
+ {
+ throw new ArgumentNullException("uri");
+ }
+
+ return GetBitmapImage(new Uri(uri));
}
/// <summary>
- /// Instantiates the main window.
+ /// Gets the bitmap image.
/// </summary>
- /// <returns>Window.</returns>
- protected override Window InstantiateMainWindow()
+ /// <param name="uri">The URI.</param>
+ /// <returns>BitmapImage.</returns>
+ /// <exception cref="System.ArgumentNullException">uri</exception>
+ public BitmapImage GetBitmapImage(Uri uri)
{
- return new MainWindow(Logger);
+ if (uri == null)
+ {
+ throw new ArgumentNullException("uri");
+ }
+
+ var bitmap = new BitmapImage
+ {
+ CreateOptions = BitmapCreateOptions.DelayCreation,
+ CacheOption = BitmapCacheOption.OnDemand,
+ UriCachePolicy = new RequestCachePolicy(RequestCacheLevel.CacheIfAvailable)
+ };
+
+ bitmap.BeginInit();
+ bitmap.UriSource = uri;
+ bitmap.EndInit();
+
+ RenderOptions.SetBitmapScalingMode(bitmap, BitmapScalingMode.Fant);
+ return bitmap;
}
}
}
diff --git a/MediaBrowser.ServerApplication/Controls/ItemUpdateNotification.xaml.cs b/MediaBrowser.ServerApplication/Controls/ItemUpdateNotification.xaml.cs
index 312e70e66..5dceba994 100644
--- a/MediaBrowser.ServerApplication/Controls/ItemUpdateNotification.xaml.cs
+++ b/MediaBrowser.ServerApplication/Controls/ItemUpdateNotification.xaml.cs
@@ -1,5 +1,4 @@
-using MediaBrowser.Common.Logging;
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
diff --git a/MediaBrowser.ServerApplication/Controls/MultiItemUpdateNotification.xaml.cs b/MediaBrowser.ServerApplication/Controls/MultiItemUpdateNotification.xaml.cs
index bab1958fd..9d58c0227 100644
--- a/MediaBrowser.ServerApplication/Controls/MultiItemUpdateNotification.xaml.cs
+++ b/MediaBrowser.ServerApplication/Controls/MultiItemUpdateNotification.xaml.cs
@@ -1,5 +1,4 @@
-using MediaBrowser.Common.Logging;
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using System;
diff --git a/MediaBrowser.ServerApplication/Logging/LogWindow.xaml b/MediaBrowser.ServerApplication/Logging/LogWindow.xaml
new file mode 100644
index 000000000..d50b55454
--- /dev/null
+++ b/MediaBrowser.ServerApplication/Logging/LogWindow.xaml
@@ -0,0 +1,8 @@
+<Window x:Class="MediaBrowser.ServerApplication.Logging.LogWindow"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ Title="Media Browser Log" Height="300" Width="968">
+ <Grid>
+ <ListBox x:Name="lbxLogData" Margin="10,10,0,0"/>
+ </Grid>
+</Window>
diff --git a/MediaBrowser.ServerApplication/Logging/LogWindow.xaml.cs b/MediaBrowser.ServerApplication/Logging/LogWindow.xaml.cs
new file mode 100644
index 000000000..fca978486
--- /dev/null
+++ b/MediaBrowser.ServerApplication/Logging/LogWindow.xaml.cs
@@ -0,0 +1,128 @@
+using MediaBrowser.Common.Kernel;
+using NLog;
+using NLog.Config;
+using NLog.Targets;
+using System.ComponentModel;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace MediaBrowser.ServerApplication.Logging
+{
+ /// <summary>
+ /// Interaction logic for LogWindow.xaml
+ /// </summary>
+ public partial class LogWindow : Window
+ {
+ /// <summary>
+ /// The _ui thread
+ /// </summary>
+ private readonly TaskScheduler _uiThread;
+ /// <summary>
+ /// The _kernel
+ /// </summary>
+ private readonly IKernel _kernel;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="LogWindow" /> class.
+ /// </summary>
+ /// <param name="kernel">The kernel.</param>
+ public LogWindow(IKernel kernel)
+ {
+ InitializeComponent();
+ _uiThread = TaskScheduler.FromCurrentSynchronizationContext();
+ _kernel = kernel;
+
+ Loaded += LogWindow_Loaded;
+ }
+
+ /// <summary>
+ /// Handles the Loaded event of the LogWindow control.
+ /// </summary>
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
+ void LogWindow_Loaded(object sender, RoutedEventArgs e)
+ {
+ var target = new TraceTarget
+ {
+ Layout = "${longdate}, ${level}, ${logger}, ${message}"
+ };
+
+ AddLogTarget(target, "LogWindowTraceTarget");
+ }
+
+ /// <summary>
+ /// Raises the <see cref="E:System.Windows.Window.Closing" /> event.
+ /// </summary>
+ /// <param name="e">A <see cref="T:System.ComponentModel.CancelEventArgs" /> that contains the event data.</param>
+ protected override void OnClosing(CancelEventArgs e)
+ {
+ base.OnClosing(e);
+
+ RemoveLogTarget("LogWindowTraceTarget");
+ }
+
+ /// <summary>
+ /// Logs the message.
+ /// </summary>
+ /// <param name="msg">The MSG.</param>
+ public async void LogMessage(string msg)
+ {
+ await Task.Factory.StartNew(() => lbxLogData.Items.Insert(0, msg.TrimEnd('\n')), CancellationToken.None, TaskCreationOptions.None, _uiThread);
+ }
+
+ /// <summary>
+ /// The log layout
+ /// </summary>
+ /// <value>The log layout.</value>
+ public string LogLayout
+ {
+ get { return "${longdate}, ${level}, ${logger}, ${message}"; }
+ }
+
+ /// <summary>
+ /// Adds the log target.
+ /// </summary>
+ /// <param name="target">The target.</param>
+ /// <param name="name">The name.</param>
+ private void AddLogTarget(Target target, string name)
+ {
+ var config = NLog.LogManager.Configuration;
+
+ config.RemoveTarget(name);
+
+ target.Name = name;
+ config.AddTarget(name, target);
+
+ var level = _kernel.Configuration.EnableDebugLevelLogging ? LogLevel.Debug : LogLevel.Info;
+
+ var rule = new LoggingRule("*", level, target);
+ config.LoggingRules.Add(rule);
+
+ NLog.LogManager.Configuration = config;
+ }
+
+ /// <summary>
+ /// Removes the log target.
+ /// </summary>
+ /// <param name="name">The name.</param>
+ private void RemoveLogTarget(string name)
+ {
+ var config = NLog.LogManager.Configuration;
+
+ config.RemoveTarget(name);
+
+ NLog.LogManager.Configuration = config;
+ }
+
+ /// <summary>
+ /// Shuts down.
+ /// </summary>
+ public async void ShutDown()
+ {
+ await Task.Factory.StartNew(Close, CancellationToken.None, TaskCreationOptions.None, _uiThread);
+ }
+
+ }
+
+}
diff --git a/MediaBrowser.ServerApplication/Logging/WindowTraceListener.cs b/MediaBrowser.ServerApplication/Logging/WindowTraceListener.cs
new file mode 100644
index 000000000..10d6ef812
--- /dev/null
+++ b/MediaBrowser.ServerApplication/Logging/WindowTraceListener.cs
@@ -0,0 +1,75 @@
+using System.Diagnostics;
+
+namespace MediaBrowser.ServerApplication.Logging
+{
+ /// <summary>
+ /// Class WindowTraceListener
+ /// </summary>
+ public class WindowTraceListener : DefaultTraceListener
+ {
+ /// <summary>
+ /// The _window
+ /// </summary>
+ private readonly LogWindow _window;
+ /// <summary>
+ /// Initializes a new instance of the <see cref="WindowTraceListener" /> class.
+ /// </summary>
+ /// <param name="window">The window.</param>
+ public WindowTraceListener(LogWindow window)
+ {
+ _window = window;
+ _window.Show();
+ Name = "MBLogWindow";
+ }
+
+ /// <summary>
+ /// Writes the value of the object's <see cref="M:System.Object.ToString" /> method to the listener you create when you implement the <see cref="T:System.Diagnostics.TraceListener" /> class.
+ /// </summary>
+ /// <param name="o">An <see cref="T:System.Object" /> whose fully qualified class name you want to write.</param>
+ public override void Write(object o)
+ {
+ var str = o as string;
+ if (str != null)
+ Write(str);
+ else
+ base.Write(o);
+ }
+
+ /// <summary>
+ /// Writes the output to the OutputDebugString function and to the <see cref="M:System.Diagnostics.Debugger.Log(System.Int32,System.String,System.String)" /> method.
+ /// </summary>
+ /// <param name="message">The message to write to OutputDebugString and <see cref="M:System.Diagnostics.Debugger.Log(System.Int32,System.String,System.String)" />.</param>
+ /// <PermissionSet>
+ /// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
+ /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
+ /// </PermissionSet>
+ public override void Write(string message)
+ {
+ _window.LogMessage(message);
+ }
+
+ /// <summary>
+ /// Writes the output to the OutputDebugString function and to the <see cref="M:System.Diagnostics.Debugger.Log(System.Int32,System.String,System.String)" /> method, followed by a carriage return and line feed (\r\n).
+ /// </summary>
+ /// <param name="message">The message to write to OutputDebugString and <see cref="M:System.Diagnostics.Debugger.Log(System.Int32,System.String,System.String)" />.</param>
+ /// <PermissionSet>
+ /// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
+ /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
+ /// </PermissionSet>
+ public override void WriteLine(string message)
+ {
+ Write(message+"\n");
+ }
+
+ /// <summary>
+ /// Releases the unmanaged resources used by the <see cref="T:System.Diagnostics.TraceListener" /> and optionally releases the managed resources.
+ /// </summary>
+ /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (_window != null)
+ _window.ShutDown();
+ base.Dispose(disposing);
+ }
+ }
+}
diff --git a/MediaBrowser.ServerApplication/MainWindow.xaml.cs b/MediaBrowser.ServerApplication/MainWindow.xaml.cs
index e020aebf7..8a312e7ef 100644
--- a/MediaBrowser.ServerApplication/MainWindow.xaml.cs
+++ b/MediaBrowser.ServerApplication/MainWindow.xaml.cs
@@ -1,9 +1,9 @@
-using MediaBrowser.Common.Logging;
-using MediaBrowser.Controller;
+using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
using MediaBrowser.ServerApplication.Controls;
+using MediaBrowser.ServerApplication.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
index a5be8d687..ff8be69e4 100644
--- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
+++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
@@ -120,6 +120,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\DotNetZip.1.9.1.8\lib\net20\Ionic.Zip.dll</HintPath>
</Reference>
+ <Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
+ </Reference>
<Reference Include="Platinum.Managed, Version=1.0.4794.22684, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\ThirdParty\UPnP\Libs\Platinum.Managed.dll</HintPath>
@@ -134,9 +138,11 @@
<Reference Include="System.Data.SQLite.Linq">
<HintPath>..\packages\System.Data.SQLite.1.0.84.0\lib\net45\System.Data.SQLite.Linq.dll</HintPath>
</Reference>
+ <Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Runtime.Remoting" />
<Reference Include="System.Web.Extensions" />
+ <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
@@ -166,6 +172,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="Logging\LogWindow.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -185,6 +195,10 @@
<Compile Include="LibraryExplorer.xaml.cs">
<DependentUpon>LibraryExplorer.xaml</DependentUpon>
</Compile>
+ <Compile Include="Logging\LogWindow.xaml.cs">
+ <DependentUpon>LogWindow.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="Logging\WindowTraceListener.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
@@ -238,6 +252,10 @@
<Project>{5356ae30-6a6e-4a64-81e3-f76c50595e64}</Project>
<Name>MediaBrowser.IsoMounter</Name>
</ProjectReference>
+ <ProjectReference Include="..\MediaBrowser.Logging.NLog\MediaBrowser.Logging.NLog.csproj">
+ <Project>{67310740-0ec4-4dc2-9921-33df38b20167}</Project>
+ <Name>MediaBrowser.Logging.NLog</Name>
+ </ProjectReference>
<ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">
<Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
<Name>MediaBrowser.Model</Name>
diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication_TemporaryKey.pfx b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication_TemporaryKey.pfx
new file mode 100644
index 000000000..64676b054
--- /dev/null
+++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication_TemporaryKey.pfx
Binary files differ
diff --git a/MediaBrowser.ServerApplication/packages.config b/MediaBrowser.ServerApplication/packages.config
index c1e5c8098..c9cf3ee00 100644
--- a/MediaBrowser.ServerApplication/packages.config
+++ b/MediaBrowser.ServerApplication/packages.config
@@ -2,5 +2,6 @@
<packages>
<package id="DotNetZip" version="1.9.1.8" targetFramework="net45" />
<package id="Hardcodet.Wpf.TaskbarNotification" version="1.0.4.0" targetFramework="net45" />
+ <package id="NLog" version="2.0.0.2000" targetFramework="net45" />
<package id="System.Data.SQLite" version="1.0.84.0" targetFramework="net45" />
</packages> \ No newline at end of file