Files
DP44/Common/DTS.Common.Serialization/.svn/pristine/80/80e54c9de9976a3fa8388b2ee8d5e4c86bee2d19.svn-base
2026-04-17 14:55:32 -04:00

58 lines
2.1 KiB
Plaintext

using System.Collections.Generic;
using System.Text;
namespace DTS.Serialization.Iso.Report
{
/// <summary>
/// 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
/// </summary>
public class SummaryReport
{
private readonly List<ChannelData> _channels = new List<ChannelData>();
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));
}
/// <summary>
/// creates a test summary report given test data
/// </summary>
/// <param name="test"></param>
/// <returns></returns>
public static SummaryReport CreateSummaryReport(Test test)
{
var report = new SummaryReport();
report.AddChannels([.. test.Channels]);
return report;
}
/// <summary>
/// outputs to path given test setup summary
/// can throw exceptions
/// </summary>
/// <param name="path"></param>
/// <param name="summary"></param>
public static void OutputToPath(string path, SummaryReport summary)
{
System.IO.File.WriteAllText(System.IO.Path.Combine(path, "TestNo_FilterList.txt"), summary.GetLines());
}
}
}