Complete Class bug fix
This commit is contained in:
parent
2b16357d44
commit
dcaaba3614
10
Adaptation/.vscode/tasks.json
vendored
10
Adaptation/.vscode/tasks.json
vendored
@ -49,6 +49,16 @@
|
|||||||
],
|
],
|
||||||
"problemMatcher": "$msCompile"
|
"problemMatcher": "$msCompile"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": "Format-Whitespaces",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"format",
|
||||||
|
"whitespace"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": "Nuget Clear",
|
"label": "Nuget Clear",
|
||||||
"command": "dotnet",
|
"command": "dotnet",
|
||||||
|
@ -20,28 +20,28 @@ internal class Complete
|
|||||||
public Summary Summary { get; }
|
public Summary Summary { get; }
|
||||||
public ReadOnlyCollection<Point> Points { get; }
|
public ReadOnlyCollection<Point> Points { get; }
|
||||||
|
|
||||||
public static Complete? Get(int take, string site, string multiple, string summaryLine, string lastUnits, string[] lines)
|
public static Complete? Get(int take, string site, string multiple, string summaryLine, string lastUnits, string lastUnitsB, ReadOnlyCollection<string> lines)
|
||||||
|
{
|
||||||
|
Complete? result;
|
||||||
|
Header? header = Header.Get(lines, site, summaryLine);
|
||||||
|
if (header is null)
|
||||||
|
result = null;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Complete? result;
|
Summary? summary = SummarySegment.Get(lines, site, summaryLine, lastUnits);
|
||||||
Header? header = Header.Get(lines, site, summaryLine);
|
if (summary is null)
|
||||||
if (header is null)
|
|
||||||
result = null;
|
result = null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Summary? summary = SummarySegment.Get(lines, site, summaryLine);
|
ReadOnlyCollection<Point> points = Point.GetCollection(lines, take, site, multiple, summaryLine, lastUnitsB) ?? throw new NullReferenceException(nameof(summary));
|
||||||
if (summary is null)
|
if (points.Count == 0)
|
||||||
result = null;
|
result = null;
|
||||||
else
|
else
|
||||||
{
|
result = new(header, summary, points);
|
||||||
ReadOnlyCollection<Point> points = Point.GetCollection(lines, take, site, multiple, summaryLine, lastUnits) ?? throw new NullReferenceException(nameof(summary));
|
|
||||||
if (points.Count == 0)
|
|
||||||
result = null;
|
|
||||||
else
|
|
||||||
result = new(header, summary, points);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,4 +49,4 @@ internal class Complete
|
|||||||
[JsonSerializable(typeof(Complete))]
|
[JsonSerializable(typeof(Complete))]
|
||||||
internal partial class CompleteSourceGenerationContext : JsonSerializerContext
|
internal partial class CompleteSourceGenerationContext : JsonSerializerContext
|
||||||
{
|
{
|
||||||
}
|
}
|
@ -128,7 +128,7 @@ internal class Header
|
|||||||
return new(results);
|
return new(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Header? Get(string[] lines, string site, string summaryLine)
|
public static Header? Get(ReadOnlyCollection<string> lines, string site, string summaryLine)
|
||||||
{
|
{
|
||||||
Header? result;
|
Header? result;
|
||||||
string json;
|
string json;
|
||||||
@ -185,4 +185,4 @@ internal class Header
|
|||||||
[JsonSerializable(typeof(Header))]
|
[JsonSerializable(typeof(Header))]
|
||||||
internal partial class HeaderSourceGenerationContext : JsonSerializerContext
|
internal partial class HeaderSourceGenerationContext : JsonSerializerContext
|
||||||
{
|
{
|
||||||
}
|
}
|
@ -77,7 +77,7 @@ internal class Point
|
|||||||
string.Empty,
|
string.Empty,
|
||||||
string.Empty);
|
string.Empty);
|
||||||
|
|
||||||
public static ReadOnlyCollection<Point> GetCollection(string[] lines, int take, string site, string multiple, string summaryLine, string lastUnits)
|
public static ReadOnlyCollection<Point> GetCollection(ReadOnlyCollection<string> lines, int take, string site, string multiple, string summaryLine, string lastUnitsB)
|
||||||
{
|
{
|
||||||
List<Point> results = new();
|
List<Point> results = new();
|
||||||
string s;
|
string s;
|
||||||
@ -89,7 +89,7 @@ internal class Point
|
|||||||
bool foundB = false;
|
bool foundB = false;
|
||||||
string[] segmentsC;
|
string[] segmentsC;
|
||||||
List<string> sites = new();
|
List<string> sites = new();
|
||||||
for (int i = 0; i < lines.Length; i++)
|
for (int i = 0; i < lines.Count; i++)
|
||||||
{
|
{
|
||||||
line = lines[i];
|
line = lines[i];
|
||||||
segmentsC = line.Split(new string[] { site }, StringSplitOptions.RemoveEmptyEntries);
|
segmentsC = line.Split(new string[] { site }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
@ -107,7 +107,7 @@ internal class Point
|
|||||||
continue;
|
continue;
|
||||||
if (!foundB && line.Contains(multiple))
|
if (!foundB && line.Contains(multiple))
|
||||||
foundB = true;
|
foundB = true;
|
||||||
if (line != lastUnits)
|
if (line != lastUnitsB)
|
||||||
continue;
|
continue;
|
||||||
if (foundB)
|
if (foundB)
|
||||||
{
|
{
|
||||||
@ -117,7 +117,7 @@ internal class Point
|
|||||||
for (int j = 0; j < sites.Count; j++)
|
for (int j = 0; j < sites.Count; j++)
|
||||||
{
|
{
|
||||||
s = sites[j];
|
s = sites[j];
|
||||||
if (i + take > lines.Length)
|
if (i + take > lines.Count)
|
||||||
break;
|
break;
|
||||||
segments = s.Split(new string[] { "(", ",", ")" }, StringSplitOptions.None);
|
segments = s.Split(new string[] { "(", ",", ")" }, StringSplitOptions.None);
|
||||||
if (segments.Length < 2)
|
if (segments.Length < 2)
|
||||||
@ -154,4 +154,4 @@ internal class Point
|
|||||||
[JsonSerializable(typeof(Point))]
|
[JsonSerializable(typeof(Point))]
|
||||||
internal partial class PointSourceGenerationContext : JsonSerializerContext
|
internal partial class PointSourceGenerationContext : JsonSerializerContext
|
||||||
{
|
{
|
||||||
}
|
}
|
@ -3,6 +3,7 @@ using Adaptation.Shared.Methods;
|
|||||||
using log4net;
|
using log4net;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -540,13 +541,15 @@ public class ProcessData : IProcessData
|
|||||||
const string multiple = "MULTIPLE";
|
const string multiple = "MULTIPLE";
|
||||||
const string summaryLine = "SUMMARY A A";
|
const string summaryLine = "SUMMARY A A";
|
||||||
const string lastUnits = "Flat Z: Grade : % Flat Z: Grade : % Flat Z: Grade : %";
|
const string lastUnits = "Flat Z: Grade : % Flat Z: Grade : % Flat Z: Grade : %";
|
||||||
|
const string lastUnitsB = "Flat Z: Grade : % Flat Z: Grade : % Flat Z: Grade : %";
|
||||||
string[] lines = File.ReadAllLines(altHeaderFileName);
|
string[] lines = File.ReadAllLines(altHeaderFileName);
|
||||||
if (lines.Length > take)
|
ReadOnlyCollection<string> collection = new(lines);
|
||||||
result = Complete.Get(take, site, multiple, summaryLine, lastUnits, lines);
|
if (collection.Count > take)
|
||||||
|
result = Complete.Get(take, site, multiple, summaryLine, lastUnits, lastUnitsB, collection);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = null;
|
result = null;
|
||||||
_Log.Warn($"File {altHeaderFileName} has less than 5 lines");
|
_Log.Warn($"File {altHeaderFileName} has less than {take} collection");
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -16,4 +16,4 @@ internal class Summary
|
|||||||
public SummarySegment? StandardDeviationPercentage { get; }
|
public SummarySegment? StandardDeviationPercentage { get; }
|
||||||
public SummarySegment? RadialGradient { get; }
|
public SummarySegment? RadialGradient { get; }
|
||||||
|
|
||||||
}
|
}
|
@ -66,7 +66,7 @@ internal class SummarySegment
|
|||||||
return new(results);
|
return new(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Summary? Get(string[] lines, string site, string summaryLine)
|
public static Summary? Get(ReadOnlyCollection<string> lines, string site, string summaryLine, string lastUnits)
|
||||||
{
|
{
|
||||||
Summary? result;
|
Summary? result;
|
||||||
string json;
|
string json;
|
||||||
@ -85,10 +85,12 @@ internal class SummarySegment
|
|||||||
continue;
|
continue;
|
||||||
if (line.Contains(site))
|
if (line.Contains(site))
|
||||||
break;
|
break;
|
||||||
|
if (line.Contains(lastUnits))
|
||||||
|
break;
|
||||||
foreach (JsonProperty jsonProperty in jsonProperties)
|
foreach (JsonProperty jsonProperty in jsonProperties)
|
||||||
{
|
{
|
||||||
segments = line.Split(new string[] { $"{jsonProperty.Name}:", $"{jsonProperty.Name} :" }, StringSplitOptions.None);
|
segments = line.Split(new string[] { $"{jsonProperty.Name}:", $"{jsonProperty.Name} :" }, StringSplitOptions.None);
|
||||||
if (segments.Length < 2 || !line.StartsWith(jsonProperty.Name))
|
if (segments.Length < 2 || (!line.StartsWith(jsonProperty.Name) && !line.StartsWith($"@ {jsonProperty.Name}")))
|
||||||
continue;
|
continue;
|
||||||
segmentsB = segments[1].Trim().Split(' ');
|
segmentsB = segments[1].Trim().Split(' ');
|
||||||
if (segmentsB.Length < 3)
|
if (segmentsB.Length < 3)
|
||||||
@ -119,4 +121,4 @@ internal class SummarySegment
|
|||||||
[JsonSerializable(typeof(SummarySegment))]
|
[JsonSerializable(typeof(SummarySegment))]
|
||||||
internal partial class SummarySegmentSourceGenerationContext : JsonSerializerContext
|
internal partial class SummarySegmentSourceGenerationContext : JsonSerializerContext
|
||||||
{
|
{
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user