using System.Collections.Generic;
using System.Text;
namespace DTS.Serialization.Iso.Report
{
///
/// this is a class to simplify outputting a summary report
/// http://manuscript.dts.local/f/cases/43495/Add-Summary-report-text-file-in-import-wizard
/// http://manuscript.dts.local/f/cases/43833/SW-Test-Summary-Report-for-data-collection-THF
///
public class SummaryReport
{
private readonly List _channels = new List();
private const string NUMBER_OF_CHANNELS = "Number of channels";
public string GetLines()
{
var sb = new StringBuilder();
sb.AppendLine($"{NUMBER_OF_CHANNELS} :{_channels.Count:000} / / / / /");
foreach (var channel in _channels)
{
sb.AppendLine(channel.GetLine());
}
return sb.ToString();
}
protected void AddChannels(Test.Module.Channel[] channels)
{
foreach( var channel in channels)
{
_channels.Add(ChannelData.CreateChannel(channel));
}
_channels.Sort((a, b) => a.ChannelNumber.CompareTo(b.ChannelNumber));
}
///
/// creates a test summary report given test data
///
///
///
public static SummaryReport CreateSummaryReport(Test test)
{
var report = new SummaryReport();
report.AddChannels([.. test.Channels]);
return report;
}
///
/// outputs to path given test setup summary
/// can throw exceptions
///
///
///
public static void OutputToPath(string path, SummaryReport summary)
{
System.IO.File.WriteAllText(System.IO.Path.Combine(path, "TestNo_FilterList.txt"), summary.GetLines());
}
}
}