This commit is contained in:
Dev
2026-04-24 10:50:19 +02:00
14 changed files with 523 additions and 0 deletions
@@ -12,12 +12,16 @@ namespace SharepointToolbox.Services.Export;
/// </summary>
public class DuplicatesCsvExportService
{
<<<<<<< HEAD
/// <summary>Writes the CSV to <paramref name="filePath"/> with UTF-8 BOM (Excel-compatible).</summary>
=======
>>>>>>> f4cc81bb71b935c6f6f050288c9e283dcca5cfa8
public async Task WriteAsync(
IReadOnlyList<DuplicateGroup> groups,
string filePath,
CancellationToken ct)
{
<<<<<<< HEAD
var csv = BuildCsv(groups);
await ExportFileWriter.WriteCsvAsync(filePath, csv, ct);
}
@@ -59,6 +63,8 @@ public class DuplicatesCsvExportService
/// </summary>
public string BuildCsv(IReadOnlyList<DuplicateGroup> groups)
{
=======
>>>>>>> f4cc81bb71b935c6f6f050288c9e283dcca5cfa8
var T = TranslationSource.Instance;
var sb = new StringBuilder();
@@ -72,9 +78,14 @@ public class DuplicatesCsvExportService
sb.AppendLine(string.Join(",", new[]
{
Csv(T["report.col.number"]),
<<<<<<< HEAD
Csv(T["report.col.group"]),
Csv(T["report.text.copies"]),
Csv(T["report.col.site"]),
=======
Csv("Group"),
Csv(T["report.text.copies"]),
>>>>>>> f4cc81bb71b935c6f6f050288c9e283dcca5cfa8
Csv(T["report.col.name"]),
Csv(T["report.col.library"]),
Csv(T["report.col.path"]),
@@ -83,6 +94,10 @@ public class DuplicatesCsvExportService
Csv(T["report.col.modified"]),
}));
<<<<<<< HEAD
=======
// Rows
>>>>>>> f4cc81bb71b935c6f6f050288c9e283dcca5cfa8
foreach (var g in groups)
{
int i = 0;
@@ -94,7 +109,10 @@ public class DuplicatesCsvExportService
Csv(i.ToString()),
Csv(g.Name),
Csv(g.Items.Count.ToString()),
<<<<<<< HEAD
Csv(item.SiteTitle),
=======
>>>>>>> f4cc81bb71b935c6f6f050288c9e283dcca5cfa8
Csv(item.Name),
Csv(item.Library),
Csv(item.Path),
@@ -105,8 +123,20 @@ public class DuplicatesCsvExportService
}
}
<<<<<<< HEAD
return sb.ToString();
}
private static string Csv(string value) => CsvSanitizer.Escape(value);
=======
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("\"", "\"\"")}\"";
}
>>>>>>> f4cc81bb71b935c6f6f050288c9e283dcca5cfa8
}