-
Notifications
You must be signed in to change notification settings - Fork 10
/
Program.cs
56 lines (47 loc) · 1.79 KB
/
Program.cs
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
using System;
using System.IO;
using OpenXmlPowerTools;
using DocumentFormat.OpenXml.Packaging;
class Program
{
static void Main(string[] args)
{
if (args.Length != 4)
{
Console.WriteLine("Usage: redlines <author_tag> <original_path.docx> <modified_path.docx> <redline_path.docx>");
return;
}
string authorTag = args[0];
string originalFilePath = args[1];
string modifiedFilePath = args[2];
string outputFilePath = args[3];
if (!File.Exists(originalFilePath) || !File.Exists(modifiedFilePath))
{
Console.WriteLine("Error: One or both files do not exist.");
return;
}
try
{
var originalBytes = File.ReadAllBytes(originalFilePath);
var modifiedBytes = File.ReadAllBytes(modifiedFilePath);
var originalDocument = new WmlDocument(originalFilePath, originalBytes);
var modifiedDocument = new WmlDocument(modifiedFilePath, modifiedBytes);
var comparisonSettings = new WmlComparerSettings
{
AuthorForRevisions = authorTag,
DetailThreshold = 0
};
var comparisonResults = WmlComparer.Compare(originalDocument, modifiedDocument, comparisonSettings);
var revisions = WmlComparer.GetRevisions(comparisonResults, comparisonSettings);
// Output results
Console.WriteLine($"Revisions found: {revisions.Count}");
File.WriteAllBytes(outputFilePath, comparisonResults.DocumentByteArray);
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
Console.WriteLine("Detailed Stack Trace:");
Console.WriteLine(ex.StackTrace);
}
}
}