Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
 /// <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);
 }
Esempio n. 4
0
 private async Task CreateLogEntry(ActivityLogEntry entry)
 {
     try
     {
         await _activityManager.CreateAsync(entry);
     }
     catch
     {
         // Logged at lower levels
     }
 }
Esempio n. 5
0
 /// <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);
 }
Esempio n. 6
0
 /// <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);
 }
Esempio n. 7
0
 /// <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);
 }
Esempio n. 10
0
 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);
 }
Esempio n. 12
0
 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
     }
 }
Esempio n. 13
0
 /// <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);
 }
Esempio n. 14
0
        /// <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);
            }
        }
Esempio n. 15
0
        /// <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);
        }
Esempio n. 16
0
 private async Task CreateLogEntry(ActivityLog entry)
 => await _activityManager.CreateAsync(entry).ConfigureAwait(false);