Filter copy for InfinityQS
Reactor 43 and 56
This commit is contained in:
		| @ -399,7 +399,8 @@ internal class ProcessDataStandardFormat | ||||
|             lines.Add(line); | ||||
|         } | ||||
|         string? json = null; | ||||
|         if (processDataStandardFormat.Footer is not null && processDataStandardFormat.Footer.Count > 0) { | ||||
|         if (processDataStandardFormat.Footer is not null && processDataStandardFormat.Footer.Count > 0) | ||||
|         { | ||||
|             Dictionary<string, string> footerKeyValuePairs = GetFooterKeyValuePairs(processDataStandardFormat.Footer); | ||||
|             Dictionary<string, Dictionary<string, string>> logisticKeyValuePairs = GetLogisticKeyValuePairs(processDataStandardFormat.Footer, footerKeyValuePairs); | ||||
|             json = JsonSerializer.Serialize(logisticKeyValuePairs, DictionaryStringDictionaryStringStringSourceGenerationContext.Default.DictionaryStringDictionaryStringString); | ||||
| @ -439,51 +440,72 @@ internal class ProcessDataStandardFormat | ||||
|         return result; | ||||
|     } | ||||
|  | ||||
|     private static Dictionary<string, string> GetFooterKeyValuePairs(ReadOnlyCollection<string> footerLines) { | ||||
|     private static Dictionary<string, string> GetFooterKeyValuePairs(ReadOnlyCollection<string> footerLines) | ||||
|     { | ||||
|         Dictionary<string, string> results = new(); | ||||
|         string[] segments; | ||||
|         foreach (string footerLine in footerLines) { | ||||
|         foreach (string footerLine in footerLines) | ||||
|         { | ||||
|             segments = footerLine.Split('\t'); | ||||
|             if (segments.Length != 2 || string.IsNullOrEmpty(segments[1].Trim())) { | ||||
|             if (segments.Length != 2 || string.IsNullOrEmpty(segments[1].Trim())) | ||||
|             { | ||||
|                 continue; | ||||
|             } | ||||
|             if (segments[1].Contains(';')) { | ||||
|             if (segments[1].Contains(';')) | ||||
|             { | ||||
|                 continue; | ||||
|             } else { | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 if (results.ContainsKey(segments[0])) | ||||
|                 { | ||||
|                     continue; | ||||
|                 } | ||||
|                 results.Add(segments[0], segments[1]); | ||||
|             } | ||||
|         } | ||||
|         return results; | ||||
|     } | ||||
|  | ||||
|     private static Dictionary<string, Dictionary<string, string>> GetLogisticKeyValuePairs(ReadOnlyCollection<string> footerLines, Dictionary<string, string> footerKeyValuePairs) { | ||||
|     private static Dictionary<string, Dictionary<string, string>> GetLogisticKeyValuePairs(ReadOnlyCollection<string> footerLines, Dictionary<string, string> footerKeyValuePairs) | ||||
|     { | ||||
|         Dictionary<string, Dictionary<string, string>> results = new(); | ||||
|         string[] segments; | ||||
|         string[] subSegments; | ||||
|         string[] subSubSegments; | ||||
|         Dictionary<string, string>? keyValue; | ||||
|         results.Add("Footer", footerKeyValuePairs); | ||||
|         foreach (string footerLine in footerLines) { | ||||
|         foreach (string footerLine in footerLines) | ||||
|         { | ||||
|             segments = footerLine.Split('\t'); | ||||
|             if (segments.Length != 2 || string.IsNullOrEmpty(segments[1].Trim())) { | ||||
|             if (segments.Length != 2 || string.IsNullOrEmpty(segments[1].Trim())) | ||||
|             { | ||||
|                 continue; | ||||
|             } | ||||
|             if (!segments[1].Contains(';') || !segments[1].Contains('=')) { | ||||
|             if (!segments[1].Contains(';') || !segments[1].Contains('=')) | ||||
|             { | ||||
|                 continue; | ||||
|             } else { | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 subSegments = segments[1].Split(';'); | ||||
|                 if (subSegments.Length < 1) { | ||||
|                 if (subSegments.Length < 1) | ||||
|                 { | ||||
|                     continue; | ||||
|                 } | ||||
|                 if (!results.TryGetValue(segments[0], out keyValue)) { | ||||
|                 if (!results.TryGetValue(segments[0], out keyValue)) | ||||
|                 { | ||||
|                     results.Add(segments[0], new()); | ||||
|                     if (!results.TryGetValue(segments[0], out keyValue)) { | ||||
|                     if (!results.TryGetValue(segments[0], out keyValue)) | ||||
|                     { | ||||
|                         throw new Exception(); | ||||
|                     } | ||||
|                 } | ||||
|                 foreach (string segment in subSegments) { | ||||
|                 foreach (string segment in subSegments) | ||||
|                 { | ||||
|                     subSubSegments = segment.Split('='); | ||||
|                     if (subSubSegments.Length != 2) { | ||||
|                     if (subSubSegments.Length != 2) | ||||
|                     { | ||||
|                         continue; | ||||
|                     } | ||||
|                     keyValue.Add(subSubSegments[0], subSubSegments[1]); | ||||
| @ -537,14 +559,15 @@ internal class ProcessDataStandardFormat | ||||
|         { | ||||
|             results.Add(string.Empty); | ||||
|             List<char> hyphens = new(); | ||||
|             results.AddRange(processDataStandardFormat.InputPDSF.Header.Select(l => l.Replace('\t', '|'))); | ||||
|             results.AddRange(processDataStandardFormat.InputPDSF.Header.Select(l => $"|{l.Replace('\t', '|')}|")); | ||||
|             results.Add(string.Empty); | ||||
|             results.Add($"|{string.Join("|", processDataStandardFormat.InputPDSF.Columns)}|"); | ||||
|             for (int i = 0; i < processDataStandardFormat.InputPDSF.Columns.Count; i++) | ||||
|                 hyphens.Add('-'); | ||||
|             results.Add($"|{string.Join("|", hyphens)}|"); | ||||
|             results.AddRange(processDataStandardFormat.InputPDSF.Body.Select(l => l.Replace('\t', '|'))); | ||||
|             results.AddRange(processDataStandardFormat.InputPDSF.Body.Select(l => $"|{l.Replace('\t', '|')}|")); | ||||
|             results.Add(string.Empty); | ||||
|             results.AddRange(processDataStandardFormat.InputPDSF.Footer.Select(l => l.Replace('\t', '|'))); | ||||
|             results.AddRange(processDataStandardFormat.InputPDSF.Footer.Select(l => $"|{l.Replace('\t', '|')}|")); | ||||
|             results.Add(string.Empty); | ||||
|             results.Add("EOF"); | ||||
|             results.Add(string.Empty); | ||||
| @ -842,5 +865,6 @@ internal partial class JsonElementCollectionSourceGenerationContext : JsonSerial | ||||
|  | ||||
| [JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)] | ||||
| [JsonSerializable(typeof(Dictionary<string, Dictionary<string, string>>))] | ||||
| internal partial class DictionaryStringDictionaryStringStringSourceGenerationContext : JsonSerializerContext { | ||||
| internal partial class DictionaryStringDictionaryStringStringSourceGenerationContext : JsonSerializerContext | ||||
| { | ||||
| } | ||||
		Reference in New Issue
	
	Block a user