diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs
index c248ae582a..b89715d1c1 100644
--- a/MediaBrowser.Api/UserLibrary/ItemsService.cs
+++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs
@@ -800,7 +800,7 @@ namespace MediaBrowser.Api.UserLibrary
return userdata.LastPlayedDate.Value;
}
- return DateTime.MaxValue;
+ return DateTime.MinValue;
}
}
}
diff --git a/MediaBrowser.Common/Kernel/BaseKernel.cs b/MediaBrowser.Common/Kernel/BaseKernel.cs
index d35ee42c93..489423d9eb 100644
--- a/MediaBrowser.Common/Kernel/BaseKernel.cs
+++ b/MediaBrowser.Common/Kernel/BaseKernel.cs
@@ -40,20 +40,6 @@ namespace MediaBrowser.Common.Kernel
}
#endregion
- #region ReloadCompleted Event
- ///
- /// Fires whenever the kernel completes reloading
- ///
- public event EventHandler ReloadCompleted;
- ///
- /// Called when [reload completed].
- ///
- private void OnReloadCompleted()
- {
- EventHelper.QueueEventIfNotNull(ReloadCompleted, this, EventArgs.Empty, Logger);
- }
- #endregion
-
#region ApplicationUpdated Event
///
/// Occurs when [application updated].
@@ -206,9 +192,7 @@ namespace MediaBrowser.Common.Kernel
{
ReloadInternal();
- OnReloadCompleted();
-
- Logger.Info("Kernel.Reload Complete");
+ Logger.Info("Kernel.Init Complete");
}
///
diff --git a/MediaBrowser.Common/Kernel/IKernel.cs b/MediaBrowser.Common/Kernel/IKernel.cs
index 0d123476ca..1a2d86d7f2 100644
--- a/MediaBrowser.Common/Kernel/IKernel.cs
+++ b/MediaBrowser.Common/Kernel/IKernel.cs
@@ -89,11 +89,6 @@ namespace MediaBrowser.Common.Kernel
/// The plug-in security manager.
ISecurityManager SecurityManager { get; set; }
- ///
- /// Occurs when [reload completed].
- ///
- event EventHandler ReloadCompleted;
-
///
/// Occurs when [configuration updated].
///
diff --git a/MediaBrowser.ServerApplication/MainWindow.xaml.cs b/MediaBrowser.ServerApplication/MainWindow.xaml.cs
index 4904eb0f7b..0d0d2d54bb 100644
--- a/MediaBrowser.ServerApplication/MainWindow.xaml.cs
+++ b/MediaBrowser.ServerApplication/MainWindow.xaml.cs
@@ -1,19 +1,13 @@
using MediaBrowser.Common.Kernel;
using MediaBrowser.Controller;
-using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
-using MediaBrowser.Model.Serialization;
-using MediaBrowser.ServerApplication.Controls;
using MediaBrowser.ServerApplication.Logging;
using System;
-using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
-using System.Threading;
using System.Windows;
-using System.Windows.Controls.Primitives;
using System.Windows.Threading;
namespace MediaBrowser.ServerApplication
@@ -23,23 +17,6 @@ namespace MediaBrowser.ServerApplication
///
public partial class MainWindow : Window, INotifyPropertyChanged
{
- ///
- /// Holds the list of new items to display when the NewItemTimer expires
- ///
- private readonly List _newlyAddedItems = new List();
-
- ///
- /// The amount of time to wait before showing a new item notification
- /// This allows us to group items together into one notification
- ///
- private const int NewItemDelay = 60000;
-
- ///
- /// The current new item timer
- ///
- /// The new item timer.
- private Timer NewItemTimer { get; set; }
-
///
/// The _logger
///
@@ -54,8 +31,6 @@ namespace MediaBrowser.ServerApplication
/// The _log manager
///
private readonly ILogManager _logManager;
-
- private readonly ILibraryManager _libraryManager;
///
/// Initializes a new instance of the class.
@@ -64,7 +39,7 @@ namespace MediaBrowser.ServerApplication
/// The logger.
/// The app host.
/// logger
- public MainWindow(ILogManager logManager, IApplicationHost appHost, ILibraryManager libraryManager)
+ public MainWindow(ILogManager logManager, IApplicationHost appHost)
{
if (logManager == null)
{
@@ -74,7 +49,6 @@ namespace MediaBrowser.ServerApplication
_logger = logManager.GetLogger("MainWindow");
_appHost = appHost;
_logManager = logManager;
- _libraryManager = libraryManager;
InitializeComponent();
@@ -92,7 +66,6 @@ namespace MediaBrowser.ServerApplication
Instance_ConfigurationUpdated(null, EventArgs.Empty);
- Kernel.Instance.ReloadCompleted += KernelReloadCompleted;
_logManager.LoggerLoaded += LoadLogWindow;
Kernel.Instance.ConfigurationUpdated += Instance_ConfigurationUpdated;
}
@@ -123,71 +96,6 @@ namespace MediaBrowser.ServerApplication
});
}
- ///
- /// Handles the LibraryChanged event of the Instance control.
- ///
- /// The source of the event.
- /// The instance containing the event data.
- void Instance_LibraryChanged(object sender, ChildrenChangedEventArgs e)
- {
- var newItems = e.ItemsAdded.Where(i => !i.IsFolder).ToList();
-
- // Use a timer to prevent lots of these notifications from showing in a short period of time
- if (newItems.Count > 0)
- {
- lock (_newlyAddedItems)
- {
- _newlyAddedItems.AddRange(newItems);
-
- if (NewItemTimer == null)
- {
- NewItemTimer = new Timer(NewItemTimerCallback, null, NewItemDelay, Timeout.Infinite);
- }
- else
- {
- NewItemTimer.Change(NewItemDelay, Timeout.Infinite);
- }
- }
- }
- }
-
- ///
- /// Called when the new item timer expires
- ///
- /// The state.
- private void NewItemTimerCallback(object state)
- {
- List newItems;
-
- // Lock the list and release all resources
- lock (_newlyAddedItems)
- {
- newItems = _newlyAddedItems.ToList();
- _newlyAddedItems.Clear();
-
- NewItemTimer.Dispose();
- NewItemTimer = null;
- }
-
- // Show the notification
- if (newItems.Count == 1)
- {
- Dispatcher.InvokeAsync(() => MbTaskbarIcon.ShowCustomBalloon(new ItemUpdateNotification(_logger)
- {
- DataContext = newItems[0]
-
- }, PopupAnimation.Slide, 6000));
- }
- else if (newItems.Count > 1)
- {
- Dispatcher.InvokeAsync(() => MbTaskbarIcon.ShowCustomBalloon(new MultiItemUpdateNotification(_logger)
- {
- DataContext = newItems
-
- }, PopupAnimation.Slide, 6000));
- }
- }
-
///
/// Loads the log window.
///
@@ -227,32 +135,6 @@ namespace MediaBrowser.ServerApplication
});
}
- ///
- /// Kernels the reload completed.
- ///
- /// The sender.
- /// The e.
- void KernelReloadCompleted(object sender, EventArgs e)
- {
- _libraryManager.LibraryChanged -= Instance_LibraryChanged;
- _libraryManager.LibraryChanged += Instance_LibraryChanged;
-
- if (_appHost.IsFirstRun)
- {
- LaunchStartupWizard();
- }
- }
-
- ///
- /// Launches the startup wizard.
- ///
- private void LaunchStartupWizard()
- {
- var user = _appHost.Resolve().Users.FirstOrDefault(u => u.Configuration.IsAdministrator);
-
- App.OpenDashboardPage("wizardStart.html", user);
- }
-
///
/// Handles the Click event of the cmdApiDocs control.
///
diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
index 158fc05608..00b68e2546 100644
--- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
+++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
@@ -158,6 +158,8 @@
+
+
MSBuild:Compile
diff --git a/MediaBrowser.ServerApplication/NewItemNotifier.cs b/MediaBrowser.ServerApplication/NewItemNotifier.cs
new file mode 100644
index 0000000000..782e04a4aa
--- /dev/null
+++ b/MediaBrowser.ServerApplication/NewItemNotifier.cs
@@ -0,0 +1,141 @@
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Plugins;
+using MediaBrowser.Model.Logging;
+using MediaBrowser.ServerApplication.Controls;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Windows.Controls.Primitives;
+
+namespace MediaBrowser.ServerApplication
+{
+ ///
+ /// Class NewItemNotifier
+ ///
+ public class NewItemNotifier : IServerEntryPoint
+ {
+ ///
+ /// Holds the list of new items to display when the NewItemTimer expires
+ ///
+ private readonly List _newlyAddedItems = new List();
+
+ ///
+ /// The amount of time to wait before showing a new item notification
+ /// This allows us to group items together into one notification
+ ///
+ private const int NewItemDelay = 60000;
+
+ ///
+ /// The current new item timer
+ ///
+ /// The new item timer.
+ private Timer NewItemTimer { get; set; }
+
+ ///
+ /// The _library manager
+ ///
+ private readonly ILibraryManager _libraryManager;
+
+ ///
+ /// The _logger
+ ///
+ private readonly ILogger _logger;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The library manager.
+ /// The log manager.
+ public NewItemNotifier(ILibraryManager libraryManager, ILogManager logManager)
+ {
+ _logger = logManager.GetLogger("NewItemNotifier");
+ _libraryManager = libraryManager;
+ }
+
+ ///
+ /// Runs this instance.
+ ///
+ public void Run()
+ {
+ _libraryManager.LibraryChanged += libraryManager_LibraryChanged;
+ }
+
+ ///
+ /// Handles the LibraryChanged event of the libraryManager control.
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ void libraryManager_LibraryChanged(object sender, ChildrenChangedEventArgs e)
+ {
+ var newItems = e.ItemsAdded.Where(i => !i.IsFolder).ToList();
+
+ // Use a timer to prevent lots of these notifications from showing in a short period of time
+ if (newItems.Count > 0)
+ {
+ lock (_newlyAddedItems)
+ {
+ _newlyAddedItems.AddRange(newItems);
+
+ if (NewItemTimer == null)
+ {
+ NewItemTimer = new Timer(NewItemTimerCallback, null, NewItemDelay, Timeout.Infinite);
+ }
+ else
+ {
+ NewItemTimer.Change(NewItemDelay, Timeout.Infinite);
+ }
+ }
+ }
+ }
+
+ ///
+ /// Called when the new item timer expires
+ ///
+ /// The state.
+ private void NewItemTimerCallback(object state)
+ {
+ List newItems;
+
+ // Lock the list and release all resources
+ lock (_newlyAddedItems)
+ {
+ newItems = _newlyAddedItems.ToList();
+ _newlyAddedItems.Clear();
+
+ NewItemTimer.Dispose();
+ NewItemTimer = null;
+ }
+
+ // Show the notification
+ if (newItems.Count == 1)
+ {
+ var window = (MainWindow) App.Current.MainWindow;
+
+ window.Dispatcher.InvokeAsync(() => window.MbTaskbarIcon.ShowCustomBalloon(new ItemUpdateNotification(_logger)
+ {
+ DataContext = newItems[0]
+
+ }, PopupAnimation.Slide, 6000));
+ }
+ else if (newItems.Count > 1)
+ {
+ var window = (MainWindow)App.Current.MainWindow;
+
+ window.Dispatcher.InvokeAsync(() => window.MbTaskbarIcon.ShowCustomBalloon(new MultiItemUpdateNotification(_logger)
+ {
+ DataContext = newItems
+
+ }, PopupAnimation.Slide, 6000));
+ }
+ }
+
+ ///
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ ///
+ public void Dispose()
+ {
+ _libraryManager.LibraryChanged -= libraryManager_LibraryChanged;
+ }
+ }
+}
diff --git a/MediaBrowser.ServerApplication/StartupWizard.cs b/MediaBrowser.ServerApplication/StartupWizard.cs
new file mode 100644
index 0000000000..c5e8c1c993
--- /dev/null
+++ b/MediaBrowser.ServerApplication/StartupWizard.cs
@@ -0,0 +1,61 @@
+using MediaBrowser.Common.Kernel;
+using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Plugins;
+using System.Linq;
+
+namespace MediaBrowser.ServerApplication
+{
+ ///
+ /// Class StartupWizard
+ ///
+ public class StartupWizard : IServerEntryPoint
+ {
+ ///
+ /// The _app host
+ ///
+ private readonly IApplicationHost _appHost;
+ ///
+ /// The _user manager
+ ///
+ private readonly IUserManager _userManager;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The app host.
+ /// The user manager.
+ public StartupWizard(IApplicationHost appHost, IUserManager userManager)
+ {
+ _appHost = appHost;
+ _userManager = userManager;
+ }
+
+ ///
+ /// Runs this instance.
+ ///
+ public void Run()
+ {
+ if (_appHost.IsFirstRun)
+ {
+ LaunchStartupWizard();
+ }
+ }
+
+ ///
+ /// Launches the startup wizard.
+ ///
+ private void LaunchStartupWizard()
+ {
+ var user = _userManager.Users.FirstOrDefault(u => u.Configuration.IsAdministrator);
+
+ App.OpenDashboardPage("wizardStart.html", user);
+ }
+
+ ///
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ ///
+ public void Dispose()
+ {
+ }
+ }
+}