Switched to xml for InfinityQS export
This commit is contained in:
@ -872,6 +872,8 @@ internal class ProcessDataStandardFormat
|
||||
string tag;
|
||||
string value;
|
||||
string[] segments;
|
||||
List<string> values;
|
||||
Dictionary<string, List<string>> results = new();
|
||||
ReadOnlyCollection<string> body = processDataStandardFormat.InputPDSF is null ?
|
||||
processDataStandardFormat.Body : processDataStandardFormat.InputPDSF.Body;
|
||||
ReadOnlyCollection<string> columns = processDataStandardFormat.InputPDSF is null ?
|
||||
@ -879,7 +881,6 @@ internal class ProcessDataStandardFormat
|
||||
List<string> lines = new() { "<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "<records>" };
|
||||
for (int i = 0; i < body.Count; i++)
|
||||
{
|
||||
lines.Add(" <record>");
|
||||
segments = body[i].Trim().Split('\t');
|
||||
if (segments.Length != columns.Count)
|
||||
break;
|
||||
@ -891,7 +892,42 @@ internal class ProcessDataStandardFormat
|
||||
.Replace("\"", """)
|
||||
.Replace("'", "'");
|
||||
tag = Regex.Replace(columns[c].Trim('"'), @"[^a-zA-Z0-9]", "_").Split('\r')[0].Split('\n')[0];
|
||||
lines.Add(string.Concat(" <", tag, '>', value, "</", tag, '>'));
|
||||
if (i == 0)
|
||||
{
|
||||
if (results.ContainsKey(tag))
|
||||
continue;
|
||||
results.Add(tag, new List<string>());
|
||||
}
|
||||
results[tag].Add(value);
|
||||
}
|
||||
}
|
||||
foreach (KeyValuePair<string, List<string>> keyValuePair in results)
|
||||
{
|
||||
if (body.Count < 3)
|
||||
break;
|
||||
if (keyValuePair.Value.Count != body.Count)
|
||||
continue;
|
||||
values = keyValuePair.Value.Distinct().ToList();
|
||||
if (values.Count == 2 && (string.IsNullOrEmpty(values[0]) || string.IsNullOrEmpty(values[1])))
|
||||
{
|
||||
for (int i = 0; i < body.Count; i++)
|
||||
keyValuePair.Value[i] = string.Empty;
|
||||
foreach (string v in values)
|
||||
{
|
||||
if (string.IsNullOrEmpty(v))
|
||||
continue;
|
||||
keyValuePair.Value[0] = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < body.Count; i++)
|
||||
{
|
||||
lines.Add(" <record>");
|
||||
foreach (KeyValuePair<string, List<string>> keyValuePair in results)
|
||||
{
|
||||
if (keyValuePair.Value.Count != body.Count)
|
||||
continue;
|
||||
lines.Add(string.Concat(" <", keyValuePair.Key, '>', keyValuePair.Value[i], "</", keyValuePair.Key, '>'));
|
||||
}
|
||||
lines.Add(" </record>");
|
||||
}
|
||||
|
Reference in New Issue
Block a user