-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
61 lines (49 loc) · 1.95 KB
/
Program.cs
File metadata and controls
61 lines (49 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using TXTextControl;
using System.Globalization;
using var textControl = new ServerTextControl();
textControl.Create();
textControl.Load("nda.docx", StreamType.WordprocessingML);
// ---- Filters ----
string? filterAuthor = "Alice Johnson";
ChangeKind? filterKind = null; // e.g. ChangeKind.Insertion
DateTime? fromDate = null; // e.g. new DateTime(2025, 1, 1)
DateTime? toDate = null; // e.g. new DateTime(2026, 1, 1)
// Accept or reject filtered changes
bool acceptChanges = true;
// ---- Collect filtered changes ----
var changes = textControl.TrackedChanges
.Cast<TrackedChange>()
.Where(c =>
(filterAuthor == null || c.UserName == filterAuthor) &&
(filterKind == null || c.ChangeKind == filterKind) &&
(fromDate == null || c.ChangeTime >= fromDate) &&
(toDate == null || c.ChangeTime <= toDate))
.ToList();
// ---- Table formatting ----
const int colKind = 12;
const int colAuthor = 20;
const int colDate = 20;
string separator =
"+" + new string('-', colKind + 2) +
"+" + new string('-', colAuthor + 2) +
"+" + new string('-', colDate + 2) + "+";
Console.WriteLine(separator);
Console.WriteLine($"| {"Change".PadRight(colKind)} | {"Author".PadRight(colAuthor)} | {"Date".PadRight(colDate)} |");
Console.WriteLine(separator);
// ---- Output rows ----
foreach (var change in changes)
{
Console.WriteLine(
$"| {change.ChangeKind.ToString().PadRight(colKind)} " +
$"| {change.UserName.PadRight(colAuthor)} " +
$"| {change.ChangeTime.ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture).PadRight(colDate)} |");
}
Console.WriteLine(separator);
Console.WriteLine($"Total filtered changes: {changes.Count}");
Console.WriteLine();
// ---- Apply decision (accept or reject) ----
foreach (var change in changes)
{
textControl.TrackedChanges.Remove(change, acceptChanges);
}
Console.WriteLine($"{changes.Count} changes {(acceptChanges ? "accepted" : "rejected")}.");