Compare commits

...

4 Commits

10 changed files with 1638 additions and 93 deletions

View File

@ -0,0 +1,4 @@
@host = eaf-prod.mes.infineon.com:9003
POST {{host}}/StatusQuery
Accept: application/json

34
.vscode/launch.json vendored
View File

@ -11,6 +11,26 @@
"preLaunchTask": "build", "preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/File-Folder-Helper.dll", "program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/File-Folder-Helper.dll",
"args": [ "args": [
"s",
"X",
"D:/Tmp",
"Day-Helper-2025-06-02",
"infineon\\MESPhares",
"BACKLOG~BIORAD2~BIORAD3~BIORAD4~BIORAD5~CDE4~CDE5~CDE6~DEP08CEPIEPSILON~DEP08SIASM~DEP08SIHTRPLC~EC~HGCV1~HGCV2~HGCV3~MESAFIBACKLOG~MET06AWCT~MET08ANLYSDIFAAST230~MET08AWCT~MET08DDUPSFS6420~MET08DDUPSP1TBI~MET08RESIHGCV~MET08RESIMAPCDE~MET08RESISRP2100~MET08THFTIRQS408M~MET08THFTIRSTRATUS~METCLIMATEC~R29~R32~R36~R47~R55~R57~R61~R62~R65~R70~R72~R73~R74~R75~R77~SP101~SPV01~SRP~TENCOR1~TENCOR2~TENCOR3~TRENDLOG~WC6INCH1~WC6INCH2~WC6INCH3~WC6INCH4~WC8INCH1~WC8INCH2~WC8INCH3",
"s",
"X",
"D:/5-Other-Small/Proxmox/ffnm",
"Day-Helper-2025-05-21",
"*.pdf",
"*.md",
"2",
"MM-dd-yy",
"Trans Date~Effective Date~Description~Withdrawal Deposit~Balance",
"s",
"X",
"D:/Tmp/phares/VisualStudioCode",
"Day-Helper-2025-05-19",
"D:/Tmp/phares/VisualStudioCode/.vscode/input.json",
"s", "s",
"X", "X",
"D:/Tmp/phares/VisualStudioCode", "D:/Tmp/phares/VisualStudioCode",
@ -22,14 +42,14 @@
"/api/SyncV1/?", "/api/SyncV1/?",
",L", ",L",
".G", ".G",
"+|G||L|+|Custom-Default", "+~G~~L~+~Custom-Default",
"", "",
"+|G||G|-|Mirror", "+~G~~G~-~Mirror",
"+|G||||Update", "+~G~~~~Update",
"+|G||L|+|Custom-Default", "+~G~~L~+~Custom-Default",
"-|G||G|+|Custom-A", "-~G~~G~+~Custom-A",
"-|L||L|+|Custom-B", "-~L~~L~+~Custom-B",
"+|L||L|-|Custom-C", "+~L~~L~-~Custom-C",
"s", "s",
"X", "X",
"\\\\mesfs.infineon.com\\EC_Characterization_Si\\Archive\\BIORAD4\\2025_Week_16\\2025-04-17", "\\\\mesfs.infineon.com\\EC_Characterization_Si\\Archive\\BIORAD4\\2025_Week_16\\2025-04-17",

View File

@ -10,6 +10,8 @@
"**/node_modules": true "**/node_modules": true
}, },
"cSpell.words": [ "cSpell.words": [
"abcdefghiklmnopqrstuvwxyz",
"Acks",
"ASPNETCORE", "ASPNETCORE",
"BIORAD", "BIORAD",
"BIRT", "BIRT",
@ -21,6 +23,7 @@
"FAMS", "FAMS",
"Gatus", "Gatus",
"GIVN", "GIVN",
"HGCV",
"HUSB", "HUSB",
"Immich", "Immich",
"INDI", "INDI",
@ -31,6 +34,7 @@
"Linc", "Linc",
"mesfs", "mesfs",
"mestsa", "mestsa",
"netrm",
"NpgSql", "NpgSql",
"NSFX", "NSFX",
"OBJE", "OBJE",
@ -44,9 +48,11 @@
"Reparse", "Reparse",
"Rijndael", "Rijndael",
"Serilog", "Serilog",
"startable",
"SUBM", "SUBM",
"SURN", "SURN",
"SYSLIB", "SYSLIB",
"TENCOR",
"VSTS", "VSTS",
"WIQL", "WIQL",
"WSJF" "WSJF"

View File

@ -54,13 +54,20 @@ internal static partial class Helper20241217
Job jobNew; Job jobNew;
string path; string path;
string? json; string? json;
string asidePath;
bool areTheyTheSame; bool areTheyTheSame;
string directoryName; string directoryName;
logger.LogInformation(args[0]);
logger.LogInformation(args[1]);
logger.LogInformation(args[2]);
logger.LogInformation(args[3]);
logger.LogInformation(args[4]);
ReadOnlyCollection<File> files; ReadOnlyCollection<File> files;
string searchPattern = args[2]; string searchPattern = args[2];
string[] ignoreFileNames = args[3].Split('~'); string[] ignoreFileNames = args[3].Split('~');
string destination = Path.GetFullPath(args[4]);
string sourceDirectory = Path.GetFullPath(args[0]); string sourceDirectory = Path.GetFullPath(args[0]);
char destinationDriveLetter = args[4].Split(':')[0][0]; char destinationDriveLetter = destination.Split(':')[0][0];
logger.LogInformation("Searching <{sourceDirectory}> with search pattern {searchPattern}", args[0], searchPattern); logger.LogInformation("Searching <{sourceDirectory}> with search pattern {searchPattern}", args[0], searchPattern);
if (Debugger.IsAttached) if (Debugger.IsAttached)
Verify(searchPattern, ignoreFileNames); Verify(searchPattern, ignoreFileNames);
@ -80,10 +87,15 @@ internal static partial class Helper20241217
continue; continue;
} }
directoryName = Path.GetFileName(record.Directory); directoryName = Path.GetFileName(record.Directory);
path = Path.Combine(record.Directory, $"{directoryName}-{DateTime.Now:yyyy-MM-dd-HH-mm-ss-fff}{record.Job.Extension}"); asidePath = Path.Combine(record.Directory, $"{directoryName}-{DateTime.Now:yyyy-MM-dd-HH-mm-ss-fff}{record.Job.Extension}");
logger.LogInformation("Writing <{directory}> extension", record.Directory); path = $"{destinationDriveLetter}{asidePath[1..]}";
WritePassedExtension(destinationDriveLetter, record, files, path); logger.LogInformation("Writing <{path}> extension", path);
WritePassedExtension(record, files, directoryName, path);
logger.LogInformation("Wrote <{path}> extension", path);
MovePassedExtension(destination, path);
logger.LogInformation("Moved <{path}> extension", path);
WriteAllText(record.Path, json); WriteAllText(record.Path, json);
Helpers.HelperDeleteEmptyDirectories.DeleteEmptyDirectories(logger, $"{destinationDriveLetter}{record.Directory[1..]}");
} }
if (Debugger.IsAttached && records.Count() == 0) if (Debugger.IsAttached && records.Count() == 0)
{ {
@ -245,8 +257,11 @@ internal static partial class Helper20241217
else else
{ {
result = false; result = false;
WriteAllText(Path.Combine(Environment.CurrentDirectory, ".vscode", "helper", "old.json"), jsonOld); if (Debugger.IsAttached)
WriteAllText(Path.Combine(Environment.CurrentDirectory, ".vscode", "helper", "new.json"), jsonNew); {
WriteAllText(Path.Combine(Environment.CurrentDirectory, ".vscode", "helper", "old.json"), jsonOld);
WriteAllText(Path.Combine(Environment.CurrentDirectory, ".vscode", "helper", "new.json"), jsonNew);
}
logger.LogInformation("<{directory}> file serialized are different {filesTotalLengthNew} != {filesTotalLengthOld}", record.Directory, filesTotalLengthNew, filesTotalLengthOld); logger.LogInformation("<{directory}> file serialized are different {filesTotalLengthNew} != {filesTotalLengthOld}", record.Directory, filesTotalLengthNew, filesTotalLengthOld);
} }
} }
@ -261,36 +276,44 @@ internal static partial class Helper20241217
System.IO.File.WriteAllText(path, text); System.IO.File.WriteAllText(path, text);
} }
private static void WritePassedExtension(char destinationDriveLetter, Record record, ReadOnlyCollection<File> files, string path) private static void WritePassedExtension(Record record, ReadOnlyCollection<File> files, string directoryName, string path)
{ {
string directoryName = Path.GetFileName(record.Directory);
if (record.Job.Extension.Equals(".iso", StringComparison.OrdinalIgnoreCase)) if (record.Job.Extension.Equals(".iso", StringComparison.OrdinalIgnoreCase))
WriteISO(destinationDriveLetter, record, files, path, directoryName); WriteISO(record, files, path, directoryName);
else if (record.Job.Extension.Equals(".zip", StringComparison.OrdinalIgnoreCase)) else if (record.Job.Extension.Equals(".zip", StringComparison.OrdinalIgnoreCase))
WriteZIP(destinationDriveLetter, record, files, path); WriteZIP(record, files, path);
else else
throw new NotImplementedException(); throw new NotImplementedException();
} }
private static void WriteISO(char destinationDriveLetter, Record record, ReadOnlyCollection<File> files, string path, string directoryName) private static void MovePassedExtension(string destination, string path)
{ {
string checkFile = $"{destinationDriveLetter}{path[1..]}"; string checkPath = $"{destination}{path[2..]}";
string checkDirectory = Path.GetDirectoryName(checkFile) ?? throw new Exception(); string checkDirectory = Path.GetDirectoryName(checkPath) ?? throw new Exception();
if (!Directory.Exists(checkDirectory))
_ = Directory.CreateDirectory(checkDirectory);
if (System.IO.File.Exists(checkPath))
throw new NotImplementedException($"<{checkPath}> already exists!");
System.IO.File.Move(path, checkPath);
}
private static void WriteISO(Record record, ReadOnlyCollection<File> files, string path, string directoryName)
{
string checkDirectory = Path.GetDirectoryName(path) ?? throw new Exception();
if (!Directory.Exists(checkDirectory)) if (!Directory.Exists(checkDirectory))
_ = Directory.CreateDirectory(checkDirectory); _ = Directory.CreateDirectory(checkDirectory);
CDBuilder builder = new() { UseJoliet = true, VolumeIdentifier = directoryName.Length < 25 ? directoryName : directoryName[..25] }; CDBuilder builder = new() { UseJoliet = true, VolumeIdentifier = directoryName.Length < 25 ? directoryName : directoryName[..25] };
foreach (File file in files) foreach (File file in files)
_ = builder.AddFile(file.RelativePath, Path.Combine(record.Directory, file.RelativePath)); _ = builder.AddFile(file.RelativePath, Path.Combine(record.Directory, file.RelativePath));
builder.Build(checkFile); builder.Build(path);
} }
private static void WriteZIP(char destinationDriveLetter, Record record, ReadOnlyCollection<File> files, string path) private static void WriteZIP(Record record, ReadOnlyCollection<File> files, string path)
{ {
string checkFile = $"{destinationDriveLetter}{path[1..]}"; string checkDirectory = Path.GetDirectoryName(path) ?? throw new Exception();
string checkDirectory = Path.GetDirectoryName(checkFile) ?? throw new Exception();
if (!Directory.Exists(checkDirectory)) if (!Directory.Exists(checkDirectory))
_ = Directory.CreateDirectory(checkDirectory); _ = Directory.CreateDirectory(checkDirectory);
using ZipArchive zip = ZipFile.Open(checkFile, ZipArchiveMode.Create); using ZipArchive zip = ZipFile.Open(path, ZipArchiveMode.Create);
string directoryEntry; string directoryEntry;
List<string> directoryEntries = []; List<string> directoryEntries = [];
foreach (File file in files) foreach (File file in files)

277
ADO2025/PI6/Envelope.cs Normal file
View File

@ -0,0 +1,277 @@
#nullable disable
#pragma warning disable CS8603
#pragma warning disable CS8632
#pragma warning disable IDE1006
namespace IFX.Shared.PasteSpecialXml.EAF.XML.API.Envelope;
// NOTE: Generated code may require at least .NET Framework 4.5 or .NET Core/Standard 2.0.
/// <remarks/>
[Serializable()]
[System.ComponentModel.DesignerCategory("code")]
[System.Xml.Serialization.XmlType(AnonymousType = true, Namespace = "http://www.w3.org/2003/05/soap-envelope")]
[System.Xml.Serialization.XmlRoot(Namespace = "http://www.w3.org/2003/05/soap-envelope", IsNullable = false)]
public partial class Envelope
{
private EnvelopeHeader? headerField;
private EnvelopeBody? bodyField;
/// <remarks/>
public EnvelopeHeader Header
{
get => this.headerField;
set => this.headerField = value;
}
/// <remarks/>
public EnvelopeBody Body
{
get => this.bodyField;
set => this.bodyField = value;
}
}
/// <remarks/>
[Serializable()]
[System.ComponentModel.DesignerCategory("code")]
[System.Xml.Serialization.XmlType(AnonymousType = true, Namespace = "http://www.w3.org/2003/05/soap-envelope")]
public partial class EnvelopeHeader
{
private Sequence? sequenceField;
private SequenceAcknowledgement? sequenceAcknowledgementField;
private Action? actionField;
private string? relatesToField;
/// <remarks/>
[System.Xml.Serialization.XmlElement(Namespace = "http://schemas.xmlsoap.org/ws/2005/02/rm")]
public Sequence Sequence
{
get => this.sequenceField;
set => this.sequenceField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElement(Namespace = "http://schemas.xmlsoap.org/ws/2005/02/rm")]
public SequenceAcknowledgement SequenceAcknowledgement
{
get => this.sequenceAcknowledgementField;
set => this.sequenceAcknowledgementField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElement(Namespace = "http://www.w3.org/2005/08/addressing")]
public Action Action
{
get => this.actionField;
set => this.actionField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElement(Namespace = "http://www.w3.org/2005/08/addressing")]
public string RelatesTo
{
get => this.relatesToField;
set => this.relatesToField = value;
}
}
/// <remarks/>
[Serializable()]
[System.ComponentModel.DesignerCategory("code")]
[System.Xml.Serialization.XmlType(AnonymousType = true, Namespace = "http://schemas.xmlsoap.org/ws/2005/02/rm")]
[System.Xml.Serialization.XmlRoot(Namespace = "http://schemas.xmlsoap.org/ws/2005/02/rm", IsNullable = false)]
public partial class Sequence
{
private string? identifierField;
private byte messageNumberField;
private object? lastMessageField;
private byte mustUnderstandField;
/// <remarks/>
public string Identifier
{
get => this.identifierField;
set => this.identifierField = value;
}
/// <remarks/>
public byte MessageNumber
{
get => this.messageNumberField;
set => this.messageNumberField = value;
}
/// <remarks/>
public object LastMessage
{
get => this.lastMessageField;
set => this.lastMessageField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://www.w3.org/2003/05/soap-envelope")]
public byte mustUnderstand
{
get => this.mustUnderstandField;
set => this.mustUnderstandField = value;
}
}
/// <remarks/>
[Serializable()]
[System.ComponentModel.DesignerCategory("code")]
[System.Xml.Serialization.XmlType(AnonymousType = true, Namespace = "http://schemas.xmlsoap.org/ws/2005/02/rm")]
[System.Xml.Serialization.XmlRoot(Namespace = "http://schemas.xmlsoap.org/ws/2005/02/rm", IsNullable = false)]
public partial class SequenceAcknowledgement
{
private string? identifierField;
private SequenceAcknowledgementAcknowledgementRange? acknowledgementRangeField;
private byte bufferRemainingField;
/// <remarks/>
public string Identifier
{
get => this.identifierField;
set => this.identifierField = value;
}
/// <remarks/>
public SequenceAcknowledgementAcknowledgementRange AcknowledgementRange
{
get => this.acknowledgementRangeField;
set => this.acknowledgementRangeField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElement(Namespace = "http://schemas.microsoft.com/ws/2006/05/rm")]
public byte BufferRemaining
{
get => this.bufferRemainingField;
set => this.bufferRemainingField = value;
}
}
/// <remarks/>
[Serializable()]
[System.ComponentModel.DesignerCategory("code")]
[System.Xml.Serialization.XmlType(AnonymousType = true, Namespace = "http://schemas.xmlsoap.org/ws/2005/02/rm")]
public partial class SequenceAcknowledgementAcknowledgementRange
{
private byte lowerField;
private byte upperField;
/// <remarks/>
[System.Xml.Serialization.XmlAttribute()]
public byte Lower
{
get => this.lowerField;
set => this.lowerField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlAttribute()]
public byte Upper
{
get => this.upperField;
set => this.upperField = value;
}
}
/// <remarks/>
[Serializable()]
[System.ComponentModel.DesignerCategory("code")]
[System.Xml.Serialization.XmlType(AnonymousType = true, Namespace = "http://www.w3.org/2005/08/addressing")]
[System.Xml.Serialization.XmlRoot(Namespace = "http://www.w3.org/2005/08/addressing", IsNullable = false)]
public partial class Action
{
private byte mustUnderstandField;
private string? valueField;
/// <remarks/>
[System.Xml.Serialization.XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://www.w3.org/2003/05/soap-envelope")]
public byte mustUnderstand
{
get => this.mustUnderstandField;
set => this.mustUnderstandField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlText()]
public string Value
{
get => this.valueField;
set => this.valueField = value;
}
}
/// <remarks/>
[Serializable()]
[System.ComponentModel.DesignerCategory("code")]
[System.Xml.Serialization.XmlType(AnonymousType = true, Namespace = "http://www.w3.org/2003/05/soap-envelope")]
public partial class EnvelopeBody
{
private CreateSequenceResponse? createSequenceResponseField;
/// <remarks/>
[System.Xml.Serialization.XmlElement(Namespace = "http://schemas.xmlsoap.org/ws/2005/02/rm")]
public CreateSequenceResponse CreateSequenceResponse
{
get => this.createSequenceResponseField;
set => this.createSequenceResponseField = value;
}
}
/// <remarks/>
[Serializable()]
[System.ComponentModel.DesignerCategory("code")]
[System.Xml.Serialization.XmlType(AnonymousType = true, Namespace = "http://schemas.xmlsoap.org/ws/2005/02/rm")]
[System.Xml.Serialization.XmlRoot(Namespace = "http://schemas.xmlsoap.org/ws/2005/02/rm", IsNullable = false)]
public partial class CreateSequenceResponse
{
private string? identifierField;
private CreateSequenceResponseAccept? acceptField;
/// <remarks/>
public string Identifier
{
get => this.identifierField;
set => this.identifierField = value;
}
/// <remarks/>
public CreateSequenceResponseAccept Accept
{
get => this.acceptField;
set => this.acceptField = value;
}
}
/// <remarks/>
[Serializable()]
[System.ComponentModel.DesignerCategory("code")]
[System.Xml.Serialization.XmlType(AnonymousType = true, Namespace = "http://schemas.xmlsoap.org/ws/2005/02/rm")]
public partial class CreateSequenceResponseAccept
{
private CreateSequenceResponseAcceptAcksTo? acksToField;
/// <remarks/>
public CreateSequenceResponseAcceptAcksTo AcksTo
{
get => this.acksToField;
set => this.acksToField = value;
}
}
/// <remarks/>
[Serializable()]
[System.ComponentModel.DesignerCategory("code")]
[System.Xml.Serialization.XmlType(AnonymousType = true, Namespace = "http://schemas.xmlsoap.org/ws/2005/02/rm")]
public partial class CreateSequenceResponseAcceptAcksTo
{
private string? addressField;
/// <remarks/>
[System.Xml.Serialization.XmlElement(Namespace = "http://www.w3.org/2005/08/addressing")]
public string Address
{
get => this.addressField;
set => this.addressField = value;
}
}

View File

@ -13,11 +13,18 @@ internal static partial class Helper20250519 {
private record RelativePath(string LeftDirectory, private record RelativePath(string LeftDirectory,
string? RightDirectory, string? RightDirectory,
Record[] Records); Record[] Records) {
public override string ToString() {
string result = JsonSerializer.Serialize(this, Helper20250519RelativePath.Default.RelativePath);
return result;
}
}
[JsonSourceGenerationOptions(WriteIndented = true)] [JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(RelativePath))] [JsonSerializable(typeof(RelativePath))]
private partial class RelativePathSourceGenerationContext : JsonSerializerContext { private partial class Helper20250519RelativePath : JsonSerializerContext {
} }
private record Review(Segment[]? AreEqual, private record Review(Segment[]? AreEqual,
@ -26,11 +33,18 @@ internal static partial class Helper20250519 {
Segment[]? NotEqualBut, Segment[]? NotEqualBut,
Record[]? Records, Record[]? Records,
Segment[]? RightSideIsNewer, Segment[]? RightSideIsNewer,
Segment[]? RightSideOnly); Segment[]? RightSideOnly) {
public override string ToString() {
string result = JsonSerializer.Serialize(this, Helper20250519Review.Default.Review);
return result;
}
}
[JsonSourceGenerationOptions(WriteIndented = true)] [JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Review))] [JsonSerializable(typeof(Review))]
private partial class ReviewSourceGenerationContext : JsonSerializerContext { private partial class Helper20250519Review : JsonSerializerContext {
} }
private record Record(string RelativePath, private record Record(string RelativePath,
@ -49,6 +63,38 @@ internal static partial class Helper20250519 {
long Ticks, long Ticks,
string UrlEncodedFile); string UrlEncodedFile);
private record Input(string RightDirectory,
string LeftDirectory,
string IncludePatternsFile,
string ExcludePatternsFile,
string[] BaseAddresses,
string Page,
string[] Segments) {
private static string GetDirectory(List<string> args) =>
Path.GetFullPath(args[0].Split('~')[0]);
internal static Input Get(List<string> args) =>
new(RightDirectory: GetDirectory(args),
LeftDirectory: Path.GetFullPath(args[2].Split('~')[0]),
IncludePatternsFile: Path.Combine(GetDirectory(args), ".vscode", args[3]),
ExcludePatternsFile: Path.Combine(GetDirectory(args), ".vscode", args[4]),
BaseAddresses: args.Count < 5 ? [] : args[5].Split('~'),
Page: args[6],
Segments: args[9].Split('~'));
public override string ToString() {
string result = JsonSerializer.Serialize(this, Helper20250519Input.Default.Input);
return result;
}
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Input))]
private partial class Helper20250519Input : JsonSerializerContext {
}
private record Logic(string Comment, private record Logic(string Comment,
char GreaterThan, char GreaterThan,
bool? LeftSideIsNewer, bool? LeftSideIsNewer,
@ -85,53 +131,53 @@ internal static partial class Helper20250519 {
const int leftSideIsNewerIndex = 1; const int leftSideIsNewerIndex = 1;
const int rightSideIsNewerIndex = 3; const int rightSideIsNewerIndex = 3;
string comment = segments[commentIndex]; string comment = segments[commentIndex];
if (string.IsNullOrEmpty(segments[leftSideOnlyIndex])) if (string.IsNullOrEmpty(segments[leftSideOnlyIndex])) {
leftSideOnly = null; leftSideOnly = null;
else if (segments[leftSideOnlyIndex][0] == plus) } else if (segments[leftSideOnlyIndex][0] == plus) {
leftSideOnly = true; leftSideOnly = true;
else if (segments[leftSideOnlyIndex][0] == minus) } else if (segments[leftSideOnlyIndex][0] == minus) {
leftSideOnly = false; leftSideOnly = false;
else { } else {
check = false; check = false;
leftSideOnly = null; leftSideOnly = null;
} }
if (string.IsNullOrEmpty(segments[leftSideIsNewerIndex])) if (string.IsNullOrEmpty(segments[leftSideIsNewerIndex])) {
leftSideIsNewer = null; leftSideIsNewer = null;
else if (segments[leftSideIsNewerIndex][0] == greaterThan) } else if (segments[leftSideIsNewerIndex][0] == greaterThan) {
leftSideIsNewer = true; leftSideIsNewer = true;
else if (segments[leftSideIsNewerIndex][0] == lessThan) } else if (segments[leftSideIsNewerIndex][0] == lessThan) {
leftSideIsNewer = false; leftSideIsNewer = false;
else { } else {
check = false; check = false;
leftSideIsNewer = null; leftSideIsNewer = null;
} }
if (string.IsNullOrEmpty(segments[notEqualButIndex])) if (string.IsNullOrEmpty(segments[notEqualButIndex])) {
notEqualBut = null; notEqualBut = null;
else if (segments[notEqualButIndex][0] == greaterThan) } else if (segments[notEqualButIndex][0] == greaterThan) {
notEqualBut = true; notEqualBut = true;
else if (segments[notEqualButIndex][0] == lessThan) } else if (segments[notEqualButIndex][0] == lessThan) {
notEqualBut = false; notEqualBut = false;
else { } else {
check = false; check = false;
notEqualBut = null; notEqualBut = null;
} }
if (string.IsNullOrEmpty(segments[rightSideIsNewerIndex])) if (string.IsNullOrEmpty(segments[rightSideIsNewerIndex])) {
rightSideIsNewer = null; rightSideIsNewer = null;
else if (segments[rightSideIsNewerIndex][0] == greaterThan) } else if (segments[rightSideIsNewerIndex][0] == greaterThan) {
rightSideIsNewer = true; rightSideIsNewer = true;
else if (segments[rightSideIsNewerIndex][0] == lessThan) } else if (segments[rightSideIsNewerIndex][0] == lessThan) {
rightSideIsNewer = false; rightSideIsNewer = false;
else { } else {
check = false; check = false;
rightSideIsNewer = null; rightSideIsNewer = null;
} }
if (string.IsNullOrEmpty(segments[rightSideOnlyIndex])) if (string.IsNullOrEmpty(segments[rightSideOnlyIndex])) {
rightSideOnly = null; rightSideOnly = null;
else if (segments[rightSideOnlyIndex][0] == plus) } else if (segments[rightSideOnlyIndex][0] == plus) {
rightSideOnly = true; rightSideOnly = true;
else if (segments[rightSideOnlyIndex][0] == minus) } else if (segments[rightSideOnlyIndex][0] == minus) {
rightSideOnly = false; rightSideOnly = false;
else { } else {
check = false; check = false;
rightSideOnly = null; rightSideOnly = null;
} }
@ -154,27 +200,46 @@ internal static partial class Helper20250519 {
return result; return result;
} }
public override string ToString() {
string result = JsonSerializer.Serialize(this, Helper20250519Logic.Default.Logic);
return result;
}
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Logic))]
private partial class Helper20250519Logic : JsonSerializerContext {
} }
internal static void LiveSync(ILogger<Worker> logger, List<string> args) { internal static void LiveSync(ILogger<Worker> logger, List<string> args) {
string[] segments = args[9].Split('~'); logger.LogInformation(args[0]);
Logic? logic = segments.Length != 6 ? null : Logic.Get(segments); logger.LogInformation(args[1]);
string[] baseAddresses = args.Count < 5 ? [] : args[5].Split('~'); logger.LogInformation(args[2]);
if (logic is null || baseAddresses.Length == 0) if (args[2].EndsWith("input.json") && !File.Exists(args[2])) {
logger.LogInformation("Invalid input!"); File.WriteAllText(args[2], "{}");
else { }
string rightDirectory = Path.GetFullPath(args[0].Split('~')[0]); string? json = !args[2].EndsWith("input.json") ? null : File.ReadAllText(args[2]);
string excludePatternsFile = Path.Combine(rightDirectory, args[4]); Input input = string.IsNullOrEmpty(json)
string includePatternsFile = Path.Combine(rightDirectory, args[3]); ? Input.Get(args)
Matcher matcher = GetMatcher(excludePatternsFile, includePatternsFile); : JsonSerializer.Deserialize(json, Helper20250519Input.Default.Input)
ReadOnlyCollection<Record> records = GetRecords(rightDirectory, matcher); ?? throw new Exception();
if (records.Count == 0) Logic? logic = input.Segments.Length != 6 ? null : Logic.Get(input.Segments);
if (logic is null || input.BaseAddresses.Length == 0) {
logger.LogInformation($"Invalid input!{Environment.NewLine}{input}");
} else {
Matcher matcher = GetMatcher(input.ExcludePatternsFile, input.IncludePatternsFile);
ReadOnlyCollection<Record> records = GetRecords(input.RightDirectory, matcher);
if (records.Count == 0) {
logger.LogInformation("No source records"); logger.LogInformation("No source records");
else { } else {
string page = args[6]; RelativePath relativePath = new(LeftDirectory: input.LeftDirectory, RightDirectory: input.RightDirectory, Records: records.ToArray());
string leftDirectory = Path.GetFullPath(args[2].Split('~')[0]); json = JsonSerializer.Serialize(relativePath, Helper20250519RelativePath.Default.RelativePath);
RelativePath relativePath = new(LeftDirectory: leftDirectory, RightDirectory: rightDirectory, Records: records.ToArray()); if (string.IsNullOrEmpty(json)) {
LiveSync180(logger, logic, baseAddresses, page, relativePath); LiveSync180(logger, logic, input.BaseAddresses, input.Page, relativePath);
} else {
File.WriteAllText(Path.Combine(input.RightDirectory, ".vscode", $"{nameof(RelativePath)}.json"), json);
}
} }
} }
} }
@ -197,11 +262,13 @@ internal static partial class Helper20250519 {
ReadOnlyCollection<ReadOnlyCollection<string>> collection = Helpers.HelperDirectory.GetFilesCollection(directory, "*", "*"); ReadOnlyCollection<ReadOnlyCollection<string>> collection = Helpers.HelperDirectory.GetFilesCollection(directory, "*", "*");
foreach (ReadOnlyCollection<string> c in collection) { foreach (ReadOnlyCollection<string> c in collection) {
foreach (string f in c) { foreach (string f in c) {
if (!matcher.Match(directory, f).HasMatches) if (!matcher.Match(directory, f).HasMatches) {
continue; continue;
}
fileInfo = new(f); fileInfo = new(f);
if (fileInfo.Length == 0) if (fileInfo.Length == 0) {
continue; continue;
}
relativePath = Path.GetRelativePath(directory, fileInfo.FullName); relativePath = Path.GetRelativePath(directory, fileInfo.FullName);
record = new(RelativePath: relativePath, record = new(RelativePath: relativePath,
Size: fileInfo.Length, Size: fileInfo.Length,
@ -216,13 +283,14 @@ internal static partial class Helper20250519 {
Review? review; Review? review;
Task<string> response; Task<string> response;
Task<HttpResponseMessage> httpResponseMessage; Task<HttpResponseMessage> httpResponseMessage;
StringContent stringContent = new(JsonSerializer.Serialize(relativePath, RelativePathSourceGenerationContext.Default.RelativePath), Encoding.UTF8, "application/json"); string json = JsonSerializer.Serialize(relativePath, Helper20250519RelativePath.Default.RelativePath);
foreach (string baseAddress in baseAddresses) { foreach (string baseAddress in baseAddresses) {
if (!baseAddress.StartsWith("http:")) { if (!baseAddress.StartsWith("http:")) {
logger.LogInformation("Not supported URL <{url}>", baseAddress); logger.LogInformation("Not supported URL <{url}>", baseAddress);
} else { } else {
HttpClient httpClient = new(); HttpClient httpClient = new();
httpClient.BaseAddress = new(baseAddress); httpClient.BaseAddress = new(baseAddress);
StringContent stringContent = new(json, Encoding.UTF8, "application/json");
httpResponseMessage = httpClient.PostAsync(page, stringContent); httpResponseMessage = httpClient.PostAsync(page, stringContent);
httpResponseMessage.Wait(); httpResponseMessage.Wait();
if (!httpResponseMessage.Result.IsSuccessStatusCode) { if (!httpResponseMessage.Result.IsSuccessStatusCode) {
@ -230,7 +298,7 @@ internal static partial class Helper20250519 {
} else { } else {
response = httpResponseMessage.Result.Content.ReadAsStringAsync(); response = httpResponseMessage.Result.Content.ReadAsStringAsync();
response.Wait(); response.Wait();
review = JsonSerializer.Deserialize(response.Result, ReviewSourceGenerationContext.Default.Review); review = JsonSerializer.Deserialize(response.Result, Helper20250519Review.Default.Review);
if (review is null) { if (review is null) {
logger.LogInformation("Failed to download: <{uniformResourceLocator}>;", httpClient.BaseAddress); logger.LogInformation("Failed to download: <{uniformResourceLocator}>;", httpClient.BaseAddress);
continue; continue;
@ -242,26 +310,36 @@ internal static partial class Helper20250519 {
} }
private static void LiveSync(ILogger<Worker> logger, Logic l, string page, RelativePath relativePath, HttpClient httpClient, Review review) { private static void LiveSync(ILogger<Worker> logger, Logic l, string page, RelativePath relativePath, HttpClient httpClient, Review review) {
if (review.NotEqualBut.Length > 0 && l is not null && l.NotEqualBut is not null && l.Raw[l.NotEqualButIndex][0] == l.Minus && !l.NotEqualBut.Value) if (review.NotEqualBut?.Length > 0 && l is not null && l.NotEqualBut is not null && l.Raw[l.NotEqualButIndex][0] == l.Minus && !l.NotEqualBut.Value) {
logger.LogDebug("Doing nothing with {name}", nameof(Logic.NotEqualBut)); logger.LogDebug("Doing nothing with {name}", nameof(Logic.NotEqualBut));
if (review.LeftSideOnly.Length > 0 && l is not null && l.LeftSideOnly is not null && l.Raw[l.LeftSideOnlyIndex][0] == l.Minus && !l.LeftSideOnly.Value) }
if (review.LeftSideOnly?.Length > 0 && l is not null && l.LeftSideOnly is not null && l.Raw[l.LeftSideOnlyIndex][0] == l.Minus && !l.LeftSideOnly.Value) {
LiveSync(logger, page, relativePath, httpClient, relativePath.LeftDirectory, (from x in review.LeftSideOnly select x.Left).ToArray().AsReadOnly(), HttpMethod.Delete, delete: false); LiveSync(logger, page, relativePath, httpClient, relativePath.LeftDirectory, (from x in review.LeftSideOnly select x.Left).ToArray().AsReadOnly(), HttpMethod.Delete, delete: false);
if (review.LeftSideIsNewer.Length > 0 && l is not null && l.LeftSideIsNewer is not null && l.Raw[l.LeftSideIsNewerIndex][0] == l.LessThan && !l.LeftSideIsNewer.Value) }
if (review.LeftSideIsNewer?.Length > 0 && l is not null && l.LeftSideIsNewer is not null && l.Raw[l.LeftSideIsNewerIndex][0] == l.LessThan && !l.LeftSideIsNewer.Value) {
throw new Exception(); // LiveSync(logger, page, relativePath, httpClient, relativePath.LeftDirectory, (from x in review.LeftSideIsNewer select x.Left).ToArray().AsReadOnly(), HttpMethod.Patch, delete: true); throw new Exception(); // LiveSync(logger, page, relativePath, httpClient, relativePath.LeftDirectory, (from x in review.LeftSideIsNewer select x.Left).ToArray().AsReadOnly(), HttpMethod.Patch, delete: true);
if (review.RightSideIsNewer.Length > 0 && l is not null && l.RightSideIsNewer is not null && l.Raw[l.RightSideIsNewerIndex][0] == l.LessThan && !l.RightSideIsNewer.Value) }
if (review.RightSideIsNewer?.Length > 0 && l is not null && l.RightSideIsNewer is not null && l.Raw[l.RightSideIsNewerIndex][0] == l.LessThan && !l.RightSideIsNewer.Value) {
throw new Exception(); // LiveSync(logger, page, relativePath, httpClient, relativePath.RightDirectory, (from x in review.RightSideIsNewer select x.Right).ToArray().AsReadOnly(), HttpMethod.Patch, delete: true); throw new Exception(); // LiveSync(logger, page, relativePath, httpClient, relativePath.RightDirectory, (from x in review.RightSideIsNewer select x.Right).ToArray().AsReadOnly(), HttpMethod.Patch, delete: true);
if (review.RightSideOnly.Length > 0 && l is not null && l.RightSideOnly is not null && l.Raw[l.RightSideOnlyIndex][0] == l.Plus && l.RightSideOnly.Value) }
if (review.RightSideOnly?.Length > 0 && l is not null && l.RightSideOnly is not null && l.Raw[l.RightSideOnlyIndex][0] == l.Plus && l.RightSideOnly.Value) {
throw new Exception(); // LiveSync(logger, page, relativePath, httpClient, relativePath.RightDirectory, (from x in review.RightSideOnly select x.Right).ToArray().AsReadOnly(), HttpMethod.Put, delete: false); throw new Exception(); // LiveSync(logger, page, relativePath, httpClient, relativePath.RightDirectory, (from x in review.RightSideOnly select x.Right).ToArray().AsReadOnly(), HttpMethod.Put, delete: false);
if (review.RightSideOnly.Length > 0 && l is not null && l.RightSideOnly is not null && l.Raw[l.RightSideOnlyIndex][0] == l.Minus && !l.RightSideOnly.Value) }
if (review.RightSideOnly?.Length > 0 && l is not null && l.RightSideOnly is not null && l.Raw[l.RightSideOnlyIndex][0] == l.Minus && !l.RightSideOnly.Value) {
LiveSync(logger, page, relativePath, httpClient, relativePath.RightDirectory, (from x in review.RightSideOnly select x.Right).ToArray().AsReadOnly(), httpMethod: null, delete: true); LiveSync(logger, page, relativePath, httpClient, relativePath.RightDirectory, (from x in review.RightSideOnly select x.Right).ToArray().AsReadOnly(), httpMethod: null, delete: true);
if (review.LeftSideOnly.Length > 0 && l is not null && l.LeftSideOnly is not null && l.Raw[l.LeftSideOnlyIndex][0] == l.Plus && l.LeftSideOnly.Value) }
if (review.LeftSideOnly?.Length > 0 && l is not null && l.LeftSideOnly is not null && l.Raw[l.LeftSideOnlyIndex][0] == l.Plus && l.LeftSideOnly.Value) {
LiveSync(logger, page, relativePath, httpClient, relativePath.LeftDirectory, (from x in review.LeftSideOnly select x.Left).ToArray().AsReadOnly(), HttpMethod.Get, delete: false); LiveSync(logger, page, relativePath, httpClient, relativePath.LeftDirectory, (from x in review.LeftSideOnly select x.Left).ToArray().AsReadOnly(), HttpMethod.Get, delete: false);
if (review.LeftSideIsNewer.Length > 0 && l is not null && l.LeftSideIsNewer is not null && l.Raw[l.LeftSideIsNewerIndex][0] == l.GreaterThan && l.LeftSideIsNewer.Value) }
if (review.LeftSideIsNewer?.Length > 0 && l is not null && l.LeftSideIsNewer is not null && l.Raw[l.LeftSideIsNewerIndex][0] == l.GreaterThan && l.LeftSideIsNewer.Value) {
LiveSync(logger, page, relativePath, httpClient, relativePath.LeftDirectory, (from x in review.LeftSideIsNewer select x.Left).ToArray().AsReadOnly(), HttpMethod.Get, delete: true); LiveSync(logger, page, relativePath, httpClient, relativePath.LeftDirectory, (from x in review.LeftSideIsNewer select x.Left).ToArray().AsReadOnly(), HttpMethod.Get, delete: true);
if (review.NotEqualBut.Length > 0 && l is not null && l.NotEqualBut is not null && l.Raw[l.NotEqualButIndex][0] == l.Plus && l.NotEqualBut.Value) }
if (review.NotEqualBut?.Length > 0 && l is not null && l.NotEqualBut is not null && l.Raw[l.NotEqualButIndex][0] == l.Plus && l.NotEqualBut.Value) {
LiveSync(logger, page, relativePath, httpClient, relativePath.LeftDirectory, (from x in review.NotEqualBut select x.Left).ToArray().AsReadOnly(), HttpMethod.Get, delete: true); LiveSync(logger, page, relativePath, httpClient, relativePath.LeftDirectory, (from x in review.NotEqualBut select x.Left).ToArray().AsReadOnly(), HttpMethod.Get, delete: true);
if (review.RightSideIsNewer.Length > 0 && l is not null && l.RightSideIsNewer is not null && l.Raw[l.RightSideIsNewerIndex][0] == l.GreaterThan && l.RightSideIsNewer.Value) }
if (review.RightSideIsNewer?.Length > 0 && l is not null && l.RightSideIsNewer is not null && l.Raw[l.RightSideIsNewerIndex][0] == l.GreaterThan && l.RightSideIsNewer.Value) {
LiveSync(logger, page, relativePath, httpClient, relativePath.RightDirectory, (from x in review.RightSideIsNewer select x.Right).ToArray().AsReadOnly(), HttpMethod.Get, delete: true); LiveSync(logger, page, relativePath, httpClient, relativePath.RightDirectory, (from x in review.RightSideIsNewer select x.Right).ToArray().AsReadOnly(), HttpMethod.Get, delete: true);
}
} }
private static void LiveSync(ILogger<Worker> logger, string page, RelativePath relativePath, HttpClient httpClient, string directory, ReadOnlyCollection<Record> records, HttpMethod? httpMethod, bool delete) { private static void LiveSync(ILogger<Worker> logger, string page, RelativePath relativePath, HttpClient httpClient, string directory, ReadOnlyCollection<Record> records, HttpMethod? httpMethod, bool delete) {
@ -308,8 +386,9 @@ internal static partial class Helper20250519 {
progressBar.Tick(); progressBar.Tick();
#endif #endif
record = records[i]; record = records[i];
if (record is null) if (record is null) {
continue; continue;
}
size = GetSizeWithSuffix(record.Size); size = GetSizeWithSuffix(record.Size);
try { try {
File.Delete(Path.Combine(directory, record.RelativePath)); File.Delete(Path.Combine(directory, record.RelativePath));
@ -359,9 +438,9 @@ internal static partial class Helper20250519 {
throw new NotImplementedException(); throw new NotImplementedException();
httpResponseMessage = httpClient.SendAsync(httpRequestMessage); httpResponseMessage = httpClient.SendAsync(httpRequestMessage);
httpResponseMessage.Wait(-1); httpResponseMessage.Wait(-1);
if (!httpResponseMessage.Result.IsSuccessStatusCode) if (!httpResponseMessage.Result.IsSuccessStatusCode) {
logger.LogInformation("Failed to {httpMethod}: <{display}> - {size};", httpMethod, verb.Display, size); logger.LogInformation("Failed to {httpMethod}: <{display}> - {size};", httpMethod, verb.Display, size);
else { } else {
try { try {
if (httpMethod != HttpMethod.Get) { if (httpMethod != HttpMethod.Get) {
duration = GetDurationWithSuffix(ticks); duration = GetDurationWithSuffix(ticks);
@ -401,12 +480,15 @@ internal static partial class Helper20250519 {
checkFile = Path.Combine(directory, record.RelativePath); checkFile = Path.Combine(directory, record.RelativePath);
checkFileName = Path.GetFileName(checkFile); checkFileName = Path.GetFileName(checkFile);
checkDirectory = Path.GetDirectoryName(checkFile); checkDirectory = Path.GetDirectoryName(checkFile);
if (string.IsNullOrEmpty(checkDirectory)) if (string.IsNullOrEmpty(checkDirectory)) {
continue; continue;
if (!Directory.Exists(checkDirectory)) }
if (!Directory.Exists(checkDirectory)) {
_ = Directory.CreateDirectory(checkDirectory); _ = Directory.CreateDirectory(checkDirectory);
if (File.Exists(checkFile) && new FileInfo(checkFile).Length == 0) }
if (File.Exists(checkFile) && new FileInfo(checkFile).Length == 0) {
File.Delete(checkFile); File.Delete(checkFile);
}
verb = new(Directory: checkDirectory, verb = new(Directory: checkDirectory,
Display: $"{checkFileName}{Environment.NewLine}{checkDirectory}", Display: $"{checkFileName}{Environment.NewLine}{checkDirectory}",
File: checkFile, File: checkFile,
@ -419,26 +501,30 @@ internal static partial class Helper20250519 {
} }
Verb[] sorted = (from l in collection orderby l.Size select l).ToArray(); Verb[] sorted = (from l in collection orderby l.Size select l).ToArray();
int stop = sorted.Length < 100 ? sorted.Length : 100; int stop = sorted.Length < 100 ? sorted.Length : 100;
for (int i = 0; i < stop; i++) for (int i = 0; i < stop; i++) {
results.Add(sorted[i]); results.Add(sorted[i]);
for (int i = sorted.Length - 1; i > stop - 1; i--) }
for (int i = sorted.Length - 1; i > stop - 1; i--) {
results.Add(sorted[i]); results.Add(sorted[i]);
if (collection.Count != results.Count) }
if (collection.Count != results.Count) {
throw new Exception(); throw new Exception();
}
return results.AsReadOnly(); return results.AsReadOnly();
} }
private static string GetDurationWithSuffix(long ticks) { private static string GetDurationWithSuffix(long ticks) {
string result; string result;
TimeSpan timeSpan = new(DateTime.Now.Ticks - ticks); TimeSpan timeSpan = new(DateTime.Now.Ticks - ticks);
if (timeSpan.TotalMilliseconds < 1000) if (timeSpan.TotalMilliseconds < 1000) {
result = $"{timeSpan.Milliseconds} ms"; result = $"{timeSpan.Milliseconds} ms";
else if (timeSpan.TotalMilliseconds < 60000) } else if (timeSpan.TotalMilliseconds < 60000) {
result = $"{Math.Floor(timeSpan.TotalSeconds)} s"; result = $"{Math.Floor(timeSpan.TotalSeconds)} s";
else if (timeSpan.TotalMilliseconds < 3600000) } else if (timeSpan.TotalMilliseconds < 3600000) {
result = $"{Math.Floor(timeSpan.TotalMinutes)} m"; result = $"{Math.Floor(timeSpan.TotalMinutes)} m";
else } else {
result = $"{Math.Floor(timeSpan.TotalHours)} h"; result = $"{Math.Floor(timeSpan.TotalHours)} h";
}
return result; return result;
} }

View File

@ -0,0 +1,184 @@
using System.Collections.ObjectModel;
using System.Globalization;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using Microsoft.Extensions.Logging;
namespace File_Folder_Helper.ADO2025.PI6;
internal static partial class Helper20250521 {
[GeneratedRegex(@"[~\-,.0-9]")]
private static partial Regex Number();
[GeneratedRegex(@"[^\u0020-\u007E]")]
private static partial Regex ASCII();
private record Record(string Directory, string FileNameWithoutExtension);
private record LineCheck(string[] Segments, DateTime TransactionDate, DateTime EffectiveDate) {
internal static LineCheck Get(int dateLineSegmentCount, string datePattern, string line) {
LineCheck result;
string[] segments = line.Split(' ');
if (segments.Length >= dateLineSegmentCount
&& segments[0].Length == datePattern.Length
&& segments[1].Length == datePattern.Length
&& DateTime.TryParseExact(segments[0], datePattern, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime transactionDate)
&& DateTime.TryParseExact(segments[1], datePattern, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime effectiveDate)) {
result = new(Segments: segments, TransactionDate: transactionDate, EffectiveDate: effectiveDate);
} else {
result = new(Segments: segments, TransactionDate: DateTime.MinValue, EffectiveDate: DateTime.MinValue);
}
return result;
}
}
private record RecordB(int I,
DateTime TransactionDate,
DateTime EffectiveDate,
string Description,
decimal WithdrawalOrDeposit,
decimal Balance);
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(RecordB[]))]
private partial class Helper20250521RecordB : JsonSerializerContext {
}
internal static void MatchDirectory(ILogger<Worker> logger, List<string> args) {
Record record;
string datePattern = args[5];
string searchPattern = args[2];
string searchPatternB = args[3];
string columns = args[6].Replace('~', ',');
int dateLineSegmentCount = int.Parse(args[4]);
string sourceDirectory = Path.GetFullPath(args[0].Split('~')[0]);
ReadOnlyDictionary<string, string> keyValuePairs = GetKeyValuePairs(searchPattern, sourceDirectory);
MoveMatchDirectory(searchPatternB, keyValuePairs, sourceDirectory);
ReadOnlyCollection<RecordB> records = GetRecords(searchPatternB, sourceDirectory, dateLineSegmentCount, datePattern, columns);
WriteRecords(sourceDirectory, records);
}
private static ReadOnlyDictionary<string, string> GetKeyValuePairs(string searchPattern, string sourceDirectory) {
Dictionary<string, string> results = [];
string[] files = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.AllDirectories);
foreach (string file in files) {
results.Add(Path.GetFileNameWithoutExtension(file), Path.GetDirectoryName(file));
}
return results.AsReadOnly();
}
private static void MoveMatchDirectory(string searchPatternB, ReadOnlyDictionary<string, string> keyValuePairs, string sourceDirectory) {
string checkFile;
string fileNameWithoutExtension;
string[] files = Directory.GetFiles(sourceDirectory, searchPatternB, SearchOption.AllDirectories);
foreach (string file in files) {
fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
if (!keyValuePairs.TryGetValue(fileNameWithoutExtension, out string? match))
continue;
checkFile = Path.Combine(match, Path.GetFileName(file));
if (File.Exists(checkFile))
continue;
File.Move(file, checkFile);
}
}
private static ReadOnlyCollection<RecordB> GetRecords(string searchPatternB, string sourceDirectory, int dateLineSegmentCount, string datePattern, string columns) {
List<RecordB> results = [];
string line;
string[] lines;
RecordB? record;
LineCheck lineCheck;
string[] files = Directory.GetFiles(sourceDirectory, searchPatternB, SearchOption.AllDirectories);
foreach (string file in files) {
lines = File.ReadAllLines(file);
for (int i = 0; i < lines.Length; i++) {
line = lines[i];
if (string.IsNullOrEmpty(line)) {
continue;
}
lineCheck = LineCheck.Get(dateLineSegmentCount, datePattern, line);
if (lineCheck.EffectiveDate == DateTime.MinValue || lineCheck.TransactionDate == DateTime.MinValue) {
continue;
} else {
record = GetRecord(dateLineSegmentCount, datePattern, lines, i, lineCheck.Segments, lineCheck.TransactionDate, lineCheck.EffectiveDate);
if (record is not null) {
i = record.I;
results.Add(record);
}
}
}
}
return results.AsReadOnly();
}
private static RecordB? GetRecord(int dateLineSegmentCount, string datePattern, string[] lines, int i, string[] segments, DateTime transactionDate, DateTime effectiveDate) {
RecordB? result = null;
string line;
RecordB record;
LineCheck lineCheck;
List<string> collection = [];
for (int j = i + 1; j < lines.Length; j++) {
line = lines[j];
if (string.IsNullOrEmpty(line)) {
continue;
}
lineCheck = LineCheck.Get(dateLineSegmentCount, datePattern, line);
if (lineCheck.EffectiveDate == DateTime.MinValue || lineCheck.TransactionDate == DateTime.MinValue) {
collection.Add(line);
} else {
if (lineCheck.Segments.Length > dateLineSegmentCount) {
collection.Insert(0, string.Join(' ', lineCheck.Segments.Skip(2)));
}
result = GetRecord(transactionDate, effectiveDate, collection.AsReadOnly(), j - 1);
break;
}
}
if (result is null && collection.Count > 0) {
result = GetRecord(transactionDate, effectiveDate, collection.AsReadOnly(), lines.Length - 1);
}
return result;
}
private static RecordB GetRecord(DateTime transactionDate, DateTime effectiveDate, ReadOnlyCollection<string> collection, int i) {
RecordB? result;
List<string> verified = [];
foreach (string check in collection) {
if (Number().Replace(check, string.Empty).Length != 0) {
verified.Clear();
} else {
verified.Add(check);
}
if (verified.Count == 2) {
break;
}
}
if (verified.Count != 2) {
result = null;
} else {
decimal balance = decimal.Parse(verified[^1]);
decimal withdrawalOrDeposit = decimal.Parse(verified[^2]);
string description = ASCII().Replace(string.Join(' ', collection.SkipLast(2)), string.Empty);
result = new(I: i,
TransactionDate: transactionDate,
EffectiveDate: effectiveDate,
Description: description,
WithdrawalOrDeposit: withdrawalOrDeposit,
Balance: balance);
}
return result;
}
private static void WriteRecords(string sourceDirectory, ReadOnlyCollection<RecordB> records) {
string json = JsonSerializer.Serialize(records.ToArray(), Helper20250521RecordB.Default.RecordBArray);
string sourceDirectoryVsCode = Path.Combine(sourceDirectory, ".vscode");
if (!Directory.Exists(sourceDirectoryVsCode))
_ = Directory.CreateDirectory(sourceDirectoryVsCode);
File.WriteAllText(Path.Combine(sourceDirectoryVsCode, $"{DateTime.Now.Ticks}.json"), json);
}
}

View File

@ -0,0 +1,394 @@
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;
}
}

View File

@ -0,0 +1,545 @@
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 Helper20250602 {
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 EquipmentAutomationFrameworkCellInstanceStateImageVerbIf(ILogger<Worker> logger, List<string> args) {
string path;
Status status;
Record? record;
string verbBy = args[2];
logger.LogInformation(args[0]);
logger.LogInformation(args[1]);
logger.LogInformation(args[2]);
logger.LogInformation(args[3]);
string[] cellInstanceNames = args[3].Split('~');
Dictionary<string, Record> records = GetEquipmentAutomationFrameworkCellInstanceStatus(development: false, staging: false, production: true);
foreach (string cellInstanceName in cellInstanceNames) {
if (!records.TryGetValue(cellInstanceName, out record)) {
logger.LogWarning("{cellInstance} not found!", cellInstanceName);
continue;
}
if (records[cellInstanceName].StateContainsDisabled) {
logger.LogWarning("{cellInstance} not found!", cellInstanceName);
}
status = GetEquipmentAutomationFrameworkCellInstanceStateImageVerbIf(logger, verbBy, cellInstanceName, record);
path = $"/images/{cellInstanceName}_{status.State}.jpg";
logger.LogInformation("{host}) {cellInstanceName} => {state} <{path}>", record.Host, cellInstanceName, status.State, path);
}
}
private static Status GetEquipmentAutomationFrameworkCellInstanceStateImageVerbIf(ILogger<Worker> logger, string verbBy, string cellInstanceName, Record record) {
Status result;
Dictionary<string, DateTime> equipmentAutomationFrameworkTriggers = [];
if (!equipmentAutomationFrameworkTriggers.ContainsKey(cellInstanceName)) {
equipmentAutomationFrameworkTriggers.Add(cellInstanceName, DateTime.MinValue);
}
result = EquipmentAutomationFrameworkCellInstanceStatus(cellInstanceName, record);
if (equipmentAutomationFrameworkTriggers[cellInstanceName] < DateTime.Now.AddSeconds(-60)) {
if (result.State == "Offline") {
EquipmentAutomationFrameworkCellInstanceStart(record.Host, record.Port, cellInstanceName, verbBy);
logger.LogInformation("Start invoked for {cellName}", cellInstanceName);
} else if (result.State == "Warning") {
EquipmentAutomationFrameworkCellInstanceRestart(record.Host, record.Port, cellInstanceName, verbBy);
logger.LogInformation("Restart invoked for {cellName}", cellInstanceName);
}
}
return result;
}
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;
}
private static void EquipmentAutomationFrameworkCellInstanceRestart(string host, int port, string cellName = "R71-HSMS", string verbBy = @"EC\EcMesEaf") {
EquipmentAutomationFrameworkCellInstanceParseCheck();
// Restart
// <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/CreateSequence</a:Action><a:MessageID>urn:uuid:09fd9303-dcfe-4563-803b-678441b12949</a:MessageID><a:To s:mustUnderstand="1">http://eaf-prod.mes.infineon.com:9003/CellControllerManager</a:To></s:Header><s:Body><CreateSequence xmlns="http://schemas.xmlsoap.org/ws/2005/02/rm"><AcksTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></AcksTo><Offer><Identifier>urn:uuid:4f2050da-4287-411b-992f-3126a5b3b35b</Identifier></Offer></CreateSequence></s:Body></s:Envelope>
// <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:fbf34c20-f381-4e82-b81f-b4c1809f14fa</r:Identifier><r:MessageNumber>1</r:MessageNumber></r:Sequence><a:Action s:mustUnderstand="1">http://tempuri.org/ICellControllerManager/RestartAllCellInstances</a:Action><a:MessageID>urn:uuid:c9f80db4-a2c2-4e53-9bed-8ba3a60b653c</a:MessageID><a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo><a:To s:mustUnderstand="1">http://eaf-prod.mes.infineon.com:9003/CellControllerManager</a:To></s:Header><s:Body><RestartAllCellInstances xmlns="http://tempuri.org/"><cellInstances xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><b:string>SP101_FileArchiver</b:string></cellInstances><updateInfo>Restarted by EC\ecphares</updateInfo></RestartAllCellInstances></s:Body></s:Envelope>
// <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:4f2050da-4287-411b-992f-3126a5b3b35b</r:Identifier><r:AcknowledgementRange Lower="1" Upper="1"/></r:SequenceAcknowledgement><r:Sequence s:mustUnderstand="1"><r:Identifier>urn:uuid:fbf34c20-f381-4e82-b81f-b4c1809f14fa</r:Identifier><r:MessageNumber>2</r:MessageNumber><r:LastMessage/></r:Sequence><a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/rm/LastMessage</a:Action><a:To s:mustUnderstand="1">http://eaf-prod.mes.infineon.com:9003/CellControllerManager</a:To></s:Header><s:Body/></s:Envelope>
// <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:4f2050da-4287-411b-992f-3126a5b3b35b</r:Identifier><r:AcknowledgementRange Lower="1" Upper="2"/></r:SequenceAcknowledgement><a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/rm/TerminateSequence</a:Action><a:MessageID>urn:uuid:3b063df5-e6df-47a5-b530-aa380a4c6a38</a:MessageID><a:To s:mustUnderstand="1">http://eaf-prod.mes.infineon.com:9003/CellControllerManager</a:To></s:Header><s:Body><r:TerminateSequence><r:Identifier>urn:uuid:fbf34c20-f381-4e82-b81f-b4c1809f14fa</r:Identifier></r:TerminateSequence></s:Body></s:Envelope>
EquipmentAutomationFrameworkCellInstanceVerb(host, port, cellName, verbBy, restart: true, stop: false, start: false);
}
private static void EquipmentAutomationFrameworkCellInstanceStart(string host, int port, string cellName = "R71-HSMS", string verbBy = @"EC\EcMesEaf") {
EquipmentAutomationFrameworkCellInstanceParseCheck();
// Start
// <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/CreateSequence</a:Action><a:MessageID>urn:uuid:a1188d61-df04-4955-b1e4-b90faff95d4d</a:MessageID><a:To s:mustUnderstand="1">http://eaf-prod.mes.infineon.com:9003/CellControllerManager</a:To></s:Header><s:Body><CreateSequence xmlns="http://schemas.xmlsoap.org/ws/2005/02/rm"><AcksTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></AcksTo><Offer><Identifier>urn:uuid:35310d6d-3d17-419c-9b4f-cf20b705e5c9</Identifier></Offer></CreateSequence></s:Body></s:Envelope>
// <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:739e01d3-5573-48a4-8bbb-53e2dfc344af</r:Identifier><r:MessageNumber>1</r:MessageNumber></r:Sequence><a:Action s:mustUnderstand="1">http://tempuri.org/ICellControllerManager/StartAllCellInstances</a:Action><a:MessageID>urn:uuid:8758eec2-b4dc-4338-ba3d-235aa15e634c</a:MessageID><a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo><a:To s:mustUnderstand="1">http://eaf-prod.mes.infineon.com:9003/CellControllerManager</a:To></s:Header><s:Body><StartAllCellInstances xmlns="http://tempuri.org/"><cellInstances xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><b:string>SP101_FileArchiver</b:string></cellInstances><updateInfo>Started by EC\ecphares</updateInfo></StartAllCellInstances></s:Body></s:Envelope>
// <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:739e01d3-5573-48a4-8bbb-53e2dfc344af</r:Identifier><r:MessageNumber>1</r:MessageNumber></r:Sequence><a:Action s:mustUnderstand="1">http://tempuri.org/ICellControllerManager/StartAllCellInstances</a:Action><a:MessageID>urn:uuid:8758eec2-b4dc-4338-ba3d-235aa15e634c</a:MessageID><a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo><a:To s:mustUnderstand="1">http://eaf-prod.mes.infineon.com:9003/CellControllerManager</a:To></s:Header><s:Body><StartAllCellInstances xmlns="http://tempuri.org/"><cellInstances xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><b:string>SP101_FileArchiver</b:string></cellInstances><updateInfo>Started by EC\ecphares</updateInfo></StartAllCellInstances></s:Body></s:Envelope>
// <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:35310d6d-3d17-419c-9b4f-cf20b705e5c9</r:Identifier><r:AcknowledgementRange Lower="1" Upper="1"/></r:SequenceAcknowledgement><r:Sequence s:mustUnderstand="1"><r:Identifier>urn:uuid:739e01d3-5573-48a4-8bbb-53e2dfc344af</r:Identifier><r:MessageNumber>2</r:MessageNumber><r:LastMessage/></r:Sequence><a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/rm/LastMessage</a:Action><a:To s:mustUnderstand="1">http://eaf-prod.mes.infineon.com:9003/CellControllerManager</a:To></s:Header><s:Body/></s:Envelope>
// <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:35310d6d-3d17-419c-9b4f-cf20b705e5c9</r:Identifier><r:AcknowledgementRange Lower="1" Upper="2"/></r:SequenceAcknowledgement><a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/rm/TerminateSequence</a:Action><a:MessageID>urn:uuid:b2bb5329-c846-4cd1-98a8-343136923702</a:MessageID><a:To s:mustUnderstand="1">http://eaf-prod.mes.infineon.com:9003/CellControllerManager</a:To></s:Header><s:Body><r:TerminateSequence><r:Identifier>urn:uuid:739e01d3-5573-48a4-8bbb-53e2dfc344af</r:Identifier></r:TerminateSequence></s:Body></s:Envelope>
EquipmentAutomationFrameworkCellInstanceVerb(host, port, cellName, verbBy, restart: false, stop: false, start: true);
}
private static void EquipmentAutomationFrameworkCellInstanceVerb(string host, int port, string cellName, string verbBy, bool restart, bool stop, bool start) {
#pragma warning disable SYSLIB0014
WebClient webClient = new();
#pragma warning restore SYSLIB0014
string xml;
string verb;
Envelope? envelope;
string updateInfoVerb;
StringBuilder stringBuilder = new();
string cellControllerManager = $"http://{host}:{port}/CellControllerManager";
if (!restart && !stop && !start) {
throw new Exception();
} else if (restart && stop && start) {
throw new Exception();
} else if (restart) {
updateInfoVerb = "Restarted";
verb = "RestartAllCellInstances";
} else if (stop) {
updateInfoVerb = "Stopped";
verb = "StopAllCellInstancesResponse";
} else if (start) {
updateInfoVerb = "Started";
verb = "StartAllCellInstances";
} else
throw new Exception();
string headerMessageID621 = Guid.NewGuid().ToString();
string bodyIdentifier621 = Guid.NewGuid().ToString();
_ = stringBuilder.Append("<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:a=\"http://www.w3.org/2005/08/addressing\">").
Append("<s:Header><a:Action s:mustUnderstand=\"1\">http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence</a:Action>").
Append("<a:MessageID>urn:uuid:").Append(headerMessageID621).Append("</a:MessageID>").
Append("<a:To s:mustUnderstand=\"1\">").Append(cellControllerManager).Append("</a:To>").
Append("</s:Header><s:Body><CreateSequence xmlns=\"http://schemas.xmlsoap.org/ws/2005/02/rm\"><AcksTo>").
Append("<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></AcksTo><Offer>").
Append("<Identifier>urn:uuid:").Append(bodyIdentifier621).Append("</Identifier>").
Append("</Offer></CreateSequence></s:Body></s:Envelope>");
xml = stringBuilder.ToString();
_ = stringBuilder.Clear();
webClient.Headers.Clear();
webClient.Headers.Add("Accept-Encoding: gzip, deflate");
webClient.Headers.Add("Content-Type: application/soap+xml; charset=utf-8");
xml = webClient.UploadString(cellControllerManager, xml);
envelope = ParseXML<Envelope>(xml, throwExceptions: true);
if (envelope is null || envelope.Body is null || envelope.Body.CreateSequenceResponse is null || string.IsNullOrEmpty(envelope.Body.CreateSequenceResponse.Identifier)) {
throw new Exception("Invalid reply! Example [urn:uuid:f1aa1fa8-9099-48b6-b27f-50e6c098605b]");
}
string headerSequenceIdentifier895 = envelope.Body.CreateSequenceResponse.Identifier["urn:uuid:".Length..];
string headerMessageID895 = Guid.NewGuid().ToString();
_ = stringBuilder.Append("<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\">").
Append("<s:Header><r:Sequence s:mustUnderstand=\"1\">").
Append("<r:Identifier>urn:uuid:").Append(headerSequenceIdentifier895).Append("</r:Identifier>").
Append("<r:MessageNumber>1</r:MessageNumber></r:Sequence>").
Append("<a:Action s:mustUnderstand=\"1\">http://tempuri.org/ICellControllerManager/").Append(verb).Append("</a:Action>").
Append("<a:MessageID>urn:uuid:").Append(headerMessageID895).Append("</a:MessageID>").
Append("<a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo>").
Append("<a:To s:mustUnderstand=\"1\">").Append(cellControllerManager).Append("</a:To>").
Append("</s:Header><s:Body>").
Append('<').Append(verb).Append(" xmlns=\"http://tempuri.org/\">").
Append("<cellInstances xmlns:b=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">").
Append("<b:string>").Append(cellName).Append("</b:string>").
Append("</cellInstances>").
Append("<updateInfo>").Append(updateInfoVerb).Append(" by ").Append(verbBy).Append("</updateInfo>").
Append("</").Append(verb).Append('>').
Append("</s:Body></s:Envelope>");
xml = stringBuilder.ToString();
_ = stringBuilder.Clear();
webClient.Headers.Clear();
webClient.Headers.Add("Accept-Encoding: gzip, deflate");
webClient.Headers.Add("Content-Type: application/soap+xml; charset=utf-8");
xml = webClient.UploadString(cellControllerManager, xml);
_ = ParseXML<Envelope>(xml, throwExceptions: true);
string headerSequenceAcknowledgementIdentifier748 = bodyIdentifier621;
string headerSequenceIdentifier748 = headerSequenceIdentifier895;
_ = stringBuilder.Append("<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\">").
Append("<s:Header><r:SequenceAcknowledgement>").
Append("<r:Identifier>urn:uuid:").Append(headerSequenceAcknowledgementIdentifier748).Append("</r:Identifier>").
Append("<r:AcknowledgementRange Lower=\"1\" Upper=\"1\"/></r:SequenceAcknowledgement><r:Sequence s:mustUnderstand=\"1\">").
Append("<r:Identifier>urn:uuid:").Append(headerSequenceIdentifier748).Append("</r:Identifier>").
Append("<r:MessageNumber>2</r:MessageNumber><r:LastMessage/></r:Sequence>").
Append("<a:Action s:mustUnderstand=\"1\">http://schemas.xmlsoap.org/ws/2005/02/rm/LastMessage</a:Action>").
Append("<a:To s:mustUnderstand=\"1\">").Append(cellControllerManager).Append("</a:To>").
Append("</s:Header><s:Body/></s:Envelope>");
xml = stringBuilder.ToString();
_ = stringBuilder.Clear();
webClient.Headers.Clear();
webClient.Headers.Add("Accept-Encoding: gzip, deflate");
webClient.Headers.Add("Content-Type: application/soap+xml; charset=utf-8");
xml = webClient.UploadString(cellControllerManager, xml);
_ = ParseXML<Envelope>(xml, throwExceptions: true);
string headerSequenceAcknowledgementIdentifier707 = bodyIdentifier621;
string headerMessageID707 = Guid.NewGuid().ToString();
string bodyTerminateSequenceIdentifier707 = headerSequenceIdentifier895;
_ = stringBuilder.Append("<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\">").
Append("<s:Header><r:SequenceAcknowledgement>").
Append("<r:Identifier>urn:uuid:").Append(headerSequenceAcknowledgementIdentifier707).Append("</r:Identifier>").
Append("<r:AcknowledgementRange Lower=\"1\" Upper=\"2\"/></r:SequenceAcknowledgement>").
Append("<a:Action s:mustUnderstand=\"1\">http://schemas.xmlsoap.org/ws/2005/02/rm/TerminateSequence</a:Action>").
Append("<a:MessageID>urn:uuid:").Append(headerMessageID707).Append("</a:MessageID>").
Append("<a:To s:mustUnderstand=\"1\">").Append(cellControllerManager).Append("</a:To>").
Append("</s:Header><s:Body>").
Append("<r:TerminateSequence>").
Append("<r:Identifier>urn:uuid:").Append(bodyTerminateSequenceIdentifier707).Append("</r:Identifier>").
Append("</r:TerminateSequence>").
Append("</s:Body></s:Envelope>");
xml = stringBuilder.ToString();
_ = stringBuilder.Clear();
webClient.Headers.Clear();
webClient.Headers.Add("Accept-Encoding: gzip, deflate");
webClient.Headers.Add("Content-Type: application/soap+xml; charset=utf-8");
xml = webClient.UploadString(cellControllerManager, xml);
_ = ParseXML<Envelope>(xml, throwExceptions: true);
}
}

View File

@ -163,6 +163,12 @@ internal static class HelperDay
ADO2025.PI5.Helper20250505.HyperTextMarkupLanguageToPortableDocumentFormat(logger, args); ADO2025.PI5.Helper20250505.HyperTextMarkupLanguageToPortableDocumentFormat(logger, args);
else if (args[1] == "Day-Helper-2025-05-19") else if (args[1] == "Day-Helper-2025-05-19")
ADO2025.PI6.Helper20250519.LiveSync(logger, args); ADO2025.PI6.Helper20250519.LiveSync(logger, args);
else if (args[1] == "Day-Helper-2025-05-21")
ADO2025.PI6.Helper20250521.MatchDirectory(logger, args);
else if (args[1] == "Day-Helper-2025-06-01")
ADO2025.PI6.Helper20250601.EquipmentAutomationFrameworkStatus(logger, args);
else if (args[1] == "Day-Helper-2025-06-02")
ADO2025.PI6.Helper20250602.EquipmentAutomationFrameworkCellInstanceStateImageVerbIf(logger, args);
else else
throw new Exception(appSettings.Company); throw new Exception(appSettings.Company);
} }