using System; using System.Collections.Generic; using Wino.Core.Domain.Enums; namespace Wino.Core.Domain.Models.Synchronization; /// /// Result of synchronizing a single folder. /// Used for partial failure tracking when one folder fails but others succeed. /// public class FolderSyncResult { /// /// Gets or sets the folder ID. /// public Guid FolderId { get; set; } /// /// Gets or sets the folder name for display purposes. /// public string FolderName { get; set; } /// /// Gets or sets whether the folder sync was successful. /// public bool Success { get; set; } /// /// Gets or sets the number of messages downloaded/synchronized. /// public int DownloadedCount { get; set; } /// /// Gets or sets the number of messages deleted locally (removed from server). /// public int DeletedCount { get; set; } /// /// Gets or sets the number of messages whose flags were updated. /// public int UpdatedCount { get; set; } /// /// Gets or sets the error message if sync failed. /// public string ErrorMessage { get; set; } /// /// Gets or sets the error severity if sync failed. /// public SynchronizerErrorSeverity? ErrorSeverity { get; set; } /// /// Gets or sets the error category if sync failed. /// public SynchronizerErrorCategory? ErrorCategory { get; set; } /// /// Gets or sets whether this folder was skipped (e.g., due to configuration). /// public bool WasSkipped { get; set; } /// /// Gets or sets the reason the folder was skipped. /// public string SkipReason { get; set; } /// /// Creates a successful folder sync result. /// public static FolderSyncResult Successful(Guid folderId, string folderName, int downloaded = 0, int deleted = 0, int updated = 0) => new() { FolderId = folderId, FolderName = folderName, Success = true, DownloadedCount = downloaded, DeletedCount = deleted, UpdatedCount = updated }; /// /// Creates a failed folder sync result. /// public static FolderSyncResult Failed(Guid folderId, string folderName, string errorMessage, SynchronizerErrorSeverity severity = SynchronizerErrorSeverity.Fatal, SynchronizerErrorCategory category = SynchronizerErrorCategory.Unknown) => new() { FolderId = folderId, FolderName = folderName, Success = false, ErrorMessage = errorMessage, ErrorSeverity = severity, ErrorCategory = category }; /// /// Creates a failed folder sync result from an error context. /// public static FolderSyncResult Failed(Guid folderId, string folderName, SynchronizerErrorContext errorContext) => new() { FolderId = folderId, FolderName = folderName, Success = false, ErrorMessage = errorContext?.ErrorMessage ?? "Unknown error", ErrorSeverity = errorContext?.Severity ?? SynchronizerErrorSeverity.Fatal, ErrorCategory = errorContext?.Category ?? SynchronizerErrorCategory.Unknown }; /// /// Creates a skipped folder sync result. /// public static FolderSyncResult Skipped(Guid folderId, string folderName, string reason) => new() { FolderId = folderId, FolderName = folderName, Success = true, // Skipping is not a failure WasSkipped = true, SkipReason = reason }; }