file-folder-helper/ADO2025/PI6/Helper-2025-06-01.cs

394 lines
27 KiB
C#
Raw Blame History

using System.Collections.ObjectModel;
using System.Globalization;
using System.Net;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using IFX.Shared.PasteSpecialXml.EAF.XML.API.Envelope;
using Microsoft.Extensions.Logging;
namespace File_Folder_Helper.ADO2025.PI6;
internal static partial class Helper20250601 {
private static readonly bool _IsEnvironment_Development = false;
private record Record(string Text, string Host, int Port, string[] Segments, bool StateContainsDisabled);
private record Status(string CellInstanceName,
string CommunicationState,
string CurrentActiveVersion,
string CurrentHost,
string ErrorDescription,
string Host,
string IsReadyForRestart,
string NPort,
int Port,
string StartTime,
string Startable,
string State,
string StopTime,
string Text);
internal static void EquipmentAutomationFrameworkStatus(ILogger<Worker> logger, List<string> args) {
Status status;
Record? record;
List<string[]> messages;
logger.LogInformation(args[0]);
logger.LogInformation(args[1]);
logger.LogInformation(args[2]);
string[] cellInstanceNames = args[2].Split('~');
Dictionary<string, Record> records;
if (_IsEnvironment_Development) {
records = GetEquipmentAutomationFrameworkCellInstanceStatus(development: true, staging: false, production: false);
} else {
records = GetEquipmentAutomationFrameworkCellInstanceStatus(development: false, staging: true, production: true);
}
foreach (string cellInstanceName in cellInstanceNames) {
if (!records.TryGetValue(cellInstanceName, out record)) {
logger.LogWarning("{cellInstance} not found!", cellInstanceName);
continue;
}
status = EquipmentAutomationFrameworkCellInstanceStatus(cellInstanceName, record);
logger.LogInformation("{host}) {cellInstanceName} => {status}", record.Host, cellInstanceName, status.ToString());
}
}
private static Dictionary<string, Record> GetEquipmentAutomationFrameworkCellInstanceStatus(bool development, bool staging, bool production) {
Dictionary<string, Record> results = [];
string key;
string host;
string text;
string state;
string response;
bool stop = false;
string[] segments;
string[] cellNames;
byte[] responseBytes;
string responseAfter;
#pragma warning disable SYSLIB0014
WebClient webClient = new();
#pragma warning restore SYSLIB0014
string disabled = "Disabled";
UnicodeCategory unicodeCategory;
StringBuilder stringBuilder = new();
EquipmentAutomationFrameworkCellInstanceParseCheck();
Dictionary<char, char> unicodeReplaces = GetUnicodeReplaces();
List<UnicodeCategory> unicodeCategories = GetUnicodeCategory();
ReadOnlyCollection<string> urls = GetUrls(development, staging, production);
// Dictionary<UnicodeCategory, List<char>> unicodeCategoriesList = new Dictionary<UnicodeCategory, List<char>>();
byte[] bodyBytes = [86, 2, 11, 1, 115, 4, 11, 1, 97, 6, 86, 8, 68, 10, 30, 0, 130, 153, 48, 104, 116, 116, 112, 58, 47, 47, 116, 101, 109, 112, 117, 114, 105, 46, 111, 114, 103, 47, 73, 83, 116, 97, 116, 117, 115, 81, 117, 101, 114, 121, 47, 71, 101, 116, 70, 97, 99, 116, 111, 114, 121, 83, 116, 97, 116, 117, 115, 68, 26, 173, 181, 241, 2, 149, 65, 209, 208, 66, 143, 234, 233, 157, 246, 118, 78, 238, 68, 44, 68, 42, 171, 20, 1, 68, 12, 30, 0, 130, 153, 49, 104, 116, 116, 112, 58, 47, 47, 101, 97, 102, 45, 112, 114, 111, 100, 46, 109, 101, 115, 46, 105, 110, 102, 105, 110, 101, 111, 110, 46, 99, 111, 109, 58, 57, 48, 48, 51, 47, 83, 116, 97, 116, 117, 115, 81, 117, 101, 114, 121, 1, 86, 14, 64, 16, 71, 101, 116, 70, 97, 99, 116, 111, 114, 121, 83, 116, 97, 116, 117, 115, 8, 19, 104, 116, 116, 112, 58, 47, 47, 116, 101, 109, 112, 117, 114, 105, 46, 111, 114, 103, 47, 64, 16, 105, 110, 99, 108, 117, 100, 101, 65, 103, 101, 110, 116, 76, 105, 115, 116, 135, 64, 17, 105, 110, 99, 108, 117, 100, 101, 83, 116, 97, 116, 117, 115, 76, 105, 115, 116, 135, 64, 23, 101, 120, 116, 101, 110, 100, 101, 100, 83, 116, 97, 116, 117, 115, 67, 101, 108, 108, 78, 97, 109, 101, 115, 9, 1, 98, 57, 104, 116, 116, 112, 58, 47, 47, 115, 99, 104, 101, 109, 97, 115, 46, 109, 105, 99, 114, 111, 115, 111, 102, 116, 46, 99, 111, 109, 47, 50, 48, 48, 51, 47, 49, 48, 47, 83, 101, 114, 105, 97, 108, 105, 122, 97, 116, 105, 111, 110, 47, 65, 114, 114, 97, 121, 115, 9, 1, 105, 41, 104, 116, 116, 112, 58, 47, 47, 119, 119, 119, 46, 119, 51, 46, 111, 114, 103, 47, 50, 48, 48, 49, 47, 88, 77, 76, 83, 99, 104, 101, 109, 97, 45, 105, 110, 115, 116, 97, 110, 99, 101, 95, 6, 115, 116, 114, 105, 110, 103, 153, 20, 66, 73, 79, 82, 65, 68, 53, 95, 70, 105, 108, 101, 65, 114, 99, 104, 105, 118, 101, 114, 1, 1, 1, 1];
foreach (string url in urls) {
if (stop) {
break;
}
segments = url.Split(':');
host = segments[0];
if (segments.Length == 0 || !int.TryParse(segments[1], out int port)) {
port = 80;
}
webClient.Headers.Clear();
webClient.Headers.Add("Accept-Encoding: gzip, deflate");
webClient.Headers.Add("Content-Type: application/soap+msbin1");
responseBytes = webClient.UploadData($"http://{host}:{port}/StatusQuery", bodyBytes);
// File.WriteAllText(@"L:\Tmp\a.txt", BitConverter.ToString(responseBytes));
response = Encoding.UTF8.GetString(responseBytes);
foreach (char c in response) {
unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c);
if (unicodeCategory == UnicodeCategory.Control && unicodeReplaces.ContainsKey(c)) {
_ = stringBuilder.Append(unicodeReplaces[c]);
} else if (unicodeCategories.Contains(unicodeCategory)) {
_ = stringBuilder.Append(c);
}
}
responseAfter = stringBuilder.ToString();
cellNames = responseAfter.Split(new string[] { "CellName" }, StringSplitOptions.None);
foreach (string segment in cellNames) {
if (stop) {
break;
}
key = string.Empty;
state = string.Empty;
segments = segment.Split(new string[] { "WindowsName" }, StringSplitOptions.None);
if (segments.Length != 2) {
continue;
}
text = segments[0];
segments = text.Replace('\r', ' ').Replace('\n', ' ').Split(' ');
for (int i = 0; i < segments.Length - 3; i++) {
if (stop) {
break;
}
if (!string.IsNullOrEmpty(segments[i]) && string.IsNullOrEmpty(key)) {
key = segments[i].Trim();
} else if (segments[i].StartsWith("State")) {
state = segments[i + 1];
break;
}
}
if (key.EndsWith("a")) {
key = key[..^1];
}
if (!results.ContainsKey(key)) {
results.Add(key, new Record(Text: text, Host: host, Port: port, Segments: segments, StateContainsDisabled: state.Contains(disabled)));
} else if (results[key].StateContainsDisabled) {
results[key] = new Record(Text: text, Host: host, Port: port, Segments: segments, StateContainsDisabled: state.Contains(disabled));
}
}
}
return results;
}
private static ReadOnlyCollection<string> GetUrls(bool development, bool staging, bool production) {
List<string> results = [];
if (development) {
results.Add("eaf-dev.mes.infineon.com:9003");
}
if (staging) {
results.Add("eaf-staging.mes.infineon.com:9003");
}
if (production) {
results.Add("eaf-prod.mes.infineon.com:9003");
}
return results.AsReadOnly();
}
private static List<UnicodeCategory> GetUnicodeCategory() {
List<UnicodeCategory> unicodeCategories = [
// UnicodeCategory.Control, // 33 - <20>
UnicodeCategory.UppercaseLetter, // 25 - ABCDEFGHIJKLMNOPQRSTUVWXY
UnicodeCategory.LowercaseLetter, // 25 - abcdefghiklmnopqrstuvwxyz
UnicodeCategory.DecimalDigitNumber, // 10 - 0123456789
UnicodeCategory.OtherPunctuation, // 10 - !"#%&,./:@
UnicodeCategory.ClosePunctuation, // 2 - )]
UnicodeCategory.MathSymbol, // 2 - |؈
UnicodeCategory.OpenPunctuation, // 2 - ([
// UnicodeCategory.OtherSymbol, // 1 - <20>
UnicodeCategory.DashPunctuation, // 1 - -
UnicodeCategory.ConnectorPunctuation, // 1 - _
UnicodeCategory.ModifierSymbol, // 1 - `
UnicodeCategory.NonSpacingMark, // 1 - ̵
UnicodeCategory.SpaceSeparator, // 1 -
UnicodeCategory.CurrencySymbol, // 1 - $
];
return unicodeCategories;
}
private static void EquipmentAutomationFrameworkCellInstanceParseCheck() {
Envelope? envelope;
string xmlStart621 = "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:a=\"http://www.w3.org/2005/08/addressing\"><s:Header><a:Action s:mustUnderstand=\"1\">http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequenceResponse</a:Action><a:RelatesTo>urn:uuid:6eb7a538-0b2b-4d04-8f2a-ab50e1e5338a</a:RelatesTo></s:Header><s:Body><CreateSequenceResponse xmlns=\"http://schemas.xmlsoap.org/ws/2005/02/rm\"><Identifier>urn:uuid:31c290af-2312-4b00-a57c-d5e1ab51e02a</Identifier><Accept><AcksTo><a:Address>http://eaf-prod.mes.infineon.com:9003/CellControllerManager</a:Address></AcksTo></Accept></CreateSequenceResponse></s:Body></s:Envelope>";
string xmlStart891 = "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:r=\"http://schemas.xmlsoap.org/ws/2005/02/rm\" xmlns:a=\"http://www.w3.org/2005/08/addressing\"><s:Header><r:Sequence s:mustUnderstand=\"1\"><r:Identifier>urn:uuid:f169e50f-5ca8-43cd-a1e9-724840ff5e00</r:Identifier><r:MessageNumber>1</r:MessageNumber></r:Sequence><r:SequenceAcknowledgement><r:Identifier>urn:uuid:31c290af-2312-4b00-a57c-d5e1ab51e02a</r:Identifier><r:AcknowledgementRange Lower=\"1\" Upper=\"1\"/><netrm:BufferRemaining xmlns:netrm=\"http://schemas.microsoft.com/ws/2006/05/rm\">8</netrm:BufferRemaining></r:SequenceAcknowledgement><a:Action s:mustUnderstand=\"1\">http://tempuri.org/ICellControllerManager/StartAllCellInstancesResponse</a:Action><a:RelatesTo>urn:uuid:38977fa4-262a-42fb-8df7-d8d3074820b2</a:RelatesTo></s:Header><s:Body><StartAllCellInstancesResponse xmlns=\"http://tempuri.org/\"/></s:Body></s:Envelope>";
string xmlStart748 = "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:r=\"http://schemas.xmlsoap.org/ws/2005/02/rm\" xmlns:a=\"http://www.w3.org/2005/08/addressing\"><s:Header><r:Sequence s:mustUnderstand=\"1\"><r:Identifier>urn:uuid:f169e50f-5ca8-43cd-a1e9-724840ff5e00</r:Identifier><r:MessageNumber>2</r:MessageNumber><r:LastMessage/></r:Sequence><r:SequenceAcknowledgement><r:Identifier>urn:uuid:31c290af-2312-4b00-a57c-d5e1ab51e02a</r:Identifier><r:AcknowledgementRange Lower=\"1\" Upper=\"2\"/><netrm:BufferRemaining xmlns:netrm=\"http://schemas.microsoft.com/ws/2006/05/rm\">8</netrm:BufferRemaining></r:SequenceAcknowledgement><a:Action s:mustUnderstand=\"1\">http://schemas.xmlsoap.org/ws/2005/02/rm/LastMessage</a:Action></s:Header><s:Body/></s:Envelope>";
string xmlStart707 = "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:r=\"http://schemas.xmlsoap.org/ws/2005/02/rm\" xmlns:a=\"http://www.w3.org/2005/08/addressing\"><s:Header><r:SequenceAcknowledgement><r:Identifier>urn:uuid:31c290af-2312-4b00-a57c-d5e1ab51e02a</r:Identifier><r:AcknowledgementRange Lower=\"1\" Upper=\"2\"/><netrm:BufferRemaining xmlns:netrm=\"http://schemas.microsoft.com/ws/2006/05/rm\">8</netrm:BufferRemaining></r:SequenceAcknowledgement><a:Action s:mustUnderstand=\"1\">http://schemas.xmlsoap.org/ws/2005/02/rm/TerminateSequence</a:Action></s:Header><s:Body><r:TerminateSequence><r:Identifier>urn:uuid:f169e50f-5ca8-43cd-a1e9-724840ff5e00</r:Identifier></r:TerminateSequence></s:Body></s:Envelope>";
string xmlStop621 = "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:a=\"http://www.w3.org/2005/08/addressing\"><s:Header><a:Action s:mustUnderstand=\"1\">http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequenceResponse</a:Action><a:RelatesTo>urn:uuid:97f7aeb4-015f-440b-b0ff-a2a5aa4f4ab9</a:RelatesTo></s:Header><s:Body><CreateSequenceResponse xmlns=\"http://schemas.xmlsoap.org/ws/2005/02/rm\"><Identifier>urn:uuid:e34d16ad-21d5-4a11-a6dc-5b5b58a74f96</Identifier><Accept><AcksTo><a:Address>http://eaf-prod.mes.infineon.com:9003/CellControllerManager</a:Address></AcksTo></Accept></CreateSequenceResponse></s:Body></s:Envelope>";
string xmlStop889 = "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:r=\"http://schemas.xmlsoap.org/ws/2005/02/rm\" xmlns:a=\"http://www.w3.org/2005/08/addressing\"><s:Header><r:Sequence s:mustUnderstand=\"1\"><r:Identifier>urn:uuid:c9a4d5b6-435b-49a4-a2f9-d93cd8aecc36</r:Identifier><r:MessageNumber>1</r:MessageNumber></r:Sequence><r:SequenceAcknowledgement><r:Identifier>urn:uuid:e34d16ad-21d5-4a11-a6dc-5b5b58a74f96</r:Identifier><r:AcknowledgementRange Lower=\"1\" Upper=\"1\"/><netrm:BufferRemaining xmlns:netrm=\"http://schemas.microsoft.com/ws/2006/05/rm\">8</netrm:BufferRemaining></r:SequenceAcknowledgement><a:Action s:mustUnderstand=\"1\">http://tempuri.org/ICellControllerManager/StopAllCellInstancesResponse</a:Action><a:RelatesTo>urn:uuid:04b8b0ea-8576-4756-b456-8a817cd10826</a:RelatesTo></s:Header><s:Body><StopAllCellInstancesResponse xmlns=\"http://tempuri.org/\"/></s:Body></s:Envelope>";
string xmlStop748 = "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:r=\"http://schemas.xmlsoap.org/ws/2005/02/rm\" xmlns:a=\"http://www.w3.org/2005/08/addressing\"><s:Header><r:Sequence s:mustUnderstand=\"1\"><r:Identifier>urn:uuid:c9a4d5b6-435b-49a4-a2f9-d93cd8aecc36</r:Identifier><r:MessageNumber>2</r:MessageNumber><r:LastMessage/></r:Sequence><r:SequenceAcknowledgement><r:Identifier>urn:uuid:e34d16ad-21d5-4a11-a6dc-5b5b58a74f96</r:Identifier><r:AcknowledgementRange Lower=\"1\" Upper=\"2\"/><netrm:BufferRemaining xmlns:netrm=\"http://schemas.microsoft.com/ws/2006/05/rm\">8</netrm:BufferRemaining></r:SequenceAcknowledgement><a:Action s:mustUnderstand=\"1\">http://schemas.xmlsoap.org/ws/2005/02/rm/LastMessage</a:Action></s:Header><s:Body/></s:Envelope>";
string xmlStop707 = "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:r=\"http://schemas.xmlsoap.org/ws/2005/02/rm\" xmlns:a=\"http://www.w3.org/2005/08/addressing\"><s:Header><r:SequenceAcknowledgement><r:Identifier>urn:uuid:e34d16ad-21d5-4a11-a6dc-5b5b58a74f96</r:Identifier><r:AcknowledgementRange Lower=\"1\" Upper=\"2\"/><netrm:BufferRemaining xmlns:netrm=\"http://schemas.microsoft.com/ws/2006/05/rm\">8</netrm:BufferRemaining></r:SequenceAcknowledgement><a:Action s:mustUnderstand=\"1\">http://schemas.xmlsoap.org/ws/2005/02/rm/TerminateSequence</a:Action></s:Header><s:Body><r:TerminateSequence><r:Identifier>urn:uuid:c9a4d5b6-435b-49a4-a2f9-d93cd8aecc36</r:Identifier></r:TerminateSequence></s:Body></s:Envelope>";
string xmlRestart621 = "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:a=\"http://www.w3.org/2005/08/addressing\"><s:Header><a:Action s:mustUnderstand=\"1\">http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequenceResponse</a:Action><a:RelatesTo>urn:uuid:e228a621-e7ab-4ebf-97ba-5571cb5f4ad7</a:RelatesTo></s:Header><s:Body><CreateSequenceResponse xmlns=\"http://schemas.xmlsoap.org/ws/2005/02/rm\"><Identifier>urn:uuid:a1650ed7-34dc-4fac-993f-ed2559c453a2</Identifier><Accept><AcksTo><a:Address>http://eaf-prod.mes.infineon.com:9003/CellControllerManager</a:Address></AcksTo></Accept></CreateSequenceResponse></s:Body></s:Envelope>";
string xmlRestart895 = "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:r=\"http://schemas.xmlsoap.org/ws/2005/02/rm\" xmlns:a=\"http://www.w3.org/2005/08/addressing\"><s:Header><r:Sequence s:mustUnderstand=\"1\"><r:Identifier>urn:uuid:50c82506-bd4d-4117-b632-640cf84d556e</r:Identifier><r:MessageNumber>1</r:MessageNumber></r:Sequence><r:SequenceAcknowledgement><r:Identifier>urn:uuid:a1650ed7-34dc-4fac-993f-ed2559c453a2</r:Identifier><r:AcknowledgementRange Lower=\"1\" Upper=\"1\"/><netrm:BufferRemaining xmlns:netrm=\"http://schemas.microsoft.com/ws/2006/05/rm\">8</netrm:BufferRemaining></r:SequenceAcknowledgement><a:Action s:mustUnderstand=\"1\">http://tempuri.org/ICellControllerManager/RestartAllCellInstancesResponse</a:Action><a:RelatesTo>urn:uuid:efaeaf12-4aa0-4cd1-8296-05019e47261a</a:RelatesTo></s:Header><s:Body><RestartAllCellInstancesResponse xmlns=\"http://tempuri.org/\"/></s:Body></s:Envelope>";
string xmlRestart748 = "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:r=\"http://schemas.xmlsoap.org/ws/2005/02/rm\" xmlns:a=\"http://www.w3.org/2005/08/addressing\"><s:Header><r:Sequence s:mustUnderstand=\"1\"><r:Identifier>urn:uuid:50c82506-bd4d-4117-b632-640cf84d556e</r:Identifier><r:MessageNumber>2</r:MessageNumber><r:LastMessage/></r:Sequence><r:SequenceAcknowledgement><r:Identifier>urn:uuid:a1650ed7-34dc-4fac-993f-ed2559c453a2</r:Identifier><r:AcknowledgementRange Lower=\"1\" Upper=\"2\"/><netrm:BufferRemaining xmlns:netrm=\"http://schemas.microsoft.com/ws/2006/05/rm\">8</netrm:BufferRemaining></r:SequenceAcknowledgement><a:Action s:mustUnderstand=\"1\">http://schemas.xmlsoap.org/ws/2005/02/rm/LastMessage</a:Action></s:Header><s:Body/></s:Envelope>";
string xmlRestart707 = "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:r=\"http://schemas.xmlsoap.org/ws/2005/02/rm\" xmlns:a=\"http://www.w3.org/2005/08/addressing\"><s:Header><r:SequenceAcknowledgement><r:Identifier>urn:uuid:a1650ed7-34dc-4fac-993f-ed2559c453a2</r:Identifier><r:AcknowledgementRange Lower=\"1\" Upper=\"2\"/><netrm:BufferRemaining xmlns:netrm=\"http://schemas.microsoft.com/ws/2006/05/rm\">8</netrm:BufferRemaining></r:SequenceAcknowledgement><a:Action s:mustUnderstand=\"1\">http://schemas.xmlsoap.org/ws/2005/02/rm/TerminateSequence</a:Action></s:Header><s:Body><r:TerminateSequence><r:Identifier>urn:uuid:50c82506-bd4d-4117-b632-640cf84d556e</r:Identifier></r:TerminateSequence></s:Body></s:Envelope>";
string[] xmlSets = [xmlStart621, xmlStart891, xmlStart748, xmlStart707, xmlStop621, xmlStop889, xmlStop748, xmlStop707, xmlRestart621, xmlRestart895, xmlRestart748, xmlRestart707];
foreach (string xmlSet in xmlSets) {
envelope = ParseXML<Envelope>(xmlSet, throwExceptions: true);
}
}
private static T? ParseXML<T>(string value, bool throwExceptions) where T : class {
object? result = null;
try {
Stream stream = ToStream(value.Trim());
XmlReader xmlReader = XmlReader.Create(stream, new XmlReaderSettings() { ConformanceLevel = ConformanceLevel.Document });
#pragma warning disable IL2026, IL2090
XmlSerializer xmlSerializer = new(typeof(T), typeof(T).GetNestedTypes());
result = xmlSerializer.Deserialize(xmlReader);
#pragma warning restore IL2026, IL2090
stream.Dispose();
} catch (Exception) {
if (throwExceptions) {
throw;
}
}
return result as T;
}
private static Stream ToStream(string value) {
MemoryStream memoryStream = new();
StreamWriter streamWriter = new(memoryStream);
streamWriter.Write(value);
streamWriter.Flush();
memoryStream.Position = 0;
return memoryStream;
}
private static Dictionary<char, char> GetUnicodeReplaces() {
Dictionary<char, char> results = new() {
{ '\u0000', ' ' },
{ '\u0001', ' ' },
{ '\u0002', ' ' },
{ '\u0003', ' ' },
{ '\u0004', ' ' },
{ '\u0005', ' ' },
{ '\u0006', ' ' },
{ '\u0007', ' ' },
{ '\u0008', ' ' },
{ '\u0009', '\t' },
{ '\u000A', '\r' },
{ '\u000B', '\r' },
{ '\u000C', '\t' },
{ '\u000D', '\r' },
{ '\u000E', ' ' },
{ '\u000F', ' ' },
{ '\u0010', ' ' },
{ '\u0011', ' ' },
{ '\u0012', ' ' },
{ '\u0013', ' ' },
{ '\u0014', ' ' },
{ '\u0015', ' ' },
{ '\u0016', ' ' },
{ '\u0017', ' ' },
{ '\u0018', ' ' },
{ '\u0019', ' ' },
{ '\u001A', ' ' },
{ '\u001B', ' ' },
{ '\u001C', '\r' },
{ '\u001D', '\t' },
{ '\u001E', '\t' },
{ '\u001F', '\t' },
{ '\u007F', ' ' },
// C1
{ '\u0080', '\t' },
{ '\u0081', ' ' },
{ '\u0082', ' ' },
{ '\u0083', ' ' },
{ '\u0084', ' ' },
{ '\u0085', '\r' },
{ '\u0086', ' ' },
{ '\u0087', ' ' },
{ '\u0088', '\t' },
{ '\u0089', '\t' },
{ '\u008A', '\t' },
{ '\u008B', '\r' },
{ '\u008C', ' ' },
{ '\u008D', ' ' },
{ '\u008E', ' ' },
{ '\u008F', ' ' },
{ '\u0090', ' ' },
{ '\u0091', ' ' },
{ '\u0092', ' ' },
{ '\u0093', ' ' },
{ '\u0094', ' ' },
{ '\u0095', ' ' },
{ '\u0096', ' ' },
{ '\u0097', ' ' },
{ '\u0098', ' ' },
{ '\u0099', ' ' },
{ '\u009A', ' ' },
{ '\u009B', ' ' },
{ '\u009C', ' ' },
{ '\u009D', ' ' },
{ '\u009E', ' ' },
{ '\u009F', ' ' }
};
return results;
}
private static Status EquipmentAutomationFrameworkCellInstanceStatus(string cellInstanceName, Record record) {
Status result;
bool stop = false;
string state = string.Empty;
string stopTime = string.Empty;
string startTime = string.Empty;
string startable = string.Empty;
string currentHost = string.Empty;
string errorDescription = string.Empty;
string isReadyForRestart = string.Empty;
string communicationState = string.Empty;
string currentActiveVersion = string.Empty;
for (int i = 0; i < record.Segments.Length - 3; i++) {
if (stop) {
break;
}
if (string.IsNullOrEmpty(state) && record.Segments[i].StartsWith("State")) {
state = record.Segments[i + 1];
} else if (string.IsNullOrEmpty(startable) && record.Segments[i].Contains("Startable")) {
startable = record.Segments[i + 1];
} else if (string.IsNullOrEmpty(stopTime) && record.Segments[i].StartsWith("StopTime")) {
stopTime = record.Segments[i + 1];
} else if (string.IsNullOrEmpty(currentHost) && record.Segments[i].Contains("CurrentHost")) {
currentHost = $"{record.Segments[i]} {record.Segments[i + 1]} {record.Segments[i + 2]}";
} else if (string.IsNullOrEmpty(errorDescription) && record.Segments[i].StartsWith("ErrorDescription")) {
errorDescription = record.Segments[i + 1];
} else if (string.IsNullOrEmpty(communicationState) && record.Segments[i].StartsWith("CommunicationState")) {
communicationState = record.Segments[i + 1];
} else if (string.IsNullOrEmpty(isReadyForRestart) && record.Segments[i].StartsWith("IsReadyForRestart")) {
isReadyForRestart = record.Segments[i + 1];
} else if (string.IsNullOrEmpty(currentActiveVersion) && record.Segments[i].Contains("CurrentActiveVersion")) {
currentActiveVersion = record.Segments[i + 1];
} else if (string.IsNullOrEmpty(startTime) && record.Segments[i].Contains("StartTime")) {
startTime = $"{record.Segments[i + 1]} {record.Segments[i + 2]} {record.Segments[i + 3]}".Split('\t')[0];
}
}
if (errorDescription != "a") {
string[] segments = record.Text.Split(new string[] { "ErrorDescription" }, StringSplitOptions.RemoveEmptyEntries);
if (segments.Length > 1) {
segments = segments[1].Split(new string[] { "Info" }, StringSplitOptions.RemoveEmptyEntries);
errorDescription = segments[0].Trim();
}
}
string nPort;
Dictionary<string, string> nPorts = GetnPorts();
if (!nPorts.ContainsKey(cellInstanceName)) {
nPort = string.Empty;
} else {
nPort = nPorts[cellInstanceName];
}
if (state.EndsWith("a")) {
state = state[0..^1];
}
if (state == "Running" && communicationState == "Not") {
state = "Warning";
}
result = new(Host: record.Host,
Port: record.Port,
Text: record.Text,
NPort: nPort,
State: state,
CellInstanceName: cellInstanceName,
StopTime: stopTime,
StartTime: startTime,
Startable: startable,
CurrentHost: currentHost,
ErrorDescription: errorDescription,
IsReadyForRestart: isReadyForRestart,
CommunicationState: communicationState,
CurrentActiveVersion: currentActiveVersion);
return result;
}
private static Dictionary<string, string> GetnPorts() {
Dictionary<string, string> results = new() {
{ "TENCOR1", "10.95.192.31" },
{ "TENCOR2", "10.95.192.32" },
{ "TENCOR3", "10.95.192.33" },
{ "HGCV1", "10.95.192.34" },
{ "HGCV2", "10.95.154.17" },
{ "HGCV3", "10.95.192.36" },
{ "BIORAD2", "10.95.192.37" },
{ "BIORAD3", "10.95.192.38" },
{ "CDE2", "10.95.192.39" },
{ "CDE3", "10.95.154.19" },
{ "CDE5", "10.95.192.40" },
{ "SPARE-1", "10.95.192.47" },
{ "SPARE-2", "10.95.192.48" },
{ "SPARE-3", "10.95.192.49" },
{ "SPARE-4", "10.95.192.50" },
{ "SPARE-5", "10.95.192.51" },
};
return results;
}
}