using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using ThreadPilot.Models;
namespace ThreadPilot.Services
{
///
/// Notification categories for throttling
///
public enum NotificationCategory
{
System,
Process,
Performance,
GameBoost,
PowerPlan,
Error,
Warning,
Information,
UserAction
}
///
/// Smart notification with metadata
///
public class SmartNotification
{
public string Id { get; set; } = Guid.NewGuid().ToString();
public string Title { get; set; } = string.Empty;
public string Message { get; set; } = string.Empty;
public NotificationPriority Priority { get; set; } = NotificationPriority.Normal;
public NotificationCategory Category { get; set; } = NotificationCategory.Information;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime? ScheduledFor { get; set; }
public TimeSpan? ExpiresAfter { get; set; }
public Dictionary Metadata { get; set; } = new();
public string DeduplicationKey { get; set; } = string.Empty;
public bool IsPersistent { get; set; } = false;
public int RetryCount { get; set; } = 0;
public int MaxRetries { get; set; } = 3;
}
///
/// Notification throttling configuration
///
public class NotificationThrottleConfig
{
public NotificationCategory Category { get; set; }
public TimeSpan MinInterval { get; set; } = TimeSpan.FromSeconds(30);
public int MaxPerHour { get; set; } = 10;
public int MaxPerDay { get; set; } = 50;
public bool EnableDeduplication { get; set; } = true;
public TimeSpan DeduplicationWindow { get; set; } = TimeSpan.FromMinutes(5);
}
///
/// User notification preferences
///
public class NotificationPreferences
{
public bool IsEnabled { get; set; } = true;
public bool DoNotDisturbMode { get; set; } = false;
public TimeSpan DoNotDisturbStart { get; set; } = TimeSpan.FromHours(22); // 10 PM
public TimeSpan DoNotDisturbEnd { get; set; } = TimeSpan.FromHours(8); // 8 AM
public NotificationPriority MinimumPriority { get; set; } = NotificationPriority.Normal;
public Dictionary CategoryEnabled { get; set; } = new();
public Dictionary ThrottleConfigs { get; set; } = new();
public bool ShowOnlyWhenMinimized { get; set; } = false;
public bool PlaySounds { get; set; } = true;
public int DefaultDisplayDuration { get; set; } = 5000; // milliseconds
}
///
/// Event arguments for smart notification events
///
public class SmartNotificationEventArgs : EventArgs
{
public SmartNotification Notification { get; set; } = new();
public string Reason { get; set; } = string.Empty;
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
}
///
/// Smart notification service with throttling and priority queuing
///
public interface ISmartNotificationService
{
///
/// Initialize the smart notification service
///
Task InitializeAsync();
///
/// Send a smart notification
///
Task SendNotificationAsync(SmartNotification notification);
///
/// Send a simple notification
///
Task SendNotificationAsync(string title, string message,
NotificationPriority priority = NotificationPriority.Normal,
NotificationCategory category = NotificationCategory.Information);
///
/// Schedule a notification for later delivery
///
Task ScheduleNotificationAsync(SmartNotification notification, DateTime deliveryTime);
///
/// Cancel a scheduled notification
///
Task CancelNotificationAsync(string notificationId);
///
/// Get pending notifications
///
Task> GetPendingNotificationsAsync();
///
/// Get notification history
///
Task> GetNotificationHistoryAsync(TimeSpan? period = null);
///
/// Clear notification history
///
Task ClearHistoryAsync();
///
/// Update user preferences
///
Task UpdatePreferencesAsync(NotificationPreferences preferences);
///
/// Get current user preferences
///
Task GetPreferencesAsync();
///
/// Enable/disable Do Not Disturb mode
///
Task SetDoNotDisturbAsync(bool enabled, TimeSpan? duration = null);
///
/// Check if Do Not Disturb is currently active
///
bool IsDoNotDisturbActive();
///
/// Get notification statistics
///
Task> GetStatisticsAsync();
///
/// Test notification delivery
///
Task TestNotificationAsync();
///
/// Event raised when a notification is sent
///
event EventHandler? NotificationSent;
///
/// Event raised when a notification is throttled
///
event EventHandler? NotificationThrottled;
///
/// Event raised when a notification is deduplicated
///
event EventHandler? NotificationDeduplicated;
///
/// Event raised when Do Not Disturb mode changes
///
event EventHandler? DoNotDisturbChanged;
}
}