|
|
|
@ -1,13 +1,10 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Jellyfin.Data.Entities;
|
|
|
|
|
using MediaBrowser.Common.Updates;
|
|
|
|
|
using MediaBrowser.Controller.Plugins;
|
|
|
|
|
using MediaBrowser.Controller.Session;
|
|
|
|
|
using MediaBrowser.Model.Activity;
|
|
|
|
|
using MediaBrowser.Model.Globalization;
|
|
|
|
|
using MediaBrowser.Model.Notifications;
|
|
|
|
|
|
|
|
|
|
namespace Emby.Server.Implementations.Activity
|
|
|
|
|
{
|
|
|
|
@ -16,7 +13,6 @@ namespace Emby.Server.Implementations.Activity
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class ActivityLogEntryPoint : IServerEntryPoint
|
|
|
|
|
{
|
|
|
|
|
private readonly IInstallationManager _installationManager;
|
|
|
|
|
private readonly ISessionManager _sessionManager;
|
|
|
|
|
private readonly IActivityManager _activityManager;
|
|
|
|
|
private readonly ILocalizationManager _localization;
|
|
|
|
@ -27,24 +23,19 @@ namespace Emby.Server.Implementations.Activity
|
|
|
|
|
/// <param name="sessionManager">The session manager.</param>
|
|
|
|
|
/// <param name="activityManager">The activity manager.</param>
|
|
|
|
|
/// <param name="localization">The localization manager.</param>
|
|
|
|
|
/// <param name="installationManager">The installation manager.</param>
|
|
|
|
|
public ActivityLogEntryPoint(
|
|
|
|
|
ISessionManager sessionManager,
|
|
|
|
|
IActivityManager activityManager,
|
|
|
|
|
ILocalizationManager localization,
|
|
|
|
|
IInstallationManager installationManager)
|
|
|
|
|
ILocalizationManager localization)
|
|
|
|
|
{
|
|
|
|
|
_sessionManager = sessionManager;
|
|
|
|
|
_activityManager = activityManager;
|
|
|
|
|
_localization = localization;
|
|
|
|
|
_installationManager = installationManager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public Task RunAsync()
|
|
|
|
|
{
|
|
|
|
|
_installationManager.PackageInstallationFailed += OnPackageInstallationFailed;
|
|
|
|
|
|
|
|
|
|
_sessionManager.SessionStarted += OnSessionStarted;
|
|
|
|
|
_sessionManager.SessionEnded += OnSessionEnded;
|
|
|
|
|
|
|
|
|
@ -101,34 +92,12 @@ namespace Emby.Server.Implementations.Activity
|
|
|
|
|
}).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void OnPackageInstallationFailed(object sender, InstallationFailedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var installationInfo = e.InstallationInfo;
|
|
|
|
|
|
|
|
|
|
await CreateLogEntry(new ActivityLog(
|
|
|
|
|
string.Format(
|
|
|
|
|
CultureInfo.InvariantCulture,
|
|
|
|
|
_localization.GetLocalizedString("NameInstallFailed"),
|
|
|
|
|
installationInfo.Name),
|
|
|
|
|
NotificationType.InstallationFailed.ToString(),
|
|
|
|
|
Guid.Empty)
|
|
|
|
|
{
|
|
|
|
|
ShortOverview = string.Format(
|
|
|
|
|
CultureInfo.InvariantCulture,
|
|
|
|
|
_localization.GetLocalizedString("VersionNumber"),
|
|
|
|
|
installationInfo.Version),
|
|
|
|
|
Overview = e.Exception.Message
|
|
|
|
|
}).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task CreateLogEntry(ActivityLog entry)
|
|
|
|
|
=> await _activityManager.CreateAsync(entry).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
_installationManager.PackageInstallationFailed -= OnPackageInstallationFailed;
|
|
|
|
|
|
|
|
|
|
_sessionManager.SessionStarted -= OnSessionStarted;
|
|
|
|
|
_sessionManager.SessionEnded -= OnSessionEnded;
|
|
|
|
|
}
|
|
|
|
|