Back to comma
This commit is contained in:
parent
ef4fdc1023
commit
d710fcc195
@ -33,17 +33,22 @@ internal class Run
|
||||
fileInfoCollection.Add(fileInfo);
|
||||
}
|
||||
|
||||
private static ReadOnlyCollection<string> GetLines(JsonElement[]? jsonElements)
|
||||
private static ReadOnlyCollection<string> GetLines(Logistics logistics, JsonElement[]? jsonElements)
|
||||
{
|
||||
List<string> results = new();
|
||||
int columns = 0;
|
||||
StringBuilder stringBuilder = new();
|
||||
results.Add($"\"Count\",{jsonElements?.Length}");
|
||||
results.Add($"\"{nameof(logistics.Sequence)}\",{logistics.Sequence}");
|
||||
results.Add($"\"{nameof(logistics.MesEntity)}\",\"{logistics.MesEntity}\"");
|
||||
string dateTimeFromSequence = logistics.DateTimeFromSequence.ToString("MM/dd/yyyy hh:mm:ss tt");
|
||||
for (int i = 0; i < jsonElements?.Length;)
|
||||
{
|
||||
_ = stringBuilder.Append('"').Append(nameof(logistics.DateTimeFromSequence)).Append('"').Append(',');
|
||||
foreach (JsonProperty jsonProperty in jsonElements[0].EnumerateObject())
|
||||
{
|
||||
columns += 1;
|
||||
_ = stringBuilder.Append('"').Append(jsonProperty.Name).Append('"').Append('\t');
|
||||
_ = stringBuilder.Append('"').Append(jsonProperty.Name).Append('"').Append(',');
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -53,14 +58,15 @@ internal class Run
|
||||
for (int i = 0; i < jsonElements?.Length; i++)
|
||||
{
|
||||
_ = stringBuilder.Clear();
|
||||
_ = stringBuilder.Append('"').Append(dateTimeFromSequence).Append('"').Append(',');
|
||||
foreach (JsonProperty jsonProperty in jsonElements[i].EnumerateObject())
|
||||
{
|
||||
if (jsonProperty.Value.ValueKind == JsonValueKind.Object)
|
||||
_ = stringBuilder.Append('\t');
|
||||
_ = stringBuilder.Append(',');
|
||||
else if (jsonProperty.Value.ValueKind != JsonValueKind.String)
|
||||
_ = stringBuilder.Append(jsonProperty.Value).Append('\t');
|
||||
_ = stringBuilder.Append(jsonProperty.Value).Append(',');
|
||||
else
|
||||
_ = stringBuilder.Append('"').Append(jsonProperty.Value).Append('"').Append('\t');
|
||||
_ = stringBuilder.Append('"').Append(jsonProperty.Value).Append('"').Append(',');
|
||||
}
|
||||
_ = stringBuilder.Remove(stringBuilder.Length - 1, 1);
|
||||
results.Add(stringBuilder.ToString());
|
||||
@ -68,11 +74,10 @@ internal class Run
|
||||
return results.AsReadOnly();
|
||||
}
|
||||
|
||||
private static void WriteTabSeparatedValues(Logistics logistics, List<FileInfo> fileInfoCollection, Run run)
|
||||
private static void WriteCommaSeparatedValues(Logistics logistics, Run run)
|
||||
{
|
||||
List<Row> results = new();
|
||||
Row row;
|
||||
FileInfo fileInfo = new($"{logistics.ReportFullPath}.tsv");
|
||||
for (int i = 0; i < run.Wafers.Count; i++)
|
||||
{
|
||||
row = new(run, i);
|
||||
@ -80,10 +85,8 @@ internal class Run
|
||||
}
|
||||
string json = JsonSerializer.Serialize(results);
|
||||
JsonElement[]? jsonElements = JsonSerializer.Deserialize<JsonElement[]>(json);
|
||||
ReadOnlyCollection<string> lines = GetLines(jsonElements);
|
||||
File.WriteAllText(fileInfo.FullName, string.Join(Environment.NewLine, lines));
|
||||
File.SetLastWriteTime(fileInfo.FullName, logistics.DateTimeFromSequence);
|
||||
fileInfoCollection.Add(fileInfo);
|
||||
ReadOnlyCollection<string> lines = GetLines(logistics, jsonElements);
|
||||
File.WriteAllText($"{logistics.ReportFullPath}.csv", string.Join(Environment.NewLine, lines));
|
||||
}
|
||||
|
||||
private static ReadOnlyCollection<string> GetWaferIds(Header header)
|
||||
@ -109,7 +112,7 @@ internal class Run
|
||||
ReadOnlyCollection<Wafer> wafers = Wafer.Get(waferIds, keyValuePairs);
|
||||
result = new(header, wafers);
|
||||
WriteJson(logistics, fileInfoCollection, result);
|
||||
WriteTabSeparatedValues(logistics, fileInfoCollection, result);
|
||||
WriteCommaSeparatedValues(logistics, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public partial class FileRead : FileReaderHandler, ISMTP
|
||||
try
|
||||
{
|
||||
extractResults = _FileRead.GetExtractResult(reportFullPath, eventName);
|
||||
if (extractResults.Item3.Length == 0 && !string.IsNullOrEmpty(extractResults.Item1) && !extractResults.Item1.Contains(Environment.NewLine))
|
||||
if (extractResults.Item3.Length == 0 && !string.IsNullOrEmpty(extractResults.Item1) && !extractResults.Item1.Contains("LOGISTICS_1"))
|
||||
throw new Exception(extractResults.Item1);
|
||||
TriggerEvents(extractResults);
|
||||
_FileRead.Move(extractResults);
|
||||
|
Loading…
x
Reference in New Issue
Block a user