71 lines
1.7 KiB
C#
71 lines
1.7 KiB
C#
using ReportGenerator.Models;
|
|
|
|
namespace ReportGenerator;
|
|
|
|
internal static class Program
|
|
{
|
|
internal static void Main(string[] args)
|
|
{
|
|
var tagFileInfos = GetTagFileInfos(args[0]);
|
|
var scanFileInfos = GetScanFileInfos(args[1]);
|
|
|
|
Directory.CreateDirectory("reports");
|
|
|
|
var stats = Scan(tagFileInfos, scanFileInfos);
|
|
|
|
foreach (var stat in stats)
|
|
{
|
|
var tableFields = stat.ToTable();
|
|
var tableInfo = new TableInfo(tableFields)
|
|
{
|
|
Title = stat.ImageName + Environment.NewLine,
|
|
RowStart = " | ",
|
|
RowEnd = Environment.NewLine,
|
|
ColumnEnd = " | "
|
|
};
|
|
|
|
var tableStr = tableInfo.ToString();
|
|
|
|
Console.WriteLine();
|
|
Console.WriteLine();
|
|
Console.WriteLine(tableStr);
|
|
Console.WriteLine();
|
|
Console.WriteLine();
|
|
}
|
|
}
|
|
|
|
private static IEnumerable<ImageStats> Scan(
|
|
IEnumerable<TagFileInfo> tagFileInfos,
|
|
IEnumerable<ScannedResultInfo> scanFileInfos
|
|
)
|
|
{
|
|
var scanFileLookup = scanFileInfos.ToLookup(i => i.ImageName);
|
|
return tagFileInfos.Select(i => new ImageStats(
|
|
i.ImageName,
|
|
i.GetWords().OrderBy(w => w).ToArray(),
|
|
scanFileLookup[i.ImageName]
|
|
));
|
|
}
|
|
|
|
|
|
private static IEnumerable<TagFileInfo> GetTagFileInfos(string dir)
|
|
{
|
|
if (!Directory.Exists(dir))
|
|
{
|
|
throw new ArgumentException($"Invalid tagged data directory '{dir}'");
|
|
}
|
|
|
|
return Directory.EnumerateFiles(dir, "*.json").Select(TagFileInfo.FromPath);
|
|
}
|
|
|
|
private static IEnumerable<ScannedResultInfo> GetScanFileInfos(string dir)
|
|
{
|
|
if (!Directory.Exists(dir))
|
|
{
|
|
throw new ArgumentException($"Invalid scan results directory '{dir}'");
|
|
}
|
|
|
|
return Directory.EnumerateFiles(dir, "*.json").Select(ScannedResultInfo.FromPath);
|
|
}
|
|
}
|