chore: release v2.4
- Add theme system (Dark/Light palettes, ModernTheme, ThemeManager) - Add InputDialog, Spinner common view - Add DuplicatesCsvExportService - Refresh views, dialogs, and view models across tabs - Update localization strings (en/fr) - Tweak services (transfer, permissions, search, user access, ownership elevation, bulk operations) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using SharepointToolbox.Core.Models;
|
||||
using SharepointToolbox.Localization;
|
||||
|
||||
namespace SharepointToolbox.Services.Export;
|
||||
|
||||
/// <summary>
|
||||
/// Exports DuplicateGroup list to CSV. Each duplicate item becomes one row;
|
||||
/// the Group column ties copies together and a Copies column gives the group size.
|
||||
/// Header row is built at write-time so culture switches are honoured.
|
||||
/// </summary>
|
||||
public class DuplicatesCsvExportService
|
||||
{
|
||||
public async Task WriteAsync(
|
||||
IReadOnlyList<DuplicateGroup> groups,
|
||||
string filePath,
|
||||
CancellationToken ct)
|
||||
{
|
||||
var T = TranslationSource.Instance;
|
||||
var sb = new StringBuilder();
|
||||
|
||||
// Summary
|
||||
sb.AppendLine($"\"{T["report.title.duplicates_short"]}\"");
|
||||
sb.AppendLine($"\"{T["report.text.duplicate_groups_found"]}\",\"{groups.Count}\"");
|
||||
sb.AppendLine($"\"{T["report.text.generated"]}\",\"{DateTime.Now:yyyy-MM-dd HH:mm:ss}\"");
|
||||
sb.AppendLine();
|
||||
|
||||
// Header
|
||||
sb.AppendLine(string.Join(",", new[]
|
||||
{
|
||||
Csv(T["report.col.number"]),
|
||||
Csv("Group"),
|
||||
Csv(T["report.text.copies"]),
|
||||
Csv(T["report.col.name"]),
|
||||
Csv(T["report.col.library"]),
|
||||
Csv(T["report.col.path"]),
|
||||
Csv(T["report.col.size_bytes"]),
|
||||
Csv(T["report.col.created"]),
|
||||
Csv(T["report.col.modified"]),
|
||||
}));
|
||||
|
||||
// Rows
|
||||
foreach (var g in groups)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var item in g.Items)
|
||||
{
|
||||
i++;
|
||||
sb.AppendLine(string.Join(",", new[]
|
||||
{
|
||||
Csv(i.ToString()),
|
||||
Csv(g.Name),
|
||||
Csv(g.Items.Count.ToString()),
|
||||
Csv(item.Name),
|
||||
Csv(item.Library),
|
||||
Csv(item.Path),
|
||||
Csv(item.SizeBytes?.ToString() ?? string.Empty),
|
||||
Csv(item.Created?.ToString("yyyy-MM-dd") ?? string.Empty),
|
||||
Csv(item.Modified?.ToString("yyyy-MM-dd") ?? string.Empty),
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
await File.WriteAllTextAsync(filePath, sb.ToString(),
|
||||
new UTF8Encoding(encoderShouldEmitUTF8Identifier: true), ct);
|
||||
}
|
||||
|
||||
private static string Csv(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return "\"\"";
|
||||
return $"\"{value.Replace("\"", "\"\"")}\"";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user