diff --git a/Adaptation/FileHandlers/RsM/ProcessData.cs b/Adaptation/FileHandlers/RsM/ProcessData.cs index 58e4351..2ae5e95 100644 --- a/Adaptation/FileHandlers/RsM/ProcessData.cs +++ b/Adaptation/FileHandlers/RsM/ProcessData.cs @@ -85,15 +85,15 @@ public class ProcessData : IProcessData return results; } - private static (string, string) GetReactorAndRDS(string defaultReactor, string defaultRDS, string text, string formattedText, string[] segments, bool hasRDS) + private static (string, string) GetReactorAndRDS(string defaultReactor, string defaultRDS, string text, string formattedText, string[] segments) { string rds; string reactor; - if (string.IsNullOrEmpty(text) || segments.Length == 0 || string.IsNullOrEmpty(formattedText) || (segments.Length > 1 && !hasRDS)) + if (string.IsNullOrEmpty(text) || segments.Length == 0 || string.IsNullOrEmpty(formattedText)) reactor = defaultReactor; else reactor = segments[0]; - if (segments.Length <= 1 || !int.TryParse(segments[1].Replace("QP", string.Empty), out int rdsValue) || rdsValue < 99) + if (segments.Length <= 1 || !int.TryParse(segments[1], out int rdsValue) || rdsValue < 99) rds = defaultRDS; else rds = segments[1]; @@ -105,11 +105,11 @@ public class ProcessData : IProcessData return new(reactor, rds); } - private static (string, string) GetLayerAndPSN(string defaultLayer, string defaultPSN, string[] segments, bool hasRDS) + private static (string, string) GetLayerAndPSN(string defaultLayer, string defaultPSN, string[] segments) { string psn; string layer; - if (segments.Length <= 2 || (segments.Length > 1 && !hasRDS)) + if (segments.Length <= 2) { psn = defaultPSN; layer = defaultLayer; @@ -193,9 +193,9 @@ public class ProcessData : IProcessData title = title.Substring(2); run = title; string[] segments = title.Split('-'); - bool hasRDS = Regex.IsMatch(title, "[-]?([QP][0-9]{4,}|[0-9]{5,})[-]?"); - (reactor, rds) = GetReactorAndRDS(defaultReactor, defaultRDS, text, title, segments, hasRDS); - (layer, psn) = GetLayerAndPSN(defaultLayer, defaultPSN, segments, hasRDS); + // bool hasRDS = Regex.IsMatch(title, "[-]?([QP][0-9]{4,}|[0-9]{5,})[-]?"); + (reactor, rds) = GetReactorAndRDS(defaultReactor, defaultRDS, text, title, segments); + (layer, psn) = GetLayerAndPSN(defaultLayer, defaultPSN, segments); zone = GetZone(segments); employee = defaultEmployee; } diff --git a/Adaptation/FileHandlers/txt/ProcessData.cs b/Adaptation/FileHandlers/txt/ProcessData.cs index f036fe3..ab03e54 100644 --- a/Adaptation/FileHandlers/txt/ProcessData.cs +++ b/Adaptation/FileHandlers/txt/ProcessData.cs @@ -242,15 +242,15 @@ public class ProcessData : IProcessData return result; } - private static (string, string) GetReactorAndRDS(string defaultReactor, string defaultRDS, string text, string formattedText, string[] segments, bool hasRDS) + private static (string, string) GetReactorAndRDS(string defaultReactor, string defaultRDS, string text, string formattedText, string[] segments) { string rds; string reactor; - if (string.IsNullOrEmpty(text) || segments.Length == 0 || string.IsNullOrEmpty(formattedText) || (segments.Length > 1 && !hasRDS)) + if (string.IsNullOrEmpty(text) || segments.Length == 0 || string.IsNullOrEmpty(formattedText)) reactor = defaultReactor; else reactor = segments[0]; - if (segments.Length <= 1 || !int.TryParse(segments[1].Replace("QP", string.Empty), out int rdsValue) || rdsValue < 99) + if (segments.Length <= 1 || !int.TryParse(segments[1], out int rdsValue) || rdsValue < 99) rds = defaultRDS; else rds = segments[1]; @@ -262,11 +262,11 @@ public class ProcessData : IProcessData return new(reactor, rds); } - private static (string, string) GetLayerAndPSN(string defaultLayer, string defaultPSN, string[] segments, bool hasRDS) + private static (string, string) GetLayerAndPSN(string defaultLayer, string defaultPSN, string[] segments) { string psn; string layer; - if (segments.Length <= 2 || (segments.Length > 1 && !hasRDS)) + if (segments.Length <= 2) { psn = defaultPSN; layer = defaultLayer; @@ -352,9 +352,9 @@ public class ProcessData : IProcessData title = title.Substring(2); run = title; string[] segments = title.Split('-'); - bool hasRDS = Regex.IsMatch(title, "[-]?([QP][0-9]{4,}|[0-9]{5,})[-]?"); - (reactor, rds) = GetReactorAndRDS(defaultReactor, defaultRDS, text, title, segments, hasRDS); - (layer, psn) = GetLayerAndPSN(defaultLayer, defaultPSN, segments, hasRDS); + // bool hasRDS = Regex.IsMatch(title, "[-]?([QP][0-9]{4,}|[0-9]{5,})[-]?"); + (reactor, rds) = GetReactorAndRDS(defaultReactor, defaultRDS, text, title, segments); + (layer, psn) = GetLayerAndPSN(defaultLayer, defaultPSN, segments); zone = GetZone(segments); employee = defaultEmployee; } diff --git a/Adaptation/_Tests/Static/RsM.cs b/Adaptation/_Tests/Static/RsM.cs index d641787..7f1a25f 100644 --- a/Adaptation/_Tests/Static/RsM.cs +++ b/Adaptation/_Tests/Static/RsM.cs @@ -136,18 +136,17 @@ public class RsM : LoggingUnitTesting, IDisposable Assert.IsTrue(descriptor.Zone is "1"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Employee)); descriptor = FileHandlers.RsM.ProcessData.GetDescriptor("P2-LOW-RR"); - Assert.IsTrue(!string.IsNullOrEmpty(descriptor.Run)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Layer)); - Assert.IsTrue(string.IsNullOrEmpty(descriptor.PSN)); + Assert.IsTrue(descriptor.PSN is "RR"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.RDS)); - Assert.IsTrue(string.IsNullOrEmpty(descriptor.Reactor)); + Assert.IsTrue(descriptor.Reactor is "P2"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Zone)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Employee)); descriptor = FileHandlers.RsM.ProcessData.GetDescriptor("75-QP1414-SPLIT4"); Assert.IsTrue(!string.IsNullOrEmpty(descriptor.Run)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Layer)); Assert.IsTrue(descriptor.PSN is "SPLIT4"); - Assert.IsTrue(descriptor.RDS is "QP1414"); + Assert.IsTrue(string.IsNullOrEmpty(descriptor.RDS)); Assert.IsTrue(descriptor.Reactor is "75"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Zone)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Employee)); diff --git a/Adaptation/_Tests/Static/txt.cs b/Adaptation/_Tests/Static/txt.cs index c4dbf1e..50a48a4 100644 --- a/Adaptation/_Tests/Static/txt.cs +++ b/Adaptation/_Tests/Static/txt.cs @@ -129,18 +129,17 @@ public class TXT : LoggingUnitTesting, IDisposable Assert.IsTrue(descriptor.Zone is "1"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Employee)); descriptor = FileHandlers.txt.ProcessData.GetDescriptor("P2-LOW-RR"); - Assert.IsTrue(!string.IsNullOrEmpty(descriptor.Title)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Layer)); - Assert.IsTrue(string.IsNullOrEmpty(descriptor.PSN)); + Assert.IsTrue(descriptor.PSN is "RR"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.RDS)); - Assert.IsTrue(string.IsNullOrEmpty(descriptor.Reactor)); + Assert.IsTrue(descriptor.Reactor is "P2"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Zone)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Employee)); descriptor = FileHandlers.txt.ProcessData.GetDescriptor("75-QP1414-SPLIT4"); Assert.IsTrue(!string.IsNullOrEmpty(descriptor.Title)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Layer)); Assert.IsTrue(descriptor.PSN is "SPLIT4"); - Assert.IsTrue(descriptor.RDS is "QP1414"); + Assert.IsTrue(string.IsNullOrEmpty(descriptor.RDS)); Assert.IsTrue(descriptor.Reactor is "75"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Zone)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Employee));