Added report generation

This commit is contained in:
Simon Gruber
2023-12-04 15:18:06 +01:00
parent 1b50b1fe53
commit 9102161b7d
25 changed files with 626 additions and 2085 deletions
+36 -17
View File
@@ -1,15 +1,11 @@
using ReportGenerator.Generator.Abstract;
using ReportGenerator.Generator.Interface;
using ReportGenerator.Generator.Interface;
using ReportGenerator.Generator.Model;
using ReportGenerator.Models;
namespace ReportGenerator;
public class ReportGenerator : FileSerializableBase
public class ReportGenerator : IDisposable
{
/// <inheritdoc />
public override string FileExtension => Document.FileExtension;
private IDocumentGenerator Document { get; }
private ICollection<ImageStats> Images { get; }
@@ -19,30 +15,34 @@ public class ReportGenerator : FileSerializableBase
IEnumerable<ImageStats> data
)
{
Document = document;
Images = data.ToArray();
Document = document;
document.Open();
}
public ReportGenerator(
string title,
IDocumentGenerator document,
IEnumerable<ImageStats> data
) : this(document, data)
{
WithTitle(title);
}
) : this(document, data) => AddTitle(title);
/// <inheritdoc />
public override string ToString() => Document.ToString();
#region Writing
#region Report content generation
public ReportGenerator WithTitle(string text)
public ReportGenerator AddTitle(string text)
{
Document.AppendHeading(1, text);
return this;
}
public ReportGenerator AddProcessorStats(string title)
{
Document.AppendHeading(2, title);
// todo show best/worst images per processor
return this;
}
public ReportGenerator AddImageStatsFull(string title)
{
Document.AppendHeading(2, title);
@@ -86,7 +86,7 @@ public class ReportGenerator : FileSerializableBase
}
})
.AppendParagraph(
$"*Comparison data generated based on {stat.Reference.Count} tagged words.*"
$"Comparison data generated based on {stat.Reference.Count} tagged words."
);
}
@@ -167,4 +167,23 @@ public class ReportGenerator : FileSerializableBase
}
#endregion
#region IDisposable
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
Document.Dispose();
}
}
/// <inheritdoc />
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
}