Nancy
This commit is contained in:
@ -383,7 +383,7 @@ public class FileRead : Properties.IFileRead
|
||||
else
|
||||
{
|
||||
string logisticsSequence = _Logistics.Sequence.ToString();
|
||||
results = Directory.GetDirectories(jobIdDirectory, string.Concat(_Logistics.MID, '*', logisticsSequence, '*'), SearchOption.TopDirectoryOnly);
|
||||
results = Directory.GetDirectories(jobIdDirectory, $"*{logisticsSequence}*", SearchOption.TopDirectoryOnly);
|
||||
}
|
||||
if ((results is null) || results.Length != 1)
|
||||
throw new Exception("Didn't find directory by logistics sequence");
|
||||
|
@ -28,14 +28,17 @@ internal class ProcessDataStandardFormat
|
||||
internal ReadOnlyCollection<string> Body { get; private set; }
|
||||
internal ReadOnlyCollection<string> Columns { get; private set; }
|
||||
internal ReadOnlyCollection<string> Logistics { get; private set; }
|
||||
internal ReadOnlyCollection<string> InputLines { get; private set; }
|
||||
|
||||
internal ProcessDataStandardFormat(ReadOnlyCollection<string> body,
|
||||
ReadOnlyCollection<string> columns,
|
||||
ReadOnlyCollection<string> inputLines,
|
||||
ReadOnlyCollection<string> logistics,
|
||||
long? sequence)
|
||||
{
|
||||
Body = body;
|
||||
Columns = columns;
|
||||
InputLines = inputLines;
|
||||
Logistics = logistics;
|
||||
Sequence = sequence;
|
||||
}
|
||||
@ -53,7 +56,7 @@ internal class ProcessDataStandardFormat
|
||||
GetString(SearchFor.Archive, addSpaces, separator);
|
||||
|
||||
internal static ProcessDataStandardFormat GetEmpty() =>
|
||||
new(new(Array.Empty<string>()), new(Array.Empty<string>()), new(Array.Empty<string>()), null);
|
||||
new(new(Array.Empty<string>()), new(Array.Empty<string>()), new(Array.Empty<string>()), new(Array.Empty<string>()), null);
|
||||
|
||||
internal static List<string> PDSFToFixedWidth(string reportFullPath)
|
||||
{
|
||||
@ -169,14 +172,20 @@ internal class ProcessDataStandardFormat
|
||||
{
|
||||
for (int i = r; i < lines.Length; i++)
|
||||
{
|
||||
if (lines[r].StartsWith("END_HEADER"))
|
||||
if (!lines[i].StartsWith("LOGISTICS_") || lines[i].StartsWith("END_HEADER"))
|
||||
break;
|
||||
logistics.Add(lines[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
result = new(logistics.AsReadOnly(), columns.AsReadOnly(), body.AsReadOnly(), null);
|
||||
if (lines.Length > 0 && body.Count == 0 && columns.Count == 0 && logistics.Count == 0)
|
||||
logistics.Add(lines[1]);
|
||||
result = new(body: body.AsReadOnly(),
|
||||
columns: columns.AsReadOnly(),
|
||||
inputLines: lines.ToList().AsReadOnly(),
|
||||
logistics: logistics.AsReadOnly(),
|
||||
sequence: null);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -229,7 +238,7 @@ internal class ProcessDataStandardFormat
|
||||
{
|
||||
for (int i = r; i < lines.Length; i++)
|
||||
{
|
||||
if (lines[r].StartsWith("END_HEADER"))
|
||||
if (!lines[i].StartsWith("LOGISTICS_") || lines[i].StartsWith("END_HEADER"))
|
||||
break;
|
||||
logistics.Add(lines[i]);
|
||||
}
|
||||
@ -245,6 +254,7 @@ internal class ProcessDataStandardFormat
|
||||
}
|
||||
result = new(body: body.AsReadOnly(),
|
||||
columns: new(columns),
|
||||
inputLines: lines.ToList().AsReadOnly(),
|
||||
logistics: logistics.AsReadOnly(),
|
||||
sequence: sequence);
|
||||
return result;
|
||||
@ -335,7 +345,8 @@ internal class ProcessDataStandardFormat
|
||||
results.Add(string.Join("\t", values));
|
||||
}
|
||||
result = new(body: new(results),
|
||||
columns: processDataStandardFormat.Columns,
|
||||
columns: processDataStandardFormatMapping.OldColumnNames,
|
||||
inputLines: processDataStandardFormat.InputLines,
|
||||
logistics: processDataStandardFormat.Logistics,
|
||||
sequence: processDataStandardFormat.Sequence);
|
||||
return result;
|
||||
@ -357,7 +368,7 @@ internal class ProcessDataStandardFormat
|
||||
results.Add($"HEADER_OFFSET\t{headerOffset}");
|
||||
results.Add($"DATA_OFFSET\t{dataOffset}");
|
||||
results.Add($"END_OFFSET\t{endOffset}");
|
||||
results.Add($"\"{string.Join("\",\t\"", processDataStandardFormat.Columns)}\"");
|
||||
results.Add($"\"{string.Join("\"\t\"", processDataStandardFormat.Columns)}\"");
|
||||
results.AddRange(processDataStandardFormat.Body);
|
||||
results.Add($"NUM_DATA_ROWS\t{processDataStandardFormat.Body.Count.ToString().PadLeft(9, '0')}");
|
||||
results.Add($"NUM_DATA_COLUMNS\t{processDataStandardFormat.Columns.Count.ToString().PadLeft(9, '0')}");
|
||||
@ -367,6 +378,8 @@ internal class ProcessDataStandardFormat
|
||||
results.Add("LOGISTICS_COLUMN\tA_LOGISTICS");
|
||||
results.Add("LOGISTICS_COLUMN\tB_LOGISTICS");
|
||||
results.AddRange(processDataStandardFormat.Logistics);
|
||||
results.Add("EOF");
|
||||
results.AddRange(processDataStandardFormat.InputLines.Select(l => l.Replace('\t', '|')));
|
||||
File.WriteAllText(path, string.Join(Environment.NewLine, results));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user