From b52f60f8eb9ea2cabdaa34b0769ce45ca875389f Mon Sep 17 00:00:00 2001 From: Dev Date: Thu, 2 Apr 2026 15:23:04 +0200 Subject: [PATCH] feat(03-01): create 7 core models and 3 service interfaces for Phase 3 - StorageNode, StorageScanOptions models - SearchResult, SearchOptions models - DuplicateItem, DuplicateGroup, DuplicateScanOptions models - IStorageService, ISearchService, IDuplicatesService interfaces --- SharepointToolbox/Core/Models/DuplicateGroup.cs | 8 ++++++++ SharepointToolbox/Core/Models/DuplicateItem.cs | 13 +++++++++++++ .../Core/Models/DuplicateScanOptions.cs | 12 ++++++++++++ SharepointToolbox/Core/Models/SearchOptions.cs | 15 +++++++++++++++ SharepointToolbox/Core/Models/SearchResult.cs | 13 +++++++++++++ SharepointToolbox/Core/Models/StorageNode.cs | 16 ++++++++++++++++ .../Core/Models/StorageScanOptions.cs | 7 +++++++ SharepointToolbox/Services/IDuplicatesService.cs | 13 +++++++++++++ SharepointToolbox/Services/ISearchService.cs | 13 +++++++++++++ SharepointToolbox/Services/IStorageService.cs | 13 +++++++++++++ 10 files changed, 123 insertions(+) create mode 100644 SharepointToolbox/Core/Models/DuplicateGroup.cs create mode 100644 SharepointToolbox/Core/Models/DuplicateItem.cs create mode 100644 SharepointToolbox/Core/Models/DuplicateScanOptions.cs create mode 100644 SharepointToolbox/Core/Models/SearchOptions.cs create mode 100644 SharepointToolbox/Core/Models/SearchResult.cs create mode 100644 SharepointToolbox/Core/Models/StorageNode.cs create mode 100644 SharepointToolbox/Core/Models/StorageScanOptions.cs create mode 100644 SharepointToolbox/Services/IDuplicatesService.cs create mode 100644 SharepointToolbox/Services/ISearchService.cs create mode 100644 SharepointToolbox/Services/IStorageService.cs diff --git a/SharepointToolbox/Core/Models/DuplicateGroup.cs b/SharepointToolbox/Core/Models/DuplicateGroup.cs new file mode 100644 index 0000000..ad42e51 --- /dev/null +++ b/SharepointToolbox/Core/Models/DuplicateGroup.cs @@ -0,0 +1,8 @@ +namespace SharepointToolbox.Core.Models; + +public class DuplicateGroup +{ + public string GroupKey { get; set; } = string.Empty; + public string Name { get; set; } = string.Empty; + public List Items { get; set; } = new(); +} diff --git a/SharepointToolbox/Core/Models/DuplicateItem.cs b/SharepointToolbox/Core/Models/DuplicateItem.cs new file mode 100644 index 0000000..c035aeb --- /dev/null +++ b/SharepointToolbox/Core/Models/DuplicateItem.cs @@ -0,0 +1,13 @@ +namespace SharepointToolbox.Core.Models; + +public class DuplicateItem +{ + public string Name { get; set; } = string.Empty; + public string Path { get; set; } = string.Empty; + public string Library { get; set; } = string.Empty; + public long? SizeBytes { get; set; } + public DateTime? Created { get; set; } + public DateTime? Modified { get; set; } + public int? FolderCount { get; set; } + public int? FileCount { get; set; } +} diff --git a/SharepointToolbox/Core/Models/DuplicateScanOptions.cs b/SharepointToolbox/Core/Models/DuplicateScanOptions.cs new file mode 100644 index 0000000..f954db4 --- /dev/null +++ b/SharepointToolbox/Core/Models/DuplicateScanOptions.cs @@ -0,0 +1,12 @@ +namespace SharepointToolbox.Core.Models; + +public record DuplicateScanOptions( + string Mode = "Files", // "Files" or "Folders" + bool MatchSize = true, + bool MatchCreated = false, + bool MatchModified = false, + bool MatchSubfolderCount = false, + bool MatchFileCount = false, + bool IncludeSubsites = false, + string? Library = null +); diff --git a/SharepointToolbox/Core/Models/SearchOptions.cs b/SharepointToolbox/Core/Models/SearchOptions.cs new file mode 100644 index 0000000..e5671e9 --- /dev/null +++ b/SharepointToolbox/Core/Models/SearchOptions.cs @@ -0,0 +1,15 @@ +namespace SharepointToolbox.Core.Models; + +public record SearchOptions( + string[] Extensions, + string? Regex, + DateTime? CreatedAfter, + DateTime? CreatedBefore, + DateTime? ModifiedAfter, + DateTime? ModifiedBefore, + string? CreatedBy, + string? ModifiedBy, + string? Library, + int MaxResults, + string SiteUrl +); diff --git a/SharepointToolbox/Core/Models/SearchResult.cs b/SharepointToolbox/Core/Models/SearchResult.cs new file mode 100644 index 0000000..6aa7f5b --- /dev/null +++ b/SharepointToolbox/Core/Models/SearchResult.cs @@ -0,0 +1,13 @@ +namespace SharepointToolbox.Core.Models; + +public class SearchResult +{ + public string Title { get; set; } = string.Empty; + public string Path { get; set; } = string.Empty; + public string FileExtension { get; set; } = string.Empty; + public DateTime? Created { get; set; } + public DateTime? LastModified { get; set; } + public string Author { get; set; } = string.Empty; + public string ModifiedBy { get; set; } = string.Empty; + public long SizeBytes { get; set; } +} diff --git a/SharepointToolbox/Core/Models/StorageNode.cs b/SharepointToolbox/Core/Models/StorageNode.cs new file mode 100644 index 0000000..5cb9453 --- /dev/null +++ b/SharepointToolbox/Core/Models/StorageNode.cs @@ -0,0 +1,16 @@ +namespace SharepointToolbox.Core.Models; + +public class StorageNode +{ + public string Name { get; set; } = string.Empty; + public string Url { get; set; } = string.Empty; + public string SiteTitle { get; set; } = string.Empty; + public string Library { get; set; } = string.Empty; + public long TotalSizeBytes { get; set; } + public long FileStreamSizeBytes { get; set; } + public long VersionSizeBytes => Math.Max(0L, TotalSizeBytes - FileStreamSizeBytes); + public long TotalFileCount { get; set; } + public DateTime? LastModified { get; set; } + public int IndentLevel { get; set; } + public List Children { get; set; } = new(); +} diff --git a/SharepointToolbox/Core/Models/StorageScanOptions.cs b/SharepointToolbox/Core/Models/StorageScanOptions.cs new file mode 100644 index 0000000..7400cc1 --- /dev/null +++ b/SharepointToolbox/Core/Models/StorageScanOptions.cs @@ -0,0 +1,7 @@ +namespace SharepointToolbox.Core.Models; + +public record StorageScanOptions( + bool PerLibrary = true, + bool IncludeSubsites = false, + int FolderDepth = 0 // 0 = library root only; >0 = recurse N levels +); diff --git a/SharepointToolbox/Services/IDuplicatesService.cs b/SharepointToolbox/Services/IDuplicatesService.cs new file mode 100644 index 0000000..e6aec69 --- /dev/null +++ b/SharepointToolbox/Services/IDuplicatesService.cs @@ -0,0 +1,13 @@ +using Microsoft.SharePoint.Client; +using SharepointToolbox.Core.Models; + +namespace SharepointToolbox.Services; + +public interface IDuplicatesService +{ + Task> ScanDuplicatesAsync( + ClientContext ctx, + DuplicateScanOptions options, + IProgress progress, + CancellationToken ct); +} diff --git a/SharepointToolbox/Services/ISearchService.cs b/SharepointToolbox/Services/ISearchService.cs new file mode 100644 index 0000000..957e32b --- /dev/null +++ b/SharepointToolbox/Services/ISearchService.cs @@ -0,0 +1,13 @@ +using Microsoft.SharePoint.Client; +using SharepointToolbox.Core.Models; + +namespace SharepointToolbox.Services; + +public interface ISearchService +{ + Task> SearchFilesAsync( + ClientContext ctx, + SearchOptions options, + IProgress progress, + CancellationToken ct); +} diff --git a/SharepointToolbox/Services/IStorageService.cs b/SharepointToolbox/Services/IStorageService.cs new file mode 100644 index 0000000..16143d6 --- /dev/null +++ b/SharepointToolbox/Services/IStorageService.cs @@ -0,0 +1,13 @@ +using Microsoft.SharePoint.Client; +using SharepointToolbox.Core.Models; + +namespace SharepointToolbox.Services; + +public interface IStorageService +{ + Task> CollectStorageAsync( + ClientContext ctx, + StorageScanOptions options, + IProgress progress, + CancellationToken ct); +}