/// <inheritdoc /> public async Task OnEvent(PlaybackStartEventArgs eventArgs) { if (eventArgs.MediaInfo == null) { _logger.LogWarning("PlaybackStart reported with null media info."); return; } if (eventArgs.Item != null && eventArgs.Item.IsThemeMedia) { // Don't report theme song or local trailer playback return; } if (eventArgs.Users.Count == 0) { return; } var user = eventArgs.Users[0]; await _activityManager.CreateAsync(new ActivityLog( string.Format( CultureInfo.InvariantCulture, _localizationManager.GetLocalizedString("UserStartedPlayingItemWithValues"), user.Username, GetItemName(eventArgs.MediaInfo), eventArgs.DeviceName), GetPlaybackNotificationType(eventArgs.MediaInfo.MediaType), user.Id)) .ConfigureAwait(false); }
public async Task <EntityDto <Guid> > CreateActivity(CreateActivityInput input) { var currentUser = await GetCurrentUserAsync(); var location = input.LocationId.HasValue ? await _locationManager.GetLocationAsync(input.LocationId.Value) : null; var tags = await _tagManager.GetTags(input.TagTexts); var activity = await _activityManager.CreateAsync(Activity.Create( input.Name, input.StartTime, input.EndTime, location, tags, currentUser )); return(new EntityDto <Guid>(activity.Id)); }
/// <inheritdoc /> public async Task OnEvent(PluginUninstalledEventArgs eventArgs) { await _activityManager.CreateAsync(new ActivityLog( string.Format( CultureInfo.InvariantCulture, _localizationManager.GetLocalizedString("PluginUninstalledWithName"), eventArgs.Argument.Name), NotificationType.PluginUninstalled.ToString(), Guid.Empty)) .ConfigureAwait(false); }
private async Task CreateLogEntry(ActivityLogEntry entry) { try { await _activityManager.CreateAsync(entry); } catch { // Logged at lower levels } }
/// <inheritdoc /> public async Task OnEvent(UserCreatedEventArgs eventArgs) { await _activityManager.CreateAsync(new ActivityLog( string.Format( CultureInfo.InvariantCulture, _localizationManager.GetLocalizedString("UserCreatedWithName"), eventArgs.Argument.Username), "UserCreated", eventArgs.Argument.Id)) .ConfigureAwait(false); }
/// <inheritdoc /> public async Task OnEvent(UserLockedOutEventArgs eventArgs) { await _activityManager.CreateAsync(new ActivityLog( string.Format( CultureInfo.InvariantCulture, _localizationManager.GetLocalizedString("UserLockedOutWithName"), eventArgs.Argument.Username), NotificationType.UserLockedOut.ToString(), eventArgs.Argument.Id) { LogSeverity = LogLevel.Error }).ConfigureAwait(false); }
/// <inheritdoc /> public async Task OnEvent(SubtitleDownloadFailureEventArgs eventArgs) { await _activityManager.CreateAsync(new ActivityLog( string.Format( CultureInfo.InvariantCulture, _localizationManager.GetLocalizedString("SubtitleDownloadFailureFromForItem"), eventArgs.Provider, GetItemName(eventArgs.Item)), "SubtitleDownloadFailure", Guid.Empty) { ItemId = eventArgs.Item.Id.ToString("N", CultureInfo.InvariantCulture), ShortOverview = eventArgs.Exception.Message }).ConfigureAwait(false); }
/// <inheritdoc /> public async Task OnEvent(GenericEventArgs <AuthenticationResult> eventArgs) { await _activityManager.CreateAsync(new ActivityLog( string.Format( CultureInfo.InvariantCulture, _localizationManager.GetLocalizedString("AuthenticationSucceededWithUserName"), eventArgs.Argument.User.Name), "AuthenticationSucceeded", eventArgs.Argument.User.Id) { ShortOverview = string.Format( CultureInfo.InvariantCulture, _localizationManager.GetLocalizedString("LabelIpAddressValue"), eventArgs.Argument.SessionInfo.RemoteEndPoint), }).ConfigureAwait(false); }
/// <inheritdoc /> public async Task OnEvent(InstallationFailedEventArgs eventArgs) { await _activityManager.CreateAsync(new ActivityLog( string.Format( CultureInfo.InvariantCulture, _localizationManager.GetLocalizedString("NameInstallFailed"), eventArgs.InstallationInfo.Name), NotificationType.InstallationFailed.ToString(), Guid.Empty) { ShortOverview = string.Format( CultureInfo.InvariantCulture, _localizationManager.GetLocalizedString("VersionNumber"), eventArgs.InstallationInfo.Version), Overview = eventArgs.Exception.Message }).ConfigureAwait(false); }
private async Task LogDownloadAsync(BaseItem item, User user, AuthorizationInfo auth) { try { await _activityManager.CreateAsync(new ActivityLog( string.Format(CultureInfo.InvariantCulture, _localization.GetLocalizedString("UserDownloadingItemWithValues"), user.Username, item.Name), "UserDownloadingContent", auth.UserId) { ShortOverview = string.Format(CultureInfo.InvariantCulture, _localization.GetLocalizedString("AppDeviceValues"), auth.Client, auth.Device), }).ConfigureAwait(false); } catch { // Logged at lower levels } }
/// <inheritdoc /> public async Task OnEvent(GenericEventArgs <AuthenticationRequest> eventArgs) { await _activityManager.CreateAsync(new ActivityLog( string.Format( CultureInfo.InvariantCulture, _localizationManager.GetLocalizedString("FailedLoginAttemptWithUserName"), eventArgs.Argument.Username), "AuthenticationFailed", Guid.Empty) { LogSeverity = LogLevel.Error, ShortOverview = string.Format( CultureInfo.InvariantCulture, _localizationManager.GetLocalizedString("LabelIpAddressValue"), eventArgs.Argument.RemoteEndPoint), }).ConfigureAwait(false); }
private void LogDownload(BaseItem item, User user, AuthorizationInfo auth) { try { _activityManager.CreateAsync(new ActivityLogEntry { Name = string.Format(_localization.GetLocalizedString("UserDownloadingItemWithValues"), user.Name, item.Name), Type = "UserDownloadingContent", ShortOverview = string.Format(_localization.GetLocalizedString("AppDeviceValues"), auth.Client, auth.Device), UserId = auth.UserId }); } catch { // Logged at lower levels } }
/// <inheritdoc /> public async Task OnEvent(PluginUpdatedEventArgs eventArgs) { await _activityManager.CreateAsync(new ActivityLog( string.Format( CultureInfo.InvariantCulture, _localizationManager.GetLocalizedString("PluginUpdatedWithName"), eventArgs.Argument.Name), NotificationType.PluginUpdateInstalled.ToString(), Guid.Empty) { ShortOverview = string.Format( CultureInfo.InvariantCulture, _localizationManager.GetLocalizedString("VersionNumber"), eventArgs.Argument.Version), Overview = eventArgs.Argument.Changelog }).ConfigureAwait(false); }
/// <inheritdoc /> public async Task OnEvent(TaskCompletionEventArgs eventArgs) { var result = eventArgs.Result; var task = eventArgs.Task; if (task.ScheduledTask is IConfigurableScheduledTask activityTask && !activityTask.IsLogged) { return; } var time = result.EndTimeUtc - result.StartTimeUtc; var runningTime = string.Format( CultureInfo.InvariantCulture, _localizationManager.GetLocalizedString("LabelRunningTimeValue"), ToUserFriendlyString(time)); if (result.Status == TaskCompletionStatus.Failed) { var vals = new List <string>(); if (!string.IsNullOrEmpty(eventArgs.Result.ErrorMessage)) { vals.Add(eventArgs.Result.ErrorMessage); } if (!string.IsNullOrEmpty(eventArgs.Result.LongErrorMessage)) { vals.Add(eventArgs.Result.LongErrorMessage); } await _activityManager.CreateAsync(new ActivityLog( string.Format(CultureInfo.InvariantCulture, _localizationManager.GetLocalizedString("ScheduledTaskFailedWithName"), task.Name), NotificationType.TaskFailed.ToString(), Guid.Empty) { LogSeverity = LogLevel.Error, Overview = string.Join(Environment.NewLine, vals), ShortOverview = runningTime }).ConfigureAwait(false); } }
/// <inheritdoc /> public async Task OnEvent(SessionEndedEventArgs eventArgs) { if (string.IsNullOrEmpty(eventArgs.Argument.UserName)) { return; } await _activityManager.CreateAsync(new ActivityLog( string.Format( CultureInfo.InvariantCulture, _localizationManager.GetLocalizedString("UserOfflineFromDevice"), eventArgs.Argument.UserName, eventArgs.Argument.DeviceName), "SessionEnded", eventArgs.Argument.UserId) { ShortOverview = string.Format( CultureInfo.InvariantCulture, _localizationManager.GetLocalizedString("LabelIpAddressValue"), eventArgs.Argument.RemoteEndPoint), }).ConfigureAwait(false); }
private async Task CreateLogEntry(ActivityLog entry) => await _activityManager.CreateAsync(entry).ConfigureAwait(false);