Spreading Resistance Profile with ChartJS,
Copy-On-Get and nuget bump (Serilog)
This commit is contained in:
72
Server/Services/csv/Info.cs
Normal file
72
Server/Services/csv/Info.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using System.Text;
|
||||
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
public class Info
|
||||
{
|
||||
|
||||
#nullable disable
|
||||
|
||||
public string Operator { get; set; }
|
||||
public string SampleName { get; set; }
|
||||
public string SoftwareVersion { get; set; }
|
||||
public string DateTime { get; set; }
|
||||
public string SystemId { get; set; }
|
||||
public string SystemSite { get; set; }
|
||||
public string SamplePosition { get; set; }
|
||||
public string Units { get; set; }
|
||||
public string CommentLength { get; set; }
|
||||
public List<string> Comments { get; set; }
|
||||
|
||||
#nullable enable
|
||||
#pragma warning disable CA1834
|
||||
|
||||
internal static Info? GetInfo(string[] lines, int start, int stop)
|
||||
{
|
||||
Info? result;
|
||||
string first;
|
||||
string[] segments;
|
||||
int? secondStart = null;
|
||||
List<string> values = new();
|
||||
List<string> comments = new();
|
||||
StringBuilder stringBuilder = new();
|
||||
for (int i = start; i < stop; i++)
|
||||
{
|
||||
segments = lines[i].Split(new string[] { "," }, StringSplitOptions.None);
|
||||
first = segments.First();
|
||||
if (first == "Comment:")
|
||||
{
|
||||
secondStart = i + 1;
|
||||
break;
|
||||
}
|
||||
_ = stringBuilder.Append(first).Append(",");
|
||||
if (segments.Length > 1)
|
||||
values.Add(segments[1]);
|
||||
else
|
||||
values.Add(string.Empty);
|
||||
}
|
||||
string header = "Operator,Sample Name,Software Version,Date & Time,System ID,System Site,Sample Position,Units,Comment Length,";
|
||||
if (secondStart is null || stringBuilder.Length != header.Length || stringBuilder.ToString() != header)
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
result = new()
|
||||
{
|
||||
Operator = values[0],
|
||||
SampleName = values[1],
|
||||
SoftwareVersion = values[2],
|
||||
DateTime = values[3],
|
||||
SystemId = values[4],
|
||||
SystemSite = values[5],
|
||||
SamplePosition = values[6],
|
||||
Units = values[7],
|
||||
CommentLength = values[8],
|
||||
Comments = comments,
|
||||
};
|
||||
for (int i = secondStart.Value; i < stop; i++)
|
||||
comments.Add(lines[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user