dotnet format --verbosity detailed --severity warn

This commit is contained in:
Mike Phares 2022-02-14 15:02:16 -07:00
parent 0cfcb46ee7
commit 1b77400643
108 changed files with 12133 additions and 14712 deletions

12
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,12 @@
{
"cSpell.words": [
"Epuipment",
"Idrv",
"Irng",
"Rcpe",
"RESIMAPCDE",
"Rsens",
"Smpl",
"Vrng"
]
}

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.Core namespace Adaptation.Eaf.Core;
public class BackboneComponent
{ {
public class BackboneComponent
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.Core namespace Adaptation.Eaf.Core;
public class BackboneStatusCache
{ {
public class BackboneStatusCache
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.Core namespace Adaptation.Eaf.Core;
public interface ILoggingSetupManager
{ {
public interface ILoggingSetupManager
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.Core namespace Adaptation.Eaf.Core;
public class StatusItem
{ {
public class StatusItem
{
}
} }

View File

@ -2,10 +2,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Adaptation.Eaf.Core namespace Adaptation.Eaf.Core;
public class Backbone
{ {
public class Backbone
{
public const string STATE_ERROR = "Error"; public const string STATE_ERROR = "Error";
public const string STATE_OFFLINE = "Offline"; public const string STATE_OFFLINE = "Offline";
public const string STATE_RUNNING = "Running"; public const string STATE_RUNNING = "Running";
@ -30,12 +30,12 @@ namespace Adaptation.Eaf.Core
protected Dictionary<string, BackboneComponent> BackboneComponents { get; } protected Dictionary<string, BackboneComponent> BackboneComponents { get; }
public void AddBackboneComponent(BackboneComponent backboneComponent) { } public void AddBackboneComponent(BackboneComponent backboneComponent) { }
public bool ContainsBackboneComponent(string id) { throw new NotImplementedException(); } public bool ContainsBackboneComponent(string id) => throw new NotImplementedException();
[Obsolete("Use the capabilities exposed via the Status property -> GetAll. Will be removed with next major release.")] [Obsolete("Use the capabilities exposed via the Status property -> GetAll. Will be removed with next major release.")]
public List<StatusItem> GetAllStatuses() { throw new NotImplementedException(); } public List<StatusItem> GetAllStatuses() => throw new NotImplementedException();
public BackboneComponent GetBackboneComponentById(string id) { throw new NotImplementedException(); } public BackboneComponent GetBackboneComponentById(string id) => throw new NotImplementedException();
public List<T> GetBackboneComponentsOfType<T>() { throw new NotImplementedException(); } public List<T> GetBackboneComponentsOfType<T>() => throw new NotImplementedException();
public List<BackboneComponent> GetBackboneComponentsOfType(Type type) { throw new NotImplementedException(); } public List<BackboneComponent> GetBackboneComponentsOfType(Type type) => throw new NotImplementedException();
public void RegisterSubprocess(int pid) { } public void RegisterSubprocess(int pid) { }
[Obsolete("Use the capabilities exposed via the Status property -> SetValue. Will be removed with next major release.")] [Obsolete("Use the capabilities exposed via the Status property -> SetValue. Will be removed with next major release.")]
public void SetStatus(string statusName, string statusValue) { } public void SetStatus(string statusName, string statusValue) { }
@ -44,5 +44,4 @@ namespace Adaptation.Eaf.Core
protected void CloseConnectionOfComponents(List<BackboneComponent> components) { } protected void CloseConnectionOfComponents(List<BackboneComponent> components) { }
protected virtual void StopAllComponents() { } protected virtual void StopAllComponents() { }
protected void StopComponents(List<BackboneComponent> components) { } protected void StopComponents(List<BackboneComponent> components) { }
}
} }

View File

@ -1,10 +1,9 @@
using System; using System;
namespace Adaptation.Eaf.Core.Smtp namespace Adaptation.Eaf.Core.Smtp;
{
public class EmailMessage public class EmailMessage
{ {
public EmailMessage() { } public EmailMessage() { }
public EmailMessage(string subject, string body, MailPriority priority = MailPriority.Normal) { } public EmailMessage(string subject, string body, MailPriority priority = MailPriority.Normal) { }
@ -12,13 +11,11 @@ namespace Adaptation.Eaf.Core.Smtp
public MailPriority Priority { get; } public MailPriority Priority { get; }
public string Subject { get; } public string Subject { get; }
public EmailMessage PriorityHigh() { throw new NotImplementedException(); } public EmailMessage PriorityHigh() => throw new NotImplementedException();
public EmailMessage PriorityLow() { throw new NotImplementedException(); } public EmailMessage PriorityLow() => throw new NotImplementedException();
public EmailMessage PriorityNormal() { throw new NotImplementedException(); } public EmailMessage PriorityNormal() => throw new NotImplementedException();
public EmailMessage SetBody(string body) { throw new NotImplementedException(); } public EmailMessage SetBody(string body) => throw new NotImplementedException();
public EmailMessage SetPriority(MailPriority priority) { throw new NotImplementedException(); } public EmailMessage SetPriority(MailPriority priority) => throw new NotImplementedException();
public EmailMessage SetSubject(string subject) { throw new NotImplementedException(); } public EmailMessage SetSubject(string subject) => throw new NotImplementedException();
}
} }

View File

@ -1,9 +1,6 @@
namespace Adaptation.Eaf.Core.Smtp namespace Adaptation.Eaf.Core.Smtp;
public interface ISmtp
{ {
public interface ISmtp
{
void Send(EmailMessage message); void Send(EmailMessage message);
}
} }

View File

@ -1,11 +1,8 @@
namespace Adaptation.Eaf.Core.Smtp namespace Adaptation.Eaf.Core.Smtp;
{
public enum MailPriority public enum MailPriority
{ {
Low = 0, Low = 0,
Normal = 1, Normal = 1,
High = 2 High = 2
}
} }

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.EquipmentCore.Control namespace Adaptation.Eaf.EquipmentCore.Control;
public class ChangeDataCollectionHandler
{ {
public class ChangeDataCollectionHandler
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.EquipmentCore.Control namespace Adaptation.Eaf.EquipmentCore.Control;
public class DataCollectionRequest
{ {
public class DataCollectionRequest
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.EquipmentCore.Control namespace Adaptation.Eaf.EquipmentCore.Control;
public class EquipmentEvent
{ {
public class EquipmentEvent
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.EquipmentCore.Control namespace Adaptation.Eaf.EquipmentCore.Control;
public class EquipmentException
{ {
public class EquipmentException
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.EquipmentCore.Control namespace Adaptation.Eaf.EquipmentCore.Control;
public class EquipmentSelfDescription
{ {
public class EquipmentSelfDescription
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.EquipmentCore.Control namespace Adaptation.Eaf.EquipmentCore.Control;
public class GetParameterValuesHandler
{ {
public class GetParameterValuesHandler
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.EquipmentCore.Control namespace Adaptation.Eaf.EquipmentCore.Control;
public interface IConnectionControl
{ {
public interface IConnectionControl
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.EquipmentCore.Control namespace Adaptation.Eaf.EquipmentCore.Control;
public interface IDataTracingHandler
{ {
public interface IDataTracingHandler
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.EquipmentCore.Control namespace Adaptation.Eaf.EquipmentCore.Control;
public interface IEquipmentCommandService
{ {
public interface IEquipmentCommandService
{
}
} }

View File

@ -1,9 +1,9 @@
using Adaptation.PeerGroup.GCL.Annotations; using Adaptation.PeerGroup.GCL.Annotations;
namespace Adaptation.Eaf.EquipmentCore.Control namespace Adaptation.Eaf.EquipmentCore.Control;
public interface IEquipmentControl : IPackageSource
{ {
public interface IEquipmentControl : IPackageSource
{
[NotNull] [NotNull]
IEquipmentSelfDescriptionBuilder SelfDescriptionBuilder { get; } IEquipmentSelfDescriptionBuilder SelfDescriptionBuilder { get; }
[NotNull] [NotNull]
@ -12,5 +12,4 @@ namespace Adaptation.Eaf.EquipmentCore.Control
IEquipmentCommandService Commands { get; } IEquipmentCommandService Commands { get; }
[NotNull] [NotNull]
IConnectionControl Connection { get; } IConnectionControl Connection { get; }
}
} }

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.EquipmentCore.Control namespace Adaptation.Eaf.EquipmentCore.Control;
public interface IEquipmentSelfDescriptionBuilder
{ {
public interface IEquipmentSelfDescriptionBuilder
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.EquipmentCore.Control namespace Adaptation.Eaf.EquipmentCore.Control;
public interface IPackage
{ {
public interface IPackage
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.EquipmentCore.Control namespace Adaptation.Eaf.EquipmentCore.Control;
public interface ISelfDescriptionLookup
{ {
public interface ISelfDescriptionLookup
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.EquipmentCore.Control namespace Adaptation.Eaf.EquipmentCore.Control;
public interface IVirtualParameterValuesHandler
{ {
public interface IVirtualParameterValuesHandler
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.EquipmentCore.Control namespace Adaptation.Eaf.EquipmentCore.Control;
public class SetParameterValuesHandler
{ {
public class SetParameterValuesHandler
{
}
} }

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.EquipmentCore.Control namespace Adaptation.Eaf.EquipmentCore.Control;
public class TraceRequest
{ {
public class TraceRequest
{
}
} }

View File

@ -3,10 +3,10 @@ using Adaptation.Eaf.EquipmentCore.SelfDescription.ElementDescription;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Adaptation.Eaf.EquipmentCore.Control namespace Adaptation.Eaf.EquipmentCore.Control;
public interface IEquipmentDataCollection
{ {
public interface IEquipmentDataCollection
{
IVirtualParameterValuesHandler VirtualParameterValuesHandler { get; } IVirtualParameterValuesHandler VirtualParameterValuesHandler { get; }
ISelfDescriptionLookup SelfDescriptionLookup { get; } ISelfDescriptionLookup SelfDescriptionLookup { get; }
EquipmentSelfDescription SelfDescription { get; } EquipmentSelfDescription SelfDescription { get; }
@ -35,5 +35,4 @@ namespace Adaptation.Eaf.EquipmentCore.Control
void TriggerTraceSample(TraceRequest traceRequest, long sampleId, IEnumerable<ParameterValue> parameters); void TriggerTraceSample(TraceRequest traceRequest, long sampleId, IEnumerable<ParameterValue> parameters);
void TriggerTraceSample(TraceRequest traceRequest, long sampleId, IEnumerable<ParameterValue> parameters, IPackage sourcePackage); void TriggerTraceSample(TraceRequest traceRequest, long sampleId, IEnumerable<ParameterValue> parameters, IPackage sourcePackage);
void TriggerTraceSample(TraceRequest traceRequest, long sampleId, IEnumerable<ParameterValue> parameters, DateTime equipmentTimeStamp); void TriggerTraceSample(TraceRequest traceRequest, long sampleId, IEnumerable<ParameterValue> parameters, DateTime equipmentTimeStamp);
}
} }

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.EquipmentCore.Control namespace Adaptation.Eaf.EquipmentCore.Control;
public interface IPackageSource
{ {
public interface IPackageSource
{
}
} }

View File

@ -2,10 +2,10 @@
using Adaptation.PeerGroup.GCL.Annotations; using Adaptation.PeerGroup.GCL.Annotations;
using System; using System;
namespace Adaptation.Eaf.EquipmentCore.DataCollection.Reporting namespace Adaptation.Eaf.EquipmentCore.DataCollection.Reporting;
public class ParameterValue
{ {
public class ParameterValue
{
public ParameterValue(EquipmentParameter definition, object value) { } public ParameterValue(EquipmentParameter definition, object value) { }
public ParameterValue(EquipmentParameter definition, object value, DateTime timestamp) { } public ParameterValue(EquipmentParameter definition, object value, DateTime timestamp) { }
@ -14,7 +14,6 @@ namespace Adaptation.Eaf.EquipmentCore.DataCollection.Reporting
public EquipmentParameter Definition { get; } public EquipmentParameter Definition { get; }
public DateTime Timestamp { get; protected set; } public DateTime Timestamp { get; protected set; }
public virtual ParameterValue Clone(EquipmentParameter newDefinition) { throw new NotImplementedException(); } public virtual ParameterValue Clone(EquipmentParameter newDefinition) => throw new NotImplementedException();
public override string ToString() { return base.ToString(); } public override string ToString() => base.ToString();
}
} }

View File

@ -1,9 +1,9 @@
using Adaptation.Eaf.EquipmentCore.SelfDescription.ParameterTypes; using Adaptation.Eaf.EquipmentCore.SelfDescription.ParameterTypes;
namespace Adaptation.Eaf.EquipmentCore.SelfDescription.ElementDescription namespace Adaptation.Eaf.EquipmentCore.SelfDescription.ElementDescription;
public class EquipmentParameter
{ {
public class EquipmentParameter
{
public EquipmentParameter(EquipmentParameter source, ParameterTypeDefinition typeDefinition) { } public EquipmentParameter(EquipmentParameter source, ParameterTypeDefinition typeDefinition) { }
public EquipmentParameter(string name, ParameterTypeDefinition typeDefinition, string description, bool isTransient = false, bool isReadOnly = true) { } public EquipmentParameter(string name, ParameterTypeDefinition typeDefinition, string description, bool isTransient = false, bool isReadOnly = true) { }
public EquipmentParameter(string id, string name, ParameterTypeDefinition typeDefinition, string description, bool isTransient = false, bool isReadOnly = true) { } public EquipmentParameter(string id, string name, ParameterTypeDefinition typeDefinition, string description, bool isTransient = false, bool isReadOnly = true) { }
@ -17,8 +17,6 @@ namespace Adaptation.Eaf.EquipmentCore.SelfDescription.ElementDescription
public bool IsTransient { get; } public bool IsTransient { get; }
public bool IsReadOnly { get; } public bool IsReadOnly { get; }
public override string ToString() { return base.ToString(); } public override string ToString() => base.ToString();
public string ToStringWithDetails() { return base.ToString(); } public string ToStringWithDetails() => base.ToString();
}
} }

View File

@ -1,12 +1,11 @@
namespace Adaptation.Eaf.EquipmentCore.SelfDescription.ParameterTypes namespace Adaptation.Eaf.EquipmentCore.SelfDescription.ParameterTypes;
public class Field
{ {
public class Field
{
public Field(string name, string description, bool canBeNull, ParameterTypeDefinition typeDefinition) { } public Field(string name, string description, bool canBeNull, ParameterTypeDefinition typeDefinition) { }
public string Name { get; } public string Name { get; }
public string Description { get; } public string Description { get; }
public ParameterTypeDefinition TypeDefinition { get; } public ParameterTypeDefinition TypeDefinition { get; }
public bool CanBeNull { get; } public bool CanBeNull { get; }
}
} }

View File

@ -1,12 +1,11 @@
namespace Adaptation.Eaf.EquipmentCore.SelfDescription.ParameterTypes namespace Adaptation.Eaf.EquipmentCore.SelfDescription.ParameterTypes;
public abstract class ParameterTypeDefinition
{ {
public abstract class ParameterTypeDefinition
{
public ParameterTypeDefinition(string name, string description) { } public ParameterTypeDefinition(string name, string description) { }
public string Name { get; } public string Name { get; }
public string Description { get; } public string Description { get; }
public override string ToString() { return base.ToString(); } public override string ToString() => base.ToString();
}
} }

View File

@ -1,12 +1,11 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace Adaptation.Eaf.EquipmentCore.SelfDescription.ParameterTypes namespace Adaptation.Eaf.EquipmentCore.SelfDescription.ParameterTypes;
public class StructuredType : ParameterTypeDefinition
{ {
public class StructuredType : ParameterTypeDefinition
{
public StructuredType(string name, string description, IList<Field> fields) : base(name, description) { } public StructuredType(string name, string description, IList<Field> fields) : base(name, description) { }
public IList<Field> Fields { get; } public IList<Field> Fields { get; }
}
} }

View File

@ -1,6 +1,5 @@
namespace Adaptation.Eaf.Management.ConfigurationData.CellAutomation namespace Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
public interface IConfigurationObject
{ {
public interface IConfigurationObject
{
}
} }

View File

@ -1,10 +1,10 @@
using System; using System;
namespace Adaptation.Eaf.Management.ConfigurationData.CellAutomation namespace Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
[System.Runtime.Serialization.DataContractAttribute(IsReference = true)]
public class ModelObjectParameterDefinition : IConfigurationObject
{ {
[System.Runtime.Serialization.DataContractAttribute(IsReference = true)]
public class ModelObjectParameterDefinition : IConfigurationObject
{
public ModelObjectParameterDefinition() { } public ModelObjectParameterDefinition() { }
public ModelObjectParameterDefinition(string name, ModelObjectParameterType valueType, object defaultValue) { } public ModelObjectParameterDefinition(string name, ModelObjectParameterType valueType, object defaultValue) { }
public ModelObjectParameterDefinition(string name, Type enumType, object defaultValue) { } public ModelObjectParameterDefinition(string name, Type enumType, object defaultValue) { }
@ -20,7 +20,6 @@ namespace Adaptation.Eaf.Management.ConfigurationData.CellAutomation
[System.Runtime.Serialization.DataMemberAttribute] [System.Runtime.Serialization.DataMemberAttribute]
public virtual string EnumType { get; set; } public virtual string EnumType { get; set; }
public virtual ModelObjectParameterDefinition Clone() { return null; } public virtual ModelObjectParameterDefinition Clone() => null;
public virtual bool IsValidValue(string value) { return false; } public virtual bool IsValidValue(string value) => false;
}
} }

View File

@ -1,7 +1,7 @@
namespace Adaptation.Eaf.Management.ConfigurationData.CellAutomation namespace Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
public enum ModelObjectParameterType
{ {
public enum ModelObjectParameterType
{
String = 0, String = 0,
Bool = 1, Bool = 1,
Byte = 2, Byte = 2,
@ -13,5 +13,4 @@
Double = 8, Double = 8,
Float = 9, Float = 9,
Enum = 10 Enum = 10
}
} }

View File

@ -1,11 +1,11 @@
using Adaptation.PeerGroup.GCL.SecsDriver; using Adaptation.PeerGroup.GCL.SecsDriver;
using System; using System;
namespace Adaptation.Eaf.Management.ConfigurationData.Semiconductor.CellInstances namespace Adaptation.Eaf.Management.ConfigurationData.Semiconductor.CellInstances;
[System.Runtime.Serialization.DataContractAttribute]
public class SecsConnectionConfiguration
{ {
[System.Runtime.Serialization.DataContractAttribute]
public class SecsConnectionConfiguration
{
public SecsConnectionConfiguration() { } public SecsConnectionConfiguration() { }
[System.Runtime.Serialization.DataMemberAttribute] [System.Runtime.Serialization.DataMemberAttribute]
@ -40,5 +40,4 @@ namespace Adaptation.Eaf.Management.ConfigurationData.Semiconductor.CellInstance
public virtual TimeSpan T7ConnectionIdle { get; set; } public virtual TimeSpan T7ConnectionIdle { get; set; }
[System.Runtime.Serialization.DataMemberAttribute] [System.Runtime.Serialization.DataMemberAttribute]
public virtual TimeSpan T8NetworkIntercharacter { get; set; } public virtual TimeSpan T8NetworkIntercharacter { get; set; }
}
} }

View File

@ -0,0 +1,141 @@
using Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
using Adaptation.Shared;
using Adaptation.Shared.Duplicator;
using Adaptation.Shared.Methods;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.Json;
namespace Adaptation.FileHandlers.Archive;
public class FileRead : Shared.FileRead, IFileRead
{
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted)
{
_MinFileLength = 10;
_NullData = string.Empty;
_Logistics = new Logistics(this);
if (_FileParameter is null)
throw new Exception(cellInstanceConnectionName);
if (_ModelObjectParameterDefinitions is null)
throw new Exception(cellInstanceConnectionName);
if (!_IsDuplicator)
throw new Exception(cellInstanceConnectionName);
}
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) => Move(extractResults, exception);
void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
string IFileRead.GetEventDescription()
{
string result = _Description.GetEventDescription();
return result;
}
List<string> IFileRead.GetHeaderNames()
{
List<string> results = _Description.GetHeaderNames();
return results;
}
string[] IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception)
{
string[] results = Move(extractResults, to, from, resolvedFileLocation, exception);
return results;
}
JsonProperty[] IFileRead.GetDefault()
{
JsonProperty[] results = _Description.GetDefault(this, _Logistics);
return results;
}
Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement()
{
Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this);
return results;
}
List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData)
{
List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData);
return results;
}
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.GetExtractResult(string reportFullPath, string eventName)
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
if (string.IsNullOrEmpty(eventName))
throw new Exception();
_ReportFullPath = reportFullPath;
DateTime dateTime = DateTime.Now;
results = GetExtractResult(reportFullPath, dateTime);
if (results.Item3 is null)
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(results.Item1, Array.Empty<Test>(), JsonSerializer.Deserialize<JsonElement[]>("[]"), results.Item4);
if (results.Item3.Length > 0 && _IsEAFHosted)
WritePDSF(this, results.Item3);
UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks);
return results;
}
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.ReExtract()
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
List<string> headerNames = _Description.GetHeaderNames();
Dictionary<string, string> keyValuePairs = _Description.GetDisplayNamesJsonElement(this);
results = ReExtract(this, headerNames, keyValuePairs);
return results;
}
void IFileRead.CheckTests(Test[] tests, bool extra)
{
if (_Description is not Description)
throw new Exception();
}
void IFileRead.Callback(object state) => throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
private void MoveArchive(DateTime dateTime)
{
if (dateTime == DateTime.MinValue)
{ }
string logisticsSequence = _Logistics.Sequence.ToString();
string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
string weekDirectory = string.Concat(_Logistics.DateTimeFromSequence.ToString("yyyy"), "_Week_", weekOfYear, @"\", _Logistics.DateTimeFromSequence.ToString("yyyy-MM-dd"));
string jobIdDirectory = string.Concat(_FileConnectorConfiguration.TargetFileLocation, @"\", _Logistics.JobID);
if (!Directory.Exists(jobIdDirectory))
_ = Directory.CreateDirectory(jobIdDirectory);
//string destinationArchiveDirectory = string.Concat(jobIdDirectory, @"\!Archive\", weekDirectory);
string destinationArchiveDirectory = string.Concat(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation), @"\Archive\", _Logistics.JobID, @"\", weekDirectory);
if (!Directory.Exists(destinationArchiveDirectory))
_ = Directory.CreateDirectory(destinationArchiveDirectory);
string[] matchDirectories = new string[] { GetDirectoriesRecursively(jobIdDirectory, logisticsSequence).FirstOrDefault() };
if ((matchDirectories is null) || matchDirectories.Length != 1)
throw new Exception("Didn't find directory by logistics sequence");
string sourceDirectory = Path.GetDirectoryName(matchDirectories[0]);
destinationArchiveDirectory = string.Concat(destinationArchiveDirectory, @"\", Path.GetFileName(sourceDirectory));
Directory.Move(sourceDirectory, destinationArchiveDirectory);
}
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
_Logistics = new Logistics(reportFullPath, pdsf.Item1);
SetFileParameterLotIDToLogisticsMID();
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf);
List<Shared.Properties.IDescription> descriptions = GetDuplicatorDescriptions(jsonElements);
Tuple<Test[], Dictionary<Test, List<Shared.Properties.IDescription>>> tuple = GetTuple(this, descriptions, extra: false);
MoveArchive(dateTime);
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tuple.Item1, jsonElements, new List<FileInfo>());
return results;
}
}

View File

@ -4,32 +4,37 @@ using Adaptation.Shared.Methods;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Adaptation.FileHandlers namespace Adaptation.FileHandlers;
{
public class CellInstanceConnectionName public class CellInstanceConnectionName
{ {
internal static IFileRead Get(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted) internal static IFileRead Get(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted)
{ {
IFileRead result; IFileRead result;
int levelIsArchive = 7;
int levelIsXToArchive = 6;
bool isDuplicator = cellInstanceConnectionName.StartsWith(cellInstanceName); bool isDuplicator = cellInstanceConnectionName.StartsWith(cellInstanceName);
if (isDuplicator) if (isDuplicator)
result = new MET08RESIMAPCDE.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted, levelIsXToArchive, levelIsArchive); {
string cellInstanceConnectionNameBase = cellInstanceConnectionName.Replace("-", string.Empty);
int hyphens = cellInstanceConnectionName.Length - cellInstanceConnectionNameBase.Length;
result = hyphens switch
{
(int)MET08RESIMAPCDE.Hyphen.IsArchive => new Archive.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted),
(int)MET08RESIMAPCDE.Hyphen.IsDummy => new Dummy.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted),
(int)MET08RESIMAPCDE.Hyphen.IsXToArchive => new ToArchive.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted),
_ => new MET08RESIMAPCDE.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted)
};
}
else else
{ {
result = cellInstanceConnectionName switch result = cellInstanceConnectionName switch
{ {
nameof(DownloadRsMFile) => new DownloadRsMFile.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted, levelIsXToArchive, levelIsArchive), nameof(DownloadRsMFile) => new DownloadRsMFile.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted),
nameof(RsM) => new RsM.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted, levelIsXToArchive, levelIsArchive), nameof(RsM) => new RsM.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted),
_ => throw new Exception(), _ => throw new Exception(),
}; };
} }
return result; return result;
} }
}
} }

View File

@ -13,18 +13,17 @@ using System.Net;
using System.Text.Json; using System.Text.Json;
using System.Threading; using System.Threading;
namespace Adaptation.FileHandlers.DownloadRsMFile namespace Adaptation.FileHandlers.DownloadRsMFile;
{
public class FileRead : Shared.FileRead, IFileRead public class FileRead : Shared.FileRead, IFileRead
{ {
private readonly Timer _Timer; private readonly Timer _Timer;
private readonly WebClient _WebClient; private readonly WebClient _WebClient;
private readonly string _StaticFileServer; private readonly string _StaticFileServer;
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted, int hyphenXToArchive, int hyphenIsArchive) : public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted, hyphenXToArchive, hyphenIsArchive) base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted)
{ {
_MinFileLength = 10; _MinFileLength = 10;
_NullData = string.Empty; _NullData = string.Empty;
@ -46,15 +45,9 @@ namespace Adaptation.FileHandlers.DownloadRsMFile
} }
} }
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) => Move(extractResults, exception);
{
Move(this, extractResults, exception);
}
void IFileRead.WaitForThread() void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
{
WaitForThread(thread: null, threadExceptions: null);
}
string IFileRead.GetEventDescription() string IFileRead.GetEventDescription()
{ {
@ -117,20 +110,9 @@ namespace Adaptation.FileHandlers.DownloadRsMFile
return results; return results;
} }
void IFileRead.CheckTests(Test[] tests, bool extra) void IFileRead.CheckTests(Test[] tests, bool extra) => throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
{
throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
}
void IFileRead.MoveArchive() void IFileRead.Callback(object state) => Callback(state);
{
throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
}
void IFileRead.Callback(object state)
{
Callback(state);
}
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime) private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
{ {
@ -217,7 +199,7 @@ namespace Adaptation.FileHandlers.DownloadRsMFile
continue; continue;
targetFileInfo = new FileInfo(Path.Combine(_FileConnectorConfiguration.TargetFileLocation, runFullFileName)); targetFileInfo = new FileInfo(Path.Combine(_FileConnectorConfiguration.TargetFileLocation, runFullFileName));
if (!Directory.Exists(targetFileInfo.Directory.FullName)) if (!Directory.Exists(targetFileInfo.Directory.FullName))
Directory.CreateDirectory(targetFileInfo.Directory.FullName); _ = Directory.CreateDirectory(targetFileInfo.Directory.FullName);
if (targetFileInfo.Exists && targetFileInfo.LastWriteTime == matchNginxFileSystemDateTime) if (targetFileInfo.Exists && targetFileInfo.LastWriteTime == matchNginxFileSystemDateTime)
continue; continue;
alternateFileInfo = new(Path.Combine(_FileConnectorConfiguration.AlternateTargetFolder, matchNginxFileSystem.Name)); alternateFileInfo = new(Path.Combine(_FileConnectorConfiguration.AlternateTargetFolder, matchNginxFileSystem.Name));
@ -266,7 +248,7 @@ namespace Adaptation.FileHandlers.DownloadRsMFile
try try
{ {
TimeSpan timeSpan = new(DateTime.Now.AddSeconds(_FileConnectorConfiguration.FileScanningIntervalInSeconds.Value).Ticks - DateTime.Now.Ticks); TimeSpan timeSpan = new(DateTime.Now.AddSeconds(_FileConnectorConfiguration.FileScanningIntervalInSeconds.Value).Ticks - DateTime.Now.Ticks);
_Timer.Change((long)timeSpan.TotalMilliseconds, Timeout.Infinite); _ = _Timer.Change((long)timeSpan.TotalMilliseconds, Timeout.Infinite);
} }
catch (Exception exception) catch (Exception exception)
{ {
@ -278,6 +260,4 @@ namespace Adaptation.FileHandlers.DownloadRsMFile
} }
} }
}
} }

View File

@ -1,12 +1,11 @@
namespace Adaptation.FileHandlers.DownloadRsMFile namespace Adaptation.FileHandlers.DownloadRsMFile;
internal class NginxFileSystem
{ {
internal class NginxFileSystem
{
public string Name { get; set; } public string Name { get; set; }
public string Type { get; set; } public string Type { get; set; }
public string MTime { get; set; } public string MTime { get; set; }
public float Size { get; set; } public float Size { get; set; }
}
} }

View File

@ -0,0 +1,308 @@
using Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
using Adaptation.Shared;
using Adaptation.Shared.Duplicator;
using Adaptation.Shared.Methods;
using Infineon.Monitoring.MonA;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text.Json;
using System.Threading;
namespace Adaptation.FileHandlers.Dummy;
public class FileRead : Shared.FileRead, IFileRead
{
private readonly Timer _Timer;
private int _LastDummyRunIndex;
private readonly string[] _CellNames;
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted)
{
_MinFileLength = 10;
_NullData = string.Empty;
_Logistics = new Logistics(this);
if (_FileParameter is null)
throw new Exception(cellInstanceConnectionName);
if (_ModelObjectParameterDefinitions is null)
throw new Exception(cellInstanceConnectionName);
if (!_IsDuplicator)
throw new Exception(cellInstanceConnectionName);
_LastDummyRunIndex = -1;
List<string> cellNames = new();
_Timer = new Timer(Callback, null, Timeout.Infinite, Timeout.Infinite);
ModelObjectParameterDefinition[] cellInstanceCollection = GetProperties(cellInstanceConnectionName, modelObjectParameters, "CellInstance.", ".Alias");
foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in cellInstanceCollection)
cellNames.Add(modelObjectParameterDefinition.Name.Split('.')[1]);
_CellNames = cellNames.ToArray();
if (Debugger.IsAttached || fileConnectorConfiguration.PreProcessingMode == FileConnectorConfiguration.PreProcessingModeEnum.Process)
Callback(null);
else
{
TimeSpan timeSpan = new(DateTime.Now.AddSeconds(_FileConnectorConfiguration.FileScanningIntervalInSeconds.Value).Ticks - DateTime.Now.Ticks);
_ = _Timer.Change((long)timeSpan.TotalMilliseconds, Timeout.Infinite);
}
}
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) => Move(extractResults, exception);
void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
string IFileRead.GetEventDescription()
{
string result = _Description.GetEventDescription();
return result;
}
List<string> IFileRead.GetHeaderNames()
{
List<string> results = _Description.GetHeaderNames();
return results;
}
string[] IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception)
{
string[] results = Move(extractResults, to, from, resolvedFileLocation, exception);
return results;
}
JsonProperty[] IFileRead.GetDefault()
{
JsonProperty[] results = _Description.GetDefault(this, _Logistics);
return results;
}
Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement()
{
Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this);
return results;
}
List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData)
{
List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData);
return results;
}
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.GetExtractResult(string reportFullPath, string eventName) => throw new Exception(string.Concat("See ", nameof(CallbackFileExists)));
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.ReExtract() => throw new Exception(string.Concat("See ", nameof(CallbackFileExists)));
void IFileRead.CheckTests(Test[] tests, bool extra)
{
if (_Description is not Description)
throw new Exception();
}
void IFileRead.Callback(object state) => Callback(state);
private void CallbackInProcessCleared(string sourceArchiveFile, string traceDummyFile, string targetFileLocation, string monARessource, string inProcessDirectory, long sequence, bool warning)
{
const string site = "sjc";
string stateName = string.Concat("Dummy_", _EventName);
const string monInURL = "http://moninhttp.sjc.infineon.com/input/text";
MonIn monIn = MonIn.GetInstance(monInURL);
try
{
if (warning)
{
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Warning.ToString() });
_ = monIn.SendStatus(site, monARessource, stateName, State.Warning);
for (int i = 1; i < 12; i++)
Thread.Sleep(500);
}
ZipFile.ExtractToDirectory(sourceArchiveFile, inProcessDirectory);
string[] files = Directory.GetFiles(inProcessDirectory, "*", SearchOption.TopDirectoryOnly);
if (files.Length > 250)
throw new Exception("Safety net!");
foreach (string file in files)
File.SetLastWriteTime(file, new DateTime(sequence));
if (!_FileConnectorConfiguration.IncludeSubDirectories.Value)
{
foreach (string file in files)
File.Move(file, Path.Combine(targetFileLocation, Path.GetFileName(file)));
}
else
{
string[] directories = Directory.GetDirectories(inProcessDirectory, "*", SearchOption.AllDirectories);
foreach (string directory in directories)
_ = Directory.CreateDirectory(string.Concat(targetFileLocation, directory.Substring(inProcessDirectory.Length)));
foreach (string file in files)
File.Move(file, string.Concat(targetFileLocation, file.Substring(inProcessDirectory.Length)));
}
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Ok.ToString() });
_ = monIn.SendStatus(site, monARessource, stateName, State.Ok);
}
catch (Exception exception)
{
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
try
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
catch (Exception) { }
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Critical.ToString(), exception.Message, exception.StackTrace });
_ = monIn.SendStatus(site, monARessource, stateName, State.Critical);
}
}
private void CallbackFileExists(string sourceArchiveFile, string traceDummyFile, string targetFileLocation, string monARessource, long sequence)
{
string[] files;
bool warning = false;
if (!_DummyRuns.ContainsKey(monARessource))
_DummyRuns.Add(monARessource, new List<long>());
if (!_DummyRuns[monARessource].Contains(sequence))
_DummyRuns[monARessource].Add(sequence);
File.AppendAllLines(traceDummyFile, new string[] { sourceArchiveFile });
string inProcessDirectory = Path.Combine(_ProgressPath, "Dummy In-Process", sequence.ToString());
if (!Directory.Exists(inProcessDirectory))
_ = Directory.CreateDirectory(inProcessDirectory);
files = Directory.GetFiles(inProcessDirectory, "*", SearchOption.AllDirectories);
if (files.Any())
{
if (files.Length > 250)
throw new Exception("Safety net!");
try
{
foreach (string file in files)
File.Delete(file);
}
catch (Exception) { }
}
if (_FileConnectorConfiguration.IncludeSubDirectories.Value)
files = Directory.GetFiles(targetFileLocation, "*", SearchOption.AllDirectories);
else
files = Directory.GetFiles(targetFileLocation, "*", SearchOption.TopDirectoryOnly);
foreach (string file in files)
{
if (new FileInfo(file).LastWriteTime.Ticks == sequence)
{
warning = true;
break;
}
}
CallbackInProcessCleared(sourceArchiveFile, traceDummyFile, targetFileLocation, monARessource, inProcessDirectory, sequence, warning);
}
private string GetCellName(string pathSegment)
{
string result = string.Empty;
foreach (string cellName in _CellNames)
{
if (pathSegment.ToLower().Contains(cellName.ToLower()))
{
result = cellName;
break;
}
}
if (string.IsNullOrEmpty(result))
{
int count;
List<(string CellName, int Count)> cellNames = new();
foreach (string cellName in _CellNames)
{
count = 0;
foreach (char @char in cellName.ToLower())
count += pathSegment.Length - pathSegment.ToLower().Replace(@char.ToString(), string.Empty).Length;
cellNames.Add(new(cellName, count));
}
result = (from l in cellNames orderby l.CellName.Length, l.Count descending select l.CellName).First();
}
return result;
}
private void Callback(object state)
{
try
{
string pathSegment;
string monARessource;
DateTime dateTime = DateTime.Now;
if (!_FileConnectorConfiguration.TargetFileLocation.Contains(_FileConnectorConfiguration.SourceFileLocation))
throw new Exception("Target must start with source");
bool check = (dateTime.Hour > 7 && dateTime.Hour < 18 && dateTime.DayOfWeek != DayOfWeek.Sunday && dateTime.DayOfWeek != DayOfWeek.Saturday);
if (!_IsEAFHosted || check)
{
string checkSegment;
string checkDirectory;
string sourceFileFilter;
string sourceArchiveFile;
string sourceFileLocation;
string weekOfYear = _Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
string traceDummyDirectory = Path.Combine(Path.GetPathRoot(_TracePath), "TracesDummy", _CellInstanceName, "Source", $"{dateTime:yyyy}___Week_{weekOfYear}");
if (!Directory.Exists(traceDummyDirectory))
_ = Directory.CreateDirectory(traceDummyDirectory);
string traceDummyFile = Path.Combine(traceDummyDirectory, $"{dateTime.Ticks} - {_CellInstanceName}.txt");
File.AppendAllText(traceDummyFile, string.Empty);
if (_FileConnectorConfiguration.SourceFileLocation.EndsWith("\\"))
sourceFileLocation = _FileConnectorConfiguration.SourceFileLocation;
else
sourceFileLocation = string.Concat(_FileConnectorConfiguration.SourceFileLocation, '\\');
for (int i = 0; i < _FileConnectorConfiguration.SourceFileFilters.Count; i++)
{
_LastDummyRunIndex += 1;
if (_LastDummyRunIndex >= _FileConnectorConfiguration.SourceFileFilters.Count)
_LastDummyRunIndex = 0;
sourceFileFilter = _FileConnectorConfiguration.SourceFileFilters[_LastDummyRunIndex];
sourceArchiveFile = Path.GetFullPath(string.Concat(sourceFileLocation, sourceFileFilter));
if (File.Exists(sourceArchiveFile))
{
checkSegment = _FileConnectorConfiguration.TargetFileLocation.Substring(sourceFileLocation.Length);
checkDirectory = Path.GetDirectoryName(sourceArchiveFile);
for (int z = 0; z < int.MaxValue; z++)
{
if (checkDirectory.Length < sourceFileLocation.Length || !checkDirectory.StartsWith(sourceFileLocation))
break;
checkDirectory = Path.GetDirectoryName(checkDirectory);
if (Directory.Exists(Path.Combine(checkDirectory, checkSegment)))
{
checkDirectory = Path.Combine(checkDirectory, checkSegment);
break;
}
}
if (!checkDirectory.EndsWith(checkSegment))
throw new Exception("Could not determine dummy target directory for extract!");
if (!long.TryParse(Path.GetFileNameWithoutExtension(sourceArchiveFile).Replace("x", string.Empty), out long sequence))
throw new Exception("Invalid file name for source archive file!");
pathSegment = checkDirectory.Substring(sourceFileLocation.Length);
monARessource = GetCellName(pathSegment);
if (string.IsNullOrEmpty(monARessource))
throw new Exception("Could not determine which cell archive file is associated with!");
if (_IsEAFHosted)
CallbackFileExists(sourceArchiveFile, traceDummyFile, checkDirectory, monARessource, sequence);
break;
}
}
}
}
catch (Exception exception)
{
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
try
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
catch (Exception) { }
}
try
{
TimeSpan timeSpan = new(DateTime.Now.AddSeconds(_FileConnectorConfiguration.FileScanningIntervalInSeconds.Value).Ticks - DateTime.Now.Ticks);
_ = _Timer.Change((long)timeSpan.TotalMilliseconds, Timeout.Infinite);
}
catch (Exception exception)
{
string subject = string.Concat("Exception:", _CellInstanceConnectionName);
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
try
{ _SMTP.SendHighPriorityEmailMessage(subject, body); }
catch (Exception) { }
}
}
}

View File

@ -16,11 +16,10 @@ using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using System.Threading; using System.Threading;
namespace Adaptation.FileHandlers.MET08RESIMAPCDE namespace Adaptation.FileHandlers.MET08RESIMAPCDE;
{
public class FileRead : Shared.FileRead, IFileRead public class FileRead : Shared.FileRead, IFileRead
{ {
private readonly Timer _Timer; private readonly Timer _Timer;
private int _LastDummyRunIndex; private int _LastDummyRunIndex;
@ -39,8 +38,8 @@ namespace Adaptation.FileHandlers.MET08RESIMAPCDE
private readonly int _HyphenIsXToOpenInsightMetrologyViewer; private readonly int _HyphenIsXToOpenInsightMetrologyViewer;
private readonly int _HyphenIsXToOpenInsightMetrologyViewerAttachments; private readonly int _HyphenIsXToOpenInsightMetrologyViewerAttachments;
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted, int hyphenXToArchive, int hyphenIsArchive) : public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted, hyphenXToArchive, hyphenIsArchive) base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted)
{ {
_MinFileLength = 10; _MinFileLength = 10;
_NullData = string.Empty; _NullData = string.Empty;
@ -51,10 +50,6 @@ namespace Adaptation.FileHandlers.MET08RESIMAPCDE
throw new Exception(cellInstanceConnectionName); throw new Exception(cellInstanceConnectionName);
if (!_IsDuplicator) if (!_IsDuplicator)
throw new Exception(cellInstanceConnectionName); throw new Exception(cellInstanceConnectionName);
if (hyphenIsArchive != (int)Hyphen.IsArchive)
throw new Exception(cellInstanceConnectionName);
if (hyphenXToArchive != (int)Hyphen.IsXToArchive)
throw new Exception(cellInstanceConnectionName);
_LastDummyRunIndex = -1; _LastDummyRunIndex = -1;
if (_HyphenIsNaEDA == 0) if (_HyphenIsNaEDA == 0)
{ } { }
@ -96,15 +91,9 @@ namespace Adaptation.FileHandlers.MET08RESIMAPCDE
} }
} }
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) => Move(extractResults, exception);
{
Move(this, extractResults, exception);
}
void IFileRead.WaitForThread() void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
{
WaitForThread(thread: null, threadExceptions: null);
}
string IFileRead.GetEventDescription() string IFileRead.GetEventDescription()
{ {
@ -169,34 +158,11 @@ namespace Adaptation.FileHandlers.MET08RESIMAPCDE
void IFileRead.CheckTests(Test[] tests, bool extra) void IFileRead.CheckTests(Test[] tests, bool extra)
{ {
if (!(_Description is Description)) if (_Description is not Description)
throw new Exception(); throw new Exception();
} }
void IFileRead.Callback(object state) void IFileRead.Callback(object state) => Callback(state);
{
Callback(state);
}
void IFileRead.MoveArchive()
{
string logisticsSequence = _Logistics.Sequence.ToString();
string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
string weekDirectory = string.Concat(_Logistics.DateTimeFromSequence.ToString("yyyy"), "_Week_", weekOfYear, @"\", _Logistics.DateTimeFromSequence.ToString("yyyy-MM-dd"));
string jobIdDirectory = string.Concat(_FileConnectorConfiguration.TargetFileLocation, @"\", _Logistics.JobID);
if (!Directory.Exists(jobIdDirectory))
Directory.CreateDirectory(jobIdDirectory);
//string destinationArchiveDirectory = string.Concat(jobIdDirectory, @"\!Archive\", weekDirectory);
string destinationArchiveDirectory = string.Concat(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation), @"\Archive\", _Logistics.JobID, @"\", weekDirectory);
if (!Directory.Exists(destinationArchiveDirectory))
Directory.CreateDirectory(destinationArchiveDirectory);
string[] matchDirectories = new string[] { GetDirectoriesRecursively(jobIdDirectory, logisticsSequence).FirstOrDefault() };
if ((matchDirectories is null) || matchDirectories.Length != 1)
throw new Exception("Didn't find directory by logistics sequence");
string sourceDirectory = Path.GetDirectoryName(matchDirectories[0]);
destinationArchiveDirectory = string.Concat(destinationArchiveDirectory, @"\", Path.GetFileName(sourceDirectory));
Directory.Move(sourceDirectory, destinationArchiveDirectory);
}
protected List<pcl.Description> GetDescriptions(JsonElement[] jsonElements) protected List<pcl.Description> GetDescriptions(JsonElement[] jsonElements)
{ {
@ -240,11 +206,11 @@ namespace Adaptation.FileHandlers.MET08RESIMAPCDE
if (segments.Length > 2) if (segments.Length > 2)
duplicateDirectory = string.Concat(duplicateDirectory, @"-", segments[2]); duplicateDirectory = string.Concat(duplicateDirectory, @"-", segments[2]);
if (!Directory.Exists(duplicateDirectory)) if (!Directory.Exists(duplicateDirectory))
Directory.CreateDirectory(duplicateDirectory); _ = Directory.CreateDirectory(duplicateDirectory);
if ((isDummyRun || isNotUsedInsightMetrologyViewerAttachments || _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) && _Hyphens != _HyphenIsXToArchive && _Hyphens != _HyphenIsArchive) if (isDummyRun || isNotUsedInsightMetrologyViewerAttachments || _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
{ {
if (!Directory.Exists(duplicateDirectory)) if (!Directory.Exists(duplicateDirectory))
Directory.CreateDirectory(duplicateDirectory); _ = Directory.CreateDirectory(duplicateDirectory);
string successDirectory; string successDirectory;
if (_Hyphens != _HyphenIsXToAPC) if (_Hyphens != _HyphenIsXToAPC)
successDirectory = string.Empty; successDirectory = string.Empty;
@ -252,7 +218,7 @@ namespace Adaptation.FileHandlers.MET08RESIMAPCDE
{ {
successDirectory = string.Concat(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation), @"\ViewerPath"); successDirectory = string.Concat(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation), @"\ViewerPath");
if (!Directory.Exists(successDirectory)) if (!Directory.Exists(successDirectory))
Directory.CreateDirectory(successDirectory); _ = Directory.CreateDirectory(successDirectory);
} }
List<Tuple<Shared.Properties.IScopeInfo, string>> tuples = new(); List<Tuple<Shared.Properties.IScopeInfo, string>> tuples = new();
string duplicateFile = string.Concat(duplicateDirectory, @"\", Path.GetFileName(reportFullPath)); string duplicateFile = string.Concat(duplicateDirectory, @"\", Path.GetFileName(reportFullPath));
@ -260,7 +226,7 @@ namespace Adaptation.FileHandlers.MET08RESIMAPCDE
string weekDirectory = string.Concat(_Logistics.DateTimeFromSequence.ToString("yyyy"), "_Week_", weekOfYear, @"\", _Logistics.DateTimeFromSequence.ToString("yyyy-MM-dd")); string weekDirectory = string.Concat(_Logistics.DateTimeFromSequence.ToString("yyyy"), "_Week_", weekOfYear, @"\", _Logistics.DateTimeFromSequence.ToString("yyyy-MM-dd"));
string logisticsSequenceMemoryDirectory = string.Concat(_MemoryPath, @"\", _EquipmentType, @"\Source\", weekDirectory, @"\", _Logistics.Sequence); string logisticsSequenceMemoryDirectory = string.Concat(_MemoryPath, @"\", _EquipmentType, @"\Source\", weekDirectory, @"\", _Logistics.Sequence);
if (!Directory.Exists(logisticsSequenceMemoryDirectory)) if (!Directory.Exists(logisticsSequenceMemoryDirectory))
Directory.CreateDirectory(logisticsSequenceMemoryDirectory); _ = Directory.CreateDirectory(logisticsSequenceMemoryDirectory);
if (_Hyphens == _HyphenIsXToAPC) if (_Hyphens == _HyphenIsXToAPC)
{ {
if (!isDummyRun && _IsEAFHosted) if (!isDummyRun && _IsEAFHosted)
@ -318,7 +284,7 @@ namespace Adaptation.FileHandlers.MET08RESIMAPCDE
File.SetLastWriteTime(reportFullPath, fileInfo.CreationTime); File.SetLastWriteTime(reportFullPath, fileInfo.CreationTime);
string jobIdDirectory = string.Concat(Path.GetDirectoryName(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation)), @"\", _Logistics.JobID); string jobIdDirectory = string.Concat(Path.GetDirectoryName(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation)), @"\", _Logistics.JobID);
if (!Directory.Exists(jobIdDirectory)) if (!Directory.Exists(jobIdDirectory))
Directory.CreateDirectory(jobIdDirectory); _ = Directory.CreateDirectory(jobIdDirectory);
string[] matchDirectories; string[] matchDirectories;
if (!_IsEAFHosted) if (!_IsEAFHosted)
matchDirectories = new string[] { Path.GetDirectoryName(Path.GetDirectoryName(reportFullPath)) }; matchDirectories = new string[] { Path.GetDirectoryName(Path.GetDirectoryName(reportFullPath)) };
@ -372,7 +338,7 @@ namespace Adaptation.FileHandlers.MET08RESIMAPCDE
if (fileCount > 0 || string.IsNullOrEmpty(checkDirectory)) if (fileCount > 0 || string.IsNullOrEmpty(checkDirectory))
{ {
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Warning.ToString() }); File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Warning.ToString() });
monIn.SendStatus(site, monARessource, stateName, State.Warning); _ = monIn.SendStatus(site, monARessource, stateName, State.Warning);
for (int i = 1; i < 12; i++) for (int i = 1; i < 12; i++)
Thread.Sleep(500); Thread.Sleep(500);
} }
@ -411,12 +377,12 @@ namespace Adaptation.FileHandlers.MET08RESIMAPCDE
{ {
string[] directories = Directory.GetDirectories(inProcessDirectory, "*", SearchOption.AllDirectories); string[] directories = Directory.GetDirectories(inProcessDirectory, "*", SearchOption.AllDirectories);
foreach (string directory in directories) foreach (string directory in directories)
Directory.CreateDirectory(string.Concat(checkDirectory, directory.Substring(inProcessDirectory.Length))); _ = Directory.CreateDirectory(string.Concat(checkDirectory, directory.Substring(inProcessDirectory.Length)));
foreach (string file in files) foreach (string file in files)
File.Move(file, string.Concat(checkDirectory, file.Substring(inProcessDirectory.Length))); File.Move(file, string.Concat(checkDirectory, file.Substring(inProcessDirectory.Length)));
} }
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Ok.ToString() }); File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Ok.ToString() });
monIn.SendStatus(site, monARessource, stateName, State.Ok); _ = monIn.SendStatus(site, monARessource, stateName, State.Ok);
} }
catch (Exception exception) catch (Exception exception)
{ {
@ -426,7 +392,7 @@ namespace Adaptation.FileHandlers.MET08RESIMAPCDE
{ _SMTP.SendHighPriorityEmailMessage(subject, body); } { _SMTP.SendHighPriorityEmailMessage(subject, body); }
catch (Exception) { } catch (Exception) { }
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Critical.ToString(), exception.Message, exception.StackTrace }); File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Critical.ToString(), exception.Message, exception.StackTrace });
monIn.SendStatus(site, monARessource, stateName, State.Critical); _ = monIn.SendStatus(site, monARessource, stateName, State.Critical);
} }
} }
} }
@ -451,7 +417,7 @@ namespace Adaptation.FileHandlers.MET08RESIMAPCDE
string weekOfYear = _Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00"); string weekOfYear = _Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
string traceDummyDirectory = string.Concat(Path.GetPathRoot(_TracePath), @"\TracesDummy\", _CellInstanceName, @"\Source\", dateTime.ToString("yyyy"), "___Week_", weekOfYear); string traceDummyDirectory = string.Concat(Path.GetPathRoot(_TracePath), @"\TracesDummy\", _CellInstanceName, @"\Source\", dateTime.ToString("yyyy"), "___Week_", weekOfYear);
if (!Directory.Exists(traceDummyDirectory)) if (!Directory.Exists(traceDummyDirectory))
Directory.CreateDirectory(traceDummyDirectory); _ = Directory.CreateDirectory(traceDummyDirectory);
string traceDummyFile = string.Concat(traceDummyDirectory, @"\", dateTime.Ticks, " - ", _CellInstanceName, ".txt"); string traceDummyFile = string.Concat(traceDummyDirectory, @"\", dateTime.Ticks, " - ", _CellInstanceName, ".txt");
File.AppendAllText(traceDummyFile, string.Empty); File.AppendAllText(traceDummyFile, string.Empty);
List<Tuple<string, string, string, string, int>> tuples = new(); List<Tuple<string, string, string, string, int>> tuples = new();
@ -498,7 +464,7 @@ namespace Adaptation.FileHandlers.MET08RESIMAPCDE
inProcessDirectory = string.Concat(progressDirectory, @"\Dummy_in process\", sequence); inProcessDirectory = string.Concat(progressDirectory, @"\Dummy_in process\", sequence);
checkDirectory = inProcessDirectory; checkDirectory = inProcessDirectory;
if (!Directory.Exists(checkDirectory)) if (!Directory.Exists(checkDirectory))
Directory.CreateDirectory(checkDirectory); _ = Directory.CreateDirectory(checkDirectory);
files = Directory.GetFiles(checkDirectory, "*", SearchOption.AllDirectories); files = Directory.GetFiles(checkDirectory, "*", SearchOption.AllDirectories);
fileCount = files.Length; fileCount = files.Length;
if (files.Any()) if (files.Any())
@ -535,7 +501,7 @@ namespace Adaptation.FileHandlers.MET08RESIMAPCDE
try try
{ {
TimeSpan timeSpan = new(DateTime.Now.AddSeconds(_FileConnectorConfiguration.FileScanningIntervalInSeconds.Value).Ticks - DateTime.Now.Ticks); TimeSpan timeSpan = new(DateTime.Now.AddSeconds(_FileConnectorConfiguration.FileScanningIntervalInSeconds.Value).Ticks - DateTime.Now.Ticks);
_Timer.Change((long)timeSpan.TotalMilliseconds, Timeout.Infinite); _ = _Timer.Change((long)timeSpan.TotalMilliseconds, Timeout.Infinite);
} }
catch (Exception exception) catch (Exception exception)
{ {
@ -547,6 +513,4 @@ namespace Adaptation.FileHandlers.MET08RESIMAPCDE
} }
} }
}
} }

View File

@ -1,8 +1,7 @@
namespace Adaptation.FileHandlers.MET08RESIMAPCDE namespace Adaptation.FileHandlers.MET08RESIMAPCDE;
{
public enum Hyphen public enum Hyphen
{ {
IsXToOpenInsightMetrologyViewer, //MetrologyWS.SendData(file, string.Concat("http://", serverName, "/api/inbound/CDE")); IsXToOpenInsightMetrologyViewer, //MetrologyWS.SendData(file, string.Concat("http://", serverName, "/api/inbound/CDE"));
IsXToIQSSi, //NA <d7p1:FileScanningIntervalInSeconds>-361</d7p1:FileScanningIntervalInSeconds> IsXToIQSSi, //NA <d7p1:FileScanningIntervalInSeconds>-361</d7p1:FileScanningIntervalInSeconds>
IsXToOpenInsight, //NA <d7p1:FileScanningIntervalInSeconds>-363</d7p1:FileScanningIntervalInSeconds> IsXToOpenInsight, //NA <d7p1:FileScanningIntervalInSeconds>-363</d7p1:FileScanningIntervalInSeconds>
@ -13,6 +12,4 @@
IsArchive, IsArchive,
IsDummy, IsDummy,
IsNaEDA IsNaEDA
}
} }

View File

@ -4,11 +4,10 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace Adaptation.FileHandlers.MET08RESIMAPCDE namespace Adaptation.FileHandlers.MET08RESIMAPCDE;
{
public class ProcessData public class ProcessData
{ {
internal static List<Tuple<int, Enum, string>> HyphenTuples => new() internal static List<Tuple<int, Enum, string>> HyphenTuples => new()
{ {
@ -51,6 +50,4 @@ namespace Adaptation.FileHandlers.MET08RESIMAPCDE
//Not used //Not used
} }
}
} }

View File

@ -4,11 +4,10 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace Adaptation.FileHandlers.MET08RESIMAPCDE namespace Adaptation.FileHandlers.MET08RESIMAPCDE;
{
public class WSRequest public class WSRequest
{ {
public bool SentToMetrology { get; set; } public bool SentToMetrology { get; set; }
public bool SentToSPC { get; set; } public bool SentToSPC { get; set; }
@ -102,6 +101,4 @@ namespace Adaptation.FileHandlers.MET08RESIMAPCDE
FilePath = onlyWSRequest; FilePath = onlyWSRequest;
} }
}
} }

View File

@ -5,13 +5,11 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.Json; using System.Text.Json;
namespace Adaptation.FileHandlers.RsM namespace Adaptation.FileHandlers.RsM;
public class Description : IDescription
{ {
public class Description : IDescription
{
public int Test { get; set; } public int Test { get; set; }
public int Count { get; set; } public int Count { get; set; }
public int Index { get; set; } public int Index { get; set; }
@ -58,10 +56,7 @@ namespace Adaptation.FileHandlers.RsM
public string UniqueId { get; set; } public string UniqueId { get; set; }
public string Zone { get; set; } public string Zone { get; set; }
string IDescription.GetEventDescription() string IDescription.GetEventDescription() => "File Has been read and parsed";
{
return "File Has been read and parsed";
}
List<string> IDescription.GetNames(IFileRead fileRead, Logistics logistics) List<string> IDescription.GetNames(IFileRead fileRead, Logistics logistics)
{ {
@ -311,6 +306,4 @@ namespace Adaptation.FileHandlers.RsM
return result; return result;
} }
}
} }

View File

@ -1,8 +1,7 @@
namespace Adaptation.FileHandlers.RsM namespace Adaptation.FileHandlers.RsM;
{
public class Detail public class Detail
{ {
public string HeaderUniqueId { get; set; } public string HeaderUniqueId { get; set; }
public string Merit { get; set; } public string Merit { get; set; }
@ -12,11 +11,6 @@
public string T { get; set; } public string T { get; set; }
public string UniqueId { get; set; } public string UniqueId { get; set; }
public override string ToString() public override string ToString() => string.Concat(Merit, ";", Pt, ";", R, ";", Rs, ";", T);
{
return string.Concat(Merit, ";", Pt, ";", R, ";", Rs, ";", T);
}
}
} }

View File

@ -9,14 +9,13 @@ using System.Linq;
using System.Text.Json; using System.Text.Json;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace Adaptation.FileHandlers.RsM namespace Adaptation.FileHandlers.RsM;
public class FileRead : Shared.FileRead, IFileRead
{ {
public class FileRead : Shared.FileRead, IFileRead public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted) :
{ base(new Description(), true, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted)
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted, int hyphenXToArchive, int hyphenIsArchive) :
base(new Description(), true, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted, hyphenXToArchive, hyphenIsArchive)
{ {
_MinFileLength = 10; _MinFileLength = 10;
_NullData = string.Empty; _NullData = string.Empty;
@ -29,15 +28,9 @@ namespace Adaptation.FileHandlers.RsM
throw new Exception(cellInstanceConnectionName); throw new Exception(cellInstanceConnectionName);
} }
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) => Move(extractResults, exception);
{
Move(this, extractResults, exception);
}
void IFileRead.WaitForThread() void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
{
WaitForThread(thread: null, threadExceptions: null);
}
string IFileRead.GetEventDescription() string IFileRead.GetEventDescription()
{ {
@ -100,20 +93,9 @@ namespace Adaptation.FileHandlers.RsM
return results; return results;
} }
void IFileRead.CheckTests(Test[] tests, bool extra) void IFileRead.CheckTests(Test[] tests, bool extra) => throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
{
throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
}
void IFileRead.MoveArchive() void IFileRead.Callback(object state) => throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
{
throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
}
void IFileRead.Callback(object state)
{
throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
}
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime) private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
{ {
@ -144,6 +126,4 @@ namespace Adaptation.FileHandlers.RsM
return results; return results;
} }
}
} }

View File

@ -10,11 +10,10 @@ using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace Adaptation.FileHandlers.RsM namespace Adaptation.FileHandlers.RsM;
{
public class ProcessData : IProcessData public class ProcessData : IProcessData
{ {
private readonly List<object> _Details; private readonly List<object> _Details;
@ -61,10 +60,7 @@ namespace Adaptation.FileHandlers.RsM
Parse(fileRead, logistics, fileInfoCollection); Parse(fileRead, logistics, fileInfoCollection);
} }
string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors) string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors) => throw new Exception(string.Concat("See ", nameof(Parse)));
{
throw new Exception(string.Concat("See ", nameof(Parse)));
}
Tuple<string, Test[], JsonElement[], List<FileInfo>> IProcessData.GetResults(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection) Tuple<string, Test[], JsonElement[], List<FileInfo>> IProcessData.GetResults(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
{ {
@ -255,25 +251,23 @@ namespace Adaptation.FileHandlers.RsM
Lot = Regex.Replace(Lot, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0]; Lot = Regex.Replace(Lot, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
StringBuilder stringBuilder = new(); StringBuilder stringBuilder = new();
string reportFileName = Path.GetFileName(logistics.ReportFullPath); string reportFileName = Path.GetFileName(logistics.ReportFullPath);
stringBuilder.AppendLine($"RUN [{Title}]"); _ = stringBuilder.AppendLine($"RUN [{Title}]");
stringBuilder.AppendLine($"Recipe {Project} \\ {RecipeName} RESISTIVITY {"####"}"); _ = stringBuilder.AppendLine($"Recipe {Project} \\ {RecipeName} RESISTIVITY {"####"}");
stringBuilder.AppendLine($"EQUIP# {EquipId} Engineer {Engineer}"); _ = stringBuilder.AppendLine($"EQUIP# {EquipId} Engineer {Engineer}");
stringBuilder.AppendLine($"LotID {Lot} D.L.RATIO {"#.####"}"); _ = stringBuilder.AppendLine($"LotID {Lot} D.L.RATIO {"#.####"}");
stringBuilder.AppendLine($"OPERATOR {Employee} TEMP {Temp} {DateTime:HH:mm MM/dd/yy}"); _ = stringBuilder.AppendLine($"OPERATOR {Employee} TEMP {Temp} {DateTime:HH:mm MM/dd/yy}");
stringBuilder.AppendLine($"AutoOptimizeGain = {"###"} AutoProbeHeightSet = {"##"}"); _ = stringBuilder.AppendLine($"AutoOptimizeGain = {"###"} AutoProbeHeightSet = {"##"}");
stringBuilder.AppendLine($"DataReject > {"#.#"}Sigma"); _ = stringBuilder.AppendLine($"DataReject > {"#.#"}Sigma");
stringBuilder.AppendLine($"0 ..\\{Project}.prj\\{RecipeName}.rcp\\{reportFileName} {DateTime:HH:mm MM/dd/yy}"); _ = stringBuilder.AppendLine($"0 ..\\{Project}.prj\\{RecipeName}.rcp\\{reportFileName} {DateTime:HH:mm MM/dd/yy}");
stringBuilder.AppendLine($"pt# R Th Rs[Ohm/sq@T] Merit"); _ = stringBuilder.AppendLine($"pt# R Th Rs[Ohm/sq@T] Merit");
for (int i = 0; i < _Details.Count; i++) for (int i = 0; i < _Details.Count; i++)
{ {
if (_Details[i] is not Detail item) if (_Details[i] is not Detail item)
continue; continue;
stringBuilder.AppendLine($"{item.Pt} {item.R} {item.T} {item.Rs} {item.Merit}"); _ = stringBuilder.AppendLine($"{item.Pt} {item.R} {item.T} {item.Rs} {item.Merit}");
} }
stringBuilder.AppendLine($"Avg = {Avg} {StandardDeviationPercentage} SEMI Radial= {"#.##%"}"); _ = stringBuilder.AppendLine($"Avg = {Avg} {StandardDeviationPercentage} SEMI Radial= {"#.##%"}");
LogBody = stringBuilder.ToString(); LogBody = stringBuilder.ToString();
} }
}
} }

View File

@ -0,0 +1,140 @@
using Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
using Adaptation.Shared;
using Adaptation.Shared.Duplicator;
using Adaptation.Shared.Methods;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
namespace Adaptation.FileHandlers.ToArchive;
public class FileRead : Shared.FileRead, IFileRead
{
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted) :
base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted)
{
_MinFileLength = 10;
_NullData = string.Empty;
_Logistics = new Logistics(this);
if (_FileParameter is null)
throw new Exception(cellInstanceConnectionName);
if (_ModelObjectParameterDefinitions is null)
throw new Exception(cellInstanceConnectionName);
if (!_IsDuplicator)
throw new Exception(cellInstanceConnectionName);
}
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception)
{
bool isErrorFile = exception is not null;
if (!isErrorFile && !string.IsNullOrEmpty(_Logistics.ReportFullPath))
{
FileInfo fileInfo = new(_Logistics.ReportFullPath);
if (fileInfo.Exists && fileInfo.LastWriteTime < fileInfo.CreationTime)
File.SetLastWriteTime(_Logistics.ReportFullPath, fileInfo.CreationTime);
}
Move(extractResults, exception);
}
void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
string IFileRead.GetEventDescription()
{
string result = _Description.GetEventDescription();
return result;
}
List<string> IFileRead.GetHeaderNames()
{
List<string> results = _Description.GetHeaderNames();
return results;
}
string[] IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception)
{
string[] results = Move(extractResults, to, from, resolvedFileLocation, exception);
return results;
}
JsonProperty[] IFileRead.GetDefault()
{
JsonProperty[] results = _Description.GetDefault(this, _Logistics);
return results;
}
Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement()
{
Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this);
return results;
}
List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData)
{
List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData);
return results;
}
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.GetExtractResult(string reportFullPath, string eventName)
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
if (string.IsNullOrEmpty(eventName))
throw new Exception();
_ReportFullPath = reportFullPath;
DateTime dateTime = DateTime.Now;
results = GetExtractResult(reportFullPath, dateTime);
if (results.Item3 is null)
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(results.Item1, Array.Empty<Test>(), JsonSerializer.Deserialize<JsonElement[]>("[]"), results.Item4);
if (results.Item3.Length > 0 && _IsEAFHosted)
WritePDSF(this, results.Item3);
UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks);
return results;
}
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.ReExtract()
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
List<string> headerNames = _Description.GetHeaderNames();
Dictionary<string, string> keyValuePairs = _Description.GetDisplayNamesJsonElement(this);
results = ReExtract(this, headerNames, keyValuePairs);
return results;
}
void IFileRead.CheckTests(Test[] tests, bool extra)
{
if (_Description is not Description)
throw new Exception();
}
void IFileRead.Callback(object state) => throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
{
if (dateTime == DateTime.MinValue)
{ }
Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, null, null, new List<FileInfo>());
_Logistics = new Logistics(this, reportFullPath, useSplitForMID: true);
SetFileParameterLotIDToLogisticsMID();
string[] segments = Path.GetFileNameWithoutExtension(reportFullPath).Split('_');
string duplicateDirectory = string.Concat(_FileConnectorConfiguration.TargetFileLocation, @"\", segments[0]);
if (segments.Length > 2)
duplicateDirectory = string.Concat(duplicateDirectory, @"-", segments[2]);
if (!Directory.Exists(duplicateDirectory))
_ = Directory.CreateDirectory(duplicateDirectory);
string logisticsSequence = _Logistics.Sequence.ToString();
bool isDummyRun = _DummyRuns.Any() && _DummyRuns.ContainsKey(_Logistics.JobID) && _DummyRuns[_Logistics.JobID].Any() && (from l in _DummyRuns[_Logistics.JobID] where l == _Logistics.Sequence select 1).Any();
List<Tuple<Shared.Properties.IScopeInfo, string>> tuples = new();
string destinationDirectory = WriteScopeInfo(_ProgressPath, _Logistics, dateTime, duplicateDirectory, tuples);
if (isDummyRun)
Shared0607(reportFullPath, duplicateDirectory, logisticsSequence, destinationDirectory);
return results;
}
}

View File

@ -5,11 +5,10 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.Json; using System.Text.Json;
namespace Adaptation.FileHandlers.pcl namespace Adaptation.FileHandlers.pcl;
{
public class Description : IDescription, Shared.Properties.IDescription public class Description : IDescription, Shared.Properties.IDescription
{ {
public int Test { get; set; } public int Test { get; set; }
public int Count { get; set; } public int Count { get; set; }
@ -57,10 +56,7 @@ namespace Adaptation.FileHandlers.pcl
public string UniqueId { get; set; } public string UniqueId { get; set; }
public string Zone { get; set; } public string Zone { get; set; }
string IDescription.GetEventDescription() string IDescription.GetEventDescription() => "File Has been read and parsed";
{
return "File Has been read and parsed";
}
List<string> IDescription.GetNames(IFileRead fileRead, Logistics logistics) List<string> IDescription.GetNames(IFileRead fileRead, Logistics logistics)
{ {
@ -310,6 +306,4 @@ namespace Adaptation.FileHandlers.pcl
return result; return result;
} }
}
} }

View File

@ -1,8 +1,7 @@
namespace Adaptation.FileHandlers.pcl namespace Adaptation.FileHandlers.pcl;
{
public class Detail public class Detail
{ {
public string HeaderUniqueId { get; set; } public string HeaderUniqueId { get; set; }
public string Merit { get; set; } public string Merit { get; set; }
@ -12,11 +11,6 @@
public string T { get; set; } public string T { get; set; }
public string UniqueId { get; set; } public string UniqueId { get; set; }
public override string ToString() public override string ToString() => string.Concat(Merit, ";", Pt, ";", R, ";", Rs, ";", T);
{
return string.Concat(Merit, ";", Pt, ";", R, ";", Rs, ";", T);
}
}
} }

View File

@ -9,14 +9,13 @@ using System.Linq;
using System.Text.Json; using System.Text.Json;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace Adaptation.FileHandlers.pcl namespace Adaptation.FileHandlers.pcl;
public class FileRead : Shared.FileRead, IFileRead
{ {
public class FileRead : Shared.FileRead, IFileRead public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted) :
{ base(new Description(), true, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted)
public FileRead(ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted, int hyphenXToArchive, int hyphenIsArchive) :
base(new Description(), true, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted, hyphenXToArchive, hyphenIsArchive)
{ {
_MinFileLength = 10; _MinFileLength = 10;
_NullData = string.Empty; _NullData = string.Empty;
@ -29,15 +28,9 @@ namespace Adaptation.FileHandlers.pcl
throw new Exception(cellInstanceConnectionName); throw new Exception(cellInstanceConnectionName);
} }
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) => Move(extractResults, exception);
{
Move(this, extractResults, exception);
}
void IFileRead.WaitForThread() void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
{
WaitForThread(thread: null, threadExceptions: null);
}
string IFileRead.GetEventDescription() string IFileRead.GetEventDescription()
{ {
@ -100,20 +93,9 @@ namespace Adaptation.FileHandlers.pcl
return results; return results;
} }
void IFileRead.CheckTests(Test[] tests, bool extra) void IFileRead.CheckTests(Test[] tests, bool extra) => throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
{
throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
}
void IFileRead.MoveArchive() void IFileRead.Callback(object state) => throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
{
throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
}
void IFileRead.Callback(object state)
{
throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
}
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime) private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
{ {
@ -140,6 +122,4 @@ namespace Adaptation.FileHandlers.pcl
return results; return results;
} }
}
} }

View File

@ -11,11 +11,10 @@ using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace Adaptation.FileHandlers.pcl namespace Adaptation.FileHandlers.pcl;
{
public class ProcessData : IProcessData public class ProcessData : IProcessData
{ {
private int _I; private int _I;
private string _Data; private string _Data;
@ -63,10 +62,7 @@ namespace Adaptation.FileHandlers.pcl
Parse(fileRead, logistics, fileInfoCollection); Parse(fileRead, logistics, fileInfoCollection);
} }
string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors) string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors) => throw new Exception(string.Concat("See ", nameof(Parse)));
{
throw new Exception(string.Concat("See ", nameof(Parse)));
}
Tuple<string, Test[], JsonElement[], List<FileInfo>> IProcessData.GetResults(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection) Tuple<string, Test[], JsonElement[], List<FileInfo>> IProcessData.GetResults(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
{ {
@ -138,10 +134,7 @@ namespace Adaptation.FileHandlers.pcl
return before; return before;
} }
private string GetToEOL() private string GetToEOL() => GetBefore("\n");
{
return GetBefore("\n");
}
private string GetToEOL(bool trim) private string GetToEOL(bool trim)
{ {
@ -316,10 +309,10 @@ namespace Adaptation.FileHandlers.pcl
AutoProbeHeightSet = GetToEOL(); AutoProbeHeightSet = GetToEOL();
ScanPast("DataReject"); ScanPast("DataReject");
DataReject = GetToEOL(); DataReject = GetToEOL();
GetToEOL(); _ = GetToEOL();
FileName = GetToEOL(); FileName = GetToEOL();
GetToEOL(); _ = GetToEOL();
GetToEOL(); _ = GetToEOL();
bool check = false; bool check = false;
while (!IsBlankLine()) while (!IsBlankLine())
{ {
@ -333,7 +326,7 @@ namespace Adaptation.FileHandlers.pcl
detail.Rs = GetToken(); detail.Rs = GetToken();
detail.Merit = GetToken(); detail.Merit = GetToken();
detail.UniqueId = string.Concat("_Point-", _Details.Count + 1); detail.UniqueId = string.Concat("_Point-", _Details.Count + 1);
GetToEOL(); _ = GetToEOL();
_Details.Add(detail); _Details.Add(detail);
} }
else else
@ -361,9 +354,9 @@ namespace Adaptation.FileHandlers.pcl
ScanPast("(Mx+Mn)"); ScanPast("(Mx+Mn)");
SemiRadial = GetToken(); SemiRadial = GetToken();
_Log.Debug($"****ProcessData - RsAv SemiRadial={SemiRadial}"); _Log.Debug($"****ProcessData - RsAv SemiRadial={SemiRadial}");
GetToEOL(); _ = GetToEOL();
int num = 0; int num = 0;
GetBefore(": "); _ = GetBefore(": ");
for (string i = GetToken(); !string.IsNullOrEmpty(i); i = GetToken()) for (string i = GetToken(); !string.IsNullOrEmpty(i); i = GetToken())
{ {
if (!i.Contains(":")) if (!i.Contains(":"))
@ -417,7 +410,7 @@ namespace Adaptation.FileHandlers.pcl
{ {
if (char.IsLetterOrDigit(c) || c == '-' || c == '.') if (char.IsLetterOrDigit(c) || c == '-' || c == '.')
{ {
equipFixed.Append(c); _ = equipFixed.Append(c);
} }
} }
EquipId = equipFixed.ToString(); EquipId = equipFixed.ToString();
@ -433,7 +426,7 @@ namespace Adaptation.FileHandlers.pcl
foreach (char c in Run) foreach (char c in Run)
{ {
if (char.IsLetterOrDigit(c) || c == '-' || c == '.') if (char.IsLetterOrDigit(c) || c == '-' || c == '.')
runFixed.Append(c); _ = runFixed.Append(c);
} }
Run = runFixed.ToString(); Run = runFixed.ToString();
@ -447,6 +440,4 @@ namespace Adaptation.FileHandlers.pcl
fileInfoCollection.Add(new FileInfo(logistics.ReportFullPath)); fileInfoCollection.Add(new FileInfo(logistics.ReportFullPath));
} }
}
} }

View File

@ -1,13 +1,12 @@
namespace Adaptation.Ifx.Eaf.Common.Configuration namespace Adaptation.Ifx.Eaf.Common.Configuration;
[System.Runtime.Serialization.DataContractAttribute]
public class ConnectionSetting
{ {
[System.Runtime.Serialization.DataContractAttribute]
public class ConnectionSetting
{
public ConnectionSetting(string name, string value) { } public ConnectionSetting(string name, string value) { }
[System.Runtime.Serialization.DataMemberAttribute] [System.Runtime.Serialization.DataMemberAttribute]
public string Name { get; set; } public string Name { get; set; }
[System.Runtime.Serialization.DataMemberAttribute] [System.Runtime.Serialization.DataMemberAttribute]
public string Value { get; set; } public string Value { get; set; }
}
} }

View File

@ -1,19 +1,18 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Adaptation.Ifx.Eaf.EquipmentConnector.File.Component namespace Adaptation.Ifx.Eaf.EquipmentConnector.File.Component;
public class File
{ {
public class File public File(string filePath) => throw new NotImplementedException();
{ public File(string filePath, DateTime timeFileFound) => throw new NotImplementedException();
public File(string filePath) { throw new NotImplementedException(); }
public File(string filePath, DateTime timeFileFound) { throw new NotImplementedException(); }
public string Path { get; } public string Path { get; }
public DateTime TimeFound { get; } public DateTime TimeFound { get; }
public bool IsErrorFile { get; } public bool IsErrorFile { get; }
public Dictionary<string, string> ContentParameters { get; } public Dictionary<string, string> ContentParameters { get; }
public File UpdateContentParameters(Dictionary<string, string> contentParameters) { throw new NotImplementedException(); } public File UpdateContentParameters(Dictionary<string, string> contentParameters) => throw new NotImplementedException();
public File UpdateParsingStatus(bool isErrorFile) { throw new NotImplementedException(); } public File UpdateParsingStatus(bool isErrorFile) => throw new NotImplementedException();
}
} }

View File

@ -2,10 +2,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Adaptation.Ifx.Eaf.EquipmentConnector.File.Component namespace Adaptation.Ifx.Eaf.EquipmentConnector.File.Component;
public class FilePathGenerator
{ {
public class FilePathGenerator
{
public const char PLACEHOLDER_IDENTIFIER = '%'; public const char PLACEHOLDER_IDENTIFIER = '%';
public const char PLACEHOLDER_SEPARATOR = ':'; public const char PLACEHOLDER_SEPARATOR = ':';
public const string PLACEHOLDER_NOT_AVAILABLE = "NA"; public const string PLACEHOLDER_NOT_AVAILABLE = "NA";
@ -15,9 +15,9 @@ namespace Adaptation.Ifx.Eaf.EquipmentConnector.File.Component
public const string PLACEHOLDER_SUB_FOLDER = "SubFolder"; public const string PLACEHOLDER_SUB_FOLDER = "SubFolder";
public const string PLACEHOLDER_CELL_NAME = "CellName"; public const string PLACEHOLDER_CELL_NAME = "CellName";
public FilePathGenerator(FileConnectorConfiguration config, Dictionary<string, string> customPattern = null) { throw new NotImplementedException(); } public FilePathGenerator(FileConnectorConfiguration config, Dictionary<string, string> customPattern = null) => throw new NotImplementedException();
public FilePathGenerator(FileConnectorConfiguration config, File file, bool isErrorFile = false, Dictionary<string, string> customPattern = null) { throw new NotImplementedException(); } public FilePathGenerator(FileConnectorConfiguration config, File file, bool isErrorFile = false, Dictionary<string, string> customPattern = null) => throw new NotImplementedException();
public FilePathGenerator(FileConnectorConfiguration config, string sourceFilePath, bool isErrorFile = false, Dictionary<string, string> customPattern = null) { throw new NotImplementedException(); } public FilePathGenerator(FileConnectorConfiguration config, string sourceFilePath, bool isErrorFile = false, Dictionary<string, string> customPattern = null) => throw new NotImplementedException();
protected string SubFolderPath { get; } protected string SubFolderPath { get; }
protected FileConnectorConfiguration Configuration { get; } protected FileConnectorConfiguration Configuration { get; }
@ -25,11 +25,10 @@ namespace Adaptation.Ifx.Eaf.EquipmentConnector.File.Component
protected bool IsErrorFile { get; } protected bool IsErrorFile { get; }
protected string DefaultPlaceHolderValue { get; } protected string DefaultPlaceHolderValue { get; }
public string GetFullTargetPath() { throw new NotImplementedException(); } public string GetFullTargetPath() => throw new NotImplementedException();
public virtual string GetTargetFileName() { throw new NotImplementedException(); } public virtual string GetTargetFileName() => throw new NotImplementedException();
public string GetTargetFolder(bool throwExceptionIfNotExist = true) { throw new NotImplementedException(); } public string GetTargetFolder(bool throwExceptionIfNotExist = true) => throw new NotImplementedException();
protected virtual string GetSubFolder(string folderPattern, string subFolderPath) { throw new NotImplementedException(); } protected virtual string GetSubFolder(string folderPattern, string subFolderPath) => throw new NotImplementedException();
protected virtual string PrepareFolderPath(string targetFolderPath, string subFolderPath) { throw new NotImplementedException(); } protected virtual string PrepareFolderPath(string targetFolderPath, string subFolderPath) => throw new NotImplementedException();
protected string ReplacePlaceholder(string inputPath) { throw new NotImplementedException(); } protected string ReplacePlaceholder(string inputPath) => throw new NotImplementedException();
}
} }

View File

@ -2,11 +2,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration namespace Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
[System.Runtime.Serialization.DataContractAttribute]
public class FileConnectorConfiguration
{ {
[System.Runtime.Serialization.DataContractAttribute]
public class FileConnectorConfiguration
{
public const ulong IDLE_EVENT_WAIT_TIME_DEFAULT = 360; public const ulong IDLE_EVENT_WAIT_TIME_DEFAULT = 360;
public const ulong FILE_HANDLE_TIMEOUT_DEFAULT = 15; public const ulong FILE_HANDLE_TIMEOUT_DEFAULT = 15;
@ -85,7 +85,7 @@ namespace Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration
[System.Runtime.Serialization.DataMemberAttribute] [System.Runtime.Serialization.DataMemberAttribute]
public string ErrorTargetFileName { get; set; } public string ErrorTargetFileName { get; set; }
public void Initialize() { throw new NotImplementedException(); } public void Initialize() => throw new NotImplementedException();
public enum PostProcessingModeEnum public enum PostProcessingModeEnum
{ {
@ -131,5 +131,4 @@ namespace Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration
IgnoreNewer = 0, IgnoreNewer = 0,
IgnoreOlder = 1 IgnoreOlder = 1
} }
}
} }

View File

@ -2,13 +2,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Adaptation.Ifx.Eaf.EquipmentConnector.File.SelfDescription namespace Adaptation.Ifx.Eaf.EquipmentConnector.File.SelfDescription;
public class FileConnectorParameterTypeDefinitionProvider
{ {
public class FileConnectorParameterTypeDefinitionProvider
{
public FileConnectorParameterTypeDefinitionProvider() { } public FileConnectorParameterTypeDefinitionProvider() { }
public IEnumerable<ParameterTypeDefinition> GetAllParameterTypeDefinition() { return null; } public IEnumerable<ParameterTypeDefinition> GetAllParameterTypeDefinition() => null;
public ParameterTypeDefinition GetParameterTypeDefinition(string name) { return null; } public ParameterTypeDefinition GetParameterTypeDefinition(string name) => null;
}
} }

View File

@ -11,7 +11,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<VSTestLogger>trx</VSTestLogger> <VSTestLogger>trx</VSTestLogger>
<VSTestResultsDirectory>../../../Trunk/MET08RESIMAPCDE/05_TestResults/TestResults</VSTestResultsDirectory> <VSTestResultsDirectory>../../../../MET08RESIMAPCDE/05_TestResults/TestResults</VSTestResultsDirectory>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows> <IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>

View File

@ -1,10 +1,9 @@
using System; using System;
namespace Adaptation.PeerGroup.GCL.Annotations namespace Adaptation.PeerGroup.GCL.Annotations;
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.Delegate, AllowMultiple = false, Inherited = true)]
public sealed class NotNullAttribute : Attribute
{ {
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.Delegate, AllowMultiple = false, Inherited = true)]
public sealed class NotNullAttribute : Attribute
{
public NotNullAttribute() { } public NotNullAttribute() { }
}
} }

View File

@ -1,8 +1,7 @@
namespace Adaptation.PeerGroup.GCL.SecsDriver namespace Adaptation.PeerGroup.GCL.SecsDriver;
public enum HsmsConnectionMode
{ {
public enum HsmsConnectionMode
{
Active = 0, Active = 0,
Passive = 1 Passive = 1
}
} }

View File

@ -1,8 +1,7 @@
namespace Adaptation.PeerGroup.GCL.SecsDriver namespace Adaptation.PeerGroup.GCL.SecsDriver;
public enum HsmsSessionMode
{ {
public enum HsmsSessionMode
{
MultiSession = 0, MultiSession = 0,
SingleSession = 1 SingleSession = 1
}
} }

View File

@ -1,8 +1,7 @@
namespace Adaptation.PeerGroup.GCL.SecsDriver namespace Adaptation.PeerGroup.GCL.SecsDriver;
public enum SecsTransportType
{ {
public enum SecsTransportType
{
HSMS = 0, HSMS = 0,
Serial = 1 Serial = 1
}
} }

View File

@ -1,7 +1,7 @@
namespace Adaptation.PeerGroup.GCL.SecsDriver namespace Adaptation.PeerGroup.GCL.SecsDriver;
public enum SerialBaudRate
{ {
public enum SerialBaudRate
{
Baud9600 = 0, Baud9600 = 0,
Baud19200 = 1, Baud19200 = 1,
Baud4800 = 2, Baud4800 = 2,
@ -12,5 +12,4 @@
Baud38400 = 7, Baud38400 = 7,
Baud57600 = 8, Baud57600 = 8,
Baud115200 = 9 Baud115200 = 9
}
} }

View File

@ -4,11 +4,10 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.Json; using System.Text.Json;
namespace Adaptation.Shared.Duplicator namespace Adaptation.Shared.Duplicator;
{
public class Description : IDescription, Properties.IDescription public class Description : IDescription, Properties.IDescription
{ {
public int Test { get; set; } public int Test { get; set; }
public int Count { get; set; } public int Count { get; set; }
@ -24,10 +23,7 @@ namespace Adaptation.Shared.Duplicator
public string MID { get; set; } public string MID { get; set; }
public string Date { get; set; } //2021-10-23 public string Date { get; set; } //2021-10-23
string IDescription.GetEventDescription() string IDescription.GetEventDescription() => "File Has been read and parsed";
{
return "File Has been read and parsed";
}
List<string> IDescription.GetNames(IFileRead fileRead, Logistics logistics) List<string> IDescription.GetNames(IFileRead fileRead, Logistics logistics)
{ {
@ -143,6 +139,4 @@ namespace Adaptation.Shared.Duplicator
return result; return result;
} }
}
} }

View File

@ -1,4 +1,4 @@
using Adaptation.Eaf.Management.ConfigurationData.CellAutomation; using Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration; using Adaptation.Ifx.Eaf.EquipmentConnector.File.Configuration;
using Adaptation.Shared.Methods; using Adaptation.Shared.Methods;
using log4net; using log4net;
@ -12,11 +12,10 @@ using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using System.Threading; using System.Threading;
namespace Adaptation.Shared namespace Adaptation.Shared;
{
public class FileRead : Properties.IFileRead public class FileRead : Properties.IFileRead
{ {
protected string _NullData; protected string _NullData;
protected readonly ILog _Log; protected readonly ILog _Log;
@ -35,10 +34,8 @@ namespace Adaptation.Shared
protected readonly Calendar _Calendar; protected readonly Calendar _Calendar;
protected readonly bool _IsSourceTimer; protected readonly bool _IsSourceTimer;
protected readonly string _VillachPath; protected readonly string _VillachPath;
protected readonly int _HyphenIsArchive;
protected readonly string _ProgressPath; protected readonly string _ProgressPath;
protected readonly string _EquipmentType; protected readonly string _EquipmentType;
protected readonly int _HyphenIsXToArchive;
protected readonly long _BreakAfterSeconds; protected readonly long _BreakAfterSeconds;
protected readonly string _ExceptionSubject; protected readonly string _ExceptionSubject;
protected readonly string _CellInstanceName; protected readonly string _CellInstanceName;
@ -66,7 +63,7 @@ namespace Adaptation.Shared
string Properties.IFileRead.CellInstanceConnectionName => _CellInstanceConnectionName; string Properties.IFileRead.CellInstanceConnectionName => _CellInstanceConnectionName;
string Properties.IFileRead.ParameterizedModelObjectDefinitionType => _ParameterizedModelObjectDefinitionType; string Properties.IFileRead.ParameterizedModelObjectDefinitionType => _ParameterizedModelObjectDefinitionType;
public FileRead(IDescription description, bool isEvent, ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted, int hyphenXToArchive, int hyphenIsArchive) public FileRead(IDescription description, bool isEvent, ISMTP smtp, Dictionary<string, string> fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, Dictionary<string, List<long>> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted)
{ {
_SMTP = smtp; _SMTP = smtp;
_IsEvent = isEvent; _IsEvent = isEvent;
@ -76,9 +73,7 @@ namespace Adaptation.Shared
_Description = description; _Description = description;
_FileParameter = fileParameter; _FileParameter = fileParameter;
_ReportFullPath = string.Empty; _ReportFullPath = string.Empty;
_HyphenIsArchive = hyphenIsArchive;
_CellInstanceName = cellInstanceName; _CellInstanceName = cellInstanceName;
_HyphenIsXToArchive = hyphenXToArchive;
_Calendar = new CultureInfo("en-US").Calendar; _Calendar = new CultureInfo("en-US").Calendar;
_Log = LogManager.GetLogger(typeof(FileRead)); _Log = LogManager.GetLogger(typeof(FileRead));
_UseCyclicalForDescription = useCyclicalForDescription; _UseCyclicalForDescription = useCyclicalForDescription;
@ -86,9 +81,9 @@ namespace Adaptation.Shared
_ModelObjectParameterDefinitions = modelObjectParameters; _ModelObjectParameterDefinitions = modelObjectParameters;
_FileConnectorConfiguration = fileConnectorConfiguration; _FileConnectorConfiguration = fileConnectorConfiguration;
_ParameterizedModelObjectDefinitionType = parameterizedModelObjectDefinitionType; _ParameterizedModelObjectDefinitionType = parameterizedModelObjectDefinitionType;
_IsSourceTimer = (fileConnectorConfiguration.SourceFileFilter.StartsWith("*Timer.txt")); _IsSourceTimer = fileConnectorConfiguration.SourceFileFilter.StartsWith("*Timer.txt");
string cellInstanceConnectionNameBase = cellInstanceConnectionName.Replace("-", string.Empty); string cellInstanceConnectionNameBase = cellInstanceConnectionName.Replace("-", string.Empty);
_Hyphens = (cellInstanceConnectionName.Length - cellInstanceConnectionNameBase.Length); _Hyphens = cellInstanceConnectionName.Length - cellInstanceConnectionNameBase.Length;
_ExceptionSubject = string.Concat("Exception:", _CellInstanceConnectionName, _FileConnectorConfiguration?.SourceDirectoryCloaking); _ExceptionSubject = string.Concat("Exception:", _CellInstanceConnectionName, _FileConnectorConfiguration?.SourceDirectoryCloaking);
string suffix; string suffix;
string[] segments = _ParameterizedModelObjectDefinitionType.Split('.'); string[] segments = _ParameterizedModelObjectDefinitionType.Split('.');
@ -147,7 +142,7 @@ namespace Adaptation.Shared
throw new Exception("_Configuration is empty?"); throw new Exception("_Configuration is empty?");
if (_FileConnectorConfiguration.TargetFileLocation.Contains('%') || _FileConnectorConfiguration.ErrorTargetFileLocation.Contains('%')) if (_FileConnectorConfiguration.TargetFileLocation.Contains('%') || _FileConnectorConfiguration.ErrorTargetFileLocation.Contains('%'))
throw new Exception("_Configuration is incorrect for a duplicator!"); throw new Exception("_Configuration is incorrect for a duplicator!");
if (!(_FileConnectorConfiguration is null)) if (_FileConnectorConfiguration is not null)
{ {
if (string.IsNullOrEmpty(_FileConnectorConfiguration.SourceDirectoryCloaking)) if (string.IsNullOrEmpty(_FileConnectorConfiguration.SourceDirectoryCloaking))
throw new Exception("SourceDirectoryCloaking is empty?"); throw new Exception("SourceDirectoryCloaking is empty?");
@ -157,7 +152,7 @@ namespace Adaptation.Shared
} }
} }
protected string GetPropertyValue(string cellInstanceConnectionName, IList<ModelObjectParameterDefinition> modelObjectParameters, string propertyName) protected static string GetPropertyValue(string cellInstanceConnectionName, IList<ModelObjectParameterDefinition> modelObjectParameters, string propertyName)
{ {
string result; string result;
List<string> results = (from l in modelObjectParameters where l.Name == propertyName select l.Value).ToList(); List<string> results = (from l in modelObjectParameters where l.Name == propertyName select l.Value).ToList();
@ -167,7 +162,7 @@ namespace Adaptation.Shared
return result; return result;
} }
protected ModelObjectParameterDefinition[] GetProperties(string cellInstanceConnectionName, IList<ModelObjectParameterDefinition> modelObjectParameters, string propertyNamePrefix) protected static ModelObjectParameterDefinition[] GetProperties(string cellInstanceConnectionName, IList<ModelObjectParameterDefinition> modelObjectParameters, string propertyNamePrefix)
{ {
ModelObjectParameterDefinition[] results = (from l in modelObjectParameters where l.Name.StartsWith(propertyNamePrefix) select l).ToArray(); ModelObjectParameterDefinition[] results = (from l in modelObjectParameters where l.Name.StartsWith(propertyNamePrefix) select l).ToArray();
if (!results.Any()) if (!results.Any())
@ -175,7 +170,7 @@ namespace Adaptation.Shared
return results; return results;
} }
protected ModelObjectParameterDefinition[] GetProperties(string cellInstanceConnectionName, IList<ModelObjectParameterDefinition> modelObjectParameters, string propertyNamePrefix, string propertyNameSuffix) protected static ModelObjectParameterDefinition[] GetProperties(string cellInstanceConnectionName, IList<ModelObjectParameterDefinition> modelObjectParameters, string propertyNamePrefix, string propertyNameSuffix)
{ {
ModelObjectParameterDefinition[] results = (from l in modelObjectParameters where l.Name.StartsWith(propertyNamePrefix) && l.Name.EndsWith(propertyNameSuffix) select l).ToArray(); ModelObjectParameterDefinition[] results = (from l in modelObjectParameters where l.Name.StartsWith(propertyNamePrefix) && l.Name.EndsWith(propertyNameSuffix) select l).ToArray();
if (!results.Any()) if (!results.Any())
@ -192,7 +187,7 @@ namespace Adaptation.Shared
protected void WaitForThread(Thread thread, List<Exception> threadExceptions) protected void WaitForThread(Thread thread, List<Exception> threadExceptions)
{ {
if (!(thread is null)) if (thread is not null)
{ {
ThreadState threadState; ThreadState threadState;
for (short i = 0; i < short.MaxValue; i++) for (short i = 0; i < short.MaxValue; i++)
@ -202,7 +197,7 @@ namespace Adaptation.Shared
else else
{ {
threadState = thread.ThreadState; threadState = thread.ThreadState;
if (threadState != ThreadState.Running && threadState != ThreadState.WaitSleepJoin) if (threadState is not ThreadState.Running and not ThreadState.WaitSleepJoin)
break; break;
} }
Thread.Sleep(500); Thread.Sleep(500);
@ -221,29 +216,29 @@ namespace Adaptation.Shared
} }
} }
protected void CreateProgressDirectory(string progressPath, Logistics logistics, int? duplicator, string[] exceptionLines) protected void CreateProgressDirectory(string[] exceptionLines)
{ {
string progressDirectory; string progressDirectory;
StringBuilder stringBuilder = new(); StringBuilder stringBuilder = new();
if (duplicator is null || duplicator.Value == 0) if (_Hyphens == 0)
progressDirectory = string.Concat(progressPath, @"\EquipmentIntegration"); progressDirectory = Path.Combine(_ProgressPath, _CellInstanceConnectionName);
else else
{ {
stringBuilder.Clear(); _ = stringBuilder.Clear();
for (int i = 0; i < duplicator.Value; i++) for (int i = 0; i < _Hyphens; i++)
{ {
if (i > 0 && (i % 2) == 0) if (i > 0 && (i % 2) == 0)
stringBuilder.Append(' '); _ = stringBuilder.Append(' ');
stringBuilder.Append('-'); _ = stringBuilder.Append('-');
} }
progressDirectory = string.Concat(progressPath, @"\", (duplicator.Value + 1).ToString().PadLeft(2, '0'), " ", stringBuilder).Trim(); progressDirectory = string.Concat(_ProgressPath, @"\", (_Hyphens + 1).ToString().PadLeft(2, '0'), " ", stringBuilder).Trim();
} }
DateTime dateTime = DateTime.Now; DateTime dateTime = DateTime.Now;
string weekOfYear = _Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00"); string weekOfYear = _Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
progressDirectory = string.Concat(progressDirectory, @"\", dateTime.ToString("yyyy"), "_Week_", weekOfYear, @"\", logistics.MID, "_", logistics.Sequence, "_", DateTime.Now.Ticks - logistics.Sequence); progressDirectory = string.Concat(progressDirectory, @"\", dateTime.ToString("yyyy"), "_Week_", weekOfYear, @"\", _Logistics.MID, "_", _Logistics.Sequence, "_", DateTime.Now.Ticks - _Logistics.Sequence);
if (!Directory.Exists(progressDirectory)) if (!Directory.Exists(progressDirectory))
Directory.CreateDirectory(progressDirectory); _ = Directory.CreateDirectory(progressDirectory);
if (!(exceptionLines is null)) if (exceptionLines is not null)
{ {
string fileName = string.Concat(progressDirectory, @"\readme.txt"); string fileName = string.Concat(progressDirectory, @"\readme.txt");
try try
@ -255,17 +250,17 @@ namespace Adaptation.Shared
protected string[] Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception) protected string[] Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception)
{ {
string[] results; string[] results;
bool isErrorFile = !(exception is null); bool isErrorFile = exception is not null;
if (!to.EndsWith(@"\")) if (!to.EndsWith(@"\"))
string.Concat(to, @"\"); _ = string.Concat(to, @"\");
if (!isErrorFile) if (!isErrorFile)
results = new string[] { }; results = Array.Empty<string>();
else else
{ {
results = new string[] { _Logistics.Sequence.ToString(), _Logistics.ReportFullPath, from, resolvedFileLocation, to, string.Empty, string.Empty, exception.Message, string.Empty, string.Empty, exception.StackTrace }; results = new string[] { _Logistics.Sequence.ToString(), _Logistics.ReportFullPath, from, resolvedFileLocation, to, string.Empty, string.Empty, exception.Message, string.Empty, string.Empty, exception.StackTrace };
Shared0449(to, results); Shared0449(to, results);
} }
if (!(extractResults is null) && !(extractResults.Item4 is null) && extractResults.Item4.Any()) if (extractResults is not null && extractResults.Item4 is not null && extractResults.Item4.Any())
{ {
string itemFile; string itemFile;
List<string> directories = new(); List<string> directories = new();
@ -276,7 +271,7 @@ namespace Adaptation.Shared
itemFile = sourceFile.FullName.Replace(from, to); itemFile = sourceFile.FullName.Replace(from, to);
Shared1880(itemFile, directories, sourceFile, isErrorFile); Shared1880(itemFile, directories, sourceFile, isErrorFile);
} }
else if (!isErrorFile && !(_Logistics is null)) else if (!isErrorFile && _Logistics is not null)
Shared1811(to, sourceFile); Shared1811(to, sourceFile);
} }
Shared0231(directories); Shared0231(directories);
@ -284,7 +279,7 @@ namespace Adaptation.Shared
return results; return results;
} }
protected IEnumerable<string> GetDirectoriesRecursively(string path, string directoryNameSegment = null) protected static IEnumerable<string> GetDirectoriesRecursively(string path, string directoryNameSegment = null)
{ {
Queue<string> queue = new(); Queue<string> queue = new();
queue.Enqueue(path); queue.Enqueue(path);
@ -319,7 +314,7 @@ namespace Adaptation.Shared
Directory.Move(matchDirectories[0], result); Directory.Move(matchDirectories[0], result);
result = string.Concat(result, @"\", logistics.Sequence); result = string.Concat(result, @"\", logistics.Sequence);
if (!Directory.Exists(result)) if (!Directory.Exists(result))
Directory.CreateDirectory(result); _ = Directory.CreateDirectory(result);
} }
return result; return result;
} }
@ -342,7 +337,7 @@ namespace Adaptation.Shared
return result; return result;
} }
protected string GetTupleFile(Logistics logistics, Properties.IScopeInfo scopeInfo, string duplicateDirectory) protected static string GetTupleFile(Logistics logistics, Properties.IScopeInfo scopeInfo, string duplicateDirectory)
{ {
string result; string result;
string rds; string rds;
@ -438,7 +433,7 @@ namespace Adaptation.Shared
try try
{ File.Delete(duplicateFiles[i]); } { File.Delete(duplicateFiles[i]); }
catch (Exception) { } catch (Exception) { }
stringBuilder.Append("<").Append(duplicateFiles[i]).Append("> "); _ = stringBuilder.Append('<').Append(duplicateFiles[i]).Append("> ");
} }
} }
throw new Exception(string.Concat("After {", _BreakAfterSeconds, "} seconds, right side of {", sourceDirectoryCloaking, "} didn't consume file(s) ", stringBuilder)); throw new Exception(string.Concat("After {", _BreakAfterSeconds, "} seconds, right side of {", sourceDirectoryCloaking, "} didn't consume file(s) ", stringBuilder));
@ -491,7 +486,7 @@ namespace Adaptation.Shared
else else
directory = Path.Combine(_TracePath, _EquipmentType, "Source", _CellInstanceName, _CellInstanceConnectionName); directory = Path.Combine(_TracePath, _EquipmentType, "Source", _CellInstanceName, _CellInstanceConnectionName);
if (!Directory.Exists(directory)) if (!Directory.Exists(directory))
Directory.CreateDirectory(directory); _ = Directory.CreateDirectory(directory);
string file = Path.Combine(directory, string.Concat(_Logistics.MesEntity, "_", _Logistics.Sequence, ".ipdsf")); string file = Path.Combine(directory, string.Concat(_Logistics.MesEntity, "_", _Logistics.Sequence, ".ipdsf"));
string lines = ProcessDataStandardFormat.GetPDSFText(fileRead, _Logistics, jsonElements, logisticsText: string.Empty); string lines = ProcessDataStandardFormat.GetPDSFText(fileRead, _Logistics, jsonElements, logisticsText: string.Empty);
File.WriteAllText(file, lines); File.WriteAllText(file, lines);
@ -503,17 +498,13 @@ namespace Adaptation.Shared
} }
} }
protected void Move(IFileRead fileRead, Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) protected void Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception)
{ {
bool isErrorFile = !(exception is null); bool isErrorFile = exception is not null;
if (!isErrorFile && _IsDuplicator) if (!isErrorFile && _IsDuplicator)
{ {
if (_Hyphens == _HyphenIsXToArchive)
Shared0192();
else if (_IsEAFHosted && _Hyphens == _HyphenIsArchive)
fileRead.MoveArchive();
if (_IsEAFHosted && !string.IsNullOrEmpty(_ProgressPath)) if (_IsEAFHosted && !string.IsNullOrEmpty(_ProgressPath))
CreateProgressDirectory(_ProgressPath, _Logistics, _Hyphens, exceptionLines: null); CreateProgressDirectory(exceptionLines: null);
} }
if (!_IsEAFHosted) if (!_IsEAFHosted)
{ {
@ -524,10 +515,10 @@ namespace Adaptation.Shared
to = Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation); to = Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation);
foreach (KeyValuePair<string, string> keyValuePair in _FileParameter) foreach (KeyValuePair<string, string> keyValuePair in _FileParameter)
to = to.Replace(string.Concat('%', keyValuePair.Key, '%'), keyValuePair.Value); to = to.Replace(string.Concat('%', keyValuePair.Key, '%'), keyValuePair.Value);
if (to.Contains("%")) if (to.Contains('%'))
_Log.Debug("Can't debug without EAF Hosting"); _Log.Debug("Can't debug without EAF Hosting");
else else
Move(extractResults, to, _FileConnectorConfiguration.SourceFileLocation, resolvedFileLocation: string.Empty, exception: null); _ = Move(extractResults, to, _FileConnectorConfiguration.SourceFileLocation, resolvedFileLocation: string.Empty, exception: null);
} }
} }
@ -592,7 +583,7 @@ namespace Adaptation.Shared
return results; return results;
} }
protected Dictionary<Test, List<Properties.IDescription>> GetKeyValuePairs(List<Properties.IDescription> descriptions) protected static Dictionary<Test, List<Properties.IDescription>> GetKeyValuePairs(List<Properties.IDescription> descriptions)
{ {
Dictionary<Test, List<Properties.IDescription>> results = new(); Dictionary<Test, List<Properties.IDescription>> results = new();
Test testKey; Test testKey;
@ -606,7 +597,7 @@ namespace Adaptation.Shared
return results; return results;
} }
protected List<Properties.IDescription> GetDuplicatorDescriptions(JsonElement[] jsonElements) protected static List<Properties.IDescription> GetDuplicatorDescriptions(JsonElement[] jsonElements)
{ {
List<Properties.IDescription> results = new(); List<Properties.IDescription> results = new();
Duplicator.Description description; Duplicator.Description description;
@ -621,7 +612,7 @@ namespace Adaptation.Shared
return results; return results;
} }
protected Tuple<Test[], Dictionary<Test, List<Properties.IDescription>>> GetTuple(IFileRead fileRead, IEnumerable<Properties.IDescription> descriptions, bool extra = false) protected static Tuple<Test[], Dictionary<Test, List<Properties.IDescription>>> GetTuple(IFileRead fileRead, IEnumerable<Properties.IDescription> descriptions, bool extra = false)
{ {
Tuple<Test[], Dictionary<Test, List<Properties.IDescription>>> result; Tuple<Test[], Dictionary<Test, List<Properties.IDescription>>> result;
Dictionary<Test, List<Properties.IDescription>> keyValuePairs = GetKeyValuePairs(descriptions.ToList()); Dictionary<Test, List<Properties.IDescription>> keyValuePairs = GetKeyValuePairs(descriptions.ToList());
@ -634,14 +625,14 @@ namespace Adaptation.Shared
protected void Shared0449(string to, string[] exceptionLines) protected void Shared0449(string to, string[] exceptionLines)
{ {
if (_IsDuplicator) if (_IsDuplicator)
CreateProgressDirectory(_ProgressPath, _Logistics, _Hyphens, exceptionLines); CreateProgressDirectory(exceptionLines: null);
else else
{ {
string fileName = string.Concat(to, @"\readme.txt"); string fileName = string.Concat(to, @"\readme.txt");
try try
{ {
if (!Directory.Exists(to)) if (!Directory.Exists(to))
Directory.CreateDirectory(to); _ = Directory.CreateDirectory(to);
File.WriteAllLines(fileName, exceptionLines); File.WriteAllLines(fileName, exceptionLines);
} }
catch (Exception ex) { _Log.Error(ex.Message); } catch (Exception ex) { _Log.Error(ex.Message); }
@ -660,7 +651,7 @@ namespace Adaptation.Shared
processingModeEnum = _FileConnectorConfiguration.ErrorPostProcessingMode.Value; processingModeEnum = _FileConnectorConfiguration.ErrorPostProcessingMode.Value;
if (processingModeEnum != FileConnectorConfiguration.PostProcessingModeEnum.Delete && !Directory.Exists(itemDirectory)) if (processingModeEnum != FileConnectorConfiguration.PostProcessingModeEnum.Delete && !Directory.Exists(itemDirectory))
{ {
Directory.CreateDirectory(itemDirectory); _ = Directory.CreateDirectory(itemDirectory);
FileInfo fileInfo = new(_Logistics.ReportFullPath); FileInfo fileInfo = new(_Logistics.ReportFullPath);
Directory.SetCreationTime(itemDirectory, fileInfo.LastWriteTime); Directory.SetCreationTime(itemDirectory, fileInfo.LastWriteTime);
} }
@ -694,14 +685,14 @@ namespace Adaptation.Shared
string weekDirectory = string.Concat(_Logistics.DateTimeFromSequence.ToString("yyyy"), "_Week_", weekOfYear, @"\", _Logistics.DateTimeFromSequence.ToString("yyyy-MM-dd")); string weekDirectory = string.Concat(_Logistics.DateTimeFromSequence.ToString("yyyy"), "_Week_", weekOfYear, @"\", _Logistics.DateTimeFromSequence.ToString("yyyy-MM-dd"));
string destinationDirectory = string.Concat(jobIdDirectory, @"\_ Ignore 100 bytes\", weekDirectory, @"\", directoryName); string destinationDirectory = string.Concat(jobIdDirectory, @"\_ Ignore 100 bytes\", weekDirectory, @"\", directoryName);
if (!Directory.Exists(destinationDirectory)) if (!Directory.Exists(destinationDirectory))
Directory.CreateDirectory(destinationDirectory); _ = Directory.CreateDirectory(destinationDirectory);
File.Move(sourceFile.FullName, string.Concat(destinationDirectory, @"\", sourceFile.Name)); File.Move(sourceFile.FullName, string.Concat(destinationDirectory, @"\", sourceFile.Name));
try try
{ {
string[] checkDirectories = Directory.GetDirectories(jobIdDirectory, "*", SearchOption.TopDirectoryOnly); string[] checkDirectories = Directory.GetDirectories(jobIdDirectory, "*", SearchOption.TopDirectoryOnly);
foreach (string checkDirectory in checkDirectories) foreach (string checkDirectory in checkDirectories)
{ {
if (!checkDirectory.Contains("_")) if (!checkDirectory.Contains('_'))
continue; continue;
if (Directory.GetDirectories(checkDirectory, "*", SearchOption.TopDirectoryOnly).Any()) if (Directory.GetDirectories(checkDirectory, "*", SearchOption.TopDirectoryOnly).Any())
continue; continue;
@ -748,7 +739,7 @@ namespace Adaptation.Shared
} }
} }
protected void Shared0607(string reportFullPath, string duplicateDirectory, string logisticsSequence, string destinationDirectory) protected static void Shared0607(string reportFullPath, string duplicateDirectory, string logisticsSequence, string destinationDirectory)
{ {
if (destinationDirectory == duplicateDirectory) if (destinationDirectory == duplicateDirectory)
throw new Exception("Check Target File Folder for %LotIDWithLogisticsSequence%_in process on CI (not Duplicator)"); throw new Exception("Check Target File Folder for %LotIDWithLogisticsSequence%_in process on CI (not Duplicator)");
@ -763,16 +754,6 @@ namespace Adaptation.Shared
File.Delete(reportFullPath); File.Delete(reportFullPath);
} }
protected void Shared0192()
{
if (!string.IsNullOrEmpty(_Logistics.ReportFullPath))
{
FileInfo fileInfo = new(_Logistics.ReportFullPath);
if (fileInfo.Exists && fileInfo.LastWriteTime < fileInfo.CreationTime)
File.SetLastWriteTime(_Logistics.ReportFullPath, fileInfo.CreationTime);
}
}
protected string[] Shared1567(string reportFullPath, List<Tuple<Properties.IScopeInfo, string>> tuples) protected string[] Shared1567(string reportFullPath, List<Tuple<Properties.IScopeInfo, string>> tuples)
{ {
string[] results; string[] results;
@ -780,7 +761,7 @@ namespace Adaptation.Shared
string logisticsSequence = _Logistics.Sequence.ToString(); string logisticsSequence = _Logistics.Sequence.ToString();
string jobIdDirectory = string.Concat(Path.GetDirectoryName(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation)), @"\", _Logistics.JobID); string jobIdDirectory = string.Concat(Path.GetDirectoryName(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation)), @"\", _Logistics.JobID);
if (!Directory.Exists(jobIdDirectory)) if (!Directory.Exists(jobIdDirectory))
Directory.CreateDirectory(jobIdDirectory); _ = Directory.CreateDirectory(jobIdDirectory);
string[] matchDirectories; string[] matchDirectories;
if (!_IsEAFHosted) if (!_IsEAFHosted)
matchDirectories = new string[] { Path.GetDirectoryName(Path.GetDirectoryName(reportFullPath)) }; matchDirectories = new string[] { Path.GetDirectoryName(Path.GetDirectoryName(reportFullPath)) };
@ -791,7 +772,7 @@ namespace Adaptation.Shared
string fileName = Path.GetFileNameWithoutExtension(reportFullPath); string fileName = Path.GetFileNameWithoutExtension(reportFullPath);
string sequenceDirectory = string.Concat(matchDirectories[0], @"\", logisticsSequence); string sequenceDirectory = string.Concat(matchDirectories[0], @"\", logisticsSequence);
if (!Directory.Exists(sequenceDirectory)) if (!Directory.Exists(sequenceDirectory))
Directory.CreateDirectory(sequenceDirectory); _ = Directory.CreateDirectory(sequenceDirectory);
foreach (Tuple<Properties.IScopeInfo, string> tuple in tuples) foreach (Tuple<Properties.IScopeInfo, string> tuple in tuples)
{ {
fileName = string.Concat(sequenceDirectory, @"\", fileName, "_", tuple.Item1.FileNameWithoutExtension, ".pdsfc"); fileName = string.Concat(sequenceDirectory, @"\", fileName, "_", tuple.Item1.FileNameWithoutExtension, ".pdsfc");
@ -816,19 +797,17 @@ namespace Adaptation.Shared
string ecCharacterizationSi = Path.GetDirectoryName(Path.GetDirectoryName(jobIdDirectory)); string ecCharacterizationSi = Path.GetDirectoryName(Path.GetDirectoryName(jobIdDirectory));
string destinationJobIdDirectory = string.Concat(ecCharacterizationSi, @"\Processed\", _Logistics.JobID); string destinationJobIdDirectory = string.Concat(ecCharacterizationSi, @"\Processed\", _Logistics.JobID);
if (!Directory.Exists(destinationJobIdDirectory)) if (!Directory.Exists(destinationJobIdDirectory))
Directory.CreateDirectory(destinationJobIdDirectory); _ = Directory.CreateDirectory(destinationJobIdDirectory);
destinationJobIdDirectory = string.Concat(destinationJobIdDirectory, @"\", Path.GetFileName(destinationDirectory).Split(new string[] { logisticsSequence }, StringSplitOptions.None)[0], _Logistics.DateTimeFromSequence.ToString("yyyy-MM-dd_hh;mm_tt_"), DateTime.Now.Ticks - _Logistics.Sequence); destinationJobIdDirectory = string.Concat(destinationJobIdDirectory, @"\", Path.GetFileName(destinationDirectory).Split(new string[] { logisticsSequence }, StringSplitOptions.None)[0], _Logistics.DateTimeFromSequence.ToString("yyyy-MM-dd_hh;mm_tt_"), DateTime.Now.Ticks - _Logistics.Sequence);
string sequenceDirectory = string.Concat(destinationJobIdDirectory, @"\", logisticsSequence); string sequenceDirectory = string.Concat(destinationJobIdDirectory, @"\", logisticsSequence);
string jsonFileName = string.Concat(sequenceDirectory, @"\", Path.GetFileNameWithoutExtension(reportFullPath), ".json"); string jsonFileName = string.Concat(sequenceDirectory, @"\", Path.GetFileNameWithoutExtension(reportFullPath), ".json");
Directory.Move(destinationDirectory, destinationJobIdDirectory); Directory.Move(destinationDirectory, destinationJobIdDirectory);
if (!Directory.Exists(sequenceDirectory)) if (!Directory.Exists(sequenceDirectory))
Directory.CreateDirectory(sequenceDirectory); _ = Directory.CreateDirectory(sequenceDirectory);
File.Copy(reportFullPath, string.Concat(sequenceDirectory, @"\", Path.GetFileName(reportFullPath)), overwrite: true); File.Copy(reportFullPath, string.Concat(sequenceDirectory, @"\", Path.GetFileName(reportFullPath)), overwrite: true);
File.WriteAllText(jsonFileName, json); File.WriteAllText(jsonFileName, json);
} }
}
} }
// 2021-12-17 -> Shared - FileRead // 2022-02-14 -> Shared - FileRead

View File

@ -1,14 +1,13 @@
using Adaptation.Shared.Methods; using Adaptation.Shared.Methods;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
namespace Adaptation.Shared namespace Adaptation.Shared;
{
public class Logistics : ILogistics public class Logistics : ILogistics
{ {
public object NullData { get; private set; } public object NullData { get; private set; }
public string JobID { get; private set; } //CellName public string JobID { get; private set; } //CellName
@ -166,7 +165,7 @@ namespace Adaptation.Shared
Logistics2 logistics2; Logistics2 logistics2;
Tags = new List<string>(); Tags = new List<string>();
Logistics2 = new List<Logistics2>(); Logistics2 = new List<Logistics2>();
for (int i = 1; i < Logistics1.Count(); i++) for (int i = 1; i < Logistics1.Count; i++)
{ {
if (Logistics1[i].StartsWith("LOGISTICS_2")) if (Logistics1[i].StartsWith("LOGISTICS_2"))
{ {
@ -174,32 +173,20 @@ namespace Adaptation.Shared
Logistics2.Add(logistics2); Logistics2.Add(logistics2);
} }
} }
for (int i = Logistics1.Count() - 1; i > -1; i--) for (int i = Logistics1.Count - 1; i > -1; i--)
{ {
if (Logistics1[i].StartsWith("LOGISTICS_2")) if (Logistics1[i].StartsWith("LOGISTICS_2"))
Logistics1.RemoveAt(i); Logistics1.RemoveAt(i);
} }
} }
public Logistics ShallowCopy() public Logistics ShallowCopy() => (Logistics)MemberwiseClone();
{
return (Logistics)MemberwiseClone();
}
private string DefaultMesEntity(DateTime dateTime) private static string DefaultMesEntity(DateTime dateTime) => string.Concat(dateTime.Ticks, "_MES_ENTITY");
{
return string.Concat(dateTime.Ticks, "_MES_ENTITY");
}
internal string GetLotViaMostCommonMethod() internal string GetLotViaMostCommonMethod() => MID.Substring(0, MID.Length - 2);
{
return MID.Substring(0, MID.Length - 2);
}
internal string GetPocketNumberViaMostCommonMethod() internal string GetPocketNumberViaMostCommonMethod() => MID.Substring(MID.Length - 2);
{
return MID.Substring(MID.Length - 2);
}
internal void Update(string dateTime, string processJobID, string mid) internal void Update(string dateTime, string processJobID, string mid)
{ {
@ -218,6 +205,4 @@ namespace Adaptation.Shared
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList(); Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics2 = new List<Logistics2>(); Logistics2 = new List<Logistics2>();
} }
}
} }

View File

@ -1,11 +1,10 @@
using System; using System;
namespace Adaptation.Shared namespace Adaptation.Shared;
public class Logistics2 : Methods.ILogistics2
{ {
public class Logistics2 : Methods.ILogistics2
{
public string MID { get; private set; } public string MID { get; private set; }
public string RunNumber { get; private set; } public string RunNumber { get; private set; }
public string SatelliteGroup { get; private set; } public string SatelliteGroup { get; private set; }
@ -76,6 +75,4 @@ namespace Adaptation.Shared
} }
} }
}
} }

View File

@ -1,11 +1,10 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.Json; using System.Text.Json;
namespace Adaptation.Shared.Methods namespace Adaptation.Shared.Methods;
{
public interface IDescription public interface IDescription
{ {
string GetEventDescription(); string GetEventDescription();
List<string> GetDetailNames(); List<string> GetDetailNames();
@ -20,6 +19,4 @@ namespace Adaptation.Shared.Methods
IDescription GetDefaultDescription(IFileRead fileRead, Logistics logistics); IDescription GetDefaultDescription(IFileRead fileRead, Logistics logistics);
List<IDescription> GetDescriptions(IFileRead fileRead, Logistics logistics, List<Test> tests, IProcessData iProcessData); List<IDescription> GetDescriptions(IFileRead fileRead, Logistics logistics, List<Test> tests, IProcessData iProcessData);
}
} }

View File

@ -3,12 +3,11 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text.Json; using System.Text.Json;
namespace Adaptation.Shared.Methods namespace Adaptation.Shared.Methods;
public interface IFileRead : Properties.IFileRead
{ {
public interface IFileRead : Properties.IFileRead
{
void MoveArchive();
void WaitForThread(); void WaitForThread();
JsonProperty[] GetDefault(); JsonProperty[] GetDefault();
void Callback(object state); void Callback(object state);
@ -21,6 +20,5 @@ namespace Adaptation.Shared.Methods
void Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception = null); void Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception = null);
Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, string eventName); Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, string eventName);
string[] Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception); string[] Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception);
}
} }

View File

@ -1,8 +1,5 @@
namespace Adaptation.Shared.Methods namespace Adaptation.Shared.Methods;
public interface ILogistics : Properties.ILogistics
{ {
public interface ILogistics : Properties.ILogistics
{
}
} }

View File

@ -1,8 +1,5 @@
namespace Adaptation.Shared.Methods namespace Adaptation.Shared.Methods;
public interface ILogistics2 : Properties.ILogistics2
{ {
public interface ILogistics2 : Properties.ILogistics2
{
}
} }

View File

@ -3,15 +3,12 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text.Json; using System.Text.Json;
namespace Adaptation.Shared.Methods namespace Adaptation.Shared.Methods;
{
public interface IProcessData : Properties.IProcessData public interface IProcessData : Properties.IProcessData
{ {
string GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors); string GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors);
Tuple<string, Test[], JsonElement[], List<FileInfo>> GetResults(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection); Tuple<string, Test[], JsonElement[], List<FileInfo>> GetResults(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection);
}
} }

View File

@ -1,9 +1,8 @@
namespace Adaptation.Shared.Methods namespace Adaptation.Shared.Methods;
public interface ISMTP
{ {
public interface ISMTP
{
void SendLowPriorityEmailMessage(string subject, string body); void SendLowPriorityEmailMessage(string subject, string body);
void SendHighPriorityEmailMessage(string subject, string body); void SendHighPriorityEmailMessage(string subject, string body);
void SendNormalPriorityEmailMessage(string subject, string body); void SendNormalPriorityEmailMessage(string subject, string body);
}
} }

View File

@ -1,11 +1,10 @@
using System; using System;
using System.IO; using System.IO;
namespace Adaptation.Shared.Metrology namespace Adaptation.Shared.Metrology;
{
public class ScopeInfo : Properties.IScopeInfo public class ScopeInfo : Properties.IScopeInfo
{ {
public Test Test { get; private set; } public Test Test { get; private set; }
public Enum Enum { get; private set; } public Enum Enum { get; private set; }
@ -296,11 +295,6 @@ namespace Adaptation.Shared.Metrology
FileName = string.Concat(FileNameWithoutExtension, ".txt"); FileName = string.Concat(FileNameWithoutExtension, ".txt");
} }
public ScopeInfo ShallowCopy() public ScopeInfo ShallowCopy() => (ScopeInfo)MemberwiseClone();
{
return (ScopeInfo)MemberwiseClone();
}
}
} }

View File

@ -1,8 +1,7 @@
namespace Adaptation.Shared.Metrology namespace Adaptation.Shared.Metrology;
{
public partial class WS public partial class WS
{ {
public class Attachment public class Attachment
{ {
@ -19,6 +18,4 @@
} }
}
} }

View File

@ -1,11 +1,10 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.Json; using System.Text.Json;
namespace Adaptation.Shared.Metrology namespace Adaptation.Shared.Metrology;
{
public partial class WS public partial class WS
{ {
// this class represents the response from the Inbound API endpoint // this class represents the response from the Inbound API endpoint
public class Results public class Results
{ {
@ -22,12 +21,7 @@ namespace Adaptation.Shared.Metrology
public List<string> Warnings { get; set; } public List<string> Warnings { get; set; }
// this is just a helper function to make displaying the results easier // this is just a helper function to make displaying the results easier
public override string ToString() public override string ToString() => JsonSerializer.Serialize(this, GetType());
{
return JsonSerializer.Serialize(this, GetType());
}
}
} }
} }

View File

@ -4,25 +4,24 @@ using System.Net.Http;
using System.Text; using System.Text;
using System.Text.Json; using System.Text.Json;
namespace Adaptation.Shared.Metrology namespace Adaptation.Shared.Metrology;
{
public partial class WS public partial class WS
{ {
public static Tuple<string, Results> SendData(string url, object payload, int timeoutSeconds = 120) public static Tuple<string, Results> SendData(string url, object payload, int timeoutSeconds = 120)
{ {
Results results = new Results(); Results results = new();
string resultsJson = string.Empty; string resultsJson = string.Empty;
try try
{ {
string json = JsonSerializer.Serialize(payload, payload.GetType()); string json = JsonSerializer.Serialize(payload, payload.GetType());
if (string.IsNullOrEmpty(url) || !url.Contains(":") || !url.Contains(".")) if (string.IsNullOrEmpty(url) || !url.Contains(":") || !url.Contains("."))
throw new Exception("Invalid URL"); throw new Exception("Invalid URL");
using (HttpClient httpClient = new HttpClient()) using (HttpClient httpClient = new())
{ {
httpClient.Timeout = new TimeSpan(0, 0, 0, timeoutSeconds, 0); httpClient.Timeout = new TimeSpan(0, 0, 0, timeoutSeconds, 0);
HttpRequestMessage httpRequestMessage = new HttpRequestMessage HttpRequestMessage httpRequestMessage = new()
{ {
RequestUri = new Uri(url), RequestUri = new Uri(url),
Method = HttpMethod.Post, Method = HttpMethod.Post,
@ -38,10 +37,10 @@ namespace Adaptation.Shared.Metrology
catch (Exception e) catch (Exception e)
{ {
Exception exception = e; Exception exception = e;
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new();
while (!(exception is null)) while (exception is not null)
{ {
stringBuilder.AppendLine(exception.Message); _ = stringBuilder.AppendLine(exception.Message);
exception = exception.InnerException; exception = exception.InnerException;
} }
if (results.Errors is null) if (results.Errors is null)
@ -62,8 +61,7 @@ namespace Adaptation.Shared.Metrology
// also, this has been made synchronous // also, this has been made synchronous
public static void AttachFile(string url, long attachToHeaderId, string attachToDataUniqueId, byte[] fileContents, string fileName, int timeoutSeconds = 60) public static void AttachFile(string url, long attachToHeaderId, string attachToDataUniqueId, byte[] fileContents, string fileName, int timeoutSeconds = 60)
{ {
using (HttpClient httpClient = new HttpClient()) using HttpClient httpClient = new();
{
string requestUrl = url + "/attachment?headerid=" + attachToHeaderId.ToString(); string requestUrl = url + "/attachment?headerid=" + attachToHeaderId.ToString();
if (!string.IsNullOrWhiteSpace(attachToDataUniqueId)) if (!string.IsNullOrWhiteSpace(attachToDataUniqueId))
{ {
@ -75,8 +73,8 @@ namespace Adaptation.Shared.Metrology
httpClient.Timeout = new TimeSpan(0, 0, 0, timeoutSeconds, 0); httpClient.Timeout = new TimeSpan(0, 0, 0, timeoutSeconds, 0);
MultipartFormDataContent multipartFormDataContent = new MultipartFormDataContent(); MultipartFormDataContent multipartFormDataContent = new();
ByteArrayContent byteArrayContent = new ByteArrayContent(fileContents); ByteArrayContent byteArrayContent = new(fileContents);
byteArrayContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream"); byteArrayContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
multipartFormDataContent.Add(byteArrayContent, "attachment", fileName); multipartFormDataContent.Add(byteArrayContent, "attachment", fileName);
@ -90,18 +88,17 @@ namespace Adaptation.Shared.Metrology
throw new Exception("Attachment failed: " + resultBody); throw new Exception("Attachment failed: " + resultBody);
} }
}
public static void AttachFiles(string url, long headerID, List<Attachment> headerAttachments = null, List<Attachment> dataAttachments = null) public static void AttachFiles(string url, long headerID, List<Attachment> headerAttachments = null, List<Attachment> dataAttachments = null)
{ {
try try
{ {
if (!(headerAttachments is null)) if (headerAttachments is not null)
{ {
foreach (Attachment attachment in headerAttachments) foreach (Attachment attachment in headerAttachments)
AttachFile(url, headerID, "", System.IO.File.ReadAllBytes(attachment.SourceFileName), attachment.DestinationFileName); AttachFile(url, headerID, "", System.IO.File.ReadAllBytes(attachment.SourceFileName), attachment.DestinationFileName);
} }
if (!(dataAttachments is null)) if (dataAttachments is not null)
{ {
foreach (Attachment attachment in dataAttachments) foreach (Attachment attachment in dataAttachments)
AttachFile(url, headerID, attachment.UniqueId, System.IO.File.ReadAllBytes(attachment.SourceFileName), attachment.DestinationFileName); AttachFile(url, headerID, attachment.UniqueId, System.IO.File.ReadAllBytes(attachment.SourceFileName), attachment.DestinationFileName);
@ -111,10 +108,10 @@ namespace Adaptation.Shared.Metrology
catch (Exception e) catch (Exception e)
{ {
Exception exception = e; Exception exception = e;
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new();
while (!(exception is null)) while (exception is not null)
{ {
stringBuilder.AppendLine(exception.Message); _ = stringBuilder.AppendLine(exception.Message);
exception = exception.InnerException; exception = exception.InnerException;
} }
//MessageBox.Show(msgs.ToString(), "Exception", //MessageBoxButtons.OK, //MessageBoxIcon.Error); //MessageBox.Show(msgs.ToString(), "Exception", //MessageBoxButtons.OK, //MessageBoxIcon.Error);
@ -122,6 +119,4 @@ namespace Adaptation.Shared.Metrology
} }
} }
}
} }

View File

@ -1,13 +1,10 @@
namespace Adaptation.Shared namespace Adaptation.Shared;
{
public enum ParameterType public enum ParameterType
{ {
String = 0, String = 0,
Integer = 2, Integer = 2,
Double = 3, Double = 3,
Boolean = 4, Boolean = 4,
StructuredType = 5 StructuredType = 5
}
} }

View File

@ -7,11 +7,10 @@ using System.Linq;
using System.Text; using System.Text;
using System.Text.Json; using System.Text.Json;
namespace Adaptation.Shared namespace Adaptation.Shared;
{
public class ProcessDataStandardFormat public class ProcessDataStandardFormat
{ {
public const string RecordStart = "RECORD_START"; public const string RecordStart = "RECORD_START";
@ -38,29 +37,29 @@ namespace Adaptation.Shared
string format = "MM/dd/yyyy HH:mm:ss"; string format = "MM/dd/yyyy HH:mm:ss";
StringBuilder stringBuilder = new(); StringBuilder stringBuilder = new();
lines = new string[] { "HEADER_TAG\tHEADER_VALUE", "FORMAT\t2.00", "NUMBER_PASSES\t0001", string.Concat("HEADER_OFFSET\t", headerOffset), string.Concat("DATA_OFFSET\t", dataOffset), string.Concat("END_OFFSET\t", endOffset) }.ToList(); lines = new string[] { "HEADER_TAG\tHEADER_VALUE", "FORMAT\t2.00", "NUMBER_PASSES\t0001", string.Concat("HEADER_OFFSET\t", headerOffset), string.Concat("DATA_OFFSET\t", dataOffset), string.Concat("END_OFFSET\t", endOffset) }.ToList();
stringBuilder.Append("\"Time\"").Append('\t'); _ = stringBuilder.Append("\"Time\"").Append('\t');
stringBuilder.Append("\"A_LOGISTICS\"").Append('\t'); _ = stringBuilder.Append("\"A_LOGISTICS\"").Append('\t');
stringBuilder.Append("\"B_LOGISTICS\"").Append('\t'); _ = stringBuilder.Append("\"B_LOGISTICS\"").Append('\t');
for (int i = 0; i < jsonElements.Length;) for (int i = 0; i < jsonElements.Length;)
{ {
foreach (JsonProperty jsonProperty in jsonElements[0].EnumerateObject()) foreach (JsonProperty jsonProperty in jsonElements[0].EnumerateObject())
{ {
columns += 1; columns += 1;
stringBuilder.Append("\"").Append(jsonProperty.Name).Append("\"").Append('\t'); _ = stringBuilder.Append("\"").Append(jsonProperty.Name).Append("\"").Append('\t');
} }
break; break;
} }
stringBuilder.Remove(stringBuilder.Length - 1, 1); _ = stringBuilder.Remove(stringBuilder.Length - 1, 1);
lines.Add(stringBuilder.ToString()); lines.Add(stringBuilder.ToString());
for (int i = 0; i < jsonElements.Length; i++) for (int i = 0; i < jsonElements.Length; i++)
{ {
stringBuilder.Clear(); _ = stringBuilder.Clear();
stringBuilder.Append("0.1").Append('\t'); _ = stringBuilder.Append("0.1").Append('\t');
stringBuilder.Append("1").Append('\t'); _ = stringBuilder.Append("1").Append('\t');
stringBuilder.Append("2").Append('\t'); _ = stringBuilder.Append("2").Append('\t');
foreach (JsonProperty jsonProperty in jsonElements[i].EnumerateObject()) foreach (JsonProperty jsonProperty in jsonElements[i].EnumerateObject())
stringBuilder.Append(jsonProperty.Value).Append('\t'); _ = stringBuilder.Append(jsonProperty.Value).Append('\t');
stringBuilder.Remove(stringBuilder.Length - 1, 1); _ = stringBuilder.Remove(stringBuilder.Length - 1, 1);
lines.Add(stringBuilder.ToString()); lines.Add(stringBuilder.ToString());
} }
lines.Add(string.Concat("NUM_DATA_ROWS ", jsonElements.Length.ToString().PadLeft(9, '0'))); lines.Add(string.Concat("NUM_DATA_ROWS ", jsonElements.Length.ToString().PadLeft(9, '0')));
@ -78,9 +77,9 @@ namespace Adaptation.Shared
lines.Add(string.Concat("LOGISTICS_2", '\t', "B_CHAMBER=;B_INFO=", fileRead.EventName, ";B_INFO2=", fileRead.EquipmentType, ";B_JOBID=", fileRead.CellInstanceName, ";B_MES_ENTITY=", fileRead.MesEntity, ";B_MID=", logistics.MID, ";B_NULL_DATA=", fileRead.NullData, ";B_PPID=NO_PPID;B_PROCESS_JOBID=", logistics.ProcessJobID, ";B_PRODUCT=;B_SEQUENCE=", logistics.Sequence, ";B_WAFER_ID=;")); lines.Add(string.Concat("LOGISTICS_2", '\t', "B_CHAMBER=;B_INFO=", fileRead.EventName, ";B_INFO2=", fileRead.EquipmentType, ";B_JOBID=", fileRead.CellInstanceName, ";B_MES_ENTITY=", fileRead.MesEntity, ";B_MID=", logistics.MID, ";B_NULL_DATA=", fileRead.NullData, ";B_PPID=NO_PPID;B_PROCESS_JOBID=", logistics.ProcessJobID, ";B_PRODUCT=;B_SEQUENCE=", logistics.Sequence, ";B_WAFER_ID=;"));
lines.Add("END_HEADER"); lines.Add("END_HEADER");
} }
stringBuilder.Clear(); _ = stringBuilder.Clear();
foreach (string line in lines) foreach (string line in lines)
stringBuilder.AppendLine(line); _ = stringBuilder.AppendLine(line);
result = stringBuilder.ToString(); result = stringBuilder.ToString();
result = result.Replace(headerOffset, result.IndexOf("NUM_DATA_ROWS").ToString().PadLeft(9, '0')). result = result.Replace(headerOffset, result.IndexOf("NUM_DATA_ROWS").ToString().PadLeft(9, '0')).
Replace(dataOffset, result.IndexOf('"').ToString().PadLeft(9, '0')). Replace(dataOffset, result.IndexOf('"').ToString().PadLeft(9, '0')).
@ -136,7 +135,7 @@ namespace Adaptation.Shared
{ {
if (lines[r].StartsWith("END_HEADER")) if (lines[r].StartsWith("END_HEADER"))
break; break;
logistics.AppendLine(lines[i]); _ = logistics.AppendLine(lines[i]);
} }
break; break;
} }
@ -159,14 +158,14 @@ namespace Adaptation.Shared
StringBuilder stringBuilder = new(); StringBuilder stringBuilder = new();
foreach (string bodyLine in bodyLines) foreach (string bodyLine in bodyLines)
{ {
stringBuilder.Append('{'); _ = stringBuilder.Append('{');
segments = bodyLine.Trim().Split('\t'); segments = bodyLine.Trim().Split('\t');
if (!lookForNumbers) if (!lookForNumbers)
{ {
for (int c = 1; c < segments.Length; c++) for (int c = 1; c < segments.Length; c++)
{ {
value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\"); value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\");
stringBuilder.Append('"').Append(columns[c]).Append("\":\"").Append(value).Append("\","); _ = stringBuilder.Append('"').Append(columns[c]).Append("\":\"").Append(value).Append("\",");
} }
} }
else else
@ -175,17 +174,17 @@ namespace Adaptation.Shared
{ {
value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\"); value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\");
if (string.IsNullOrEmpty(value)) if (string.IsNullOrEmpty(value))
stringBuilder.Append('"').Append(columns[c]).Append("\":").Append(value).Append("null,"); _ = stringBuilder.Append('"').Append(columns[c]).Append("\":").Append(value).Append("null,");
else if (value.All(char.IsDigit)) else if (value.All(char.IsDigit))
stringBuilder.Append('"').Append(columns[c]).Append("\":").Append(value).Append(","); _ = stringBuilder.Append('"').Append(columns[c]).Append("\":").Append(value).Append(",");
else else
stringBuilder.Append('"').Append(columns[c]).Append("\":\"").Append(value).Append("\","); _ = stringBuilder.Append('"').Append(columns[c]).Append("\":\"").Append(value).Append("\",");
} }
} }
stringBuilder.Remove(stringBuilder.Length - 1, 1); _ = stringBuilder.Remove(stringBuilder.Length - 1, 1);
stringBuilder.AppendLine("},"); _ = stringBuilder.AppendLine("},");
} }
stringBuilder.Remove(stringBuilder.Length - 3, 3); _ = stringBuilder.Remove(stringBuilder.Length - 3, 3);
results = JsonSerializer.Deserialize<JsonElement[]>(string.Concat("[", stringBuilder, "]")); results = JsonSerializer.Deserialize<JsonElement[]>(string.Concat("[", stringBuilder, "]"));
} }
return results; return results;
@ -268,25 +267,13 @@ namespace Adaptation.Shared
return string.Concat(((int)searchFor).ToString().PadLeft(2, '0'), separator, searchFor.ToString().Replace("In", string.Concat(separator, "In")).Replace("Ex", string.Concat(separator, "Ex"))); return string.Concat(((int)searchFor).ToString().PadLeft(2, '0'), separator, searchFor.ToString().Replace("In", string.Concat(separator, "In")).Replace("Ex", string.Concat(separator, "Ex")));
} }
public static string EquipmentIntegration(bool addSpaces = true, char separator = ' ') public static string EquipmentIntegration(bool addSpaces = true, char separator = ' ') => GetString(SearchFor.EquipmentIntegration, addSpaces, separator);
{
return GetString(SearchFor.EquipmentIntegration, addSpaces, separator);
}
public static string BusinessIntegration(bool addSpaces = true, char separator = ' ') public static string BusinessIntegration(bool addSpaces = true, char separator = ' ') => GetString(SearchFor.BusinessIntegration, addSpaces, separator);
{
return GetString(SearchFor.BusinessIntegration, addSpaces, separator);
}
public static string SystemExport(bool addSpaces = true, char separator = ' ') public static string SystemExport(bool addSpaces = true, char separator = ' ') => GetString(SearchFor.SystemExport, addSpaces, separator);
{
return GetString(SearchFor.SystemExport, addSpaces, separator);
}
public static string Archive(bool addSpaces = true, char separator = ' ') public static string Archive(bool addSpaces = true, char separator = ' ') => GetString(SearchFor.Archive, addSpaces, separator);
{
return GetString(SearchFor.Archive, addSpaces, separator);
}
public static string GetLines(Logistics logistics, Properties.IScopeInfo scopeInfo, List<string> names, Dictionary<string, List<string>> keyValuePairs, string dateFormat, string timeFormat, List<string> pairedParameterNames, bool useDateTimeFromSequence = true, string format = "", List<string> ignoreParameterNames = null) public static string GetLines(Logistics logistics, Properties.IScopeInfo scopeInfo, List<string> names, Dictionary<string, List<string>> keyValuePairs, string dateFormat, string timeFormat, List<string> pairedParameterNames, bool useDateTimeFromSequence = true, string format = "", List<string> ignoreParameterNames = null)
{ {
@ -301,7 +288,7 @@ namespace Adaptation.Shared
const string columnDate = "Date"; const string columnDate = "Date";
const string columnTime = "Time"; const string columnTime = "Time";
const string firstDuplicate = "_1"; const string firstDuplicate = "_1";
result.AppendLine(scopeInfo.Header); _ = result.AppendLine(scopeInfo.Header);
StringBuilder line = new(); StringBuilder line = new();
if (logistics.NullData is null) if (logistics.NullData is null)
nullData = string.Empty; nullData = string.Empty;
@ -310,8 +297,8 @@ namespace Adaptation.Shared
int count = (from l in keyValuePairs select l.Value.Count).Min(); int count = (from l in keyValuePairs select l.Value.Count).Min();
for (int r = 0; r < count; r++) for (int r = 0; r < count; r++)
{ {
line.Clear(); _ = line.Clear();
line.Append("!"); _ = line.Append("!");
foreach (KeyValuePair<string, List<string>> keyValuePair in keyValuePairs) foreach (KeyValuePair<string, List<string>> keyValuePair in keyValuePairs)
{ {
if (!names.Contains(keyValuePair.Key)) if (!names.Contains(keyValuePair.Key))
@ -323,29 +310,29 @@ namespace Adaptation.Shared
if (string.IsNullOrEmpty(keyValuePair.Value[r]) || keyValuePair.Value[r] == nullData) if (string.IsNullOrEmpty(keyValuePair.Value[r]) || keyValuePair.Value[r] == nullData)
continue; continue;
else else
result.Append(line).Append(keyValuePair.Key).Append(';').AppendLine(keyValuePair.Value[r]); _ = result.Append(line).Append(keyValuePair.Key).Append(';').AppendLine(keyValuePair.Value[r]);
} }
else else
{ {
if (useDateTimeFromSequence && keyValuePair.Key == columnDate) if (useDateTimeFromSequence && keyValuePair.Key == columnDate)
line.Append(logistics.DateTimeFromSequence.ToString(dateFormat)); _ = line.Append(logistics.DateTimeFromSequence.ToString(dateFormat));
else if (useDateTimeFromSequence && keyValuePair.Key == columnTime) else if (useDateTimeFromSequence && keyValuePair.Key == columnTime)
line.Append(logistics.DateTimeFromSequence.ToString(timeFormat)); _ = line.Append(logistics.DateTimeFromSequence.ToString(timeFormat));
else if (!useDateTimeFromSequence && keyValuePair.Key == columnDate && keyValuePair.Value[r].Length == format.Length) else if (!useDateTimeFromSequence && keyValuePair.Key == columnDate && keyValuePair.Value[r].Length == format.Length)
line.Append(DateTime.ParseExact(keyValuePair.Value[r], format, CultureInfo.InvariantCulture).ToString(dateFormat)); _ = line.Append(DateTime.ParseExact(keyValuePair.Value[r], format, CultureInfo.InvariantCulture).ToString(dateFormat));
else if (!useDateTimeFromSequence && keyValuePair.Key == columnTime && keyValuePairs.ContainsKey(string.Concat(keyValuePair.Key, firstDuplicate)) && keyValuePairs[string.Concat(keyValuePair.Key, firstDuplicate)][r].Length == format.Length) else if (!useDateTimeFromSequence && keyValuePair.Key == columnTime && keyValuePairs.ContainsKey(string.Concat(keyValuePair.Key, firstDuplicate)) && keyValuePairs[string.Concat(keyValuePair.Key, firstDuplicate)][r].Length == format.Length)
line.Append(DateTime.ParseExact(keyValuePairs[string.Concat(keyValuePair.Key, firstDuplicate)][r], format, CultureInfo.InvariantCulture).ToString(timeFormat)); _ = line.Append(DateTime.ParseExact(keyValuePairs[string.Concat(keyValuePair.Key, firstDuplicate)][r], format, CultureInfo.InvariantCulture).ToString(timeFormat));
else if (string.IsNullOrEmpty(keyValuePair.Value[r]) || keyValuePair.Value[r] == nullData) else if (string.IsNullOrEmpty(keyValuePair.Value[r]) || keyValuePair.Value[r] == nullData)
line.Append(nullData); _ = line.Append(nullData);
else else
line.Append(keyValuePair.Value[r]); _ = line.Append(keyValuePair.Value[r]);
line.Append(';'); _ = line.Append(';');
} }
} }
if (!pairedParameterNames.Any()) if (!pairedParameterNames.Any())
{ {
line.Remove(line.Length - 1, 1); _ = line.Remove(line.Length - 1, 1);
result.AppendLine(line.ToString()); _ = result.AppendLine(line.ToString());
} }
} }
return result.ToString(); return result.ToString();
@ -401,19 +388,19 @@ namespace Adaptation.Shared
vs[s] = segments[s].Length; vs[s] = segments[s].Length;
} }
} }
stringBuilder.Clear(); _ = stringBuilder.Clear();
for (int s = 0; s < segments.Length; s++) for (int s = 0; s < segments.Length; s++)
stringBuilder.Append((s + 1).ToString().PadLeft(vs[s], ' ')).Append(outputSeperator); _ = stringBuilder.Append((s + 1).ToString().PadLeft(vs[s], ' ')).Append(outputSeperator);
stringBuilder.Remove(stringBuilder.Length - 1, 1); _ = stringBuilder.Remove(stringBuilder.Length - 1, 1);
results.Add(stringBuilder.ToString()); results.Add(stringBuilder.ToString());
for (int i = group[0]; i <= group[1]; i++) for (int i = group[0]; i <= group[1]; i++)
{ {
line = lines[i]; line = lines[i];
stringBuilder.Clear(); _ = stringBuilder.Clear();
segments = line.Split(inputSeperator); segments = line.Split(inputSeperator);
for (int s = 0; s < segments.Length; s++) for (int s = 0; s < segments.Length; s++)
stringBuilder.Append(segments[s].PadLeft(vs[s], ' ')).Append(outputSeperator); _ = stringBuilder.Append(segments[s].PadLeft(vs[s], ' ')).Append(outputSeperator);
stringBuilder.Remove(stringBuilder.Length - 1, 1); _ = stringBuilder.Remove(stringBuilder.Length - 1, 1);
results.Add(stringBuilder.ToString()); results.Add(stringBuilder.ToString());
} }
results.Add(string.Empty); results.Add(string.Empty);
@ -421,6 +408,4 @@ namespace Adaptation.Shared
return results; return results;
} }
}
} }

View File

@ -1,13 +1,10 @@
namespace Adaptation.Shared.Properties namespace Adaptation.Shared.Properties;
{
public interface IDescription public interface IDescription
{ {
int Test { get; } int Test { get; }
int Count { get; } int Count { get; }
int Index { get; } int Index { get; }
}
} }

View File

@ -1,8 +1,7 @@
namespace Adaptation.Shared.Properties namespace Adaptation.Shared.Properties;
{
public interface IFileRead public interface IFileRead
{ {
bool IsEvent { get; } bool IsEvent { get; }
string NullData { get; } string NullData { get; }
string MesEntity { get; } string MesEntity { get; }
@ -15,6 +14,4 @@ namespace Adaptation.Shared.Properties
bool UseCyclicalForDescription { get; } bool UseCyclicalForDescription { get; }
string CellInstanceConnectionName { get; } string CellInstanceConnectionName { get; }
string ParameterizedModelObjectDefinitionType { get; } string ParameterizedModelObjectDefinitionType { get; }
}
} }

View File

@ -1,11 +1,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Adaptation.Shared.Properties namespace Adaptation.Shared.Properties;
{
public interface ILogistics public interface ILogistics
{ {
public object NullData { get; } public object NullData { get; }
public string JobID { get; } //CellName public string JobID { get; } //CellName
@ -20,6 +19,4 @@ namespace Adaptation.Shared.Properties
public List<string> Logistics1 { get; set; } public List<string> Logistics1 { get; set; }
public List<Logistics2> Logistics2 { get; set; } public List<Logistics2> Logistics2 { get; set; }
}
} }

View File

@ -1,8 +1,7 @@
namespace Adaptation.Shared.Properties namespace Adaptation.Shared.Properties;
{
public interface ILogistics2 public interface ILogistics2
{ {
public string MID { get; } public string MID { get; }
public string RunNumber { get; } public string RunNumber { get; }
@ -12,6 +11,4 @@ namespace Adaptation.Shared.Properties
public string WaferLot { get; } public string WaferLot { get; }
public string Recipe { get; } public string Recipe { get; }
}
} }

View File

@ -1,13 +1,10 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace Adaptation.Shared.Properties namespace Adaptation.Shared.Properties;
{
public interface IProcessData public interface IProcessData
{ {
List<object> Details { get; } List<object> Details { get; }
}
} }

View File

@ -1,10 +1,9 @@
using System; using System;
namespace Adaptation.Shared.Properties namespace Adaptation.Shared.Properties;
{
public interface IScopeInfo public interface IScopeInfo
{ {
Enum Enum { get; } Enum Enum { get; }
string HTML { get; } string HTML { get; }
@ -15,6 +14,4 @@ namespace Adaptation.Shared.Properties
string QueryFilter { get; } string QueryFilter { get; }
string FileNameWithoutExtension { get; } string FileNameWithoutExtension { get; }
}
} }

View File

@ -1,8 +1,7 @@
namespace Adaptation.Shared namespace Adaptation.Shared;
{
public enum Test public enum Test
{ {
AFMRoughness = 34, AFMRoughness = 34,
BioRadQS408M = 25, BioRadQS408M = 25,
BioRadStratus = 26, BioRadStratus = 26,
@ -21,15 +20,20 @@ namespace Adaptation.Shared
DailyRPMXY = 18, DailyRPMXY = 18,
Denton = 9, Denton = 9,
DiffusionLength = 45, DiffusionLength = 45,
GRATXTCenter = 51,
GRATXTEdge = 52, //Largest
GrowthRateXML = 50,
Hall = 10, Hall = 10,
HgCV = 23, HgCV = 23,
JVXRD = 47,
Lehighton = 13, Lehighton = 13,
LogbookCAC = 49,
Microscope = 46, Microscope = 46,
MonthlyCV = 4, MonthlyCV = 4,
MonthlyHall = 11, MonthlyHall = 11,
MonthlyXRD = 32, MonthlyXRD = 32,
Photoreflectance = 22, Photoreflectance = 22,
PlatoA = 48, //Largest PlatoA = 48,
RPMAverage = 16, RPMAverage = 16,
RPMPLRatio = 17, RPMPLRatio = 17,
RPMXY = 15, RPMXY = 15,
@ -50,8 +54,5 @@ namespace Adaptation.Shared
WeeklyXRDSLStks = 43, WeeklyXRDSLStks = 43,
WeeklyXRDXRR = 44, WeeklyXRDXRR = 44,
XRDWeightedAverage = 31, XRDWeightedAverage = 31,
JVXRD = 47, XRDXY = 30,
XRDXY = 30
}
} }

View File

@ -5,19 +5,16 @@ using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
namespace _Tests.CreateSelfDescription.Staging.v2_36_1 namespace _Tests.CreateSelfDescription.Staging.v2_36_1;
[TestClass]
public class CDE2 : EAFLoggingUnitTesting
{ {
internal static CDE2 EAFLoggingUnitTesting { get; private set; }
[TestClass]
public class CDE2 : EAFLoggingUnitTesting
{
private static CDE2 _EAFLoggingUnitTesting;
internal static CDE2 EAFLoggingUnitTesting => _EAFLoggingUnitTesting;
public CDE2() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false) public CDE2() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false)
{ {
if (_EAFLoggingUnitTesting is null) if (EAFLoggingUnitTesting is null)
throw new Exception(); throw new Exception();
} }
@ -28,10 +25,10 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
[ClassInitialize] [ClassInitialize]
public static void ClassInitialize(TestContext testContext) public static void ClassInitialize(TestContext testContext)
{ {
if (_EAFLoggingUnitTesting is null) if (EAFLoggingUnitTesting is null)
_EAFLoggingUnitTesting = new CDE2(testContext); EAFLoggingUnitTesting = new CDE2(testContext);
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize"));
string[] fileNameAndText = _EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName); string[] fileNameAndText = EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName);
File.WriteAllText(fileNameAndText[0], fileNameAndText[1]); File.WriteAllText(fileNameAndText[0], fileNameAndText[1]);
File.WriteAllText(fileNameAndText[2], fileNameAndText[3]); File.WriteAllText(fileNameAndText[2], fileNameAndText[3]);
} }
@ -39,10 +36,10 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
[ClassCleanup()] [ClassCleanup()]
public static void ClassCleanup() public static void ClassCleanup()
{ {
if (!(_EAFLoggingUnitTesting.Logger is null)) if (EAFLoggingUnitTesting.Logger is not null)
_EAFLoggingUnitTesting.Logger.LogInformation("Cleanup"); EAFLoggingUnitTesting.Logger.LogInformation("Cleanup");
if (!(_EAFLoggingUnitTesting is null)) if (EAFLoggingUnitTesting is not null)
_EAFLoggingUnitTesting.Dispose(); EAFLoggingUnitTesting.Dispose();
} }
[TestMethod] [TestMethod]
@ -50,8 +47,6 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
{ {
} }
}
} }
// dotnet build --runtime win-x64 // dotnet build --runtime win-x64

View File

@ -7,19 +7,16 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
namespace _Tests.CreateSelfDescription.Staging.v2_36_1 namespace _Tests.CreateSelfDescription.Staging.v2_36_1;
[TestClass]
public class CDE3_EQPT : EAFLoggingUnitTesting
{ {
internal static CDE3_EQPT EAFLoggingUnitTesting { get; private set; }
[TestClass]
public class CDE3_EQPT : EAFLoggingUnitTesting
{
private static CDE3_EQPT _EAFLoggingUnitTesting;
internal static CDE3_EQPT EAFLoggingUnitTesting => _EAFLoggingUnitTesting;
public CDE3_EQPT() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false) public CDE3_EQPT() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false)
{ {
if (_EAFLoggingUnitTesting is null) if (EAFLoggingUnitTesting is null)
throw new Exception(); throw new Exception();
} }
@ -30,10 +27,10 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
[ClassInitialize] [ClassInitialize]
public static void ClassInitialize(TestContext testContext) public static void ClassInitialize(TestContext testContext)
{ {
if (_EAFLoggingUnitTesting is null) if (EAFLoggingUnitTesting is null)
_EAFLoggingUnitTesting = new CDE3_EQPT(testContext); EAFLoggingUnitTesting = new CDE3_EQPT(testContext);
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize"));
string[] fileNameAndText = _EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName); string[] fileNameAndText = EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName);
File.WriteAllText(fileNameAndText[0], fileNameAndText[1]); File.WriteAllText(fileNameAndText[0], fileNameAndText[1]);
File.WriteAllText(fileNameAndText[2], fileNameAndText[3]); File.WriteAllText(fileNameAndText[2], fileNameAndText[3]);
} }
@ -41,10 +38,10 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
[ClassCleanup()] [ClassCleanup()]
public static void ClassCleanup() public static void ClassCleanup()
{ {
if (!(_EAFLoggingUnitTesting.Logger is null)) if (EAFLoggingUnitTesting.Logger is not null)
_EAFLoggingUnitTesting.Logger.LogInformation("Cleanup"); EAFLoggingUnitTesting.Logger.LogInformation("Cleanup");
if (!(_EAFLoggingUnitTesting is null)) if (EAFLoggingUnitTesting is not null)
_EAFLoggingUnitTesting.Dispose(); EAFLoggingUnitTesting.Dispose();
} }
[TestMethod] [TestMethod]
@ -52,15 +49,13 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
{ {
string check = "WafrMeas.log|.RsM"; string check = "WafrMeas.log|.RsM";
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
string[] fileNameAndJson = _EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase); string[] fileNameAndJson = EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
Assert.IsTrue(fileNameAndJson[1].Contains(check)); Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]); File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
IFileRead fileRead = _EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false); IFileRead fileRead = EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName)); Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
}
} }
} }

View File

@ -7,19 +7,16 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
namespace _Tests.CreateSelfDescription.Staging.v2_36_1 namespace _Tests.CreateSelfDescription.Staging.v2_36_1;
[TestClass]
public class CDE3 : EAFLoggingUnitTesting
{ {
internal static CDE3 EAFLoggingUnitTesting { get; private set; }
[TestClass]
public class CDE3 : EAFLoggingUnitTesting
{
private static CDE3 _EAFLoggingUnitTesting;
internal static CDE3 EAFLoggingUnitTesting => _EAFLoggingUnitTesting;
public CDE3() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false) public CDE3() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false)
{ {
if (_EAFLoggingUnitTesting is null) if (EAFLoggingUnitTesting is null)
throw new Exception(); throw new Exception();
} }
@ -30,10 +27,10 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
[ClassInitialize] [ClassInitialize]
public static void ClassInitialize(TestContext testContext) public static void ClassInitialize(TestContext testContext)
{ {
if (_EAFLoggingUnitTesting is null) if (EAFLoggingUnitTesting is null)
_EAFLoggingUnitTesting = new CDE3(testContext); EAFLoggingUnitTesting = new CDE3(testContext);
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize"));
string[] fileNameAndText = _EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName); string[] fileNameAndText = EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName);
File.WriteAllText(fileNameAndText[0], fileNameAndText[1]); File.WriteAllText(fileNameAndText[0], fileNameAndText[1]);
File.WriteAllText(fileNameAndText[2], fileNameAndText[3]); File.WriteAllText(fileNameAndText[2], fileNameAndText[3]);
} }
@ -41,10 +38,10 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
[ClassCleanup()] [ClassCleanup()]
public static void ClassCleanup() public static void ClassCleanup()
{ {
if (!(_EAFLoggingUnitTesting.Logger is null)) if (EAFLoggingUnitTesting.Logger is not null)
_EAFLoggingUnitTesting.Logger.LogInformation("Cleanup"); EAFLoggingUnitTesting.Logger.LogInformation("Cleanup");
if (!(_EAFLoggingUnitTesting is null)) if (EAFLoggingUnitTesting is not null)
_EAFLoggingUnitTesting.Dispose(); EAFLoggingUnitTesting.Dispose();
} }
[TestMethod] [TestMethod]
@ -52,15 +49,13 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
{ {
string check = "*.RsM"; string check = "*.RsM";
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
string[] fileNameAndJson = _EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase); string[] fileNameAndJson = EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
Assert.IsTrue(fileNameAndJson[1].Contains(check)); Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]); File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
IFileRead fileRead = _EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false); IFileRead fileRead = EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName)); Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
}
} }
} }

View File

@ -10,19 +10,16 @@ using System.Reflection;
using System.Text.Json; using System.Text.Json;
using System.Threading; using System.Threading;
namespace _Tests.CreateSelfDescription.Staging.v2_36_1 namespace _Tests.CreateSelfDescription.Staging.v2_36_1;
[TestClass]
public class CDE5 : EAFLoggingUnitTesting
{ {
internal static CDE5 EAFLoggingUnitTesting { get; private set; }
[TestClass]
public class CDE5 : EAFLoggingUnitTesting
{
private static CDE5 _EAFLoggingUnitTesting;
internal static CDE5 EAFLoggingUnitTesting => _EAFLoggingUnitTesting;
public CDE5() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false) public CDE5() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false)
{ {
if (_EAFLoggingUnitTesting is null) if (EAFLoggingUnitTesting is null)
throw new Exception(); throw new Exception();
} }
@ -33,10 +30,10 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
[ClassInitialize] [ClassInitialize]
public static void ClassInitialize(TestContext testContext) public static void ClassInitialize(TestContext testContext)
{ {
if (_EAFLoggingUnitTesting is null) if (EAFLoggingUnitTesting is null)
_EAFLoggingUnitTesting = new CDE5(testContext); EAFLoggingUnitTesting = new CDE5(testContext);
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize"));
string[] fileNameAndText = _EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName); string[] fileNameAndText = EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName);
File.WriteAllText(fileNameAndText[0], fileNameAndText[1]); File.WriteAllText(fileNameAndText[0], fileNameAndText[1]);
File.WriteAllText(fileNameAndText[2], fileNameAndText[3]); File.WriteAllText(fileNameAndText[2], fileNameAndText[3]);
} }
@ -44,10 +41,10 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
[ClassCleanup()] [ClassCleanup()]
public static void ClassCleanup() public static void ClassCleanup()
{ {
if (!(_EAFLoggingUnitTesting.Logger is null)) if (EAFLoggingUnitTesting.Logger is not null)
_EAFLoggingUnitTesting.Logger.LogInformation("Cleanup"); EAFLoggingUnitTesting.Logger.LogInformation("Cleanup");
if (!(_EAFLoggingUnitTesting is null)) if (EAFLoggingUnitTesting is not null)
_EAFLoggingUnitTesting.Dispose(); EAFLoggingUnitTesting.Dispose();
} }
[TestMethod] [TestMethod]
@ -55,8 +52,6 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
{ {
} }
}
} }
// dotnet build --runtime win-x64 // dotnet build --runtime win-x64

View File

@ -7,19 +7,16 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
namespace _Tests.CreateSelfDescription.Staging.v2_36_1 namespace _Tests.CreateSelfDescription.Staging.v2_36_1;
[TestClass]
public class MET08RESIMAPCDE : EAFLoggingUnitTesting
{ {
internal static MET08RESIMAPCDE EAFLoggingUnitTesting { get; private set; }
[TestClass]
public class MET08RESIMAPCDE : EAFLoggingUnitTesting
{
private static MET08RESIMAPCDE _EAFLoggingUnitTesting;
internal static MET08RESIMAPCDE EAFLoggingUnitTesting => _EAFLoggingUnitTesting;
public MET08RESIMAPCDE() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false) public MET08RESIMAPCDE() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false)
{ {
if (_EAFLoggingUnitTesting is null) if (EAFLoggingUnitTesting is null)
throw new Exception(); throw new Exception();
} }
@ -30,10 +27,10 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
[ClassInitialize] [ClassInitialize]
public static void ClassInitialize(TestContext testContext) public static void ClassInitialize(TestContext testContext)
{ {
if (_EAFLoggingUnitTesting is null) if (EAFLoggingUnitTesting is null)
_EAFLoggingUnitTesting = new MET08RESIMAPCDE(testContext); EAFLoggingUnitTesting = new MET08RESIMAPCDE(testContext);
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize"));
string[] fileNameAndText = _EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName); string[] fileNameAndText = EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName);
File.WriteAllText(fileNameAndText[0], fileNameAndText[1]); File.WriteAllText(fileNameAndText[0], fileNameAndText[1]);
File.WriteAllText(fileNameAndText[2], fileNameAndText[3]); File.WriteAllText(fileNameAndText[2], fileNameAndText[3]);
} }
@ -41,10 +38,10 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
[ClassCleanup()] [ClassCleanup()]
public static void ClassCleanup() public static void ClassCleanup()
{ {
if (!(_EAFLoggingUnitTesting.Logger is null)) if (EAFLoggingUnitTesting.Logger is not null)
_EAFLoggingUnitTesting.Logger.LogInformation("Cleanup"); EAFLoggingUnitTesting.Logger.LogInformation("Cleanup");
if (!(_EAFLoggingUnitTesting is null)) if (EAFLoggingUnitTesting is not null)
_EAFLoggingUnitTesting.Dispose(); EAFLoggingUnitTesting.Dispose();
} }
[TestMethod] [TestMethod]
@ -52,13 +49,13 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
{ {
string check = "~IsXToOpenInsightMetrologyViewer"; string check = "~IsXToOpenInsightMetrologyViewer";
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
string[] fileNameAndJson = _EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase); string[] fileNameAndJson = EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
Assert.IsTrue(fileNameAndJson[1].Contains(check)); Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]); File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
IFileRead fileRead = _EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false); IFileRead fileRead = EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName)); Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
} }
[TestMethod] [TestMethod]
@ -66,13 +63,13 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
{ {
string check = "~IsXToIQSSi"; string check = "~IsXToIQSSi";
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
string[] fileNameAndJson = _EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase); string[] fileNameAndJson = EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
Assert.IsTrue(fileNameAndJson[1].Contains(check)); Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]); File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
IFileRead fileRead = _EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false); IFileRead fileRead = EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName)); Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
} }
[TestMethod] [TestMethod]
@ -80,13 +77,13 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
{ {
string check = "~IsXToOpenInsight"; string check = "~IsXToOpenInsight";
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
string[] fileNameAndJson = _EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase); string[] fileNameAndJson = EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
Assert.IsTrue(fileNameAndJson[1].Contains(check)); Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]); File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
IFileRead fileRead = _EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false); IFileRead fileRead = EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName)); Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
} }
[TestMethod] [TestMethod]
@ -94,13 +91,13 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
{ {
string check = "~IsXToOpenInsightMetrologyViewerAttachments"; string check = "~IsXToOpenInsightMetrologyViewerAttachments";
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
string[] fileNameAndJson = _EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase); string[] fileNameAndJson = EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
Assert.IsTrue(fileNameAndJson[1].Contains(check)); Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]); File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
IFileRead fileRead = _EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false); IFileRead fileRead = EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName)); Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
} }
[TestMethod] [TestMethod]
@ -108,13 +105,13 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
{ {
string check = "~IsXToAPC"; string check = "~IsXToAPC";
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
string[] fileNameAndJson = _EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase); string[] fileNameAndJson = EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
Assert.IsTrue(fileNameAndJson[1].Contains(check)); Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]); File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
IFileRead fileRead = _EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false); IFileRead fileRead = EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName)); Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
} }
[TestMethod] [TestMethod]
@ -122,13 +119,13 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
{ {
string check = "~IsXToSPaCe"; string check = "~IsXToSPaCe";
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
string[] fileNameAndJson = _EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase); string[] fileNameAndJson = EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
Assert.IsTrue(fileNameAndJson[1].Contains(check)); Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]); File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
IFileRead fileRead = _EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false); IFileRead fileRead = EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName)); Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
} }
[TestMethod] [TestMethod]
@ -136,13 +133,13 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
{ {
string check = "~IsXToArchive"; string check = "~IsXToArchive";
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
string[] fileNameAndJson = _EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase); string[] fileNameAndJson = EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
Assert.IsTrue(fileNameAndJson[1].Contains(check)); Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]); File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
IFileRead fileRead = _EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false); IFileRead fileRead = EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName)); Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
} }
[TestMethod] [TestMethod]
@ -150,13 +147,13 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
{ {
string check = "~IsArchive"; string check = "~IsArchive";
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
string[] fileNameAndJson = _EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase); string[] fileNameAndJson = EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
Assert.IsTrue(fileNameAndJson[1].Contains(check)); Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]); File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
IFileRead fileRead = _EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false); IFileRead fileRead = EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName)); Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
} }
[TestMethod] [TestMethod]
@ -164,15 +161,13 @@ namespace _Tests.CreateSelfDescription.Staging.v2_36_1
{ {
string check = "~IsDummy"; string check = "~IsDummy";
MethodBase methodBase = new StackFrame().GetMethod(); MethodBase methodBase = new StackFrame().GetMethod();
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
string[] fileNameAndJson = _EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase); string[] fileNameAndJson = EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
Assert.IsTrue(fileNameAndJson[1].Contains(check)); Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]); File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
IFileRead fileRead = _EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false); IFileRead fileRead = EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName)); Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
}
} }
} }

View File

@ -8,12 +8,11 @@ using System.IO;
using System.Reflection; using System.Reflection;
using System.Text.Json; using System.Text.Json;
namespace _Tests.Extract.Staging.v2_36_1 namespace _Tests.Extract.Staging.v2_36_1;
{
[TestClass] [TestClass]
public class CDE3_EQPT public class CDE3_EQPT
{ {
private static CreateSelfDescription.Staging.v2_36_1.CDE3_EQPT _CDE3_EQPT; private static CreateSelfDescription.Staging.v2_36_1.CDE3_EQPT _CDE3_EQPT;
@ -25,12 +24,7 @@ namespace _Tests.Extract.Staging.v2_36_1
} }
[TestMethod] [TestMethod]
public void Staging__v2_36_1__CDE3_EQPT__DownloadRsMFile() public void Staging__v2_36_1__CDE3_EQPT__DownloadRsMFile() => _CDE3_EQPT.Staging__v2_36_1__CDE3_EQPT__DownloadRsMFile();
{
_CDE3_EQPT.Staging__v2_36_1__CDE3_EQPT__DownloadRsMFile();
}
}
} }

View File

@ -8,12 +8,11 @@ using System.IO;
using System.Reflection; using System.Reflection;
using System.Text.Json; using System.Text.Json;
namespace _Tests.Extract.Staging.v2_36_1 namespace _Tests.Extract.Staging.v2_36_1;
{
[TestClass] [TestClass]
public class CDE3 public class CDE3
{ {
private static CreateSelfDescription.Staging.v2_36_1.CDE3 _CDE3; private static CreateSelfDescription.Staging.v2_36_1.CDE3 _CDE3;
@ -25,10 +24,7 @@ namespace _Tests.Extract.Staging.v2_36_1
} }
[TestMethod] [TestMethod]
public void Staging__v2_36_1__CDE3__RsM() public void Staging__v2_36_1__CDE3__RsM() => _CDE3.Staging__v2_36_1__CDE3__RsM();
{
_CDE3.Staging__v2_36_1__CDE3__RsM();
}
[TestMethod] [TestMethod]
public void Staging__v2_36_1__CDE3__RsM643047560320000000__Normal() public void Staging__v2_36_1__CDE3__RsM643047560320000000__Normal()
@ -44,7 +40,7 @@ namespace _Tests.Extract.Staging.v2_36_1
Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1)); Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1));
Assert.IsTrue(extractResult.Item3.Length > 0, "extractResult Array Length check!"); Assert.IsTrue(extractResult.Item3.Length > 0, "extractResult Array Length check!");
Assert.IsNotNull(extractResult.Item4); Assert.IsNotNull(extractResult.Item4);
Logistics logistics = new Logistics(fileRead); Logistics logistics = new(fileRead);
dateTime = Adaptation.FileHandlers.RsM.ProcessData.GetDateTime(logistics, string.Empty); dateTime = Adaptation.FileHandlers.RsM.ProcessData.GetDateTime(logistics, string.Empty);
Assert.IsTrue(dateTime == logistics.DateTimeFromSequence); Assert.IsTrue(dateTime == logistics.DateTimeFromSequence);
dateTime = Adaptation.FileHandlers.RsM.ProcessData.GetDateTime(logistics, "00:13 09/27/38"); dateTime = Adaptation.FileHandlers.RsM.ProcessData.GetDateTime(logistics, "00:13 09/27/38");
@ -69,7 +65,7 @@ Avg = 577.2195 0.58% SEMI Radial= 0.81%
bool logBodyCheck = logBody.Trim() == extractResult.Item1.Trim(); bool logBodyCheck = logBody.Trim() == extractResult.Item1.Trim();
if (!logBodyCheck) if (!logBodyCheck)
{ {
Process.Start("explorer.exe", variables[5]); _ = Process.Start("explorer.exe", variables[5]);
File.WriteAllText(Path.Combine(variables[5], $"{Path.GetFileName(variables[5])}.log"), extractResult.Item1); File.WriteAllText(Path.Combine(variables[5], $"{Path.GetFileName(variables[5])}.log"), extractResult.Item1);
} }
Assert.IsTrue(logBodyCheck, "Log Body doesn't match!"); Assert.IsTrue(logBodyCheck, "Log Body doesn't match!");
@ -85,8 +81,6 @@ Avg = 577.2195 0.58% SEMI Radial= 0.81%
Helpers.Metrology.UpdatePassDirectory(variables[2]); Helpers.Metrology.UpdatePassDirectory(variables[2]);
} }
}
} }
// dotnet build --runtime win-x64 // dotnet build --runtime win-x64

View File

@ -8,12 +8,11 @@ using System.IO;
using System.Reflection; using System.Reflection;
using System.Text.Json; using System.Text.Json;
namespace _Tests.Extract.Staging.v2_36_1 namespace _Tests.Extract.Staging.v2_36_1;
{
[TestClass] [TestClass]
public class MET08RESIMAPCDE public class MET08RESIMAPCDE
{ {
private static CreateSelfDescription.Staging.v2_36_1.MET08RESIMAPCDE _MET08RESIMAPCDE; private static CreateSelfDescription.Staging.v2_36_1.MET08RESIMAPCDE _MET08RESIMAPCDE;
@ -25,10 +24,7 @@ namespace _Tests.Extract.Staging.v2_36_1
} }
[TestMethod] [TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE() public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE() => _MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE();
{
_MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE();
}
[TestMethod] [TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE637710931421087642__Normal() public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE637710931421087642__Normal()
@ -43,7 +39,7 @@ namespace _Tests.Extract.Staging.v2_36_1
Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1)); Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1));
Assert.IsTrue(extractResult.Item3.Length > 0, "extractResult Array Length check!"); Assert.IsTrue(extractResult.Item3.Length > 0, "extractResult Array Length check!");
Assert.IsNotNull(extractResult.Item4); Assert.IsNotNull(extractResult.Item4);
Logistics logistics = new Logistics(fileRead); Logistics logistics = new(fileRead);
Tuple<string, string[], string[]> pdsfNew = Helpers.Metrology.GetLogisticsColumnsAndBody(fileRead, logistics, extractResult, pdsf); Tuple<string, string[], string[]> pdsfNew = Helpers.Metrology.GetLogisticsColumnsAndBody(fileRead, logistics, extractResult, pdsf);
Helpers.Metrology.CompareSave(variables[5], pdsf, pdsfNew); Helpers.Metrology.CompareSave(variables[5], pdsf, pdsfNew);
Assert.IsTrue(pdsf.Item1 == pdsfNew.Item1, "Item1 check!"); Assert.IsTrue(pdsf.Item1 == pdsfNew.Item1, "Item1 check!");
@ -57,54 +53,28 @@ namespace _Tests.Extract.Staging.v2_36_1
} }
[TestMethod] [TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_() public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_() => _MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_();
{
_MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_();
}
[TestMethod] [TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE__() public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE__() => _MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE__();
{
_MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE__();
}
[TestMethod] [TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE___() public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE___() => _MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE___();
{
_MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE___();
}
[TestMethod] [TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE____() public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE____() => _MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE____();
{
_MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE____();
}
[TestMethod] [TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_____() public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_____() => _MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_____();
{
_MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_____();
}
[TestMethod] [TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE______() public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE______() => _MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE______();
{
_MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE______();
}
[TestMethod] [TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_______() public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_______() => _MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_______();
{
_MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_______();
}
[TestMethod] [TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE________() public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE________() => _MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE________();
{
_MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE________();
}
}
} }

View File

@ -9,11 +9,10 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text.Json; using System.Text.Json;
namespace _Tests.Helpers namespace _Tests.Helpers;
{
public class Metrology public class Metrology
{ {
internal static Tuple<string, string[], string[]> GetLogisticsColumnsAndBody(string fileFullName) internal static Tuple<string, string[], string[]> GetLogisticsColumnsAndBody(string fileFullName)
{ {
@ -35,7 +34,7 @@ namespace _Tests.Helpers
string[] pdsfFiles; string[] pdsfFiles;
pdsfFiles = Directory.GetFiles(searchDirectory, searchPattern, SearchOption.TopDirectoryOnly); pdsfFiles = Directory.GetFiles(searchDirectory, searchPattern, SearchOption.TopDirectoryOnly);
if (!pdsfFiles.Any()) if (!pdsfFiles.Any())
Process.Start("explorer.exe", searchDirectory); _ = Process.Start("explorer.exe", searchDirectory);
Assert.IsTrue(pdsfFiles.Any(), "GetFiles check"); Assert.IsTrue(pdsfFiles.Any(), "GetFiles check");
results = GetLogisticsColumnsAndBody(pdsfFiles[0]); results = GetLogisticsColumnsAndBody(pdsfFiles[0]);
} }
@ -59,7 +58,7 @@ namespace _Tests.Helpers
internal static string[] GetItem2(Tuple<string, string[], string[]> pdsf, Tuple<string, string[], string[]> pdsfNew) internal static string[] GetItem2(Tuple<string, string[], string[]> pdsf, Tuple<string, string[], string[]> pdsfNew)
{ {
JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions() { WriteIndented = true }; JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
string jsonOld = JsonSerializer.Serialize(pdsf.Item2, pdsf.Item2.GetType(), jsonSerializerOptions); string jsonOld = JsonSerializer.Serialize(pdsf.Item2, pdsf.Item2.GetType(), jsonSerializerOptions);
string jsonNew = JsonSerializer.Serialize(pdsfNew.Item2, pdsfNew.Item2.GetType(), jsonSerializerOptions); string jsonNew = JsonSerializer.Serialize(pdsfNew.Item2, pdsfNew.Item2.GetType(), jsonSerializerOptions);
return new string[] { jsonOld, jsonNew }; return new string[] { jsonOld, jsonNew };
@ -109,7 +108,6 @@ namespace _Tests.Helpers
if (after.Length < ticks.Length) if (after.Length < ticks.Length)
{ {
connectionName = after; connectionName = after;
connectionNameAndTicks = ticks;
} }
else else
{ {
@ -129,7 +127,7 @@ namespace _Tests.Helpers
{ {
if (join[0] != join[1]) if (join[0] != join[1])
{ {
Process.Start("explorer.exe", textFileDirectory); _ = Process.Start("explorer.exe", textFileDirectory);
File.WriteAllText(Path.Combine(textFileDirectory, "0.tsv"), join[0]); File.WriteAllText(Path.Combine(textFileDirectory, "0.tsv"), join[0]);
File.WriteAllText(Path.Combine(textFileDirectory, "1.tsv"), join[1]); File.WriteAllText(Path.Combine(textFileDirectory, "1.tsv"), join[1]);
} }
@ -139,7 +137,7 @@ namespace _Tests.Helpers
{ {
if (json[0] != json[1]) if (json[0] != json[1])
{ {
Process.Start("explorer.exe", textFileDirectory); _ = Process.Start("explorer.exe", textFileDirectory);
File.WriteAllText(Path.Combine(textFileDirectory, "0.json"), json[0]); File.WriteAllText(Path.Combine(textFileDirectory, "0.json"), json[0]);
File.WriteAllText(Path.Combine(textFileDirectory, "1.json"), json[1]); File.WriteAllText(Path.Combine(textFileDirectory, "1.json"), json[1]);
} }
@ -149,12 +147,10 @@ namespace _Tests.Helpers
{ {
if (pdsf.Item1 != pdsfNew.Item1) if (pdsf.Item1 != pdsfNew.Item1)
{ {
Process.Start("explorer.exe", textFileDirectory); _ = Process.Start("explorer.exe", textFileDirectory);
File.WriteAllText(Path.Combine(textFileDirectory, "0.dat"), pdsf.Item1); File.WriteAllText(Path.Combine(textFileDirectory, "0.dat"), pdsf.Item1);
File.WriteAllText(Path.Combine(textFileDirectory, "1.dat"), pdsfNew.Item1); File.WriteAllText(Path.Combine(textFileDirectory, "1.dat"), pdsfNew.Item1);
} }
} }
}
} }

View File

@ -20,11 +20,10 @@ using System.Xml;
using System.Xml.Linq; using System.Xml.Linq;
using System.Xml.Serialization; using System.Xml.Serialization;
namespace Shared namespace Shared;
{
public class AdaptationTesting : ISMTP public class AdaptationTesting : ISMTP
{ {
protected readonly string _Environment; protected readonly string _Environment;
protected readonly string _HostNameAndPort; protected readonly string _HostNameAndPort;
@ -50,20 +49,11 @@ namespace Shared
public Dictionary<string, string> ParameterizedModelObjectDefinitionTypes => _ParameterizedModelObjectDefinitionTypes; public Dictionary<string, string> ParameterizedModelObjectDefinitionTypes => _ParameterizedModelObjectDefinitionTypes;
public Dictionary<string, List<Tuple<string, string>>> EquipmentDictionaryEventDescriptions => _EquipmentDictionaryEventDescriptions; public Dictionary<string, List<Tuple<string, string>>> EquipmentDictionaryEventDescriptions => _EquipmentDictionaryEventDescriptions;
void ISMTP.SendLowPriorityEmailMessage(string subject, string body) void ISMTP.SendLowPriorityEmailMessage(string subject, string body) => throw new NotImplementedException();
{
throw new NotImplementedException();
}
void ISMTP.SendHighPriorityEmailMessage(string subject, string body) void ISMTP.SendHighPriorityEmailMessage(string subject, string body) => throw new NotImplementedException();
{
throw new NotImplementedException();
}
void ISMTP.SendNormalPriorityEmailMessage(string subject, string body) void ISMTP.SendNormalPriorityEmailMessage(string subject, string body) => throw new NotImplementedException();
{
throw new NotImplementedException();
}
public AdaptationTesting(TestContext testContext, bool skipEquipmentDictionary) public AdaptationTesting(TestContext testContext, bool skipEquipmentDictionary)
{ {
@ -83,13 +73,13 @@ namespace Shared
_EquipmentDictionaryEventDescriptions = new Dictionary<string, List<Tuple<string, string>>>(); _EquipmentDictionaryEventDescriptions = new Dictionary<string, List<Tuple<string, string>>>();
} }
protected string GetEnvironment(TestContext testContext) protected static string GetEnvironment(TestContext testContext)
{ {
string result = testContext.TestName.Split('_')[0]; string result = testContext.TestName.Split('_')[0];
return result; return result;
} }
protected string GetHostNameAndPort(string environment) protected static string GetHostNameAndPort(string environment)
{ {
string result; string result;
result = environment switch result = environment switch
@ -127,7 +117,7 @@ namespace Shared
return result; return result;
} }
protected string GetCellInstanceConnectionName(string cellInstanceConnectionName) protected static string GetCellInstanceConnectionName(string cellInstanceConnectionName)
{ {
string result; string result;
if (string.IsNullOrEmpty(cellInstanceConnectionName) || cellInstanceConnectionName[cellInstanceConnectionName.Length - 1] != '_') if (string.IsNullOrEmpty(cellInstanceConnectionName) || cellInstanceConnectionName[cellInstanceConnectionName.Length - 1] != '_')
@ -135,8 +125,8 @@ namespace Shared
else else
{ {
bool check = false; bool check = false;
List<char> chars = new List<char>(); List<char> chars = new();
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new();
for (int i = cellInstanceConnectionName.Length - 1; i > -1; i--) for (int i = cellInstanceConnectionName.Length - 1; i > -1; i--)
{ {
if (!check && cellInstanceConnectionName[i] != '_') if (!check && cellInstanceConnectionName[i] != '_')
@ -147,7 +137,7 @@ namespace Shared
chars.Add(cellInstanceConnectionName[i]); chars.Add(cellInstanceConnectionName[i]);
} }
for (int i = chars.Count - 1; i > -1; i--) for (int i = chars.Count - 1; i > -1; i--)
stringBuilder.Append(chars[i]); _ = stringBuilder.Append(chars[i]);
result = stringBuilder.ToString(); result = stringBuilder.ToString();
} }
return result; return result;
@ -202,7 +192,7 @@ namespace Shared
string after = methodBaseName.Substring(before.Length); string after = methodBaseName.Substring(before.Length);
string versionDirectory = Path.Combine(testResultsDirectory, _Environment, cellInstanceName, cellInstanceVersionName); string versionDirectory = Path.Combine(testResultsDirectory, _Environment, cellInstanceName, cellInstanceVersionName);
if (!Directory.Exists(versionDirectory)) if (!Directory.Exists(versionDirectory))
Directory.CreateDirectory(versionDirectory); _ = Directory.CreateDirectory(versionDirectory);
comment = segments[segments.Length - 1]; comment = segments[segments.Length - 1];
if (after.Length < ticks.Length || after == comment) if (after.Length < ticks.Length || after == comment)
{ {
@ -223,7 +213,7 @@ namespace Shared
ticks = connectionNameAndTicks.Substring(cellInstanceConnectionNameFromMethodBaseName.Length); ticks = connectionNameAndTicks.Substring(cellInstanceConnectionNameFromMethodBaseName.Length);
} }
} }
if (string.IsNullOrEmpty(ticks) || string.IsNullOrEmpty(cellInstanceConnectionNameFromMethodBaseName) || !long.TryParse(ticks, out long _)) if (string.IsNullOrEmpty(ticks) || string.IsNullOrEmpty(cellInstanceConnectionNameFromMethodBaseName) || !long.TryParse(ticks, out _))
{ {
ticks = string.Empty; ticks = string.Empty;
comment = string.Empty; comment = string.Empty;
@ -233,7 +223,7 @@ namespace Shared
string methodBaseNameWithActualCICN = GetMethodBaseNameWithActualCICN(methodBaseName, rawCellInstanceName, cellInstanceConnectionNameFromMethodBaseName, cellInstanceConnectionName, ticks); string methodBaseNameWithActualCICN = GetMethodBaseNameWithActualCICN(methodBaseName, rawCellInstanceName, cellInstanceConnectionNameFromMethodBaseName, cellInstanceConnectionName, ticks);
if (string.IsNullOrEmpty(ticks)) if (string.IsNullOrEmpty(ticks))
{ {
textFiles = new string[] { }; textFiles = Array.Empty<string>();
fileFullName = Path.Combine(versionDirectory, methodBaseNameWithActualCICN, $"{cellInstanceConnectionNameFromMethodBaseName}.json"); fileFullName = Path.Combine(versionDirectory, methodBaseNameWithActualCICN, $"{cellInstanceConnectionNameFromMethodBaseName}.json");
} }
else else
@ -243,10 +233,10 @@ namespace Shared
fileFullName = Path.Combine(versionDirectory, segments[0], $"{cellInstanceConnectionNameFromMethodBaseName}.json"); fileFullName = Path.Combine(versionDirectory, segments[0], $"{cellInstanceConnectionNameFromMethodBaseName}.json");
if (!Directory.Exists(textDirectory)) if (!Directory.Exists(textDirectory))
{ {
textFiles = new string[] { }; textFiles = Array.Empty<string>();
string renameDirectory = Path.Combine(Path.GetDirectoryName(textDirectory), $"_Rename - {Path.GetFileName(textDirectory)}"); string renameDirectory = Path.Combine(Path.GetDirectoryName(textDirectory), $"_Rename - {Path.GetFileName(textDirectory)}");
Directory.CreateDirectory(renameDirectory); _ = Directory.CreateDirectory(renameDirectory);
Process.Start("explorer.exe", renameDirectory); _ = Process.Start("explorer.exe", renameDirectory);
File.WriteAllText(Path.Combine(renameDirectory, $"{nameof(FileConnectorConfiguration.SourceFileFilter)}.txt"), string.Empty); File.WriteAllText(Path.Combine(renameDirectory, $"{nameof(FileConnectorConfiguration.SourceFileFilter)}.txt"), string.Empty);
File.WriteAllText(Path.Combine(renameDirectory, $"{nameof(FileConnectorConfiguration.SourceFileLocation)}.txt"), string.Empty); File.WriteAllText(Path.Combine(renameDirectory, $"{nameof(FileConnectorConfiguration.SourceFileLocation)}.txt"), string.Empty);
} }
@ -255,7 +245,7 @@ namespace Shared
textFiles = Directory.GetFiles(textDirectory, "*.txt", SearchOption.TopDirectoryOnly); textFiles = Directory.GetFiles(textDirectory, "*.txt", SearchOption.TopDirectoryOnly);
if (!textFiles.Any()) if (!textFiles.Any())
{ {
Process.Start("explorer.exe", textDirectory); _ = Process.Start("explorer.exe", textDirectory);
File.WriteAllText(Path.Combine(textDirectory, "_ Why.why"), string.Empty); File.WriteAllText(Path.Combine(textDirectory, "_ Why.why"), string.Empty);
} }
} }
@ -282,54 +272,27 @@ namespace Shared
return results; return results;
} }
internal string GetEnvironment(string[] segments) internal static string GetEnvironment(string[] segments) => segments[0];
{
return segments[0];
}
internal string GetRawCellInstanceName(string[] segments) internal static string GetRawCellInstanceName(string[] segments) => segments[1];
{
return segments[1];
}
internal string GetCellInstanceName(string[] segments) internal static string GetCellInstanceName(string[] segments) => segments[2];
{
return segments[2];
}
internal string GetCellInstanceVersionName(string[] segments) internal static string GetCellInstanceVersionName(string[] segments) => segments[3];
{
return segments[3];
}
internal string GetCellInstanceConnectionNameFromMethodBaseName(string[] segments) internal static string GetCellInstanceConnectionNameFromMethodBaseName(string[] segments) => segments[4];
{
return segments[4];
}
internal string GetCellInstanceConnectionName(string[] segments) internal static string GetCellInstanceConnectionName(string[] segments) => segments[5];
{
return segments[5];
}
internal string GetTicks(string[] segments) internal static string GetTicks(string[] segments) => segments[6];
{
return segments[6];
}
internal string GetComment(string[] segments) internal static string GetComment(string[] segments) => segments[7];
{
return segments[7];
}
internal FileInfo GetFileName(string[] segments) internal static FileInfo GetFileName(string[] segments) => new(segments[8]);
{
return new FileInfo(segments[8]);
}
internal string[] GetTextFiles(string[] segments) internal static string[] GetTextFiles(string[] segments)
{ {
List<string> results = new List<string>(); List<string> results = new();
if (segments.Length > 8) if (segments.Length > 8)
{ {
for (int i = 9; i < segments.Length; i++) for (int i = 9; i < segments.Length; i++)
@ -338,24 +301,24 @@ namespace Shared
return results.ToArray(); return results.ToArray();
} }
protected Stream ToStream(string @this) protected static Stream ToStream(string @this)
{ {
MemoryStream memoryStream = new MemoryStream(); MemoryStream memoryStream = new();
StreamWriter streamWriter = new StreamWriter(memoryStream); StreamWriter streamWriter = new(memoryStream);
streamWriter.Write(@this); streamWriter.Write(@this);
streamWriter.Flush(); streamWriter.Flush();
memoryStream.Position = 0; memoryStream.Position = 0;
return memoryStream; return memoryStream;
} }
internal T ParseXML<T>(string @this, bool throwExceptions) where T : class internal static T ParseXML<T>(string @this, bool throwExceptions) where T : class
{ {
object result = null; object result = null;
try try
{ {
Stream stream = ToStream(@this.Trim()); Stream stream = ToStream(@this.Trim());
XmlReader xmlReader = XmlReader.Create(stream, new XmlReaderSettings() { ConformanceLevel = ConformanceLevel.Document }); XmlReader xmlReader = XmlReader.Create(stream, new XmlReaderSettings() { ConformanceLevel = ConformanceLevel.Document });
XmlSerializer xmlSerializer = new XmlSerializer(typeof(T), typeof(T).GetNestedTypes()); XmlSerializer xmlSerializer = new(typeof(T), typeof(T).GetNestedTypes());
result = xmlSerializer.Deserialize(xmlReader); result = xmlSerializer.Deserialize(xmlReader);
stream.Dispose(); stream.Dispose();
} }
@ -367,7 +330,7 @@ namespace Shared
return result as T; return result as T;
} }
protected CellInstanceVersion GetCellInstanceVersion(string url) protected static CellInstanceVersion GetCellInstanceVersion(string url)
{ {
CellInstanceVersion result; CellInstanceVersion result;
byte[] byteArray; byte[] byteArray;
@ -408,11 +371,11 @@ namespace Shared
return result; return result;
} }
protected Dictionary<string, int[]> GetComponentModelComponentsIndexes(CellInstanceVersion cellInstanceVersion, string cellInstanceConnectionName) protected static Dictionary<string, int[]> GetComponentModelComponentsIndexes(CellInstanceVersion cellInstanceVersion, string cellInstanceConnectionName)
{ {
Dictionary<string, int[]> results = new Dictionary<string, int[]>(); Dictionary<string, int[]> results = new();
ComponentsCellComponent componentsCellComponent; ComponentsCellComponent componentsCellComponent;
if (!(cellInstanceVersion.ComponentModel.Components is null)) if (cellInstanceVersion.ComponentModel.Components is not null)
{ {
for (int i = 0; i < cellInstanceVersion.ComponentModel.Components.Length; i++) for (int i = 0; i < cellInstanceVersion.ComponentModel.Components.Length; i++)
{ {
@ -430,7 +393,7 @@ namespace Shared
return results; return results;
} }
protected int[] GetCellInstanceConnectionNameIndexes(string cellInstanceConnectionName, Dictionary<string, int[]> componentModelComponentsIndexes) protected static int[] GetCellInstanceConnectionNameIndexes(string cellInstanceConnectionName, Dictionary<string, int[]> componentModelComponentsIndexes)
{ {
int[] result; int[] result;
if (string.IsNullOrEmpty(cellInstanceConnectionName)) if (string.IsNullOrEmpty(cellInstanceConnectionName))
@ -444,40 +407,22 @@ namespace Shared
return result; return result;
} }
protected bool GetNoEvents(ComponentsCellComponentCellComponent componentsCellComponentCellComponent) protected string[] GetCSharpTextB(FileInfo fileInfo, string cellInstanceName, string cellInstanceVersionName, CellInstanceVersion cellInstanceVersion)
{ {
bool result = componentsCellComponentCellComponent.Equipment.EquipmentDictionaries?.CellEquipmentDictionaryReference?.DictionaryName is null; List<string> results = new();
return result;
}
protected string GetEquipmentDictionaryName(ComponentsCellComponentCellComponent componentsCellComponentCellComponent, bool noEvents, string defaultEquipmentDictionaryName)
{
string result;
if (noEvents)
result = defaultEquipmentDictionaryName;
else
result = componentsCellComponentCellComponent.Equipment.EquipmentDictionaries.CellEquipmentDictionaryReference.DictionaryName;
return result;
}
protected string[] GetCSharpTextB(string cellInstanceName, string cellInstanceVersionName, CellInstanceVersion cellInstanceVersion, FileInfo fileInfo)
{
List<string> results = new List<string>();
string check; string check;
bool noEvents;
string loopName; string loopName;
string equipmentTypeName; string equipmentTypeName;
string equipmentDictionaryName;
string methodName = string.Empty; string methodName = string.Empty;
string extractText = string.Empty; string extractText = string.Empty;
string defaultEquipmentDictionaryName; StringBuilder stringBuilder = new();
string createSelfDescriptionText = string.Empty; string createSelfDescriptionText = string.Empty;
StringBuilder stringBuilder = new StringBuilder();
List<string> componentsCellComponentCellComponentEquipmentNames = new(); List<string> componentsCellComponentCellComponentEquipmentNames = new();
string cellInstanceNameWithoutHyphen = cellInstanceName.Replace('-', '_'); string cellInstanceNameWithoutHyphen = cellInstanceName.Replace('-', '_');
ComponentsCellComponentCellComponent componentsCellComponentCellComponent; ComponentsCellComponentCellComponent componentsCellComponentCellComponent;
List<string> componentsCellComponentCellComponentEquipmentTypeNames = new(); List<string> componentsCellComponentCellComponentEquipmentTypeNames = new();
string cellInstanceVersionNameAsCode = cellInstanceVersionName.Replace('.', '_'); string cellInstanceVersionNameAsCode = cellInstanceVersionName.Replace('.', '_');
List<string> componentsCellComponentCellComponentEquipmentDictionaryNames = new();
const string sourceDirectoryCloaking = nameof(FileConnectorConfiguration.SourceDirectoryCloaking); const string sourceDirectoryCloaking = nameof(FileConnectorConfiguration.SourceDirectoryCloaking);
for (int i = 1; i < 3; i++) for (int i = 1; i < 3; i++)
{ {
@ -487,14 +432,13 @@ namespace Shared
loopName = "CreateSelfDescription"; loopName = "CreateSelfDescription";
else else
throw new Exception(); throw new Exception();
defaultEquipmentDictionaryName = string.Empty;
if (i == 2) if (i == 2)
stringBuilder. _ = stringBuilder.
AppendLine("using Microsoft.VisualStudio.TestTools.UnitTesting;"). AppendLine("using Microsoft.VisualStudio.TestTools.UnitTesting;").
AppendLine("using Shared;"). AppendLine("using Shared;").
AppendLine("using System.Diagnostics;"); AppendLine("using System.Diagnostics;");
else if (i == 1) else if (i == 1)
stringBuilder. _ = stringBuilder.
AppendLine("using Adaptation.Shared.Methods;"). AppendLine("using Adaptation.Shared.Methods;").
AppendLine("using Microsoft.Extensions.Logging;"). AppendLine("using Microsoft.Extensions.Logging;").
AppendLine("using Microsoft.VisualStudio.TestTools.UnitTesting;"). AppendLine("using Microsoft.VisualStudio.TestTools.UnitTesting;").
@ -508,19 +452,19 @@ namespace Shared
AppendLine("using System.Threading;"); AppendLine("using System.Threading;");
else else
throw new Exception(); throw new Exception();
stringBuilder.AppendLine(). _ = stringBuilder.AppendLine().
Append("namespace _Tests.").Append(loopName).Append('.').Append(_Environment).Append('.').AppendLine(cellInstanceVersionNameAsCode). Append("namespace _Tests.").Append(loopName).Append('.').Append(_Environment).Append('.').AppendLine(cellInstanceVersionNameAsCode).
AppendLine("{"). AppendLine("{").
AppendLine(). AppendLine().
AppendLine("[TestClass]"); AppendLine("[TestClass]");
if (i == 2) if (i == 2)
stringBuilder. _ = stringBuilder.
Append("public class ").AppendLine(cellInstanceNameWithoutHyphen). Append("public class ").AppendLine(cellInstanceNameWithoutHyphen).
AppendLine("{"). AppendLine("{").
AppendLine(). AppendLine().
Append("private static CreateSelfDescription.").Append(_Environment).Append('.').Append(cellInstanceVersionNameAsCode).Append('.').Append(cellInstanceNameWithoutHyphen).Append(" _").Append(cellInstanceNameWithoutHyphen).AppendLine(";"); Append("private static CreateSelfDescription.").Append(_Environment).Append('.').Append(cellInstanceVersionNameAsCode).Append('.').Append(cellInstanceNameWithoutHyphen).Append(" _").Append(cellInstanceNameWithoutHyphen).AppendLine(";");
else if (i == 1) else if (i == 1)
stringBuilder. _ = stringBuilder.
Append("public class ").Append(cellInstanceNameWithoutHyphen).AppendLine(" : EAFLoggingUnitTesting"). Append("public class ").Append(cellInstanceNameWithoutHyphen).AppendLine(" : EAFLoggingUnitTesting").
AppendLine("{"). AppendLine("{").
AppendLine(). AppendLine().
@ -529,9 +473,9 @@ namespace Shared
else else
throw new Exception(); throw new Exception();
if (i == 2) if (i == 2)
stringBuilder.AppendLine(); _ = stringBuilder.AppendLine();
else if (i == 1) else if (i == 1)
stringBuilder. _ = stringBuilder.
AppendLine(). AppendLine().
Append("public ").Append(cellInstanceNameWithoutHyphen).AppendLine("() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false)"). Append("public ").Append(cellInstanceNameWithoutHyphen).AppendLine("() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false)").
AppendLine("{"). AppendLine("{").
@ -545,17 +489,17 @@ namespace Shared
AppendLine(); AppendLine();
else else
throw new Exception(); throw new Exception();
stringBuilder. _ = stringBuilder.
AppendLine("[ClassInitialize]"). AppendLine("[ClassInitialize]").
AppendLine("public static void ClassInitialize(TestContext testContext)"). AppendLine("public static void ClassInitialize(TestContext testContext)").
AppendLine("{"); AppendLine("{");
if (i == 2) if (i == 2)
stringBuilder. _ = stringBuilder.
Append("CreateSelfDescription.").Append(_Environment).Append('.').Append(cellInstanceVersionNameAsCode).Append('.').Append(cellInstanceNameWithoutHyphen).AppendLine(".ClassInitialize(testContext);"). Append("CreateSelfDescription.").Append(_Environment).Append('.').Append(cellInstanceVersionNameAsCode).Append('.').Append(cellInstanceNameWithoutHyphen).AppendLine(".ClassInitialize(testContext);").
Append("_").Append(cellInstanceNameWithoutHyphen).Append(" = CreateSelfDescription.").Append(_Environment).Append('.').Append(cellInstanceVersionNameAsCode).Append('.').Append(cellInstanceNameWithoutHyphen).AppendLine(".EAFLoggingUnitTesting;"). Append('_').Append(cellInstanceNameWithoutHyphen).Append(" = CreateSelfDescription.").Append(_Environment).Append('.').Append(cellInstanceVersionNameAsCode).Append('.').Append(cellInstanceNameWithoutHyphen).AppendLine(".EAFLoggingUnitTesting;").
AppendLine("}"); AppendLine("}");
else if (i == 1) else if (i == 1)
stringBuilder. _ = stringBuilder.
AppendLine("if (_EAFLoggingUnitTesting is null)"). AppendLine("if (_EAFLoggingUnitTesting is null)").
Append("_EAFLoggingUnitTesting = new ").Append(cellInstanceNameWithoutHyphen).AppendLine("(testContext);"). Append("_EAFLoggingUnitTesting = new ").Append(cellInstanceNameWithoutHyphen).AppendLine("(testContext);").
AppendLine("_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, \" - ClassInitialize\"));"). AppendLine("_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, \" - ClassInitialize\"));").
@ -566,9 +510,9 @@ namespace Shared
else else
throw new Exception(); throw new Exception();
if (i == 2) if (i == 2)
stringBuilder.AppendLine(); _ = stringBuilder.AppendLine();
else if (i == 1) else if (i == 1)
stringBuilder. _ = stringBuilder.
AppendLine(). AppendLine().
AppendLine("[ClassCleanup()]"). AppendLine("[ClassCleanup()]").
AppendLine("public static void ClassCleanup()"). AppendLine("public static void ClassCleanup()").
@ -586,18 +530,8 @@ namespace Shared
if (componentsCellComponent.Children.Length != 1) if (componentsCellComponent.Children.Length != 1)
continue; continue;
componentsCellComponentCellComponent = componentsCellComponent.Children[0]; componentsCellComponentCellComponent = componentsCellComponent.Children[0];
noEvents = GetNoEvents(componentsCellComponentCellComponent); if (componentsCellComponentCellComponent.Equipment.EquipmentDictionaries?.CellEquipmentDictionaryReference?.DictionaryName is not null)
if (noEvents) componentsCellComponentCellComponentEquipmentDictionaryNames.Add(componentsCellComponentCellComponent.Equipment.EquipmentDictionaries?.CellEquipmentDictionaryReference?.DictionaryName);
continue;
defaultEquipmentDictionaryName = GetEquipmentDictionaryName(componentsCellComponentCellComponent, noEvents, defaultEquipmentDictionaryName);
}
if (string.IsNullOrEmpty(defaultEquipmentDictionaryName))
throw new Exception("At least one dictionary name should be marked as used in EAF CI!");
foreach (ComponentsCellComponent componentsCellComponent in cellInstanceVersion.ComponentModel.Components)
{
if (componentsCellComponent.Children.Length != 1)
continue;
componentsCellComponentCellComponent = componentsCellComponent.Children[0];
componentsCellComponentCellComponentEquipmentNames.Add(componentsCellComponentCellComponent.Equipment.Name); componentsCellComponentCellComponentEquipmentNames.Add(componentsCellComponentCellComponent.Equipment.Name);
componentsCellComponentCellComponentEquipmentTypeNames.Add(componentsCellComponentCellComponent.Equipment.EquipmentType.Name); componentsCellComponentCellComponentEquipmentTypeNames.Add(componentsCellComponentCellComponent.Equipment.EquipmentType.Name);
methodName = $"{_Environment}__{cellInstanceVersionNameAsCode}__{cellInstanceNameWithoutHyphen}__{componentsCellComponentCellComponent.Equipment.Name.Replace('-', '_')}"; methodName = $"{_Environment}__{cellInstanceVersionNameAsCode}__{cellInstanceNameWithoutHyphen}__{componentsCellComponentCellComponent.Equipment.Name.Replace('-', '_')}";
@ -607,40 +541,38 @@ namespace Shared
check = (from l in componentsCellComponentCellComponent.Equipment.ConnectionSettings.Setting where l.Name == sourceDirectoryCloaking select l.Value).FirstOrDefault(); check = (from l in componentsCellComponentCellComponent.Equipment.ConnectionSettings.Setting where l.Name == sourceDirectoryCloaking select l.Value).FirstOrDefault();
if (string.IsNullOrEmpty(check)) if (string.IsNullOrEmpty(check))
check = componentsCellComponentCellComponent.Equipment.SourceFileFilter; check = componentsCellComponentCellComponent.Equipment.SourceFileFilter;
stringBuilder. _ = stringBuilder.
AppendLine("[TestMethod]"). AppendLine("[TestMethod]").
Append("public void ").Append(methodName).AppendLine("()"). Append("public void ").Append(methodName).AppendLine("()").
AppendLine("{"); AppendLine("{");
if (i == 2) if (i == 2)
stringBuilder.Append("_").Append(cellInstanceNameWithoutHyphen).Append('.').Append(methodName).AppendLine("();"); _ = stringBuilder.Append('_').Append(cellInstanceNameWithoutHyphen).Append('.').Append(methodName).AppendLine("();");
else if (i == 1) else if (i == 1)
{ {
if (componentsCellComponentCellComponent.Equipment.EquipmentType.Version != cellInstanceVersionName) if (componentsCellComponentCellComponent.Equipment.EquipmentType.Version != cellInstanceVersionName)
throw new Exception("Versions should match!"); throw new Exception("Versions should match!");
equipmentTypeName = componentsCellComponentCellComponent.Equipment.EquipmentType.Name; equipmentTypeName = componentsCellComponentCellComponent.Equipment.EquipmentType.Name;
noEvents = GetNoEvents(componentsCellComponentCellComponent); _ = stringBuilder.
equipmentDictionaryName = GetEquipmentDictionaryName(componentsCellComponentCellComponent, noEvents, defaultEquipmentDictionaryName); Append("string check = \"").Append(check.Split('\\').Last()).AppendLine("\";").
stringBuilder.
Append("string check = \"").Append(check).AppendLine("\";").
AppendLine("MethodBase methodBase = new StackFrame().GetMethod();"). AppendLine("MethodBase methodBase = new StackFrame().GetMethod();").
AppendLine("_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, \" - Getting configuration\"));"). AppendLine("_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, \" - Getting configuration\"));").
AppendLine("string[] fileNameAndJson = _EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);"). AppendLine("string[] fileNameAndJson = _EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);").
AppendLine("Assert.IsTrue(fileNameAndJson[1].Contains(check));"). AppendLine("Assert.IsTrue(fileNameAndJson[1].Contains(check));").
AppendLine("File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);"); AppendLine("File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);");
if (componentsCellComponentCellComponent.Equipment.EquipmentType.Name == componentsCellComponentCellComponentEquipmentTypeNames[0]) if (componentsCellComponentCellComponent.Equipment.EquipmentType.Name == componentsCellComponentCellComponentEquipmentTypeNames[0])
stringBuilder. _ = stringBuilder.
AppendLine("IFileRead fileRead = _EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);"). AppendLine("IFileRead fileRead = _EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);").
AppendLine("Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));"); AppendLine("Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));");
stringBuilder. _ = stringBuilder.
AppendLine("_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, \" - Exit\"));"); AppendLine("_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, \" - Exit\"));");
} }
else else
throw new Exception(); throw new Exception();
stringBuilder. _ = stringBuilder.
AppendLine("}"). AppendLine("}").
AppendLine(); AppendLine();
} }
stringBuilder. _ = stringBuilder.
AppendLine("}"). AppendLine("}").
AppendLine(). AppendLine().
AppendLine("}"). AppendLine("}").
@ -655,14 +587,14 @@ namespace Shared
createSelfDescriptionText = stringBuilder.ToString().Trim(); createSelfDescriptionText = stringBuilder.ToString().Trim();
else else
throw new Exception(); throw new Exception();
stringBuilder.Clear(); _ = stringBuilder.Clear();
} }
if (string.IsNullOrEmpty(cellInstanceVersion.FrozenBy)) if (componentsCellComponentCellComponentEquipmentDictionaryNames.Any() && string.IsNullOrEmpty(cellInstanceVersion.FrozenBy))
{ {
if (!cellInstanceVersion.CellCommunicatingRule.Contains('.') || !(from l in componentsCellComponentCellComponentEquipmentNames where l == cellInstanceVersion.CellCommunicatingRule.Split('.')[0] select true).Any()) if (!cellInstanceVersion.CellCommunicatingRule.EndsWith(".Communicating") || !(from l in componentsCellComponentCellComponentEquipmentNames where l == cellInstanceVersion.CellCommunicatingRule.Split('.')[0] select true).Any())
throw new Exception("CellCommunicatingRule not correct in Mango!"); throw new Exception($"{methodName} - CellCommunicatingRule not correct in Mango!");
if (!cellInstanceVersion.CellNotCommunicatingRule.Contains('.') || !(from l in componentsCellComponentCellComponentEquipmentNames where l == cellInstanceVersion.CellNotCommunicatingRule.Split('.')[0] select true).Any()) if (!cellInstanceVersion.CellNotCommunicatingRule.EndsWith(".NotCommunicating") || !(from l in componentsCellComponentCellComponentEquipmentNames where l == cellInstanceVersion.CellNotCommunicatingRule.Split('.')[0] select true).Any())
throw new Exception("CellNotCommunicatingRule not correct in Mango!"); throw new Exception($"{methodName} - CellNotCommunicatingRule not correct in Mango!");
} }
string versionLevelDirectory = Path.GetDirectoryName(fileInfo.DirectoryName); string versionLevelDirectory = Path.GetDirectoryName(fileInfo.DirectoryName);
results.Add(Path.Combine(versionLevelDirectory, $"{cellInstanceName}-0-CreateSelfDescription.txt")); results.Add(Path.Combine(versionLevelDirectory, $"{cellInstanceName}-0-CreateSelfDescription.txt"));
@ -672,11 +604,12 @@ namespace Shared
return results.ToArray(); return results.ToArray();
} }
protected FileConnectorConfiguration GetFileConnectorConfiguration(string json, ComponentsCellComponentCellComponent componentsCellComponentCellComponent) protected static FileConnectorConfiguration GetFileConnectorConfiguration(string json, ComponentsCellComponentCellComponent componentsCellComponentCellComponent)
{ {
FileConnectorConfiguration result; FileConnectorConfiguration result;
const string sourceDirectoryCloaking = nameof(FileConnectorConfiguration.SourceDirectoryCloaking); const string sourceDirectoryCloaking = nameof(FileConnectorConfiguration.SourceDirectoryCloaking);
JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions { Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) } }; JsonSerializerOptions jsonSerializerOptions = new()
{ Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) } };
json = json.Replace(string.Concat("\"", nameof(FileConnectorConfiguration.ConnectionSettings), "\":"), string.Concat("\"Ignore", nameof(FileConnectorConfiguration.ConnectionSettings), "\":")); json = json.Replace(string.Concat("\"", nameof(FileConnectorConfiguration.ConnectionSettings), "\":"), string.Concat("\"Ignore", nameof(FileConnectorConfiguration.ConnectionSettings), "\":"));
result = JsonSerializer.Deserialize<FileConnectorConfiguration>(json, jsonSerializerOptions); result = JsonSerializer.Deserialize<FileConnectorConfiguration>(json, jsonSerializerOptions);
if (string.IsNullOrEmpty(result.SourceFileFilter)) if (string.IsNullOrEmpty(result.SourceFileFilter))
@ -691,7 +624,7 @@ namespace Shared
result.FolderAgeCheckIndividualSubFolders = false; result.FolderAgeCheckIndividualSubFolders = false;
result.ConnectionSettings = new List<ConnectionSetting>(); result.ConnectionSettings = new List<ConnectionSetting>();
result.SourceFileFilters = result.SourceFileFilter.Split('|').ToList(); result.SourceFileFilters = result.SourceFileFilter.Split('|').ToList();
if (!(componentsCellComponentCellComponent.Equipment?.ConnectionSettings is null)) if (componentsCellComponentCellComponent.Equipment?.ConnectionSettings is not null)
{ {
foreach (Setting setting in componentsCellComponentCellComponent.Equipment.ConnectionSettings.Setting) foreach (Setting setting in componentsCellComponentCellComponent.Equipment.ConnectionSettings.Setting)
result.ConnectionSettings.Add(new ConnectionSetting(null, null) { Name = setting.Name, Value = setting.Value }); result.ConnectionSettings.Add(new ConnectionSetting(null, null) { Name = setting.Name, Value = setting.Value });
@ -727,7 +660,7 @@ namespace Shared
return result; return result;
} }
protected EquipmentTypeVersion GetEquipmentTypeVersion(string url) protected static EquipmentTypeVersion GetEquipmentTypeVersion(string url)
{ {
EquipmentTypeVersion result; EquipmentTypeVersion result;
byte[] byteArray; byte[] byteArray;
@ -752,7 +685,7 @@ namespace Shared
return result; return result;
} }
protected Tuple<string, string, string, EquipmentTypeVersion> GetEquipmentTypeVersionTuple(string cellInstanceName, string cellInstanceVersionName, CellInstanceVersion cellInstanceVersion, string cellInstanceConnectionName) protected Tuple<string, string, string, EquipmentTypeVersion> GetEquipmentTypeVersionTuple(CellInstanceVersion cellInstanceVersion, string cellInstanceConnectionName)
{ {
Tuple<string, string, string, EquipmentTypeVersion> result; Tuple<string, string, string, EquipmentTypeVersion> result;
EquipmentTypeVersion equipmentTypeVersion; EquipmentTypeVersion equipmentTypeVersion;
@ -786,7 +719,8 @@ namespace Shared
protected IList<ModelObjectParameterDefinition> GetModelObjectParameters(string json) protected IList<ModelObjectParameterDefinition> GetModelObjectParameters(string json)
{ {
IList<ModelObjectParameterDefinition> results; IList<ModelObjectParameterDefinition> results;
JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions { Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) } }; JsonSerializerOptions jsonSerializerOptions = new()
{ Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) } };
JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json); JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
string parameters = "Parameters"; string parameters = "Parameters";
string fileHandlerObjectTypes = nameof(FileHandlerObjectTypes); string fileHandlerObjectTypes = nameof(FileHandlerObjectTypes);
@ -835,8 +769,10 @@ namespace Shared
{ {
if (componentsCellComponentCellComponentEquipment?.EquipmentDictionaries.CellEquipmentDictionaryReference is null) if (componentsCellComponentCellComponentEquipment?.EquipmentDictionaries.CellEquipmentDictionaryReference is null)
{ {
equipmentDictionaryName = equipmentTypeVersion.Dictionaries.EquipmentTypeDictionaryReference.DictionaryName; // equipmentDictionaryName = equipmentTypeVersion.Dictionaries.EquipmentTypeDictionaryReference.DictionaryName;
equipmentDictionaryVersionName = equipmentTypeVersion.Dictionaries.EquipmentTypeDictionaryReference.DictionaryVersion; // equipmentDictionaryVersionName = equipmentTypeVersion.Dictionaries.EquipmentTypeDictionaryReference.DictionaryVersion;
equipmentDictionaryName = string.Empty;
equipmentDictionaryVersionName = string.Empty;
} }
else else
{ {
@ -848,7 +784,7 @@ namespace Shared
return results; return results;
} }
protected EquipmentDictionaryVersion GetEquipmentDictionaryVersion(string url) protected static EquipmentDictionaryVersion GetEquipmentDictionaryVersion(string url)
{ {
EquipmentDictionaryVersion result; EquipmentDictionaryVersion result;
string xml; string xml;
@ -870,7 +806,7 @@ namespace Shared
return result; return result;
} }
protected Tuple<string, string, string, EquipmentDictionaryVersion> GetEquipmentDictionaryVersionTuple(string cellInstanceName, string cellInstanceVersionName, CellInstanceVersion cellInstanceVersion, string cellInstanceConnectionName, EquipmentTypeVersion equipmentTypeVersion) protected Tuple<string, string, string, EquipmentDictionaryVersion> GetEquipmentDictionaryVersionTuple(CellInstanceVersion cellInstanceVersion, string cellInstanceConnectionName, EquipmentTypeVersion equipmentTypeVersion)
{ {
Tuple<string, string, string, EquipmentDictionaryVersion> result; Tuple<string, string, string, EquipmentDictionaryVersion> result;
string equipmentDictionaryName; string equipmentDictionaryName;
@ -915,6 +851,8 @@ namespace Shared
results = new List<Tuple<string, string>>(); results = new List<Tuple<string, string>>();
else if (string.IsNullOrEmpty(equipmentDictionaryVersionTuple.Item1)) else if (string.IsNullOrEmpty(equipmentDictionaryVersionTuple.Item1))
throw new Exception(); throw new Exception();
else if (equipmentDictionaryVersionTuple?.Item4?.Events?.Event is null)
results = new List<Tuple<string, string>>();
else if (_EquipmentDictionaryEventDescriptions.ContainsKey(equipmentDictionaryVersionTuple.Item1)) else if (_EquipmentDictionaryEventDescriptions.ContainsKey(equipmentDictionaryVersionTuple.Item1))
results = _EquipmentDictionaryEventDescriptions[equipmentDictionaryVersionTuple.Item1]; results = _EquipmentDictionaryEventDescriptions[equipmentDictionaryVersionTuple.Item1];
else else
@ -933,15 +871,16 @@ namespace Shared
return result; return result;
} }
protected Dictionary<string, object> GetKeyValuePairs(string cellInstanceName, string cellInstanceVersionName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, List<Tuple<string, string>> equipmentDictionaryIsAlwaysEnabledEvents) protected Dictionary<string, object> GetKeyValuePairs(string cellInstanceName, string cellInstanceVersionName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList<ModelObjectParameterDefinition> modelObjectParameters, string equipmentDictionaryName, List<Tuple<string, string>> equipmentDictionaryIsAlwaysEnabledEvents)
{ {
Dictionary<string, object> results = new Dictionary<string, object> Dictionary<string, object> results = new()
{ {
{ nameof(Environment), _Environment }, { nameof(Environment), _Environment },
{ nameof(HostNameAndPort), _HostNameAndPort }, { nameof(HostNameAndPort), _HostNameAndPort },
{ nameof(cellInstanceName), cellInstanceName }, { nameof(cellInstanceName), cellInstanceName },
{ nameof(equipmentTypeName), equipmentTypeName }, { nameof(equipmentTypeName), equipmentTypeName },
{ nameof(cellInstanceVersionName), cellInstanceVersionName }, { nameof(cellInstanceVersionName), cellInstanceVersionName },
{ nameof(equipmentDictionaryName), equipmentDictionaryName },
{ nameof(cellInstanceConnectionName), cellInstanceConnectionName }, { nameof(cellInstanceConnectionName), cellInstanceConnectionName },
{ nameof(FileConnectorConfiguration), fileConnectorConfiguration }, { nameof(FileConnectorConfiguration), fileConnectorConfiguration },
{ nameof(IList<ModelObjectParameterDefinition>), modelObjectParameters }, { nameof(IList<ModelObjectParameterDefinition>), modelObjectParameters },
@ -960,9 +899,9 @@ namespace Shared
string cellInstanceVersionName = GetCellInstanceVersionName(segments); string cellInstanceVersionName = GetCellInstanceVersionName(segments);
string cellInstanceConnectionName = GetCellInstanceConnectionName(segments); string cellInstanceConnectionName = GetCellInstanceConnectionName(segments);
if (!string.IsNullOrEmpty(cellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName)) if (!string.IsNullOrEmpty(cellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName))
Directory.CreateDirectory(fileInfo.Directory.FullName); _ = Directory.CreateDirectory(fileInfo.Directory.FullName);
Tuple<string, CellInstanceVersion> cellInstanceVersionTuple = GetCellInstanceVersionTuple(cellInstanceName, cellInstanceVersionName); Tuple<string, CellInstanceVersion> cellInstanceVersionTuple = GetCellInstanceVersionTuple(cellInstanceName, cellInstanceVersionName);
results = GetCSharpTextB(cellInstanceName, cellInstanceVersionName, cellInstanceVersionTuple.Item2, fileInfo); results = GetCSharpTextB(fileInfo, cellInstanceName, cellInstanceVersionName, cellInstanceVersionTuple.Item2);
return results; return results;
} }
@ -975,15 +914,15 @@ namespace Shared
string cellInstanceVersionName = GetCellInstanceVersionName(segments); string cellInstanceVersionName = GetCellInstanceVersionName(segments);
string cellInstanceConnectionName = GetCellInstanceConnectionName(segments); string cellInstanceConnectionName = GetCellInstanceConnectionName(segments);
if (!string.IsNullOrEmpty(cellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName)) if (!string.IsNullOrEmpty(cellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName))
Directory.CreateDirectory(fileInfo.Directory.FullName); _ = Directory.CreateDirectory(fileInfo.Directory.FullName);
Tuple<string, CellInstanceVersion> cellInstanceVersionTuple = GetCellInstanceVersionTuple(cellInstanceName, cellInstanceVersionName); Tuple<string, CellInstanceVersion> cellInstanceVersionTuple = GetCellInstanceVersionTuple(cellInstanceName, cellInstanceVersionName);
Tuple<string, FileConnectorConfiguration> fileConnectorConfigurationTuple = GetFileConnectorConfigurationTuple(cellInstanceVersionTuple, cellInstanceConnectionName); Tuple<string, FileConnectorConfiguration> fileConnectorConfigurationTuple = GetFileConnectorConfigurationTuple(cellInstanceVersionTuple, cellInstanceConnectionName);
Tuple<string, string, string, EquipmentTypeVersion> equipmentTypeVersionTuple = GetEquipmentTypeVersionTuple(cellInstanceName, cellInstanceVersionName, cellInstanceVersionTuple.Item2, cellInstanceConnectionName); Tuple<string, string, string, EquipmentTypeVersion> equipmentTypeVersionTuple = GetEquipmentTypeVersionTuple(cellInstanceVersionTuple.Item2, cellInstanceConnectionName);
Tuple<string, string> parameterizedModelObjectDefinitionTypeTuple = GetParameterizedModelObjectDefinitionTypeTuple(equipmentTypeVersionTuple); Tuple<string, string> parameterizedModelObjectDefinitionTypeTuple = GetParameterizedModelObjectDefinitionTypeTuple(equipmentTypeVersionTuple);
Tuple<string, IList<ModelObjectParameterDefinition>> modelObjectParametersTuple = GetModelObjectParameters(equipmentTypeVersionTuple); Tuple<string, IList<ModelObjectParameterDefinition>> modelObjectParametersTuple = GetModelObjectParameters(equipmentTypeVersionTuple);
Tuple<string, string, string, EquipmentDictionaryVersion> equipmentDictionaryVersionTuple = GetEquipmentDictionaryVersionTuple(cellInstanceName, cellInstanceVersionName, cellInstanceVersionTuple.Item2, cellInstanceConnectionName, equipmentTypeVersionTuple.Item4); Tuple<string, string, string, EquipmentDictionaryVersion> equipmentDictionaryVersionTuple = GetEquipmentDictionaryVersionTuple(cellInstanceVersionTuple.Item2, cellInstanceConnectionName, equipmentTypeVersionTuple.Item4);
Tuple<string, List<Tuple<string, string>>> equipmentDictionaryIsAlwaysEnabledEventsTuple = GetEquipmentDictionaryIsAlwaysEnabledEventsTuple(equipmentDictionaryVersionTuple); Tuple<string, List<Tuple<string, string>>> equipmentDictionaryIsAlwaysEnabledEventsTuple = GetEquipmentDictionaryIsAlwaysEnabledEventsTuple(equipmentDictionaryVersionTuple);
Dictionary<string, object> objects = GetKeyValuePairs(cellInstanceName, cellInstanceVersionName, cellInstanceConnectionName, fileConnectorConfigurationTuple.Item2, equipmentTypeVersionTuple.Item2, parameterizedModelObjectDefinitionTypeTuple.Item2, modelObjectParametersTuple.Item2, equipmentDictionaryIsAlwaysEnabledEventsTuple.Item2); Dictionary<string, object> objects = GetKeyValuePairs(cellInstanceName, cellInstanceVersionName, cellInstanceConnectionName, fileConnectorConfigurationTuple.Item2, equipmentTypeVersionTuple.Item2, parameterizedModelObjectDefinitionTypeTuple.Item2, modelObjectParametersTuple.Item2, equipmentDictionaryVersionTuple.Item2, equipmentDictionaryIsAlwaysEnabledEventsTuple.Item2);
string json = JsonSerializer.Serialize(objects, new JsonSerializerOptions { WriteIndented = true }); string json = JsonSerializer.Serialize(objects, new JsonSerializerOptions { WriteIndented = true });
results = new string[] { fileInfo.FullName, json }; results = new string[] { fileInfo.FullName, json };
return results; return results;
@ -996,16 +935,19 @@ namespace Shared
FileInfo fileInfo = GetFileName(segments); FileInfo fileInfo = GetFileName(segments);
string cellInstanceName = GetCellInstanceName(segments); string cellInstanceName = GetCellInstanceName(segments);
string cellInstanceVersionName = GetCellInstanceVersionName(segments); string cellInstanceVersionName = GetCellInstanceVersionName(segments);
Dictionary<string, string> fileParameter = new Dictionary<string, string>(); Dictionary<string, string> fileParameter = new();
string cellInstanceConnectionName = GetCellInstanceConnectionName(segments); string cellInstanceConnectionName = GetCellInstanceConnectionName(segments);
if (!string.IsNullOrEmpty(cellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName)) if (!string.IsNullOrEmpty(cellInstanceConnectionName) && !Directory.Exists(fileInfo.DirectoryName))
Directory.CreateDirectory(fileInfo.Directory.FullName); _ = Directory.CreateDirectory(fileInfo.Directory.FullName);
Dictionary<string, List<long>> dummyRuns = new Dictionary<string, List<long>>(); Dictionary<string, List<long>> dummyRuns = new();
Tuple<string, CellInstanceVersion> cellInstanceVersionTuple = GetCellInstanceVersionTuple(cellInstanceName, cellInstanceVersionName); Tuple<string, CellInstanceVersion> cellInstanceVersionTuple = GetCellInstanceVersionTuple(cellInstanceName, cellInstanceVersionName);
Tuple<string, FileConnectorConfiguration> fileConnectorConfigurationTuple = GetFileConnectorConfigurationTuple(cellInstanceVersionTuple, cellInstanceConnectionName); Tuple<string, FileConnectorConfiguration> fileConnectorConfigurationTuple = GetFileConnectorConfigurationTuple(cellInstanceVersionTuple, cellInstanceConnectionName);
Tuple<string, string, string, EquipmentTypeVersion> equipmentTypeVersionTuple = GetEquipmentTypeVersionTuple(cellInstanceName, cellInstanceVersionName, cellInstanceVersionTuple.Item2, cellInstanceConnectionName); Tuple<string, string, string, EquipmentTypeVersion> equipmentTypeVersionTuple = GetEquipmentTypeVersionTuple(cellInstanceVersionTuple.Item2, cellInstanceConnectionName);
Tuple<string, string> parameterizedModelObjectDefinitionTypeTuple = GetParameterizedModelObjectDefinitionTypeTuple(equipmentTypeVersionTuple); Tuple<string, string> parameterizedModelObjectDefinitionTypeTuple = GetParameterizedModelObjectDefinitionTypeTuple(equipmentTypeVersionTuple);
Tuple<string, IList<ModelObjectParameterDefinition>> modelObjectParametersTuple = GetModelObjectParameters(equipmentTypeVersionTuple); Tuple<string, IList<ModelObjectParameterDefinition>> modelObjectParametersTuple = GetModelObjectParameters(equipmentTypeVersionTuple);
Tuple<string, string, string, EquipmentDictionaryVersion> equipmentDictionaryVersionTuple = GetEquipmentDictionaryVersionTuple(cellInstanceVersionTuple.Item2, cellInstanceConnectionName, equipmentTypeVersionTuple.Item4);
_ = GetEquipmentDictionaryIsAlwaysEnabledEventsTuple(equipmentDictionaryVersionTuple);
if (!string.IsNullOrEmpty(sourceFileLocation) && sourceFileLocation != fileConnectorConfigurationTuple.Item2.SourceFileLocation) if (!string.IsNullOrEmpty(sourceFileLocation) && sourceFileLocation != fileConnectorConfigurationTuple.Item2.SourceFileLocation)
fileConnectorConfigurationTuple.Item2.SourceFileLocation = sourceFileLocation; fileConnectorConfigurationTuple.Item2.SourceFileLocation = sourceFileLocation;
if (!string.IsNullOrEmpty(sourceFileFilter) && sourceFileFilter != fileConnectorConfigurationTuple.Item2.SourceFileFilter) if (!string.IsNullOrEmpty(sourceFileFilter) && sourceFileFilter != fileConnectorConfigurationTuple.Item2.SourceFileFilter)
@ -1013,7 +955,7 @@ namespace Shared
fileConnectorConfigurationTuple.Item2.SourceFileFilter = sourceFileFilter; fileConnectorConfigurationTuple.Item2.SourceFileFilter = sourceFileFilter;
fileConnectorConfigurationTuple.Item2.SourceFileFilters = sourceFileFilter.Split('|').ToList(); fileConnectorConfigurationTuple.Item2.SourceFileFilters = sourceFileFilter.Split('|').ToList();
} }
result = Adaptation.FileHandlers.CellInstanceConnectionName.Get(this, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfigurationTuple.Item2, equipmentTypeVersionTuple.Item2, parameterizedModelObjectDefinitionTypeTuple.Item2, modelObjectParametersTuple.Item2, dummyRuns, useCyclicalForDescription, isEAFHosted: false); result = Adaptation.FileHandlers.CellInstanceConnectionName.Get(this, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfigurationTuple.Item2, equipmentTypeVersionTuple.Item2, parameterizedModelObjectDefinitionTypeTuple.Item2, modelObjectParametersTuple.Item2, equipmentDictionaryVersionTuple.Item2, dummyRuns, useCyclicalForDescription, isEAFHosted: false);
return result; return result;
} }
@ -1061,7 +1003,7 @@ namespace Shared
} }
} }
if (!Directory.Exists(fileInfo.Directory.FullName)) if (!Directory.Exists(fileInfo.Directory.FullName))
Directory.CreateDirectory(fileInfo.Directory.FullName); _ = Directory.CreateDirectory(fileInfo.Directory.FullName);
if (!fileInfo.Exists) if (!fileInfo.Exists)
throw new Exception(); throw new Exception();
string json = File.ReadAllText(fileInfo.FullName); string json = File.ReadAllText(fileInfo.FullName);
@ -1073,7 +1015,8 @@ namespace Shared
JsonElement fileConnectorConfigurationJsonElement = jsonElement.GetProperty(nameof(FileConnectorConfiguration)); JsonElement fileConnectorConfigurationJsonElement = jsonElement.GetProperty(nameof(FileConnectorConfiguration));
if (fileConnectorConfigurationJsonElement.ValueKind != JsonValueKind.Object) if (fileConnectorConfigurationJsonElement.ValueKind != JsonValueKind.Object)
throw new Exception(); throw new Exception();
JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions { Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) } }; JsonSerializerOptions jsonSerializerOptions = new()
{ Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) } };
FileConnectorConfiguration fileConnectorConfiguration = JsonSerializer.Deserialize<FileConnectorConfiguration>(fileConnectorConfigurationJsonElement.ToString(), jsonSerializerOptions); FileConnectorConfiguration fileConnectorConfiguration = JsonSerializer.Deserialize<FileConnectorConfiguration>(fileConnectorConfigurationJsonElement.ToString(), jsonSerializerOptions);
if (!string.IsNullOrEmpty(sourceFileFilter)) if (!string.IsNullOrEmpty(sourceFileFilter))
fileConnectorConfiguration.SourceFileFilter = sourceFileFilter; fileConnectorConfiguration.SourceFileFilter = sourceFileFilter;
@ -1113,7 +1056,6 @@ namespace Shared
return results; return results;
} }
}
} }
// namespace _Tests.Helpers { public class AdaptationTesting { } } // namespace _Tests.Helpers { public class AdaptationTesting { } }
// 2022-02-02 -> AdaptationTesting

View File

@ -1,11 +1,10 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using System; using System;
namespace Shared namespace Shared;
{
public class EAFLoggingUnitTesting : LoggingUnitTesting, IDisposable public class EAFLoggingUnitTesting : LoggingUnitTesting, IDisposable
{ {
protected readonly AdaptationTesting _AdaptationTesting; protected readonly AdaptationTesting _AdaptationTesting;
@ -20,11 +19,6 @@ namespace Shared
_AdaptationTesting = new AdaptationTesting(testContext, skipEquipmentDictionary); _AdaptationTesting = new AdaptationTesting(testContext, skipEquipmentDictionary);
} }
public new void Dispose() public new void Dispose() => base.Dispose();
{
base.Dispose();
}
}
} }

View File

@ -2,11 +2,10 @@ using System;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Shared namespace Shared;
{
public class IsEnvironment public class IsEnvironment
{ {
public enum Name public enum Name
{ {
@ -166,6 +165,4 @@ namespace Shared
return result; return result;
} }
}
} }

Some files were not shown because too many files have changed in this diff Show More