diff --git a/ii/MainWindow.cs b/ii/MainWindow.cs index 7dc9349b..1c25b2e8 100644 --- a/ii/MainWindow.cs +++ b/ii/MainWindow.cs @@ -6,6 +6,7 @@ using IsIdentifiable.Rules; using System; using System.Collections.Generic; +using System.IO; using System.IO.Abstractions; using System.Linq; using System.Text; @@ -86,7 +87,8 @@ public MainWindow(IsIdentifiableOptions analyserOpts, IsIdentifiableReviewerOpti Menu = new MenuBar(new MenuBarItem[] { new("_File (F9)", new MenuItem [] { new("_Open Report",null, OpenReport), - new("_Quit", null, static () => Application.RequestStop()) + new("_Export 'Outstanding Failures'", null, ExportOutstandingFailures), + new("_Quit", null, static () => Application.RequestStop()), }), new("_Options", new MenuItem [] { miCustomPatterns = new MenuItem("_Custom Patterns",null,ToggleCustomPatterns){CheckType = MenuItemCheckStyle.Checked,Checked = false} @@ -431,6 +433,24 @@ private void Update() BeginNext(); } + private void ExportOutstandingFailures() + { + if (rulesView.OutstandingFiles == null) + { + Helpers.ShowMessage("Error", "You must evaluate the rules on a report first."); + return; + } + + var now = DateTime.UtcNow.ToString("s").Replace(':', '-'); + var fileName = $"OutstandingFiles-{now}.csv"; + using var sw = new StreamWriter(fileName); + + foreach (var file in rulesView.OutstandingFiles) + sw.WriteLine(file); + + Helpers.ShowMessage("Complete", $"Wrote {rulesView.OutstandingFiles.Count} unique item(s) to {fileName}"); + } + private void OpenReport() { using var ofd = new OpenDialog("Load CSV Report", "Enter file path to load") diff --git a/ii/Views/RulesView.cs b/ii/Views/RulesView.cs index ea3c1490..dc681d1e 100644 --- a/ii/Views/RulesView.cs +++ b/ii/Views/RulesView.cs @@ -17,6 +17,8 @@ class RulesView : View public IgnoreRuleGenerator? Ignorer { get; private set; } public RowUpdater? Updater { get; private set; } + public List? OutstandingFiles { get; private set; } + private readonly TreeView _treeView; /// @@ -536,6 +538,8 @@ private void EvaluateRuleCoverageAsync(Label stage, ProgressBar progress, Label .OrderByDescending(v => v.Failures.Sum(f => f.NumberOfTimesReported)) .Cast() .ToList(); + + OutstandingFiles = outstandingFailures.Select(x => x.Value.Failure.Resource).Distinct().ToList(); } private static void SetProgress(ProgressBar pb, View tp, int done, int max)