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,47 +2,46 @@
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_OFFLINE = "Offline";
public const string STATE_ERROR = "Error"; public const string STATE_RUNNING = "Running";
public const string STATE_OFFLINE = "Offline"; public const string STATE_SHUTDOWN = "Shutting Down";
public const string STATE_RUNNING = "Running"; public const string STATE_STARTING = "Starting";
public const string STATE_SHUTDOWN = "Shutting Down";
public const string STATE_STARTING = "Starting";
protected Backbone() { } protected Backbone() { }
[NotNull] [NotNull]
public static Backbone Instance { get; } public static Backbone Instance { get; }
[NotNull] [NotNull]
public ILoggingSetupManager LoggingConfigurationManager { get; set; } public ILoggingSetupManager LoggingConfigurationManager { get; set; }
public BackboneStatusCache Status { get; } public BackboneStatusCache Status { get; }
public bool IsAutomatedRestartActive { get; } public bool IsAutomatedRestartActive { get; }
public bool IsReadyForRestart { get; } public bool IsReadyForRestart { get; }
public string StartTime { get; } public string StartTime { get; }
public string State { get; } public string State { get; }
public string Name { get; } public string Name { get; }
public string ConfigurationServiceAddress { get; } public string ConfigurationServiceAddress { get; }
public string CellName { get; } public string CellName { get; }
protected bool IsInitialized { get; set; } protected bool IsInitialized { get; set; }
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) { }
[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(BackboneComponent source, string statusName, string statusValue) { } public void SetStatus(BackboneComponent source, string statusName, string statusValue) { }
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,24 +1,21 @@
using System; using System;
namespace Adaptation.Eaf.Core.Smtp namespace Adaptation.Eaf.Core.Smtp;
public class EmailMessage
{ {
public EmailMessage() { }
public EmailMessage(string subject, string body, MailPriority priority = MailPriority.Normal) { }
public class EmailMessage public string Body { get; }
{ public MailPriority Priority { get; }
public EmailMessage() { } public string Subject { get; }
public EmailMessage(string subject, string body, MailPriority priority = MailPriority.Normal) { }
public string Body { get; } public EmailMessage PriorityHigh() => throw new NotImplementedException();
public MailPriority Priority { get; } public EmailMessage PriorityLow() => throw new NotImplementedException();
public string Subject { get; } public EmailMessage PriorityNormal() => throw new NotImplementedException();
public EmailMessage SetBody(string body) => throw new NotImplementedException();
public EmailMessage PriorityHigh() { throw new NotImplementedException(); } public EmailMessage SetPriority(MailPriority priority) => throw new NotImplementedException();
public EmailMessage PriorityLow() { throw new NotImplementedException(); } public EmailMessage SetSubject(string subject) => throw new NotImplementedException();
public EmailMessage PriorityNormal() { throw new NotImplementedException(); }
public EmailMessage SetBody(string body) { throw new NotImplementedException(); }
public EmailMessage SetPriority(MailPriority priority) { 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
{ {
void Send(EmailMessage message);
public interface ISmtp
{
void Send(EmailMessage message);
}
} }

View File

@ -1,11 +1,8 @@
namespace Adaptation.Eaf.Core.Smtp namespace Adaptation.Eaf.Core.Smtp;
public enum MailPriority
{ {
Low = 0,
public enum MailPriority Normal = 1,
{ High = 2
Low = 0,
Normal = 1,
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,16 +1,15 @@
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]
{ IEquipmentSelfDescriptionBuilder SelfDescriptionBuilder { get; }
[NotNull] [NotNull]
IEquipmentSelfDescriptionBuilder SelfDescriptionBuilder { get; } IEquipmentDataCollection DataCollection { get; }
[NotNull] [NotNull]
IEquipmentDataCollection DataCollection { get; } IEquipmentCommandService Commands { get; }
[NotNull] [NotNull]
IEquipmentCommandService Commands { get; } IConnectionControl Connection { get; }
[NotNull]
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,37 +3,36 @@ 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
{
IVirtualParameterValuesHandler VirtualParameterValuesHandler { get; }
ISelfDescriptionLookup SelfDescriptionLookup { get; }
EquipmentSelfDescription SelfDescription { get; }
IEnumerable<DataCollectionRequest> ActiveRequests { get; }
IDataTracingHandler DataTracingHandler { get; }
ParameterValue CreateParameterValue(EquipmentParameter parameter, object value); public interface IEquipmentDataCollection
void NotifyDataTracingAvailable(bool isAvailable); {
void RegisterChangeDataCollectionHandler(ChangeDataCollectionHandler handler); IVirtualParameterValuesHandler VirtualParameterValuesHandler { get; }
void RegisterDataTracingHandler(IDataTracingHandler handler); ISelfDescriptionLookup SelfDescriptionLookup { get; }
void RegisterGetParameterValuesHandler(GetParameterValuesHandler handler); EquipmentSelfDescription SelfDescription { get; }
void RegisterSetParameterValuesHandler(SetParameterValuesHandler handler); IEnumerable<DataCollectionRequest> ActiveRequests { get; }
void TriggerDeactivate(DataCollectionRequest deactivateRequest); IDataTracingHandler DataTracingHandler { get; }
void TriggerEvent(EquipmentEvent equipmentEvent, IEnumerable<ParameterValue> parameters);
void TriggerEvent(EquipmentEvent equipmentEvent, IEnumerable<ParameterValue> parameters, IPackage sourcePackage); ParameterValue CreateParameterValue(EquipmentParameter parameter, object value);
void TriggerExceptionClear(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters); void NotifyDataTracingAvailable(bool isAvailable);
void TriggerExceptionClear(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters, IPackage sourcePackage); void RegisterChangeDataCollectionHandler(ChangeDataCollectionHandler handler);
void TriggerExceptionClear(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters, string severityOverride, string descriptionOverride); void RegisterDataTracingHandler(IDataTracingHandler handler);
void TriggerExceptionClear(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters, string severityOverride, string descriptionOverride, IPackage sourcePackage); void RegisterGetParameterValuesHandler(GetParameterValuesHandler handler);
void TriggerExceptionSet(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters, string severityOverride, string descriptionOverride, IPackage sourcePackage); void RegisterSetParameterValuesHandler(SetParameterValuesHandler handler);
void TriggerExceptionSet(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters, string severityOverride, string descriptionOverride); void TriggerDeactivate(DataCollectionRequest deactivateRequest);
void TriggerExceptionSet(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters, IPackage sourcePackage); void TriggerEvent(EquipmentEvent equipmentEvent, IEnumerable<ParameterValue> parameters);
void TriggerExceptionSet(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters); void TriggerEvent(EquipmentEvent equipmentEvent, IEnumerable<ParameterValue> parameters, IPackage sourcePackage);
void TriggerPerformanceRestored(); void TriggerExceptionClear(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters);
void TriggerPerformanceWarning(); void TriggerExceptionClear(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters, IPackage sourcePackage);
void TriggerTraceSample(TraceRequest traceRequest, long sampleId, IEnumerable<ParameterValue> parameters); void TriggerExceptionClear(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters, string severityOverride, string descriptionOverride);
void TriggerTraceSample(TraceRequest traceRequest, long sampleId, IEnumerable<ParameterValue> parameters, IPackage sourcePackage); void TriggerExceptionClear(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters, string severityOverride, string descriptionOverride, IPackage sourcePackage);
void TriggerTraceSample(TraceRequest traceRequest, long sampleId, IEnumerable<ParameterValue> parameters, DateTime equipmentTimeStamp); void TriggerExceptionSet(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters, string severityOverride, string descriptionOverride, IPackage sourcePackage);
} void TriggerExceptionSet(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters, string severityOverride, string descriptionOverride);
void TriggerExceptionSet(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters, IPackage sourcePackage);
void TriggerExceptionSet(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters);
void TriggerPerformanceRestored();
void TriggerPerformanceWarning();
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, 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,19 +2,18 @@
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, DateTime timestamp) { }
public ParameterValue(EquipmentParameter definition, object value) { }
public ParameterValue(EquipmentParameter definition, object value, DateTime timestamp) { }
public virtual object Value { get; protected internal set; } public virtual object Value { get; protected internal set; }
[NotNull] [NotNull]
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,24 +1,22 @@
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(string name, ParameterTypeDefinition typeDefinition, string description, bool isTransient = false, bool isReadOnly = true) { }
public EquipmentParameter(EquipmentParameter source, ParameterTypeDefinition typeDefinition) { } public EquipmentParameter(string id, 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 string Name { get; } public string Name { get; }
public string Id { get; } public string Id { get; }
public string Description { get; } public string Description { get; }
public string SourcePath { get; } public string SourcePath { get; }
public string SourceEquipment { get; } public string SourceEquipment { get; }
public ParameterTypeDefinition TypeDefinition { get; } public ParameterTypeDefinition TypeDefinition { get; }
public bool IsTransient { get; } public bool IsTransient { get; }
public bool IsReadOnly { get; } public bool IsReadOnly { get; }
public override string ToString() { return base.ToString(); }
public string ToStringWithDetails() { return base.ToString(); }
}
public override string ToString() => 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 Field(string name, string description, bool canBeNull, ParameterTypeDefinition typeDefinition) { }
public string Name { get; } public class Field
public string Description { get; } {
public ParameterTypeDefinition TypeDefinition { get; } public Field(string name, string description, bool canBeNull, ParameterTypeDefinition typeDefinition) { }
public bool CanBeNull { get; }
} public string Name { get; }
public string Description { get; }
public ParameterTypeDefinition TypeDefinition { 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,26 +1,25 @@
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 ModelObjectParameterDefinition() { }
public class ModelObjectParameterDefinition : IConfigurationObject public ModelObjectParameterDefinition(string name, ModelObjectParameterType valueType, object defaultValue) { }
{ public ModelObjectParameterDefinition(string name, Type enumType, object defaultValue) { }
public ModelObjectParameterDefinition() { }
public ModelObjectParameterDefinition(string name, ModelObjectParameterType valueType, object defaultValue) { }
public ModelObjectParameterDefinition(string name, Type enumType, object defaultValue) { }
[System.Runtime.Serialization.DataMemberAttribute] [System.Runtime.Serialization.DataMemberAttribute]
public virtual long Id { get; set; } public virtual long Id { get; set; }
[System.Runtime.Serialization.DataMemberAttribute] [System.Runtime.Serialization.DataMemberAttribute]
public virtual string Name { get; set; } public virtual string Name { get; set; }
[System.Runtime.Serialization.DataMemberAttribute] [System.Runtime.Serialization.DataMemberAttribute]
public virtual string Value { get; set; } public virtual string Value { get; set; }
[System.Runtime.Serialization.DataMemberAttribute] [System.Runtime.Serialization.DataMemberAttribute]
public virtual ModelObjectParameterType ValueType { get; set; } public virtual ModelObjectParameterType ValueType { get; set; }
[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,17 +1,16 @@
namespace Adaptation.Eaf.Management.ConfigurationData.CellAutomation namespace Adaptation.Eaf.Management.ConfigurationData.CellAutomation;
public enum ModelObjectParameterType
{ {
public enum ModelObjectParameterType String = 0,
{ Bool = 1,
String = 0, Byte = 2,
Bool = 1, SignedByte = 3,
Byte = 2, Integer = 4,
SignedByte = 3, UnsignedInteger = 5,
Integer = 4, LongInteger = 6,
UnsignedInteger = 5, UnsignedLongInteger = 7,
LongInteger = 6, Double = 8,
UnsignedLongInteger = 7, Float = 9,
Double = 8, Enum = 10
Float = 9,
Enum = 10
}
} }

View File

@ -1,44 +1,43 @@
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
{
public SecsConnectionConfiguration() { }
[System.Runtime.Serialization.DataMemberAttribute] [System.Runtime.Serialization.DataContractAttribute]
public virtual TimeSpan T6HsmsControlMessage { get; set; } public class SecsConnectionConfiguration
[System.Runtime.Serialization.DataMemberAttribute] {
public virtual TimeSpan T5ConnectionSeperation { get; set; } public SecsConnectionConfiguration() { }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual TimeSpan T4InterBlock { get; set; } [System.Runtime.Serialization.DataMemberAttribute]
[System.Runtime.Serialization.DataMemberAttribute] public virtual TimeSpan T6HsmsControlMessage { get; set; }
public virtual TimeSpan T3MessageReply { get; set; } [System.Runtime.Serialization.DataMemberAttribute]
[System.Runtime.Serialization.DataMemberAttribute] public virtual TimeSpan T5ConnectionSeperation { get; set; }
public virtual TimeSpan T2Protocol { get; set; } [System.Runtime.Serialization.DataMemberAttribute]
[System.Runtime.Serialization.DataMemberAttribute] public virtual TimeSpan T4InterBlock { get; set; }
public virtual TimeSpan T1InterCharacter { get; set; } [System.Runtime.Serialization.DataMemberAttribute]
[System.Runtime.Serialization.DataMemberAttribute] public virtual TimeSpan T3MessageReply { get; set; }
public virtual SerialBaudRate? BaudRate { get; set; } [System.Runtime.Serialization.DataMemberAttribute]
[System.Runtime.Serialization.DataMemberAttribute] public virtual TimeSpan T2Protocol { get; set; }
public virtual SecsTransportType? PortType { get; set; } [System.Runtime.Serialization.DataMemberAttribute]
[System.Runtime.Serialization.DataMemberAttribute] public virtual TimeSpan T1InterCharacter { get; set; }
public virtual long? Port { get; set; } [System.Runtime.Serialization.DataMemberAttribute]
[System.Runtime.Serialization.DataMemberAttribute] public virtual SerialBaudRate? BaudRate { get; set; }
public virtual TimeSpan LinkTestTimer { get; set; } [System.Runtime.Serialization.DataMemberAttribute]
[System.Runtime.Serialization.DataMemberAttribute] public virtual SecsTransportType? PortType { get; set; }
public virtual string Host { get; set; } [System.Runtime.Serialization.DataMemberAttribute]
[System.Runtime.Serialization.DataMemberAttribute] public virtual long? Port { get; set; }
public virtual long? DeviceId { get; set; } [System.Runtime.Serialization.DataMemberAttribute]
[System.Runtime.Serialization.DataMemberAttribute] public virtual TimeSpan LinkTestTimer { get; set; }
public virtual HsmsSessionMode? SessionMode { get; set; } [System.Runtime.Serialization.DataMemberAttribute]
[System.Runtime.Serialization.DataMemberAttribute] public virtual string Host { get; set; }
public virtual HsmsConnectionMode? ConnectionMode { get; set; } [System.Runtime.Serialization.DataMemberAttribute]
[System.Runtime.Serialization.DataMemberAttribute] public virtual long? DeviceId { get; set; }
public virtual TimeSpan T7ConnectionIdle { get; set; } [System.Runtime.Serialization.DataMemberAttribute]
[System.Runtime.Serialization.DataMemberAttribute] public virtual HsmsSessionMode? SessionMode { get; set; }
public virtual TimeSpan T8NetworkIntercharacter { get; set; } [System.Runtime.Serialization.DataMemberAttribute]
} public virtual HsmsConnectionMode? ConnectionMode { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual TimeSpan T7ConnectionIdle { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
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)
{ {
IFileRead result;
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) bool isDuplicator = cellInstanceConnectionName.StartsWith(cellInstanceName);
if (isDuplicator)
{ {
IFileRead result; string cellInstanceConnectionNameBase = cellInstanceConnectionName.Replace("-", string.Empty);
int levelIsArchive = 7; int hyphens = cellInstanceConnectionName.Length - cellInstanceConnectionNameBase.Length;
int levelIsXToArchive = 6; result = hyphens switch
bool isDuplicator = cellInstanceConnectionName.StartsWith(cellInstanceName);
if (isDuplicator)
result = new MET08RESIMAPCDE.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted, levelIsXToArchive, levelIsArchive);
else
{ {
result = cellInstanceConnectionName 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),
nameof(DownloadRsMFile) => new DownloadRsMFile.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted, levelIsXToArchive, levelIsArchive), (int)MET08RESIMAPCDE.Hyphen.IsXToArchive => new ToArchive.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), _ => new MET08RESIMAPCDE.FileRead(smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted)
_ => throw new Exception(), };
};
}
return result;
} }
else
{
result = cellInstanceConnectionName switch
{
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),
_ => throw new Exception(),
};
}
return result;
} }
} }

View File

@ -13,271 +13,251 @@ 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 WebClient _WebClient;
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) :
base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted)
{ {
_MinFileLength = 10;
private readonly Timer _Timer; _NullData = string.Empty;
private readonly WebClient _WebClient; _Logistics = new Logistics(this);
private readonly string _StaticFileServer; if (_FileParameter is null)
throw new Exception(cellInstanceConnectionName);
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) : if (_ModelObjectParameterDefinitions is null)
base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted, hyphenXToArchive, hyphenIsArchive) throw new Exception(cellInstanceConnectionName);
if (_IsDuplicator)
throw new Exception(cellInstanceConnectionName);
_WebClient = new WebClient();
_StaticFileServer = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, string.Concat("CellInstance.", cellInstanceName, ".StaticFileServer"));
if (!Debugger.IsAttached && fileConnectorConfiguration.PreProcessingMode != FileConnectorConfiguration.PreProcessingModeEnum.Process)
_Timer = new Timer(Callback, null, (int)(fileConnectorConfiguration.FileScanningIntervalInSeconds * 1000), Timeout.Infinite);
else
{ {
_MinFileLength = 10; _Timer = new Timer(Callback, null, Timeout.Infinite, Timeout.Infinite);
_NullData = string.Empty; Callback(null);
_Logistics = new Logistics(this); }
if (_FileParameter is null) }
throw new Exception(cellInstanceConnectionName);
if (_ModelObjectParameterDefinitions is null) void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) => Move(extractResults, exception);
throw new Exception(cellInstanceConnectionName);
if (_IsDuplicator) void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
throw new Exception(cellInstanceConnectionName);
_WebClient = new WebClient(); string IFileRead.GetEventDescription()
_StaticFileServer = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, string.Concat("CellInstance.", cellInstanceName, ".StaticFileServer")); {
if (!Debugger.IsAttached && fileConnectorConfiguration.PreProcessingMode != FileConnectorConfiguration.PreProcessingModeEnum.Process) string result = _Description.GetEventDescription();
_Timer = new Timer(Callback, null, (int)(fileConnectorConfiguration.FileScanningIntervalInSeconds * 1000), Timeout.Infinite); return result;
else }
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, new 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) => 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)
{
if (reportFullPath is null)
{ }
if (dateTime == DateTime.MinValue)
{ }
throw new Exception(string.Concat("See ", nameof(Callback)));
}
private void DownloadRsMFile()
{
if (_WebClient is null)
throw new Exception();
if (string.IsNullOrEmpty(_StaticFileServer))
throw new Exception();
string logText;
string runJson;
string rootJson;
string[] logLines;
string runFileName;
string[] logSegments;
string targetFileName;
string runFullFileName;
FileInfo targetFileInfo;
FileInfo alternateFileInfo;
List<string> runFullFileNameSegments;
string dateTimeFormat = "yy/MM/dd HH:mm:ss";
NginxFileSystem[] runNginxFileSystemCollection;
NginxFileSystem[] rootNginxFileSystemCollection;
DateTime fileAgeThresholdDateTime = DateTime.Now;
string nginxFormat = "ddd, dd MMM yyyy HH:mm:ss zzz";
List<Tuple<DateTime, FileInfo, FileInfo, string>> possibleDownload = new();
string[] segments = _FileConnectorConfiguration.FileAgeThreshold.Split(':');
JsonSerializerOptions propertyNameCaseInsensitiveJsonSerializerOptions = new() { PropertyNameCaseInsensitive = true };
for (int i = 0; i < segments.Length; i++)
{
fileAgeThresholdDateTime = i switch
{ {
_Timer = new Timer(Callback, null, Timeout.Infinite, Timeout.Infinite); 0 => fileAgeThresholdDateTime.AddDays(double.Parse(segments[i]) * -1),
Callback(null); 1 => fileAgeThresholdDateTime.AddHours(double.Parse(segments[i]) * -1),
} 2 => fileAgeThresholdDateTime.AddMinutes(double.Parse(segments[i]) * -1),
3 => fileAgeThresholdDateTime.AddSeconds(double.Parse(segments[i]) * -1),
_ => throw new Exception(),
};
} }
rootJson = _WebClient.DownloadString(string.Concat("http://", _StaticFileServer));
void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) rootNginxFileSystemCollection = JsonSerializer.Deserialize<NginxFileSystem[]>(rootJson, propertyNameCaseInsensitiveJsonSerializerOptions);
foreach (NginxFileSystem rootNginxFileSystem in rootNginxFileSystemCollection)
{ {
Move(this, extractResults, exception); if (!(from l in _FileConnectorConfiguration.SourceFileFilters where rootNginxFileSystem.Name == l select false).Any())
} continue;
logText = _WebClient.DownloadString(string.Concat("http://", _StaticFileServer, '/', rootNginxFileSystem.Name));
void IFileRead.WaitForThread() logLines = logText.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
{ foreach (string logLine in logLines)
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, new 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)
{
throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
}
void IFileRead.MoveArchive()
{
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)
{
if (reportFullPath is null)
{ }
if (dateTime == DateTime.MinValue)
{ }
throw new Exception(string.Concat("See ", nameof(Callback)));
}
private void DownloadRsMFile()
{
if (_WebClient is null)
throw new Exception();
if (string.IsNullOrEmpty(_StaticFileServer))
throw new Exception();
string logText;
string runJson;
string rootJson;
string[] logLines;
string runFileName;
string[] logSegments;
string targetFileName;
string runFullFileName;
FileInfo targetFileInfo;
FileInfo alternateFileInfo;
List<string> runFullFileNameSegments;
string dateTimeFormat = "yy/MM/dd HH:mm:ss";
NginxFileSystem[] runNginxFileSystemCollection;
NginxFileSystem[] rootNginxFileSystemCollection;
DateTime fileAgeThresholdDateTime = DateTime.Now;
string nginxFormat = "ddd, dd MMM yyyy HH:mm:ss zzz";
List<Tuple<DateTime, FileInfo, FileInfo, string>> possibleDownload = new();
string[] segments = _FileConnectorConfiguration.FileAgeThreshold.Split(':');
JsonSerializerOptions propertyNameCaseInsensitiveJsonSerializerOptions = new() { PropertyNameCaseInsensitive = true };
for (int i = 0; i < segments.Length; i++)
{ {
fileAgeThresholdDateTime = i switch if (string.IsNullOrEmpty(logLine))
{
0 => fileAgeThresholdDateTime.AddDays(double.Parse(segments[i]) * -1),
1 => fileAgeThresholdDateTime.AddHours(double.Parse(segments[i]) * -1),
2 => fileAgeThresholdDateTime.AddMinutes(double.Parse(segments[i]) * -1),
3 => fileAgeThresholdDateTime.AddSeconds(double.Parse(segments[i]) * -1),
_ => throw new Exception(),
};
}
rootJson = _WebClient.DownloadString(string.Concat("http://", _StaticFileServer));
rootNginxFileSystemCollection = JsonSerializer.Deserialize<NginxFileSystem[]>(rootJson, propertyNameCaseInsensitiveJsonSerializerOptions);
foreach (NginxFileSystem rootNginxFileSystem in rootNginxFileSystemCollection)
{
if (!(from l in _FileConnectorConfiguration.SourceFileFilters where rootNginxFileSystem.Name == l select false).Any())
continue; continue;
logText = _WebClient.DownloadString(string.Concat("http://", _StaticFileServer, '/', rootNginxFileSystem.Name)); logSegments = logLine.Split('<');
logLines = logText.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); if (logSegments.Length < 1 || !DateTime.TryParseExact(logSegments[0].Trim(), dateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime tvsDateTime))
foreach (string logLine in logLines) continue;
if (tvsDateTime < fileAgeThresholdDateTime)
continue;
if (logSegments.Length < 2)
continue;
runFullFileName = logSegments[1].Split('>')[0];
if (!(from l in _FileConnectorConfiguration.SourceFileFilters where runFullFileName.EndsWith(l) select false).Any())
continue;
runFullFileNameSegments = runFullFileName.Split('\\').ToList();
runFileName = runFullFileNameSegments[runFullFileNameSegments.Count - 1];
runFullFileNameSegments.RemoveAt(runFullFileNameSegments.Count - 1);
runJson = _WebClient.DownloadString(string.Concat("http://", _StaticFileServer, '/', string.Join("/", runFullFileNameSegments)));
runFullFileNameSegments.Add(runFileName);
runNginxFileSystemCollection = JsonSerializer.Deserialize<NginxFileSystem[]>(runJson, propertyNameCaseInsensitiveJsonSerializerOptions);
foreach (NginxFileSystem matchNginxFileSystem in runNginxFileSystemCollection)
{ {
if (string.IsNullOrEmpty(logLine)) if (matchNginxFileSystem.Name != runFileName)
continue; continue;
logSegments = logLine.Split('<'); if (!(from l in _FileConnectorConfiguration.SourceFileFilters where matchNginxFileSystem.Name.EndsWith(l) select false).Any())
if (logSegments.Length < 1 || !DateTime.TryParseExact(logSegments[0].Trim(), dateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime tvsDateTime))
continue; continue;
if (tvsDateTime < fileAgeThresholdDateTime) if (!DateTime.TryParseExact(matchNginxFileSystem.MTime.Replace("GMT", "+00:00"), nginxFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime matchNginxFileSystemDateTime))
continue; continue;
if (logSegments.Length < 2) if (matchNginxFileSystemDateTime < fileAgeThresholdDateTime)
continue; continue;
runFullFileName = logSegments[1].Split('>')[0]; targetFileInfo = new FileInfo(Path.Combine(_FileConnectorConfiguration.TargetFileLocation, runFullFileName));
if (!(from l in _FileConnectorConfiguration.SourceFileFilters where runFullFileName.EndsWith(l) select false).Any()) if (!Directory.Exists(targetFileInfo.Directory.FullName))
_ = Directory.CreateDirectory(targetFileInfo.Directory.FullName);
if (targetFileInfo.Exists && targetFileInfo.LastWriteTime == matchNginxFileSystemDateTime)
continue; continue;
runFullFileNameSegments = runFullFileName.Split('\\').ToList(); alternateFileInfo = new(Path.Combine(_FileConnectorConfiguration.AlternateTargetFolder, matchNginxFileSystem.Name));
runFileName = runFullFileNameSegments[runFullFileNameSegments.Count - 1]; targetFileName = string.Concat("http://", _StaticFileServer, '/', string.Join("/", runFullFileNameSegments));
runFullFileNameSegments.RemoveAt(runFullFileNameSegments.Count - 1); possibleDownload.Add(new(matchNginxFileSystemDateTime, targetFileInfo, alternateFileInfo, targetFileName));
runJson = _WebClient.DownloadString(string.Concat("http://", _StaticFileServer, '/', string.Join("/", runFullFileNameSegments))); break;
runFullFileNameSegments.Add(runFileName);
runNginxFileSystemCollection = JsonSerializer.Deserialize<NginxFileSystem[]>(runJson, propertyNameCaseInsensitiveJsonSerializerOptions);
foreach (NginxFileSystem matchNginxFileSystem in runNginxFileSystemCollection)
{
if (matchNginxFileSystem.Name != runFileName)
continue;
if (!(from l in _FileConnectorConfiguration.SourceFileFilters where matchNginxFileSystem.Name.EndsWith(l) select false).Any())
continue;
if (!DateTime.TryParseExact(matchNginxFileSystem.MTime.Replace("GMT", "+00:00"), nginxFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime matchNginxFileSystemDateTime))
continue;
if (matchNginxFileSystemDateTime < fileAgeThresholdDateTime)
continue;
targetFileInfo = new FileInfo(Path.Combine(_FileConnectorConfiguration.TargetFileLocation, runFullFileName));
if (!Directory.Exists(targetFileInfo.Directory.FullName))
Directory.CreateDirectory(targetFileInfo.Directory.FullName);
if (targetFileInfo.Exists && targetFileInfo.LastWriteTime == matchNginxFileSystemDateTime)
continue;
alternateFileInfo = new(Path.Combine(_FileConnectorConfiguration.AlternateTargetFolder, matchNginxFileSystem.Name));
targetFileName = string.Concat("http://", _StaticFileServer, '/', string.Join("/", runFullFileNameSegments));
possibleDownload.Add(new(matchNginxFileSystemDateTime, targetFileInfo, alternateFileInfo, targetFileName));
break;
}
if (possibleDownload.Any())
break;
} }
if (possibleDownload.Any()) if (possibleDownload.Any())
break; break;
} }
if (possibleDownload.Any()) if (possibleDownload.Any())
{ break;
possibleDownload = (from l in possibleDownload orderby l.Item1 select l).ToList();
alternateFileInfo = possibleDownload[0].Item3;
targetFileName = possibleDownload[0].Item4;
targetFileInfo = possibleDownload[0].Item2;
DateTime matchNginxFileSystemDateTime = possibleDownload[0].Item1;
if (alternateFileInfo.Exists)
File.Delete(alternateFileInfo.FullName);
if (targetFileInfo.Exists)
File.Delete(targetFileInfo.FullName);
_WebClient.DownloadFile(targetFileName, targetFileInfo.FullName);
targetFileInfo.LastWriteTime = matchNginxFileSystemDateTime;
File.Copy(targetFileInfo.FullName, alternateFileInfo.FullName);
}
} }
if (possibleDownload.Any())
private void Callback(object state)
{ {
try possibleDownload = (from l in possibleDownload orderby l.Item1 select l).ToList();
{ alternateFileInfo = possibleDownload[0].Item3;
if (_IsEAFHosted) targetFileName = possibleDownload[0].Item4;
DownloadRsMFile(); targetFileInfo = possibleDownload[0].Item2;
} DateTime matchNginxFileSystemDateTime = possibleDownload[0].Item1;
catch (Exception exception) if (alternateFileInfo.Exists)
{ File.Delete(alternateFileInfo.FullName);
string subject = string.Concat("Exception:", _CellInstanceConnectionName); if (targetFileInfo.Exists)
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace); File.Delete(targetFileInfo.FullName);
try _WebClient.DownloadFile(targetFileName, targetFileInfo.FullName);
{ _SMTP.SendHighPriorityEmailMessage(subject, body); } targetFileInfo.LastWriteTime = matchNginxFileSystemDateTime;
catch (Exception) { } File.Copy(targetFileInfo.FullName, alternateFileInfo.FullName);
}
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) { }
}
} }
}
private void Callback(object state)
{
try
{
if (_IsEAFHosted)
DownloadRsMFile();
}
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

@ -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,526 +16,373 @@ 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 int _LastDummyRunIndex;
private readonly string _IqsFile;
private readonly int _HyphenIsDummy;
private readonly int _HyphenIsNaEDA;
private readonly string _MemoryPath;
private readonly int _HyphenIsXToAPC;
private readonly int _HyphenIsXToIQSSi;
private readonly int _HyphenIsXToSPaCe;
private readonly int _HyphenIsXToOpenInsight;
private readonly string _EventNameFileReadDaily;
private readonly string _OpenInsightFilePattern;
private readonly string _OpenInsightMetrologyViewerAPI;
private readonly Dictionary<string, string> _CellNames;
private readonly int _HyphenIsXToOpenInsightMetrologyViewer;
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) :
base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted)
{ {
_MinFileLength = 10;
private readonly Timer _Timer; _NullData = string.Empty;
private int _LastDummyRunIndex; _Logistics = new Logistics(this);
private readonly string _IqsFile; if (_FileParameter is null)
private readonly int _HyphenIsDummy; throw new Exception(cellInstanceConnectionName);
private readonly int _HyphenIsNaEDA; if (_ModelObjectParameterDefinitions is null)
private readonly string _MemoryPath; throw new Exception(cellInstanceConnectionName);
private readonly int _HyphenIsXToAPC; if (!_IsDuplicator)
private readonly int _HyphenIsXToIQSSi; throw new Exception(cellInstanceConnectionName);
private readonly int _HyphenIsXToSPaCe; _LastDummyRunIndex = -1;
private readonly int _HyphenIsXToOpenInsight; if (_HyphenIsNaEDA == 0)
private readonly string _EventNameFileReadDaily; { }
private readonly string _OpenInsightFilePattern; if (_HyphenIsXToSPaCe == 0)
private readonly string _OpenInsightMetrologyViewerAPI; { }
private readonly Dictionary<string, string> _CellNames; if (_HyphenIsXToIQSSi == 0)
private readonly int _HyphenIsXToOpenInsightMetrologyViewer; { }
private readonly int _HyphenIsXToOpenInsightMetrologyViewerAttachments; _CellNames = new Dictionary<string, string>();
_HyphenIsNaEDA = (int)Hyphen.IsNaEDA;
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) : _HyphenIsDummy = (int)Hyphen.IsDummy;
base(new Description(), false, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted, hyphenXToArchive, hyphenIsArchive) _HyphenIsXToAPC = (int)Hyphen.IsXToAPC;
_HyphenIsXToIQSSi = (int)Hyphen.IsXToIQSSi;
_HyphenIsXToSPaCe = (int)Hyphen.IsXToSPaCe;
_HyphenIsXToOpenInsight = (int)Hyphen.IsXToOpenInsight;
_EventNameFileReadDaily = string.Concat(_EventNameFileRead, "Daily");
_IqsFile = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "IQS.File");
_MemoryPath = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "Path.Memory");
_HyphenIsXToOpenInsightMetrologyViewer = (int)Hyphen.IsXToOpenInsightMetrologyViewer;
_HyphenIsXToOpenInsightMetrologyViewerAttachments = (int)Hyphen.IsXToOpenInsightMetrologyViewerAttachments;
_OpenInsightFilePattern = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.FilePattern");
_OpenInsightMetrologyViewerAPI = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.MetrologyViewerAPI");
ModelObjectParameterDefinition[] cellInstanceCollection = GetProperties(cellInstanceConnectionName, modelObjectParameters, "CellInstance.", ".Path");
foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in cellInstanceCollection)
_CellNames.Add(modelObjectParameterDefinition.Name.Split('.')[1], modelObjectParameterDefinition.Value);
if (_Hyphens == _HyphenIsDummy)
{ {
_MinFileLength = 10; if (Debugger.IsAttached || fileConnectorConfiguration.PreProcessingMode == FileConnectorConfiguration.PreProcessingModeEnum.Process)
_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);
if (hyphenIsArchive != (int)Hyphen.IsArchive)
throw new Exception(cellInstanceConnectionName);
if (hyphenXToArchive != (int)Hyphen.IsXToArchive)
throw new Exception(cellInstanceConnectionName);
_LastDummyRunIndex = -1;
if (_HyphenIsNaEDA == 0)
{ }
if (_HyphenIsXToSPaCe == 0)
{ }
if (_HyphenIsXToIQSSi == 0)
{ }
_CellNames = new Dictionary<string, string>();
_HyphenIsNaEDA = (int)Hyphen.IsNaEDA;
_HyphenIsDummy = (int)Hyphen.IsDummy;
_HyphenIsXToAPC = (int)Hyphen.IsXToAPC;
_HyphenIsXToIQSSi = (int)Hyphen.IsXToIQSSi;
_HyphenIsXToSPaCe = (int)Hyphen.IsXToSPaCe;
_HyphenIsXToOpenInsight = (int)Hyphen.IsXToOpenInsight;
_EventNameFileReadDaily = string.Concat(_EventNameFileRead, "Daily");
_IqsFile = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "IQS.File");
_MemoryPath = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "Path.Memory");
_HyphenIsXToOpenInsightMetrologyViewer = (int)Hyphen.IsXToOpenInsightMetrologyViewer;
_HyphenIsXToOpenInsightMetrologyViewerAttachments = (int)Hyphen.IsXToOpenInsightMetrologyViewerAttachments;
_OpenInsightFilePattern = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.FilePattern");
_OpenInsightMetrologyViewerAPI = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "OpenInsight.MetrologyViewerAPI");
ModelObjectParameterDefinition[] cellInstanceCollection = GetProperties(cellInstanceConnectionName, modelObjectParameters, "CellInstance.", ".Path");
foreach (ModelObjectParameterDefinition modelObjectParameterDefinition in cellInstanceCollection)
_CellNames.Add(modelObjectParameterDefinition.Name.Split('.')[1], modelObjectParameterDefinition.Value);
if (_Hyphens == _HyphenIsDummy)
{ {
if (Debugger.IsAttached || fileConnectorConfiguration.PreProcessingMode == FileConnectorConfiguration.PreProcessingModeEnum.Process) _Timer = new Timer(Callback, null, Timeout.Infinite, Timeout.Infinite);
{ Callback(null);
_Timer = new Timer(Callback, null, Timeout.Infinite, Timeout.Infinite); }
Callback(null); else
} {
else int milliSeconds;
{ milliSeconds = (int)((fileConnectorConfiguration.FileScanningIntervalInSeconds * 1000) / 2);
int milliSeconds; _Timer = new Timer(Callback, null, milliSeconds, Timeout.Infinite);
milliSeconds = (int)((fileConnectorConfiguration.FileScanningIntervalInSeconds * 1000) / 2); milliSeconds += 2000;
_Timer = new Timer(Callback, null, milliSeconds, Timeout.Infinite);
milliSeconds += 2000;
}
} }
} }
}
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()
{ {
string result = _Description.GetEventDescription(); string result = _Description.GetEventDescription();
return result; return result;
} }
List<string> IFileRead.GetHeaderNames() List<string> IFileRead.GetHeaderNames()
{ {
List<string> results = _Description.GetHeaderNames(); List<string> results = _Description.GetHeaderNames();
return results; return results;
} }
string[] IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception) 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); string[] results = Move(extractResults, to, from, resolvedFileLocation, exception);
return results; return results;
} }
JsonProperty[] IFileRead.GetDefault() JsonProperty[] IFileRead.GetDefault()
{ {
JsonProperty[] results = _Description.GetDefault(this, _Logistics); JsonProperty[] results = _Description.GetDefault(this, _Logistics);
return results; return results;
} }
Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement() Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement()
{ {
Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this); Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this);
return results; return results;
} }
List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData) List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData)
{ {
List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData); List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData);
return results; return results;
} }
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.GetExtractResult(string reportFullPath, string eventName) 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, new 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) => Callback(state);
protected List<pcl.Description> GetDescriptions(JsonElement[] jsonElements)
{
List<pcl.Description> results = new();
pcl.Description description;
JsonSerializerOptions jsonSerializerOptions = new() { NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString };
foreach (JsonElement jsonElement in jsonElements)
{ {
Tuple<string, Test[], JsonElement[], List<FileInfo>> results; if (jsonElement.ValueKind != JsonValueKind.Object)
if (string.IsNullOrEmpty(eventName))
throw new Exception(); throw new Exception();
_ReportFullPath = reportFullPath; description = JsonSerializer.Deserialize<pcl.Description>(jsonElement.ToString(), jsonSerializerOptions);
DateTime dateTime = DateTime.Now; results.Add(description);
results = GetExtractResult(reportFullPath, dateTime);
if (results.Item3 is null)
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(results.Item1, new Test[] { }, JsonSerializer.Deserialize<JsonElement[]>("[]"), results.Item4);
if (results.Item3.Length > 0 && _IsEAFHosted)
WritePDSF(this, results.Item3);
UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks);
return results;
} }
return results;
}
Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.ReExtract() private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
string duplicateDirectory;
Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
_Logistics = new Logistics(reportFullPath, pdsf.Item1);
SetFileParameterLotIDToLogisticsMID();
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf);
List<pcl.Description> descriptions = GetDescriptions(jsonElements);
Tuple<Test[], Dictionary<Test, List<Shared.Properties.IDescription>>> tuple = GetTuple(this, from l in descriptions select (Shared.Properties.IDescription)l, extra: false);
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tuple.Item1, jsonElements, new List<FileInfo>());
bool isNotUsedInsightMetrologyViewerAttachments = (!(_FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) && _Hyphens == _HyphenIsXToOpenInsightMetrologyViewerAttachments);
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());
if (isDummyRun)
{ {
Tuple<string, Test[], JsonElement[], List<FileInfo>> results; try
List<string> headerNames = _Description.GetHeaderNames(); { File.SetLastWriteTime(reportFullPath, dateTime); }
Dictionary<string, string> keyValuePairs = _Description.GetDisplayNamesJsonElement(this); catch (Exception) { }
results = ReExtract(this, headerNames, keyValuePairs);
return results;
} }
string[] segments = Path.GetFileNameWithoutExtension(reportFullPath).Split('_');
void IFileRead.CheckTests(Test[] tests, bool extra) if (_Hyphens != _HyphenIsXToOpenInsight)
duplicateDirectory = string.Concat(_FileConnectorConfiguration.TargetFileLocation, @"\", segments[0]);
else
duplicateDirectory = string.Concat(Path.GetDirectoryName(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation)), @"\Data");
if (segments.Length > 2)
duplicateDirectory = string.Concat(duplicateDirectory, @"-", segments[2]);
if (!Directory.Exists(duplicateDirectory))
_ = Directory.CreateDirectory(duplicateDirectory);
if (isDummyRun || isNotUsedInsightMetrologyViewerAttachments || _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0)
{ {
if (!(_Description is Description)) if (!Directory.Exists(duplicateDirectory))
throw new Exception(); _ = Directory.CreateDirectory(duplicateDirectory);
} string successDirectory;
if (_Hyphens != _HyphenIsXToAPC)
void IFileRead.Callback(object state) successDirectory = string.Empty;
{ else
Callback(state); {
} successDirectory = string.Concat(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation), @"\ViewerPath");
if (!Directory.Exists(successDirectory))
void IFileRead.MoveArchive() _ = Directory.CreateDirectory(successDirectory);
{ }
string logisticsSequence = _Logistics.Sequence.ToString(); List<Tuple<Shared.Properties.IScopeInfo, string>> tuples = new();
string duplicateFile = string.Concat(duplicateDirectory, @"\", Path.GetFileName(reportFullPath));
string weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00"); 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 weekDirectory = string.Concat(_Logistics.DateTimeFromSequence.ToString("yyyy"), "_Week_", weekOfYear, @"\", _Logistics.DateTimeFromSequence.ToString("yyyy-MM-dd"));
string jobIdDirectory = string.Concat(_FileConnectorConfiguration.TargetFileLocation, @"\", _Logistics.JobID); string logisticsSequenceMemoryDirectory = string.Concat(_MemoryPath, @"\", _EquipmentType, @"\Source\", weekDirectory, @"\", _Logistics.Sequence);
if (!Directory.Exists(jobIdDirectory)) if (!Directory.Exists(logisticsSequenceMemoryDirectory))
Directory.CreateDirectory(jobIdDirectory); _ = Directory.CreateDirectory(logisticsSequenceMemoryDirectory);
//string destinationArchiveDirectory = string.Concat(jobIdDirectory, @"\!Archive\", weekDirectory); if (_Hyphens == _HyphenIsXToAPC)
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)
{
List<pcl.Description> results = new();
pcl.Description description;
JsonSerializerOptions jsonSerializerOptions = new() { NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString };
foreach (JsonElement jsonElement in jsonElements)
{ {
if (jsonElement.ValueKind != JsonValueKind.Object) if (!isDummyRun && _IsEAFHosted)
throw new Exception(); File.Copy(reportFullPath, duplicateFile, overwrite: true);
description = JsonSerializer.Deserialize<pcl.Description>(jsonElement.ToString(), jsonSerializerOptions);
results.Add(description);
} }
return results;
}
private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
string duplicateDirectory;
Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath);
_Logistics = new Logistics(reportFullPath, pdsf.Item1);
SetFileParameterLotIDToLogisticsMID();
JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf);
List<pcl.Description> descriptions = GetDescriptions(jsonElements);
Tuple<Test[], Dictionary<Test, List<Shared.Properties.IDescription>>> tuple = GetTuple(this, from l in descriptions select (Shared.Properties.IDescription)l, extra: false);
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(pdsf.Item1, tuple.Item1, jsonElements, new List<FileInfo>());
bool isNotUsedInsightMetrologyViewerAttachments = (!(_FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) && _Hyphens == _HyphenIsXToOpenInsightMetrologyViewerAttachments);
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());
if (isDummyRun)
{
try
{ File.SetLastWriteTime(reportFullPath, dateTime); }
catch (Exception) { }
}
string[] segments = Path.GetFileNameWithoutExtension(reportFullPath).Split('_');
if (_Hyphens != _HyphenIsXToOpenInsight)
duplicateDirectory = string.Concat(_FileConnectorConfiguration.TargetFileLocation, @"\", segments[0]);
else else
duplicateDirectory = string.Concat(Path.GetDirectoryName(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation)), @"\Data");
if (segments.Length > 2)
duplicateDirectory = string.Concat(duplicateDirectory, @"-", segments[2]);
if (!Directory.Exists(duplicateDirectory))
Directory.CreateDirectory(duplicateDirectory);
if ((isDummyRun || isNotUsedInsightMetrologyViewerAttachments || _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) && _Hyphens != _HyphenIsXToArchive && _Hyphens != _HyphenIsArchive)
{ {
if (!Directory.Exists(duplicateDirectory)) if (_Hyphens == _HyphenIsXToOpenInsightMetrologyViewer)
Directory.CreateDirectory(duplicateDirectory);
string successDirectory;
if (_Hyphens != _HyphenIsXToAPC)
successDirectory = string.Empty;
else
{
successDirectory = string.Concat(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation), @"\ViewerPath");
if (!Directory.Exists(successDirectory))
Directory.CreateDirectory(successDirectory);
}
List<Tuple<Shared.Properties.IScopeInfo, string>> tuples = new();
string duplicateFile = string.Concat(duplicateDirectory, @"\", Path.GetFileName(reportFullPath));
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 logisticsSequenceMemoryDirectory = string.Concat(_MemoryPath, @"\", _EquipmentType, @"\Source\", weekDirectory, @"\", _Logistics.Sequence);
if (!Directory.Exists(logisticsSequenceMemoryDirectory))
Directory.CreateDirectory(logisticsSequenceMemoryDirectory);
if (_Hyphens == _HyphenIsXToAPC)
{
if (!isDummyRun && _IsEAFHosted)
File.Copy(reportFullPath, duplicateFile, overwrite: true);
}
else
{
if (_Hyphens == _HyphenIsXToOpenInsightMetrologyViewer)
{
WSRequest wsRequest = new(this, _Logistics, descriptions);
if (!isDummyRun && _IsEAFHosted)
{
Tuple<string, WS.Results> wsResults = WS.SendData(_OpenInsightMetrologyViewerAPI, wsRequest);
if (!wsResults.Item2.Success)
throw new Exception(wsResults.ToString());
_Log.Debug(wsResults.Item2.HeaderID);
File.WriteAllText(string.Concat(logisticsSequenceMemoryDirectory, @"\", nameof(WS.Results), ".json"), wsResults.Item1);
}
}
else
{
Test test;
string lines;
Shared.Properties.IScopeInfo scopeInfo;
foreach (KeyValuePair<Test, List<Shared.Properties.IDescription>> keyValuePair in tuple.Item2)
{
test = keyValuePair.Key;
//scopeInfo = new ScopeInfo(test);
if (_Hyphens != _HyphenIsXToOpenInsight)
scopeInfo = new ScopeInfo(test, _IqsFile);
else
scopeInfo = new ScopeInfo(test, _OpenInsightFilePattern);
//lines = ProcessDataStandardFormat.GetLines(this, scopeInfo, names, values, dateFormat: "M/d/yyyy hh:mm:ss tt", timeFormat: string.Empty, pairedColumns: ExtractResultPairedColumns);
lines = ProcessData.GetLines(this, _Logistics, descriptions);
tuples.Add(new Tuple<Shared.Properties.IScopeInfo, string>(scopeInfo, lines));
}
}
if (_Hyphens == _HyphenIsXToOpenInsightMetrologyViewerAttachments)
{
string[] matchDirectories = Shared1567(reportFullPath, tuples);
if (!isDummyRun && _IsEAFHosted && !isNotUsedInsightMetrologyViewerAttachments)
ProcessData.PostOpenInsightMetrologyViewerAttachments(this, dateTime, logisticsSequenceMemoryDirectory, descriptions, matchDirectories[0]);
}
}
if (_Hyphens != _HyphenIsXToOpenInsightMetrologyViewer && _Hyphens != _HyphenIsXToOpenInsightMetrologyViewerAttachments)
Shared0413(dateTime, isDummyRun, successDirectory, duplicateDirectory, tuples, duplicateFile);
}
if (_Hyphens == _HyphenIsXToOpenInsightMetrologyViewerAttachments)
{
string destinationDirectory;
//string destinationDirectory = WriteScopeInfo(_ProgressPath, _Logistics, dateTime, duplicateDirectory, tuples);
FileInfo fileInfo = new(reportFullPath);
string logisticsSequence = _Logistics.Sequence.ToString();
if (fileInfo.Exists && fileInfo.LastWriteTime < fileInfo.CreationTime)
File.SetLastWriteTime(reportFullPath, fileInfo.CreationTime);
string jobIdDirectory = string.Concat(Path.GetDirectoryName(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation)), @"\", _Logistics.JobID);
if (!Directory.Exists(jobIdDirectory))
Directory.CreateDirectory(jobIdDirectory);
string[] matchDirectories;
if (!_IsEAFHosted)
matchDirectories = new string[] { Path.GetDirectoryName(Path.GetDirectoryName(reportFullPath)) };
else
matchDirectories = Directory.GetDirectories(jobIdDirectory, string.Concat(_Logistics.MID, '*', logisticsSequence, '*'), SearchOption.TopDirectoryOnly);
if ((matchDirectories is null) || matchDirectories.Length != 1)
throw new Exception("Didn't find directory by logistics sequence");
destinationDirectory = matchDirectories[0];
if (isDummyRun)
Shared0607(reportFullPath, duplicateDirectory, logisticsSequence, destinationDirectory);
else
{ {
WSRequest wsRequest = new(this, _Logistics, descriptions); WSRequest wsRequest = new(this, _Logistics, descriptions);
JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true }; if (!isDummyRun && _IsEAFHosted)
string json = JsonSerializer.Serialize(wsRequest, wsRequest.GetType(), jsonSerializerOptions);
if (_IsEAFHosted)
Shared1277(reportFullPath, destinationDirectory, logisticsSequence, jobIdDirectory, json);
else
{ {
string jsonFileName = Path.ChangeExtension(reportFullPath, ".json"); Tuple<string, WS.Results> wsResults = WS.SendData(_OpenInsightMetrologyViewerAPI, wsRequest);
string historicalText = File.ReadAllText(jsonFileName); if (!wsResults.Item2.Success)
if (json != historicalText) throw new Exception(wsResults.ToString());
throw new Exception("File doesn't match historical!"); _Log.Debug(wsResults.Item2.HeaderID);
File.WriteAllText(string.Concat(logisticsSequenceMemoryDirectory, @"\", nameof(WS.Results), ".json"), wsResults.Item1);
} }
} }
} else
return results;
}
private void CallbackIsDummy(string traceDummyFile, List<Tuple<string, string, string, string, int>> tuples, bool fileConnectorConfigurationIncludeSubDirectories, bool includeSubDirectoriesExtra)
{
int fileCount;
string[] files;
string monARessource;
string checkDirectory;
string sourceArchiveFile;
string inProcessDirectory;
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);
foreach (Tuple<string, string, string, string, int> item in tuples)
{
monARessource = item.Item1;
sourceArchiveFile = item.Item2;
inProcessDirectory = item.Item3;
checkDirectory = item.Item4;
fileCount = item.Item5;
try
{ {
if (fileCount > 0 || string.IsNullOrEmpty(checkDirectory)) Test test;
string lines;
Shared.Properties.IScopeInfo scopeInfo;
foreach (KeyValuePair<Test, List<Shared.Properties.IDescription>> keyValuePair in tuple.Item2)
{ {
File.AppendAllLines(traceDummyFile, new string[] { site, monARessource, stateName, State.Warning.ToString() }); test = keyValuePair.Key;
monIn.SendStatus(site, monARessource, stateName, State.Warning); //scopeInfo = new ScopeInfo(test);
for (int i = 1; i < 12; i++) if (_Hyphens != _HyphenIsXToOpenInsight)
Thread.Sleep(500); scopeInfo = new ScopeInfo(test, _IqsFile);
}
else if (inProcessDirectory == checkDirectory)
continue;
if (!_IsEAFHosted)
continue;
if (!File.Exists(sourceArchiveFile))
continue;
if (!long.TryParse(Path.GetFileNameWithoutExtension(sourceArchiveFile).Replace("x", string.Empty), out long sequence))
continue;
ZipFile.ExtractToDirectory(sourceArchiveFile, inProcessDirectory);
if (fileConnectorConfigurationIncludeSubDirectories && includeSubDirectoriesExtra)
{
if (_EventName == _EventNameFileRead)
checkDirectory = string.Concat(checkDirectory, @"\", sequence);
else if (_EventName == _EventNameFileReadDaily)
checkDirectory = string.Concat(checkDirectory, @"\Source\", sequence);
else else
throw new Exception(); scopeInfo = new ScopeInfo(test, _OpenInsightFilePattern);
//lines = ProcessDataStandardFormat.GetLines(this, scopeInfo, names, values, dateFormat: "M/d/yyyy hh:mm:ss tt", timeFormat: string.Empty, pairedColumns: ExtractResultPairedColumns);
lines = ProcessData.GetLines(this, _Logistics, descriptions);
tuples.Add(new Tuple<Shared.Properties.IScopeInfo, string>(scopeInfo, lines));
} }
if (fileConnectorConfigurationIncludeSubDirectories)
files = Directory.GetFiles(inProcessDirectory, "*", SearchOption.AllDirectories);
else
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 (!fileConnectorConfigurationIncludeSubDirectories)
{
foreach (string file in files)
File.Move(file, string.Concat(checkDirectory, @"\", Path.GetFileName(file)));
}
else
{
string[] directories = Directory.GetDirectories(inProcessDirectory, "*", SearchOption.AllDirectories);
foreach (string directory in directories)
Directory.CreateDirectory(string.Concat(checkDirectory, directory.Substring(inProcessDirectory.Length)));
foreach (string file in files)
File.Move(file, string.Concat(checkDirectory, 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) if (_Hyphens == _HyphenIsXToOpenInsightMetrologyViewerAttachments)
{ {
string subject = string.Concat("Exception:", _CellInstanceConnectionName); string[] matchDirectories = Shared1567(reportFullPath, tuples);
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace); if (!isDummyRun && _IsEAFHosted && !isNotUsedInsightMetrologyViewerAttachments)
try ProcessData.PostOpenInsightMetrologyViewerAttachments(this, dateTime, logisticsSequenceMemoryDirectory, descriptions, matchDirectories[0]);
{ _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);
} }
} }
if (_Hyphens != _HyphenIsXToOpenInsightMetrologyViewer && _Hyphens != _HyphenIsXToOpenInsightMetrologyViewerAttachments)
Shared0413(dateTime, isDummyRun, successDirectory, duplicateDirectory, tuples, duplicateFile);
} }
if (_Hyphens == _HyphenIsXToOpenInsightMetrologyViewerAttachments)
private void Callback(object state)
{ {
if (_Hyphens != _HyphenIsDummy) string destinationDirectory;
throw new Exception(); //string destinationDirectory = WriteScopeInfo(_ProgressPath, _Logistics, dateTime, duplicateDirectory, tuples);
try FileInfo fileInfo = new(reportFullPath);
string logisticsSequence = _Logistics.Sequence.ToString();
if (fileInfo.Exists && fileInfo.LastWriteTime < fileInfo.CreationTime)
File.SetLastWriteTime(reportFullPath, fileInfo.CreationTime);
string jobIdDirectory = string.Concat(Path.GetDirectoryName(Path.GetDirectoryName(_FileConnectorConfiguration.TargetFileLocation)), @"\", _Logistics.JobID);
if (!Directory.Exists(jobIdDirectory))
_ = Directory.CreateDirectory(jobIdDirectory);
string[] matchDirectories;
if (!_IsEAFHosted)
matchDirectories = new string[] { Path.GetDirectoryName(Path.GetDirectoryName(reportFullPath)) };
else
matchDirectories = Directory.GetDirectories(jobIdDirectory, string.Concat(_Logistics.MID, '*', logisticsSequence, '*'), SearchOption.TopDirectoryOnly);
if ((matchDirectories is null) || matchDirectories.Length != 1)
throw new Exception("Didn't find directory by logistics sequence");
destinationDirectory = matchDirectories[0];
if (isDummyRun)
Shared0607(reportFullPath, duplicateDirectory, logisticsSequence, destinationDirectory);
else
{ {
DateTime dateTime = DateTime.Now; WSRequest wsRequest = new(this, _Logistics, descriptions);
bool check = (dateTime.Hour > 7 && dateTime.Hour < 18 && dateTime.DayOfWeek != DayOfWeek.Sunday && dateTime.DayOfWeek != DayOfWeek.Saturday); JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
if (check) string json = JsonSerializer.Serialize(wsRequest, wsRequest.GetType(), jsonSerializerOptions);
if (_IsEAFHosted)
Shared1277(reportFullPath, destinationDirectory, logisticsSequence, jobIdDirectory, json);
else
{ {
int fileCount; string jsonFileName = Path.ChangeExtension(reportFullPath, ".json");
string[] files; string historicalText = File.ReadAllText(jsonFileName);
string monARessource; if (json != historicalText)
string checkDirectory; throw new Exception("File doesn't match historical!");
string sourceArchiveFile;
string sourceFileLocation;
string inProcessDirectory;
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);
if (!Directory.Exists(traceDummyDirectory))
Directory.CreateDirectory(traceDummyDirectory);
string traceDummyFile = string.Concat(traceDummyDirectory, @"\", dateTime.Ticks, " - ", _CellInstanceName, ".txt");
File.AppendAllText(traceDummyFile, string.Empty);
List<Tuple<string, string, string, string, int>> tuples = new();
string progressDirectory = Path.GetFullPath(string.Concat(_FileConnectorConfiguration.SourceFileLocation, @"\_ Progress"));
if (progressDirectory != _ProgressPath || !Directory.Exists(progressDirectory))
throw new Exception("Invalid progress path");
foreach (KeyValuePair<string, string> keyValuePair in _CellNames)
{
monARessource = keyValuePair.Key;
if (!keyValuePair.Value.Contains(@"\"))
continue;
foreach (string sourceFileFilter in _FileConnectorConfiguration.SourceFileFilter.Split('|'))
{
if (sourceFileFilter.ToLower().StartsWith(keyValuePair.Value.Replace(@"\", string.Empty)))
sourceFileLocation = Path.GetFullPath(_FileConnectorConfiguration.SourceFileLocation);
else if (_FileConnectorConfiguration.SourceFileLocation.ToLower().EndsWith(keyValuePair.Value))
sourceFileLocation = Path.GetFullPath(_FileConnectorConfiguration.SourceFileLocation);
else
sourceFileLocation = Path.GetFullPath(string.Concat(_FileConnectorConfiguration.SourceFileLocation, @"\", keyValuePair.Value));
sourceArchiveFile = Path.GetFullPath(string.Concat(sourceFileLocation, @"\", sourceFileFilter));
if (!File.Exists(sourceArchiveFile))
continue;
if (!_DummyRuns.ContainsKey(monARessource))
_DummyRuns.Add(monARessource, new List<long>());
tuples.Add(new Tuple<string, string, string, string, int>(monARessource, sourceFileFilter, sourceFileLocation, sourceArchiveFile, 0));
}
}
File.AppendAllLines(traceDummyFile, from l in tuples select l.Item4);
if (tuples.Any())
{
_LastDummyRunIndex += 1;
if (_LastDummyRunIndex >= tuples.Count)
_LastDummyRunIndex = 0;
monARessource = tuples[_LastDummyRunIndex].Item1;
string sourceFileFilter = tuples[_LastDummyRunIndex].Item2;
sourceFileLocation = tuples[_LastDummyRunIndex].Item3;
sourceArchiveFile = tuples[_LastDummyRunIndex].Item4;
//fileCount = tuples[_LastDummyRunIndex].Item5;
tuples.Clear();
if (long.TryParse(Path.GetFileNameWithoutExtension(sourceArchiveFile).Replace("x", string.Empty), out long sequence))
{
if (!_DummyRuns[monARessource].Contains(sequence))
_DummyRuns[monARessource].Add(sequence);
inProcessDirectory = string.Concat(progressDirectory, @"\Dummy_in process\", sequence);
checkDirectory = inProcessDirectory;
if (!Directory.Exists(checkDirectory))
Directory.CreateDirectory(checkDirectory);
files = Directory.GetFiles(checkDirectory, "*", SearchOption.AllDirectories);
fileCount = files.Length;
if (files.Any())
{
if (files.Length > 250)
throw new Exception("Safety net!");
try
{
foreach (string file in files)
File.Delete(file);
}
catch (Exception) { }
}
tuples.Add(new Tuple<string, string, string, string, int>(monARessource, sourceArchiveFile, inProcessDirectory, checkDirectory, fileCount));
checkDirectory = sourceFileLocation;
files = Directory.GetFiles(checkDirectory, string.Concat("*", sequence, "*"), SearchOption.TopDirectoryOnly);
fileCount = files.Length;
tuples.Add(new Tuple<string, string, string, string, int>(monARessource, sourceArchiveFile, inProcessDirectory, checkDirectory, fileCount));
}
}
if (tuples.Any())
//CallbackIsDummy(traceDummyFile, tuples, FileConnectorConfiguration.IncludeSubDirectories.Value, includeSubDirectoriesExtra: false);
CallbackIsDummy(traceDummyFile, tuples, fileConnectorConfigurationIncludeSubDirectories: true, includeSubDirectoriesExtra: true);
} }
} }
catch (Exception exception) }
{ return results;
string subject = string.Concat("Exception:", _CellInstanceConnectionName); }
string body = string.Concat(exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace);
try private void CallbackIsDummy(string traceDummyFile, List<Tuple<string, string, string, string, int>> tuples, bool fileConnectorConfigurationIncludeSubDirectories, bool includeSubDirectoriesExtra)
{ _SMTP.SendHighPriorityEmailMessage(subject, body); } {
catch (Exception) { } int fileCount;
} string[] files;
string monARessource;
string checkDirectory;
string sourceArchiveFile;
string inProcessDirectory;
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);
foreach (Tuple<string, string, string, string, int> item in tuples)
{
monARessource = item.Item1;
sourceArchiveFile = item.Item2;
inProcessDirectory = item.Item3;
checkDirectory = item.Item4;
fileCount = item.Item5;
try try
{ {
TimeSpan timeSpan = new(DateTime.Now.AddSeconds(_FileConnectorConfiguration.FileScanningIntervalInSeconds.Value).Ticks - DateTime.Now.Ticks); if (fileCount > 0 || string.IsNullOrEmpty(checkDirectory))
_Timer.Change((long)timeSpan.TotalMilliseconds, Timeout.Infinite); {
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);
}
else if (inProcessDirectory == checkDirectory)
continue;
if (!_IsEAFHosted)
continue;
if (!File.Exists(sourceArchiveFile))
continue;
if (!long.TryParse(Path.GetFileNameWithoutExtension(sourceArchiveFile).Replace("x", string.Empty), out long sequence))
continue;
ZipFile.ExtractToDirectory(sourceArchiveFile, inProcessDirectory);
if (fileConnectorConfigurationIncludeSubDirectories && includeSubDirectoriesExtra)
{
if (_EventName == _EventNameFileRead)
checkDirectory = string.Concat(checkDirectory, @"\", sequence);
else if (_EventName == _EventNameFileReadDaily)
checkDirectory = string.Concat(checkDirectory, @"\Source\", sequence);
else
throw new Exception();
}
if (fileConnectorConfigurationIncludeSubDirectories)
files = Directory.GetFiles(inProcessDirectory, "*", SearchOption.AllDirectories);
else
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 (!fileConnectorConfigurationIncludeSubDirectories)
{
foreach (string file in files)
File.Move(file, string.Concat(checkDirectory, @"\", Path.GetFileName(file)));
}
else
{
string[] directories = Directory.GetDirectories(inProcessDirectory, "*", SearchOption.AllDirectories);
foreach (string directory in directories)
_ = Directory.CreateDirectory(string.Concat(checkDirectory, directory.Substring(inProcessDirectory.Length)));
foreach (string file in files)
File.Move(file, string.Concat(checkDirectory, 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) catch (Exception exception)
{ {
@ -544,9 +391,126 @@ namespace Adaptation.FileHandlers.MET08RESIMAPCDE
try try
{ _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 });
_ = monIn.SendStatus(site, monARessource, stateName, State.Critical);
} }
} }
}
private void Callback(object state)
{
if (_Hyphens != _HyphenIsDummy)
throw new Exception();
try
{
DateTime dateTime = DateTime.Now;
bool check = (dateTime.Hour > 7 && dateTime.Hour < 18 && dateTime.DayOfWeek != DayOfWeek.Sunday && dateTime.DayOfWeek != DayOfWeek.Saturday);
if (check)
{
int fileCount;
string[] files;
string monARessource;
string checkDirectory;
string sourceArchiveFile;
string sourceFileLocation;
string inProcessDirectory;
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);
if (!Directory.Exists(traceDummyDirectory))
_ = Directory.CreateDirectory(traceDummyDirectory);
string traceDummyFile = string.Concat(traceDummyDirectory, @"\", dateTime.Ticks, " - ", _CellInstanceName, ".txt");
File.AppendAllText(traceDummyFile, string.Empty);
List<Tuple<string, string, string, string, int>> tuples = new();
string progressDirectory = Path.GetFullPath(string.Concat(_FileConnectorConfiguration.SourceFileLocation, @"\_ Progress"));
if (progressDirectory != _ProgressPath || !Directory.Exists(progressDirectory))
throw new Exception("Invalid progress path");
foreach (KeyValuePair<string, string> keyValuePair in _CellNames)
{
monARessource = keyValuePair.Key;
if (!keyValuePair.Value.Contains(@"\"))
continue;
foreach (string sourceFileFilter in _FileConnectorConfiguration.SourceFileFilter.Split('|'))
{
if (sourceFileFilter.ToLower().StartsWith(keyValuePair.Value.Replace(@"\", string.Empty)))
sourceFileLocation = Path.GetFullPath(_FileConnectorConfiguration.SourceFileLocation);
else if (_FileConnectorConfiguration.SourceFileLocation.ToLower().EndsWith(keyValuePair.Value))
sourceFileLocation = Path.GetFullPath(_FileConnectorConfiguration.SourceFileLocation);
else
sourceFileLocation = Path.GetFullPath(string.Concat(_FileConnectorConfiguration.SourceFileLocation, @"\", keyValuePair.Value));
sourceArchiveFile = Path.GetFullPath(string.Concat(sourceFileLocation, @"\", sourceFileFilter));
if (!File.Exists(sourceArchiveFile))
continue;
if (!_DummyRuns.ContainsKey(monARessource))
_DummyRuns.Add(monARessource, new List<long>());
tuples.Add(new Tuple<string, string, string, string, int>(monARessource, sourceFileFilter, sourceFileLocation, sourceArchiveFile, 0));
}
}
File.AppendAllLines(traceDummyFile, from l in tuples select l.Item4);
if (tuples.Any())
{
_LastDummyRunIndex += 1;
if (_LastDummyRunIndex >= tuples.Count)
_LastDummyRunIndex = 0;
monARessource = tuples[_LastDummyRunIndex].Item1;
string sourceFileFilter = tuples[_LastDummyRunIndex].Item2;
sourceFileLocation = tuples[_LastDummyRunIndex].Item3;
sourceArchiveFile = tuples[_LastDummyRunIndex].Item4;
//fileCount = tuples[_LastDummyRunIndex].Item5;
tuples.Clear();
if (long.TryParse(Path.GetFileNameWithoutExtension(sourceArchiveFile).Replace("x", string.Empty), out long sequence))
{
if (!_DummyRuns[monARessource].Contains(sequence))
_DummyRuns[monARessource].Add(sequence);
inProcessDirectory = string.Concat(progressDirectory, @"\Dummy_in process\", sequence);
checkDirectory = inProcessDirectory;
if (!Directory.Exists(checkDirectory))
_ = Directory.CreateDirectory(checkDirectory);
files = Directory.GetFiles(checkDirectory, "*", SearchOption.AllDirectories);
fileCount = files.Length;
if (files.Any())
{
if (files.Length > 250)
throw new Exception("Safety net!");
try
{
foreach (string file in files)
File.Delete(file);
}
catch (Exception) { }
}
tuples.Add(new Tuple<string, string, string, string, int>(monARessource, sourceArchiveFile, inProcessDirectory, checkDirectory, fileCount));
checkDirectory = sourceFileLocation;
files = Directory.GetFiles(checkDirectory, string.Concat("*", sequence, "*"), SearchOption.TopDirectoryOnly);
fileCount = files.Length;
tuples.Add(new Tuple<string, string, string, string, int>(monARessource, sourceArchiveFile, inProcessDirectory, checkDirectory, fileCount));
}
}
if (tuples.Any())
//CallbackIsDummy(traceDummyFile, tuples, FileConnectorConfiguration.IncludeSubDirectories.Value, includeSubDirectoriesExtra: false);
CallbackIsDummy(traceDummyFile, tuples, fileConnectorConfigurationIncludeSubDirectories: true, includeSubDirectoriesExtra: true);
}
}
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

@ -1,18 +1,15 @@
namespace Adaptation.FileHandlers.MET08RESIMAPCDE namespace Adaptation.FileHandlers.MET08RESIMAPCDE;
public enum Hyphen
{ {
IsXToOpenInsightMetrologyViewer, //MetrologyWS.SendData(file, string.Concat("http://", serverName, "/api/inbound/CDE"));
public enum Hyphen IsXToIQSSi, //NA <d7p1:FileScanningIntervalInSeconds>-361</d7p1:FileScanningIntervalInSeconds>
{ IsXToOpenInsight, //NA <d7p1:FileScanningIntervalInSeconds>-363</d7p1:FileScanningIntervalInSeconds>
IsXToOpenInsightMetrologyViewer, //MetrologyWS.SendData(file, string.Concat("http://", serverName, "/api/inbound/CDE")); IsXToOpenInsightMetrologyViewerAttachments, //Site-None <d7p1:FileScanningIntervalInSeconds>-362</d7p1:FileScanningIntervalInSeconds>
IsXToIQSSi, //NA <d7p1:FileScanningIntervalInSeconds>-361</d7p1:FileScanningIntervalInSeconds> IsXToAPC,
IsXToOpenInsight, //NA <d7p1:FileScanningIntervalInSeconds>-363</d7p1:FileScanningIntervalInSeconds> IsXToSPaCe,
IsXToOpenInsightMetrologyViewerAttachments, //Site-None <d7p1:FileScanningIntervalInSeconds>-362</d7p1:FileScanningIntervalInSeconds> IsXToArchive,
IsXToAPC, IsArchive,
IsXToSPaCe, IsDummy,
IsXToArchive, IsNaEDA
IsArchive,
IsDummy,
IsNaEDA
}
} }

View File

@ -4,53 +4,50 @@ 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()
{ {
new Tuple<int, Enum, string>(0, Hyphen.IsNaEDA, @"\EC_EDA\Staging\Traces\~\Source"),
new Tuple<int, Enum, string>(15, Hyphen.IsXToOpenInsightMetrologyViewer, @"\EC_EAFLog\TracesMES\~\Source"),
new Tuple<int, Enum, string>(-36, Hyphen.IsXToIQSSi, @"\EC_SPC_Si\Traces\~\PollPath"),
new Tuple<int, Enum, string>(-36, Hyphen.IsXToOpenInsight, @"\\messa01ec.ec.local\APPS\Metrology\~\Source"),
new Tuple<int, Enum, string>(-36, Hyphen.IsXToOpenInsightMetrologyViewerAttachments, @"\EC_Characterization_Si\In Process\~\Source"),
new Tuple<int, Enum, string>(360, Hyphen.IsXToAPC, @"\EC_APC\Staging\Traces\~\PollPath"),
new Tuple<int, Enum, string>(-36, Hyphen.IsXToSPaCe, @"\EC_SPC_Si\Traces\~\Source"),
new Tuple<int, Enum, string>(180, Hyphen.IsXToArchive, @"\EC_EAFLog\TracesArchive\~\Source"),
new Tuple<int, Enum, string>(36, Hyphen.IsArchive, @"\EC_Characterization_Si\Processed")
//new Tuple<int, Enum, string>("IsDummy"
};
internal static List<Tuple<int, Enum, string>> HyphenTuples => new() internal static string GetLines(IFileRead fileRead, Logistics logistics, List<pcl.Description> descriptions)
{ {
new Tuple<int, Enum, string>(0, Hyphen.IsNaEDA, @"\EC_EDA\Staging\Traces\~\Source"), StringBuilder result = new();
new Tuple<int, Enum, string>(15, Hyphen.IsXToOpenInsightMetrologyViewer, @"\EC_EAFLog\TracesMES\~\Source"), if (fileRead is null)
new Tuple<int, Enum, string>(-36, Hyphen.IsXToIQSSi, @"\EC_SPC_Si\Traces\~\PollPath"), { }
new Tuple<int, Enum, string>(-36, Hyphen.IsXToOpenInsight, @"\\messa01ec.ec.local\APPS\Metrology\~\Source"), if (logistics is null)
new Tuple<int, Enum, string>(-36, Hyphen.IsXToOpenInsightMetrologyViewerAttachments, @"\EC_Characterization_Si\In Process\~\Source"), { }
new Tuple<int, Enum, string>(360, Hyphen.IsXToAPC, @"\EC_APC\Staging\Traces\~\PollPath"), if (descriptions is null)
new Tuple<int, Enum, string>(-36, Hyphen.IsXToSPaCe, @"\EC_SPC_Si\Traces\~\Source"), { }
new Tuple<int, Enum, string>(180, Hyphen.IsXToArchive, @"\EC_EAFLog\TracesArchive\~\Source"), return result.ToString();
new Tuple<int, Enum, string>(36, Hyphen.IsArchive, @"\EC_Characterization_Si\Processed") }
//new Tuple<int, Enum, string>("IsDummy"
};
internal static string GetLines(IFileRead fileRead, Logistics logistics, List<pcl.Description> descriptions)
{
StringBuilder result = new();
if (fileRead is null)
{ }
if (logistics is null)
{ }
if (descriptions is null)
{ }
return result.ToString();
}
internal static void PostOpenInsightMetrologyViewerAttachments(IFileRead fileRead, DateTime dateTime, string logisticsSequenceMemoryDirectory, List<pcl.Description> descriptions, string matchDirectory)
{
if (fileRead is null)
{ }
if (dateTime == DateTime.MinValue)
{ }
if (logisticsSequenceMemoryDirectory is null)
{ }
if (descriptions is null)
{ }
if (matchDirectory is null)
{ }
//Not used
}
internal static void PostOpenInsightMetrologyViewerAttachments(IFileRead fileRead, DateTime dateTime, string logisticsSequenceMemoryDirectory, List<pcl.Description> descriptions, string matchDirectory)
{
if (fileRead is null)
{ }
if (dateTime == DateTime.MinValue)
{ }
if (logisticsSequenceMemoryDirectory is null)
{ }
if (descriptions is null)
{ }
if (matchDirectory is null)
{ }
//Not used
} }
} }

View File

@ -4,104 +4,101 @@ 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 SentToSPC { get; set; }
//
public string AutoOptimizeGain { get; set; }
public string AutoProbeHeightSet { get; set; }
public string Avg { get; set; }
public string CellName { get; set; }
public string DLRatio { get; set; }
public string DataReject { get; set; }
public string Date { get; set; }
public string Engineer { get; set; }
public string EquipId { get; set; }
public string FileName { get; set; }
public string FilePath { get; set; }
public string Id { get; set; }
public string Layer { get; set; }
public string LotId { get; set; }
public string Op { get; set; }
public string PSN { get; set; }
public string RDS { get; set; }
public string Reactor { get; set; }
public string Recipe { get; set; }
public string ResistivitySpec { get; set; }
public string Run { get; set; }
public string SemiRadial { get; set; }
public string StDev { get; set; }
public string Temp { get; set; }
public string UniqueId { get; set; }
public string Zone { get; set; }
public List<pcl.Detail> Details { get; protected set; }
[Obsolete("For json")] public WSRequest() { }
internal WSRequest(IFileRead fileRead, Logistics logistics, List<pcl.Description> descriptions)
{ {
Id = "-1";
public bool SentToMetrology { get; set; } if (fileRead is null)
public bool SentToSPC { get; set; } { }
// CellName = logistics.MesEntity;
Details = new List<pcl.Detail>();
public string AutoOptimizeGain { get; set; } if (descriptions[0] is not pcl.Description x)
public string AutoProbeHeightSet { get; set; } throw new Exception();
public string Avg { get; set; } //Header
public string CellName { get; set; }
public string DLRatio { get; set; }
public string DataReject { get; set; }
public string Date { get; set; }
public string Engineer { get; set; }
public string EquipId { get; set; }
public string FileName { get; set; }
public string FilePath { get; set; }
public string Id { get; set; }
public string Layer { get; set; }
public string LotId { get; set; }
public string Op { get; set; }
public string PSN { get; set; }
public string RDS { get; set; }
public string Reactor { get; set; }
public string Recipe { get; set; }
public string ResistivitySpec { get; set; }
public string Run { get; set; }
public string SemiRadial { get; set; }
public string StDev { get; set; }
public string Temp { get; set; }
public string UniqueId { get; set; }
public string Zone { get; set; }
public List<pcl.Detail> Details { get; protected set; }
[Obsolete("For json")] public WSRequest() { }
internal WSRequest(IFileRead fileRead, Logistics logistics, List<pcl.Description> descriptions)
{ {
Id = "-1"; AutoOptimizeGain = x.AutoOptimizeGain;
if (fileRead is null) AutoProbeHeightSet = x.AutoProbeHeightSet;
{ } Avg = x.Avg;
CellName = logistics.MesEntity; DLRatio = x.DLRatio;
Details = new List<pcl.Detail>(); DataReject = x.DataReject;
if (descriptions[0] is not pcl.Description x) Date = x.Date;
throw new Exception(); Op = x.Employee;
//Header Engineer = x.Engineer;
{ EquipId = x.EquipId;
AutoOptimizeGain = x.AutoOptimizeGain; FileName = x.FileName;
AutoProbeHeightSet = x.AutoProbeHeightSet; Layer = x.Layer;
Avg = x.Avg; LotId = x.Lot;
DLRatio = x.DLRatio; PSN = x.PSN;
DataReject = x.DataReject; RDS = x.RDS;
Date = x.Date; Reactor = x.Reactor;
Op = x.Employee; Recipe = x.Recipe;
Engineer = x.Engineer; ResistivitySpec = x.ResistivitySpec;
EquipId = x.EquipId; Run = x.Run;
FileName = x.FileName; SemiRadial = x.SemiRadial;
Layer = x.Layer; StDev = x.StdDev;
LotId = x.Lot; Temp = x.Temp;
PSN = x.PSN; UniqueId = x.UniqueId;
RDS = x.RDS; Zone = x.Zone;
Reactor = x.Reactor;
Recipe = x.Recipe;
ResistivitySpec = x.ResistivitySpec;
Run = x.Run;
SemiRadial = x.SemiRadial;
StDev = x.StdDev;
Temp = x.Temp;
UniqueId = x.UniqueId;
Zone = x.Zone;
}
pcl.Detail detail;
foreach (pcl.Description description in descriptions)
{
detail = new pcl.Detail
{
HeaderUniqueId = description.HeaderUniqueId,
Merit = description.Merit,
Pt = description.Pt,
R = description.R,
Rs = description.Rs,
T = description.T,
UniqueId = description.UniqueId
};
Details.Add(detail);
}
if (Date is null)
Date = logistics.DateTimeFromSequence.ToString();
if (UniqueId is null && Details.Any())
UniqueId = Details[0].HeaderUniqueId;
string onlyWSRequest = string.Empty;
FilePath = onlyWSRequest;
} }
pcl.Detail detail;
foreach (pcl.Description description in descriptions)
{
detail = new pcl.Detail
{
HeaderUniqueId = description.HeaderUniqueId,
Merit = description.Merit,
Pt = description.Pt,
R = description.R,
Rs = description.Rs,
T = description.T,
UniqueId = description.UniqueId
};
Details.Add(detail);
}
if (Date is null)
Date = logistics.DateTimeFromSequence.ToString();
if (UniqueId is null && Details.Any())
UniqueId = Details[0].HeaderUniqueId;
string onlyWSRequest = string.Empty;
FilePath = onlyWSRequest;
} }
} }

View File

@ -5,312 +5,305 @@ 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 Count { get; set; }
public int Index { get; set; }
//
public string EventName { get; set; }
public string NullData { get; set; }
public string JobID { get; set; }
public string Sequence { get; set; }
public string MesEntity { get; set; }
public string ReportFullPath { get; set; }
public string ProcessJobID { get; set; }
public string MID { get; set; }
//
public string Date { get; set; }
public string Employee { get; set; }
public string Lot { get; set; }
public string PSN { get; set; }
public string Reactor { get; set; }
public string Recipe { get; set; }
//
public string AutoOptimizeGain { get; set; }
public string AutoProbeHeightSet { get; set; }
public string Avg { get; set; }
public string DataReject { get; set; }
public string DLRatio { get; set; }
public string Merit { get; set; }
public string Pt { get; set; }
public string R { get; set; }
public string ResistivitySpec { get; set; }
public string Rs { get; set; }
public string SemiRadial { get; set; }
public string StdDev { get; set; }
public string T { get; set; }
public string Temp { get; set; }
//
public string Engineer { get; set; }
public string EquipId { get; set; }
public string FileName { get; set; }
public string HeaderUniqueId { get; set; }
public string Id { get; set; }
public string Layer { get; set; }
public string RDS { get; set; }
public string Run { get; set; }
public string UniqueId { get; set; }
public string Zone { get; set; }
string IDescription.GetEventDescription() => "File Has been read and parsed";
List<string> IDescription.GetNames(IFileRead fileRead, Logistics logistics)
{ {
List<string> results = new();
IDescription description = GetDefault(fileRead, logistics);
string json = JsonSerializer.Serialize(description, description.GetType());
object @object = JsonSerializer.Deserialize<object>(json);
if (@object is not JsonElement jsonElement)
throw new Exception();
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
results.Add(jsonProperty.Name);
return results;
}
List<string> IDescription.GetDetailNames()
public int Test { get; set; } {
public int Count { get; set; } List<string> results = new()
public int Index { get; set; }
//
public string EventName { get; set; }
public string NullData { get; set; }
public string JobID { get; set; }
public string Sequence { get; set; }
public string MesEntity { get; set; }
public string ReportFullPath { get; set; }
public string ProcessJobID { get; set; }
public string MID { get; set; }
//
public string Date { get; set; }
public string Employee { get; set; }
public string Lot { get; set; }
public string PSN { get; set; }
public string Reactor { get; set; }
public string Recipe { get; set; }
//
public string AutoOptimizeGain { get; set; }
public string AutoProbeHeightSet { get; set; }
public string Avg { get; set; }
public string DataReject { get; set; }
public string DLRatio { get; set; }
public string Merit { get; set; }
public string Pt { get; set; }
public string R { get; set; }
public string ResistivitySpec { get; set; }
public string Rs { get; set; }
public string SemiRadial { get; set; }
public string StdDev { get; set; }
public string T { get; set; }
public string Temp { get; set; }
//
public string Engineer { get; set; }
public string EquipId { get; set; }
public string FileName { get; set; }
public string HeaderUniqueId { get; set; }
public string Id { get; set; }
public string Layer { get; set; }
public string RDS { get; set; }
public string Run { get; set; }
public string UniqueId { get; set; }
public string Zone { get; set; }
string IDescription.GetEventDescription()
{ {
return "File Has been read and parsed"; nameof(AutoOptimizeGain),
nameof(AutoProbeHeightSet),
nameof(Avg),
nameof(DataReject),
nameof(DLRatio),
nameof(Merit),
nameof(Pt),
nameof(R),
nameof(ResistivitySpec),
nameof(Rs),
nameof(SemiRadial),
nameof(StdDev),
nameof(T),
nameof(Temp)
};
return results;
}
List<string> IDescription.GetHeaderNames()
{
List<string> results = new()
{
nameof(Date),
nameof(Employee),
nameof(Lot),
nameof(PSN),
nameof(Reactor),
nameof(Recipe)
};
return results;
}
IDescription IDescription.GetDisplayNames()
{
Description result = GetDisplayNames();
return result;
}
List<string> IDescription.GetParameterNames()
{
List<string> results = new()
{
nameof(Engineer),
nameof(EquipId),
nameof(FileName),
nameof(HeaderUniqueId),
nameof(Id),
nameof(Layer),
nameof(RDS),
nameof(Run),
nameof(UniqueId),
nameof(Zone)
};
return results;
}
JsonProperty[] IDescription.GetDefault(IFileRead fileRead, Logistics logistics)
{
JsonProperty[] results;
IDescription description = GetDefault(fileRead, logistics);
string json = JsonSerializer.Serialize(description, description.GetType());
object @object = JsonSerializer.Deserialize<object>(json);
results = ((JsonElement)@object).EnumerateObject().ToArray();
return results;
}
List<string> IDescription.GetPairedParameterNames()
{
List<string> results = new();
return results;
}
List<string> IDescription.GetIgnoreParameterNames(Test test)
{
List<string> results = new();
return results;
}
IDescription IDescription.GetDefaultDescription(IFileRead fileRead, Logistics logistics)
{
Description result = GetDefault(fileRead, logistics);
return result;
}
Dictionary<string, string> IDescription.GetDisplayNamesJsonElement(IFileRead fileRead)
{
Dictionary<string, string> results = new();
IDescription description = GetDisplayNames();
string json = JsonSerializer.Serialize(description, description.GetType());
JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
{
if (!results.ContainsKey(jsonProperty.Name))
results.Add(jsonProperty.Name, string.Empty);
if (jsonProperty.Value is JsonElement jsonPropertyValue)
results[jsonProperty.Name] = jsonPropertyValue.ToString();
} }
return results;
}
List<string> IDescription.GetNames(IFileRead fileRead, Logistics logistics) List<IDescription> IDescription.GetDescriptions(IFileRead fileRead, Logistics logistics, List<Test> tests, IProcessData iProcessData)
{
List<IDescription> results = new();
if (iProcessData is null || !iProcessData.Details.Any() || iProcessData is not ProcessData processData)
results.Add(GetDefault(fileRead, logistics));
else
{ {
List<string> results = new(); string nullData;
IDescription description = GetDefault(fileRead, logistics); Description description;
string json = JsonSerializer.Serialize(description, description.GetType()); object configDataNullData = fileRead.NullData;
object @object = JsonSerializer.Deserialize<object>(json); if (configDataNullData is null)
if (@object is not JsonElement jsonElement) nullData = string.Empty;
throw new Exception();
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
results.Add(jsonProperty.Name);
return results;
}
List<string> IDescription.GetDetailNames()
{
List<string> results = new()
{
nameof(AutoOptimizeGain),
nameof(AutoProbeHeightSet),
nameof(Avg),
nameof(DataReject),
nameof(DLRatio),
nameof(Merit),
nameof(Pt),
nameof(R),
nameof(ResistivitySpec),
nameof(Rs),
nameof(SemiRadial),
nameof(StdDev),
nameof(T),
nameof(Temp)
};
return results;
}
List<string> IDescription.GetHeaderNames()
{
List<string> results = new()
{
nameof(Date),
nameof(Employee),
nameof(Lot),
nameof(PSN),
nameof(Reactor),
nameof(Recipe)
};
return results;
}
IDescription IDescription.GetDisplayNames()
{
Description result = GetDisplayNames();
return result;
}
List<string> IDescription.GetParameterNames()
{
List<string> results = new()
{
nameof(Engineer),
nameof(EquipId),
nameof(FileName),
nameof(HeaderUniqueId),
nameof(Id),
nameof(Layer),
nameof(RDS),
nameof(Run),
nameof(UniqueId),
nameof(Zone)
};
return results;
}
JsonProperty[] IDescription.GetDefault(IFileRead fileRead, Logistics logistics)
{
JsonProperty[] results;
IDescription description = GetDefault(fileRead, logistics);
string json = JsonSerializer.Serialize(description, description.GetType());
object @object = JsonSerializer.Deserialize<object>(json);
results = ((JsonElement)@object).EnumerateObject().ToArray();
return results;
}
List<string> IDescription.GetPairedParameterNames()
{
List<string> results = new();
return results;
}
List<string> IDescription.GetIgnoreParameterNames(Test test)
{
List<string> results = new();
return results;
}
IDescription IDescription.GetDefaultDescription(IFileRead fileRead, Logistics logistics)
{
Description result = GetDefault(fileRead, logistics);
return result;
}
Dictionary<string, string> IDescription.GetDisplayNamesJsonElement(IFileRead fileRead)
{
Dictionary<string, string> results = new();
IDescription description = GetDisplayNames();
string json = JsonSerializer.Serialize(description, description.GetType());
JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
{
if (!results.ContainsKey(jsonProperty.Name))
results.Add(jsonProperty.Name, string.Empty);
if (jsonProperty.Value is JsonElement jsonPropertyValue)
results[jsonProperty.Name] = jsonPropertyValue.ToString();
}
return results;
}
List<IDescription> IDescription.GetDescriptions(IFileRead fileRead, Logistics logistics, List<Test> tests, IProcessData iProcessData)
{
List<IDescription> results = new();
if (iProcessData is null || !iProcessData.Details.Any() || iProcessData is not ProcessData processData)
results.Add(GetDefault(fileRead, logistics));
else else
nullData = configDataNullData.ToString();
for (int i = 0; i < iProcessData.Details.Count; i++)
{ {
string nullData; if (iProcessData.Details[i] is not Detail detail)
Description description; continue;
object configDataNullData = fileRead.NullData; description = new Description
if (configDataNullData is null)
nullData = string.Empty;
else
nullData = configDataNullData.ToString();
for (int i = 0; i < iProcessData.Details.Count; i++)
{ {
if (iProcessData.Details[i] is not Detail detail) Test = (int)tests[i],
continue; Count = tests.Count,
description = new Description Index = i,
{ //
Test = (int)tests[i], EventName = fileRead.EventName,
Count = tests.Count, NullData = nullData,
Index = i, JobID = fileRead.CellInstanceName,
// Sequence = logistics.Sequence.ToString(),
EventName = fileRead.EventName, MesEntity = logistics.MesEntity,
NullData = nullData, ReportFullPath = logistics.ReportFullPath,
JobID = fileRead.CellInstanceName, ProcessJobID = logistics.ProcessJobID,
Sequence = logistics.Sequence.ToString(), MID = logistics.MID,
MesEntity = logistics.MesEntity, //
ReportFullPath = logistics.ReportFullPath, Date = processData.Date,
ProcessJobID = logistics.ProcessJobID, Employee = processData.Engineer,
MID = logistics.MID, Lot = processData.Lot,
// PSN = processData.PSN,
Date = processData.Date, Reactor = processData.Reactor,
Employee = processData.Engineer, Recipe = processData.Recipe,
Lot = processData.Lot, //
PSN = processData.PSN, AutoOptimizeGain = processData.AutoOptimizeGain,
Reactor = processData.Reactor, AutoProbeHeightSet = processData.AutoProbeHeightSet,
Recipe = processData.Recipe, Avg = processData.Avg,
// DataReject = processData.DataReject,
AutoOptimizeGain = processData.AutoOptimizeGain, DLRatio = processData.DLRatio,
AutoProbeHeightSet = processData.AutoProbeHeightSet, Merit = detail.Merit,
Avg = processData.Avg, Pt = detail.Pt,
DataReject = processData.DataReject, R = detail.R,
DLRatio = processData.DLRatio, ResistivitySpec = processData.ResistivitySpec,
Merit = detail.Merit, Rs = detail.Rs,
Pt = detail.Pt, SemiRadial = processData.SemiRadial,
R = detail.R, StdDev = processData.StandardDeviationPercentage,
ResistivitySpec = processData.ResistivitySpec, T = detail.T,
Rs = detail.Rs, Temp = processData.Temp,
SemiRadial = processData.SemiRadial, //
StdDev = processData.StandardDeviationPercentage, Engineer = processData.Engineer,
T = detail.T, EquipId = processData.EquipId,
Temp = processData.Temp, FileName = processData.FileName,
// HeaderUniqueId = detail.HeaderUniqueId,
Engineer = processData.Engineer, Id = processData.UniqueId,
EquipId = processData.EquipId, Layer = processData.Layer,
FileName = processData.FileName, RDS = processData.RDS,
HeaderUniqueId = detail.HeaderUniqueId, Run = processData.Run,
Id = processData.UniqueId, UniqueId = detail.UniqueId,
Layer = processData.Layer, Zone = processData.Zone
RDS = processData.RDS, };
Run = processData.Run, results.Add(description);
UniqueId = detail.UniqueId,
Zone = processData.Zone
};
results.Add(description);
}
} }
return results;
} }
return results;
}
private Description GetDisplayNames() private Description GetDisplayNames()
{
Description result = new();
return result;
}
private Description GetDefault(IFileRead fileRead, Logistics logistics)
{
Description result = new()
{ {
Description result = new(); Test = -1,
return result; Count = 0,
} Index = -1,
//
private Description GetDefault(IFileRead fileRead, Logistics logistics) EventName = fileRead.EventName,
{ NullData = fileRead.NullData,
Description result = new() JobID = fileRead.CellInstanceName,
{ Sequence = logistics.Sequence.ToString(),
Test = -1, MesEntity = fileRead.MesEntity,
Count = 0, ReportFullPath = logistics.ReportFullPath,
Index = -1, ProcessJobID = logistics.ProcessJobID,
// MID = logistics.MID,
EventName = fileRead.EventName, //
NullData = fileRead.NullData, Date = nameof(Date),
JobID = fileRead.CellInstanceName, Employee = nameof(Employee),
Sequence = logistics.Sequence.ToString(), Lot = nameof(Lot),
MesEntity = fileRead.MesEntity, PSN = nameof(PSN),
ReportFullPath = logistics.ReportFullPath, Reactor = nameof(Reactor),
ProcessJobID = logistics.ProcessJobID, Recipe = nameof(Recipe),
MID = logistics.MID, //
// AutoOptimizeGain = nameof(AutoOptimizeGain),
Date = nameof(Date), AutoProbeHeightSet = nameof(AutoProbeHeightSet),
Employee = nameof(Employee), Avg = nameof(Avg),
Lot = nameof(Lot), DataReject = nameof(DataReject),
PSN = nameof(PSN), DLRatio = nameof(DLRatio),
Reactor = nameof(Reactor), Merit = nameof(Merit),
Recipe = nameof(Recipe), Pt = nameof(Pt),
// R = nameof(R),
AutoOptimizeGain = nameof(AutoOptimizeGain), ResistivitySpec = nameof(ResistivitySpec),
AutoProbeHeightSet = nameof(AutoProbeHeightSet), Rs = nameof(Rs),
Avg = nameof(Avg), SemiRadial = nameof(SemiRadial),
DataReject = nameof(DataReject), StdDev = nameof(StdDev),
DLRatio = nameof(DLRatio), T = nameof(T),
Merit = nameof(Merit), Temp = nameof(Temp),
Pt = nameof(Pt), //
R = nameof(R), Engineer = nameof(Engineer),
ResistivitySpec = nameof(ResistivitySpec), EquipId = nameof(EquipId),
Rs = nameof(Rs), FileName = nameof(FileName),
SemiRadial = nameof(SemiRadial), HeaderUniqueId = nameof(HeaderUniqueId),
StdDev = nameof(StdDev), Id = nameof(Id),
T = nameof(T), Layer = nameof(Layer),
Temp = nameof(Temp), RDS = nameof(RDS),
// Run = nameof(Run),
Engineer = nameof(Engineer), UniqueId = nameof(UniqueId),
EquipId = nameof(EquipId), Zone = nameof(Zone),
FileName = nameof(FileName), };
HeaderUniqueId = nameof(HeaderUniqueId), return result;
Id = nameof(Id),
Layer = nameof(Layer),
RDS = nameof(RDS),
Run = nameof(Run),
UniqueId = nameof(UniqueId),
Zone = nameof(Zone),
};
return result;
}
} }
} }

View File

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

View File

@ -9,141 +9,121 @@ 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)
{ {
_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);
}
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) : void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) => Move(extractResults, exception);
base(new Description(), true, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted, hyphenXToArchive, hyphenIsArchive)
{
_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) void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
{
Move(this, extractResults, exception);
}
void IFileRead.WaitForThread() string IFileRead.GetEventDescription()
{ {
WaitForThread(thread: null, threadExceptions: null); string result = _Description.GetEventDescription();
} return result;
}
string IFileRead.GetEventDescription() List<string> IFileRead.GetHeaderNames()
{ {
string result = _Description.GetEventDescription(); List<string> results = _Description.GetHeaderNames();
return result; return results;
} }
List<string> IFileRead.GetHeaderNames() string[] IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception)
{ {
List<string> results = _Description.GetHeaderNames(); string[] results = Move(extractResults, to, from, resolvedFileLocation, exception);
return results; return results;
} }
string[] IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception) JsonProperty[] IFileRead.GetDefault()
{ {
string[] results = Move(extractResults, to, from, resolvedFileLocation, exception); JsonProperty[] results = _Description.GetDefault(this, _Logistics);
return results; return results;
} }
JsonProperty[] IFileRead.GetDefault() Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement()
{ {
JsonProperty[] results = _Description.GetDefault(this, _Logistics); Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this);
return results; return results;
} }
Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement() List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData)
{ {
Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this); List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData);
return results; return results;
} }
List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData) Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.GetExtractResult(string reportFullPath, string eventName)
{ {
List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData); Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
return 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, new 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.GetExtractResult(string reportFullPath, string eventName) Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.ReExtract()
{ {
Tuple<string, Test[], JsonElement[], List<FileInfo>> results; Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
if (string.IsNullOrEmpty(eventName)) List<string> headerNames = _Description.GetHeaderNames();
throw new Exception(); Dictionary<string, string> keyValuePairs = _Description.GetDisplayNamesJsonElement(this);
_ReportFullPath = reportFullPath; results = ReExtract(this, headerNames, keyValuePairs);
DateTime dateTime = DateTime.Now; return results;
results = GetExtractResult(reportFullPath, dateTime); }
if (results.Item3 is null)
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(results.Item1, new 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() void IFileRead.CheckTests(Test[] tests, bool extra) => throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
{
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) void IFileRead.Callback(object state) => throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
{
throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
}
void IFileRead.MoveArchive() private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, null, null, new List<FileInfo>());
_Logistics = new Logistics(this, reportFullPath, useSplitForMID: true);
SetFileParameterLotIDToLogisticsMID();
if (reportFullPath.Length < _MinFileLength)
results.Item4.Add(new FileInfo(reportFullPath));
else
{ {
throw new Exception(string.Concat("Not ", nameof(_IsDuplicator))); string logBody = string.Empty;
} IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4);
if (iProcessData is ProcessData processData)
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)
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, null, null, new List<FileInfo>());
_Logistics = new Logistics(this, reportFullPath, useSplitForMID: true);
SetFileParameterLotIDToLogisticsMID();
if (reportFullPath.Length < _MinFileLength)
results.Item4.Add(new FileInfo(reportFullPath));
else
{ {
string logBody = string.Empty; string mid = string.Concat(processData.Reactor, "-", processData.RDS, "-", processData.PSN);
IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4); mid = Regex.Replace(mid, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
if (iProcessData is ProcessData processData) _Logistics.MID = mid;
{ SetFileParameterLotID(mid);
string mid = string.Concat(processData.Reactor, "-", processData.RDS, "-", processData.PSN); _Logistics.ProcessJobID = processData.Reactor;
mid = Regex.Replace(mid, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0]; logBody = processData.LogBody;
_Logistics.MID = mid;
SetFileParameterLotID(mid);
_Logistics.ProcessJobID = processData.Reactor;
logBody = processData.LogBody;
}
if (!iProcessData.Details.Any())
throw new Exception(string.Concat("No Data - ", dateTime.Ticks));
results = iProcessData.GetResults(this, _Logistics, results.Item4);
if (!_IsEAFHosted)
results = new(logBody, results.Item2, results.Item3, results.Item4);
} }
return results; if (!iProcessData.Details.Any())
throw new Exception(string.Concat("No Data - ", dateTime.Ticks));
results = iProcessData.GetResults(this, _Logistics, results.Item4);
if (!_IsEAFHosted)
results = new(logBody, results.Item2, results.Item3, results.Item4);
} }
return results;
} }
} }

View File

@ -10,270 +10,264 @@ 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;
public string JobID { get; set; }
public string MesEntity { get; set; }
public string AutoOptimizeGain { get; set; }
public string AutoProbeHeightSet { get; set; }
public string Avg { get; set; }
public string DLRatio { get; set; }
public string DataReject { get; set; }
public string Date { get; set; }
public DateTime DateTime { get; set; }
public string Employee { get; set; }
public string EquipId { get; set; }
public string Engineer { get; set; }
public string FileName { get; set; }
public string Layer { get; set; }
public string Lot { get; set; }
public string LogBody { get; set; }
public string PSN { get; set; }
public string Project { get; set; }
public string RDS { get; set; }
public string Reactor { get; set; }
public string Recipe { get; set; }
public string RecipeName { get; set; }
public string ResistivitySpec { get; set; }
public string Run { get; set; }
public string SemiRadial { get; set; }
public string StandardDeviation { get; set; }
public string StandardDeviationPercentage { get; set; }
public string Temp { get; set; }
public string Title { get; set; }
public string UniqueId { get; set; }
public string Zone { get; set; }
List<object> Shared.Properties.IProcessData.Details => _Details;
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
{ {
JobID = logistics.JobID;
fileInfoCollection.Clear();
_Details = new List<object>();
MesEntity = logistics.MesEntity;
Parse(fileRead, logistics, fileInfoCollection);
}
private readonly List<object> _Details; string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors) => throw new Exception(string.Concat("See ", nameof(Parse)));
public string JobID { get; set; } Tuple<string, Test[], JsonElement[], List<FileInfo>> IProcessData.GetResults(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
public string MesEntity { get; set; } {
public string AutoOptimizeGain { get; set; } Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
public string AutoProbeHeightSet { get; set; } List<Test> tests = new();
public string Avg { get; set; } foreach (object item in _Details)
public string DLRatio { get; set; } tests.Add(Test.CDE);
public string DataReject { get; set; } List<IDescription> descriptions = fileRead.GetDescriptions(fileRead, tests, this);
public string Date { get; set; } if (tests.Count != descriptions.Count)
public DateTime DateTime { get; set; } throw new Exception();
public string Employee { get; set; } for (int i = 0; i < tests.Count; i++)
public string EquipId { get; set; }
public string Engineer { get; set; }
public string FileName { get; set; }
public string Layer { get; set; }
public string Lot { get; set; }
public string LogBody { get; set; }
public string PSN { get; set; }
public string Project { get; set; }
public string RDS { get; set; }
public string Reactor { get; set; }
public string Recipe { get; set; }
public string RecipeName { get; set; }
public string ResistivitySpec { get; set; }
public string Run { get; set; }
public string SemiRadial { get; set; }
public string StandardDeviation { get; set; }
public string StandardDeviationPercentage { get; set; }
public string Temp { get; set; }
public string Title { get; set; }
public string UniqueId { get; set; }
public string Zone { get; set; }
List<object> Shared.Properties.IProcessData.Details => _Details;
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
{ {
JobID = logistics.JobID; if (descriptions[i] is not Description description)
fileInfoCollection.Clear(); throw new Exception();
_Details = new List<object>(); if (description.Test != (int)tests[i])
MesEntity = logistics.MesEntity;
Parse(fileRead, logistics, fileInfoCollection);
}
string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors)
{
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>> results;
List<Test> tests = new();
foreach (object item in _Details)
tests.Add(Test.CDE);
List<IDescription> descriptions = fileRead.GetDescriptions(fileRead, tests, this);
if (tests.Count != descriptions.Count)
throw new Exception(); throw new Exception();
for (int i = 0; i < tests.Count; i++)
{
if (descriptions[i] is not Description description)
throw new Exception();
if (description.Test != (int)tests[i])
throw new Exception();
}
List<Description> fileReadDescriptions = (from l in descriptions select (Description)l).ToList();
string json = JsonSerializer.Serialize(fileReadDescriptions, fileReadDescriptions.GetType());
JsonElement[] jsonElements = JsonSerializer.Deserialize<JsonElement[]>(json);
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(logistics.Logistics1[0], tests.ToArray(), jsonElements, fileInfoCollection);
return results;
} }
List<Description> fileReadDescriptions = (from l in descriptions select (Description)l).ToList();
string json = JsonSerializer.Serialize(fileReadDescriptions, fileReadDescriptions.GetType());
JsonElement[] jsonElements = JsonSerializer.Deserialize<JsonElement[]>(json);
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(logistics.Logistics1[0], tests.ToArray(), jsonElements, fileInfoCollection);
return results;
}
private void SetTitleData(string[] segments) private void SetTitleData(string[] segments)
{
if (segments.Length > 0)
{ {
if (segments.Length > 0) Title = segments[0];
// Remove illegal characters \/:*?"<>| found in the Run.
Run = Regex.Replace(segments[0], @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
string[] parsedBatch = segments[0].Split('-');
if (parsedBatch.Length > 0)
Reactor = parsedBatch[0];
if (parsedBatch.Length > 1)
RDS = parsedBatch[1];
if (parsedBatch.Length > 2)
{ {
Title = segments[0]; string[] parsedPSN = parsedBatch[2].Split('.');
// Remove illegal characters \/:*?"<>| found in the Run. if (parsedPSN.Length > 0)
Run = Regex.Replace(segments[0], @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0]; PSN = parsedPSN[0];
string[] parsedBatch = segments[0].Split('-'); if (parsedPSN.Length > 1)
if (parsedBatch.Length > 0) Layer = parsedPSN[1];
Reactor = parsedBatch[0];
if (parsedBatch.Length > 1)
RDS = parsedBatch[1];
if (parsedBatch.Length > 2)
{
string[] parsedPSN = parsedBatch[2].Split('.');
if (parsedPSN.Length > 0)
PSN = parsedPSN[0];
if (parsedPSN.Length > 1)
Layer = parsedPSN[1];
}
if (parsedBatch.Length > 3)
Zone = parsedBatch[3];
} }
if (parsedBatch.Length > 3)
Zone = parsedBatch[3];
} }
}
private void SetFileNameData(string[] segments) private void SetFileNameData(string[] segments)
{
if (segments.Length > 1)
FileName = segments[0];
if (segments.Length > 2)
{ {
if (segments.Length > 1) Project = segments[1];
FileName = segments[0]; RecipeName = segments[2];
if (segments.Length > 2) Recipe = string.Concat(segments[1], " \\ ", segments[2]);
{
Project = segments[1];
RecipeName = segments[2];
Recipe = string.Concat(segments[1], " \\ ", segments[2]);
}
} }
}
internal static DateTime GetDateTime(Logistics logistics, string dateTimeText) internal static DateTime GetDateTime(Logistics logistics, string dateTimeText)
{
DateTime result;
string inputDateFormat = "HH:mm MM/dd/yy";
if (dateTimeText.Length != inputDateFormat.Length)
result = logistics.DateTimeFromSequence;
else
{ {
DateTime result; if (!DateTime.TryParseExact(dateTimeText, inputDateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTimeParsed))
string inputDateFormat = "HH:mm MM/dd/yy";
if (dateTimeText.Length != inputDateFormat.Length)
result = logistics.DateTimeFromSequence; result = logistics.DateTimeFromSequence;
else else
{ {
if (!DateTime.TryParseExact(dateTimeText, inputDateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTimeParsed)) if (dateTimeParsed < logistics.DateTimeFromSequence.AddDays(1) && dateTimeParsed > logistics.DateTimeFromSequence.AddDays(-1))
result = logistics.DateTimeFromSequence; result = dateTimeParsed;
else else
result = logistics.DateTimeFromSequence;
}
}
return result;
}
private void SetDateTimeData(Logistics logistics, string[] segments)
{
DateTime dateTime;
if (segments.Length < 2)
dateTime = logistics.DateTimeFromSequence;
else
{
string dateTimeText = string.Concat(segments[0], ' ', segments[1]);
dateTime = GetDateTime(logistics, dateTimeText);
}
DateTime = dateTime;
Date = dateTime.ToString();
if (segments.Length > 3 && float.TryParse(segments[2], out float temp))
Temp = temp.ToString("0.0");
if (segments.Length > 7 && segments[6] == "Avg=")
Avg = segments[7];
if (segments.Length > 7 && segments[8] == "Dev=")
StandardDeviation = segments[9];
if (!string.IsNullOrEmpty(Avg) && !string.IsNullOrEmpty(StandardDeviation) && float.TryParse(Avg, out float average) && float.TryParse(StandardDeviation, out float standardDeviation))
StandardDeviationPercentage = Math.Round(standardDeviation / average, 4).ToString("0.00%");
}
private void SetOperatorData(string[] segments)
{
if (segments.Length > 1)
Employee = segments[0];
if (segments.Length > 2)
EquipId = segments[1];
}
private void SetEngineerData(string[] segments)
{
if (segments.Length > 1)
Engineer = segments[0];
}
private void SetNumProbePointsData(string[] segments)
{
if (segments.Length > 6)
DataReject = segments[6];
}
private Detail GetRData(string[] segments)
{
Detail result = new();
if (segments.Length > 0 && float.TryParse(segments[0], out float r))
result.R = r.ToString("0.0");
if (segments.Length > 1 && float.TryParse(segments[1], out float t))
result.T = t.ToString("0.0");
if (segments.Length > 2 && float.TryParse(segments[2], out float rs))
result.Rs = rs.ToString("0.0000");
if (segments.Length > 12 && float.TryParse(segments[12], out float merit))
result.Merit = merit.ToString("0.00");
result.Pt = "-1";
result.UniqueId = string.Empty;
return result;
}
private void Parse(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
{
if (fileRead is null)
{ }
Lot = "LotID";
Detail detail;
if (fileInfoCollection is null)
{ }
string timeFormat = "yyyyMMddHHmmss";
string[] separator = new string[] { " " };
string[] lines = File.ReadAllLines(logistics.ReportFullPath);
for (int i = 0; i < lines.Length; i++)
{
if (lines[i].Contains(",<Title>"))
SetTitleData(lines[i].Split(separator, StringSplitOptions.RemoveEmptyEntries));
else if (lines[i].Contains(",<FileName, Proj,Rcpe, LotID,WfrID>"))
SetFileNameData(lines[i].Split(separator, StringSplitOptions.RemoveEmptyEntries));
else if (lines[i].Contains(",<DateTime,Temp,TCR%,N|P>"))
SetDateTimeData(logistics, lines[i].Split(separator, StringSplitOptions.RemoveEmptyEntries));
else if (lines[i].Contains(",<Operator, Epuipment>"))
SetOperatorData(lines[i].Split(separator, StringSplitOptions.RemoveEmptyEntries));
else if (lines[i].Contains(",<Engineer>"))
SetEngineerData(lines[i].Split(separator, StringSplitOptions.RemoveEmptyEntries));
else if (lines[i].Contains(",<NumProbePoints, SingleOrDualProbeConfig, #ActPrbPts, Rsens,IdrvMx,VinGain, DataRejectSigma, MeritThreshold>"))
SetNumProbePointsData(lines[i].Split(separator, StringSplitOptions.RemoveEmptyEntries));
else if (lines[i].Contains(",<R,Th,Data, Rs,RsA,RsB, #Smpl, x,y, Irng,Vrng,ChiSq,merit,DataIntegrity>"))
{
for (int z = i; z < lines.Length; z++)
{ {
if (dateTimeParsed < logistics.DateTimeFromSequence.AddDays(1) && dateTimeParsed > logistics.DateTimeFromSequence.AddDays(-1)) i = z;
result = dateTimeParsed; if (string.IsNullOrEmpty(lines[z]))
else continue;
result = logistics.DateTimeFromSequence; detail = GetRData(lines[z].Split(separator, StringSplitOptions.RemoveEmptyEntries));
_Details.Add(detail);
} }
} }
return result;
} }
UniqueId = string.Concat(EquipId, "_", Run, "_", logistics.DateTimeFromSequence.ToString(timeFormat));
private void SetDateTimeData(Logistics logistics, string[] segments) for (int i = 0; i < _Details.Count; i++)
{ {
DateTime dateTime; if (_Details[i] is not Detail item)
if (segments.Length < 2) continue;
dateTime = logistics.DateTimeFromSequence; item.HeaderUniqueId = UniqueId;
else item.Pt = (i + 1).ToString();
{ item.UniqueId = string.Concat(item, "_Point-", item.Pt);
string dateTimeText = string.Concat(segments[0], ' ', segments[1]);
dateTime = GetDateTime(logistics, dateTimeText);
}
DateTime = dateTime;
Date = dateTime.ToString();
if (segments.Length > 3 && float.TryParse(segments[2], out float temp))
Temp = temp.ToString("0.0");
if (segments.Length > 7 && segments[6] == "Avg=")
Avg = segments[7];
if (segments.Length > 7 && segments[8] == "Dev=")
StandardDeviation = segments[9];
if (!string.IsNullOrEmpty(Avg) && !string.IsNullOrEmpty(StandardDeviation) && float.TryParse(Avg, out float average) && float.TryParse(StandardDeviation, out float standardDeviation))
StandardDeviationPercentage = Math.Round(standardDeviation / average, 4).ToString("0.00%");
} }
// Remove illegal characters \/:*?"<>| found in the Lot.
private void SetOperatorData(string[] segments) Lot = Regex.Replace(Lot, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
StringBuilder stringBuilder = new();
string reportFileName = Path.GetFileName(logistics.ReportFullPath);
_ = stringBuilder.AppendLine($"RUN [{Title}]");
_ = stringBuilder.AppendLine($"Recipe {Project} \\ {RecipeName} RESISTIVITY {"####"}");
_ = stringBuilder.AppendLine($"EQUIP# {EquipId} Engineer {Engineer}");
_ = stringBuilder.AppendLine($"LotID {Lot} D.L.RATIO {"#.####"}");
_ = stringBuilder.AppendLine($"OPERATOR {Employee} TEMP {Temp} {DateTime:HH:mm MM/dd/yy}");
_ = stringBuilder.AppendLine($"AutoOptimizeGain = {"###"} AutoProbeHeightSet = {"##"}");
_ = stringBuilder.AppendLine($"DataReject > {"#.#"}Sigma");
_ = stringBuilder.AppendLine($"0 ..\\{Project}.prj\\{RecipeName}.rcp\\{reportFileName} {DateTime:HH:mm MM/dd/yy}");
_ = stringBuilder.AppendLine($"pt# R Th Rs[Ohm/sq@T] Merit");
for (int i = 0; i < _Details.Count; i++)
{ {
if (segments.Length > 1) if (_Details[i] is not Detail item)
Employee = segments[0]; continue;
if (segments.Length > 2) _ = stringBuilder.AppendLine($"{item.Pt} {item.R} {item.T} {item.Rs} {item.Merit}");
EquipId = segments[1];
} }
_ = stringBuilder.AppendLine($"Avg = {Avg} {StandardDeviationPercentage} SEMI Radial= {"#.##%"}");
private void SetEngineerData(string[] segments) LogBody = stringBuilder.ToString();
{
if (segments.Length > 1)
Engineer = segments[0];
}
private void SetNumProbePointsData(string[] segments)
{
if (segments.Length > 6)
DataReject = segments[6];
}
private Detail GetRData(string[] segments)
{
Detail result = new();
if (segments.Length > 0 && float.TryParse(segments[0], out float r))
result.R = r.ToString("0.0");
if (segments.Length > 1 && float.TryParse(segments[1], out float t))
result.T = t.ToString("0.0");
if (segments.Length > 2 && float.TryParse(segments[2], out float rs))
result.Rs = rs.ToString("0.0000");
if (segments.Length > 12 && float.TryParse(segments[12], out float merit))
result.Merit = merit.ToString("0.00");
result.Pt = "-1";
result.UniqueId = string.Empty;
return result;
}
private void Parse(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
{
if (fileRead is null)
{ }
Lot = "LotID";
Detail detail;
if (fileInfoCollection is null)
{ }
string timeFormat = "yyyyMMddHHmmss";
string[] separator = new string[] { " " };
string[] lines = File.ReadAllLines(logistics.ReportFullPath);
for (int i = 0; i < lines.Length; i++)
{
if (lines[i].Contains(",<Title>"))
SetTitleData(lines[i].Split(separator, StringSplitOptions.RemoveEmptyEntries));
else if (lines[i].Contains(",<FileName, Proj,Rcpe, LotID,WfrID>"))
SetFileNameData(lines[i].Split(separator, StringSplitOptions.RemoveEmptyEntries));
else if (lines[i].Contains(",<DateTime,Temp,TCR%,N|P>"))
SetDateTimeData(logistics, lines[i].Split(separator, StringSplitOptions.RemoveEmptyEntries));
else if (lines[i].Contains(",<Operator, Epuipment>"))
SetOperatorData(lines[i].Split(separator, StringSplitOptions.RemoveEmptyEntries));
else if (lines[i].Contains(",<Engineer>"))
SetEngineerData(lines[i].Split(separator, StringSplitOptions.RemoveEmptyEntries));
else if (lines[i].Contains(",<NumProbePoints, SingleOrDualProbeConfig, #ActPrbPts, Rsens,IdrvMx,VinGain, DataRejectSigma, MeritThreshold>"))
SetNumProbePointsData(lines[i].Split(separator, StringSplitOptions.RemoveEmptyEntries));
else if (lines[i].Contains(",<R,Th,Data, Rs,RsA,RsB, #Smpl, x,y, Irng,Vrng,ChiSq,merit,DataIntegrity>"))
{
for (int z = i; z < lines.Length; z++)
{
i = z;
if (string.IsNullOrEmpty(lines[z]))
continue;
detail = GetRData(lines[z].Split(separator, StringSplitOptions.RemoveEmptyEntries));
_Details.Add(detail);
}
}
}
UniqueId = string.Concat(EquipId, "_", Run, "_", logistics.DateTimeFromSequence.ToString(timeFormat));
for (int i = 0; i < _Details.Count; i++)
{
if (_Details[i] is not Detail item)
continue;
item.HeaderUniqueId = UniqueId;
item.Pt = (i + 1).ToString();
item.UniqueId = string.Concat(item, "_Point-", item.Pt);
}
// Remove illegal characters \/:*?"<>| found in the Lot.
Lot = Regex.Replace(Lot, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
StringBuilder stringBuilder = new();
string reportFileName = Path.GetFileName(logistics.ReportFullPath);
stringBuilder.AppendLine($"RUN [{Title}]");
stringBuilder.AppendLine($"Recipe {Project} \\ {RecipeName} RESISTIVITY {"####"}");
stringBuilder.AppendLine($"EQUIP# {EquipId} Engineer {Engineer}");
stringBuilder.AppendLine($"LotID {Lot} D.L.RATIO {"#.####"}");
stringBuilder.AppendLine($"OPERATOR {Employee} TEMP {Temp} {DateTime:HH:mm MM/dd/yy}");
stringBuilder.AppendLine($"AutoOptimizeGain = {"###"} AutoProbeHeightSet = {"##"}");
stringBuilder.AppendLine($"DataReject > {"#.#"}Sigma");
stringBuilder.AppendLine($"0 ..\\{Project}.prj\\{RecipeName}.rcp\\{reportFileName} {DateTime:HH:mm MM/dd/yy}");
stringBuilder.AppendLine($"pt# R Th Rs[Ohm/sq@T] Merit");
for (int i = 0; i < _Details.Count; i++)
{
if (_Details[i] is not Detail item)
continue;
stringBuilder.AppendLine($"{item.Pt} {item.R} {item.T} {item.Rs} {item.Merit}");
}
stringBuilder.AppendLine($"Avg = {Avg} {StandardDeviationPercentage} SEMI Radial= {"#.##%"}");
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,311 +5,305 @@ 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 Count { get; set; }
public int Index { get; set; }
//
public string EventName { get; set; }
public string NullData { get; set; }
public string JobID { get; set; }
public string Sequence { get; set; }
public string MesEntity { get; set; }
public string ReportFullPath { get; set; }
public string ProcessJobID { get; set; }
public string MID { get; set; }
//
public string Date { get; set; }
public string Employee { get; set; }
public string Lot { get; set; }
public string PSN { get; set; }
public string Reactor { get; set; }
public string Recipe { get; set; }
//
public string AutoOptimizeGain { get; set; }
public string AutoProbeHeightSet { get; set; }
public string Avg { get; set; }
public string DataReject { get; set; }
public string DLRatio { get; set; }
public string Merit { get; set; }
public string Pt { get; set; }
public string R { get; set; }
public string ResistivitySpec { get; set; }
public string Rs { get; set; }
public string SemiRadial { get; set; }
public string StdDev { get; set; }
public string T { get; set; }
public string Temp { get; set; }
//
public string Engineer { get; set; }
public string EquipId { get; set; }
public string FileName { get; set; }
public string HeaderUniqueId { get; set; }
public string Id { get; set; }
public string Layer { get; set; }
public string RDS { get; set; }
public string Run { get; set; }
public string UniqueId { get; set; }
public string Zone { get; set; }
string IDescription.GetEventDescription() => "File Has been read and parsed";
List<string> IDescription.GetNames(IFileRead fileRead, Logistics logistics)
{ {
List<string> results = new();
IDescription description = GetDefault(fileRead, logistics);
string json = JsonSerializer.Serialize(description, description.GetType());
object @object = JsonSerializer.Deserialize<object>(json);
if (@object is not JsonElement jsonElement)
throw new Exception();
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
results.Add(jsonProperty.Name);
return results;
}
public int Test { get; set; } List<string> IDescription.GetDetailNames()
public int Count { get; set; } {
public int Index { get; set; } List<string> results = new()
//
public string EventName { get; set; }
public string NullData { get; set; }
public string JobID { get; set; }
public string Sequence { get; set; }
public string MesEntity { get; set; }
public string ReportFullPath { get; set; }
public string ProcessJobID { get; set; }
public string MID { get; set; }
//
public string Date { get; set; }
public string Employee { get; set; }
public string Lot { get; set; }
public string PSN { get; set; }
public string Reactor { get; set; }
public string Recipe { get; set; }
//
public string AutoOptimizeGain { get; set; }
public string AutoProbeHeightSet { get; set; }
public string Avg { get; set; }
public string DataReject { get; set; }
public string DLRatio { get; set; }
public string Merit { get; set; }
public string Pt { get; set; }
public string R { get; set; }
public string ResistivitySpec { get; set; }
public string Rs { get; set; }
public string SemiRadial { get; set; }
public string StdDev { get; set; }
public string T { get; set; }
public string Temp { get; set; }
//
public string Engineer { get; set; }
public string EquipId { get; set; }
public string FileName { get; set; }
public string HeaderUniqueId { get; set; }
public string Id { get; set; }
public string Layer { get; set; }
public string RDS { get; set; }
public string Run { get; set; }
public string UniqueId { get; set; }
public string Zone { get; set; }
string IDescription.GetEventDescription()
{ {
return "File Has been read and parsed"; nameof(AutoOptimizeGain),
nameof(AutoProbeHeightSet),
nameof(Avg),
nameof(DataReject),
nameof(DLRatio),
nameof(Merit),
nameof(Pt),
nameof(R),
nameof(ResistivitySpec),
nameof(Rs),
nameof(SemiRadial),
nameof(StdDev),
nameof(T),
nameof(Temp)
};
return results;
}
List<string> IDescription.GetHeaderNames()
{
List<string> results = new()
{
nameof(Date),
nameof(Employee),
nameof(Lot),
nameof(PSN),
nameof(Reactor),
nameof(Recipe)
};
return results;
}
IDescription IDescription.GetDisplayNames()
{
Description result = GetDisplayNames();
return result;
}
List<string> IDescription.GetParameterNames()
{
List<string> results = new()
{
nameof(Engineer),
nameof(EquipId),
nameof(FileName),
nameof(HeaderUniqueId),
nameof(Id),
nameof(Layer),
nameof(RDS),
nameof(Run),
nameof(UniqueId),
nameof(Zone)
};
return results;
}
JsonProperty[] IDescription.GetDefault(IFileRead fileRead, Logistics logistics)
{
JsonProperty[] results;
IDescription description = GetDefault(fileRead, logistics);
string json = JsonSerializer.Serialize(description, description.GetType());
object @object = JsonSerializer.Deserialize<object>(json);
results = ((JsonElement)@object).EnumerateObject().ToArray();
return results;
}
List<string> IDescription.GetPairedParameterNames()
{
List<string> results = new();
return results;
}
List<string> IDescription.GetIgnoreParameterNames(Test test)
{
List<string> results = new();
return results;
}
IDescription IDescription.GetDefaultDescription(IFileRead fileRead, Logistics logistics)
{
Description result = GetDefault(fileRead, logistics);
return result;
}
Dictionary<string, string> IDescription.GetDisplayNamesJsonElement(IFileRead fileRead)
{
Dictionary<string, string> results = new();
IDescription description = GetDisplayNames();
string json = JsonSerializer.Serialize(description, description.GetType());
JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
{
if (!results.ContainsKey(jsonProperty.Name))
results.Add(jsonProperty.Name, string.Empty);
if (jsonProperty.Value is JsonElement jsonPropertyValue)
results[jsonProperty.Name] = jsonPropertyValue.ToString();
} }
return results;
}
List<string> IDescription.GetNames(IFileRead fileRead, Logistics logistics) List<IDescription> IDescription.GetDescriptions(IFileRead fileRead, Logistics logistics, List<Test> tests, IProcessData iProcessData)
{
List<IDescription> results = new();
if (iProcessData is null || !iProcessData.Details.Any() || iProcessData is not ProcessData processData)
results.Add(GetDefault(fileRead, logistics));
else
{ {
List<string> results = new(); string nullData;
IDescription description = GetDefault(fileRead, logistics); Description description;
string json = JsonSerializer.Serialize(description, description.GetType()); object configDataNullData = fileRead.NullData;
object @object = JsonSerializer.Deserialize<object>(json); if (configDataNullData is null)
if (@object is not JsonElement jsonElement) nullData = string.Empty;
throw new Exception();
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
results.Add(jsonProperty.Name);
return results;
}
List<string> IDescription.GetDetailNames()
{
List<string> results = new()
{
nameof(AutoOptimizeGain),
nameof(AutoProbeHeightSet),
nameof(Avg),
nameof(DataReject),
nameof(DLRatio),
nameof(Merit),
nameof(Pt),
nameof(R),
nameof(ResistivitySpec),
nameof(Rs),
nameof(SemiRadial),
nameof(StdDev),
nameof(T),
nameof(Temp)
};
return results;
}
List<string> IDescription.GetHeaderNames()
{
List<string> results = new()
{
nameof(Date),
nameof(Employee),
nameof(Lot),
nameof(PSN),
nameof(Reactor),
nameof(Recipe)
};
return results;
}
IDescription IDescription.GetDisplayNames()
{
Description result = GetDisplayNames();
return result;
}
List<string> IDescription.GetParameterNames()
{
List<string> results = new()
{
nameof(Engineer),
nameof(EquipId),
nameof(FileName),
nameof(HeaderUniqueId),
nameof(Id),
nameof(Layer),
nameof(RDS),
nameof(Run),
nameof(UniqueId),
nameof(Zone)
};
return results;
}
JsonProperty[] IDescription.GetDefault(IFileRead fileRead, Logistics logistics)
{
JsonProperty[] results;
IDescription description = GetDefault(fileRead, logistics);
string json = JsonSerializer.Serialize(description, description.GetType());
object @object = JsonSerializer.Deserialize<object>(json);
results = ((JsonElement)@object).EnumerateObject().ToArray();
return results;
}
List<string> IDescription.GetPairedParameterNames()
{
List<string> results = new();
return results;
}
List<string> IDescription.GetIgnoreParameterNames(Test test)
{
List<string> results = new();
return results;
}
IDescription IDescription.GetDefaultDescription(IFileRead fileRead, Logistics logistics)
{
Description result = GetDefault(fileRead, logistics);
return result;
}
Dictionary<string, string> IDescription.GetDisplayNamesJsonElement(IFileRead fileRead)
{
Dictionary<string, string> results = new();
IDescription description = GetDisplayNames();
string json = JsonSerializer.Serialize(description, description.GetType());
JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
{
if (!results.ContainsKey(jsonProperty.Name))
results.Add(jsonProperty.Name, string.Empty);
if (jsonProperty.Value is JsonElement jsonPropertyValue)
results[jsonProperty.Name] = jsonPropertyValue.ToString();
}
return results;
}
List<IDescription> IDescription.GetDescriptions(IFileRead fileRead, Logistics logistics, List<Test> tests, IProcessData iProcessData)
{
List<IDescription> results = new();
if (iProcessData is null || !iProcessData.Details.Any() || iProcessData is not ProcessData processData)
results.Add(GetDefault(fileRead, logistics));
else else
nullData = configDataNullData.ToString();
for (int i = 0; i < iProcessData.Details.Count; i++)
{ {
string nullData; if (iProcessData.Details[i] is not Detail detail)
Description description; continue;
object configDataNullData = fileRead.NullData; description = new Description
if (configDataNullData is null)
nullData = string.Empty;
else
nullData = configDataNullData.ToString();
for (int i = 0; i < iProcessData.Details.Count; i++)
{ {
if (iProcessData.Details[i] is not Detail detail) Test = (int)tests[i],
continue; Count = tests.Count,
description = new Description Index = i,
{ //
Test = (int)tests[i], EventName = fileRead.EventName,
Count = tests.Count, NullData = nullData,
Index = i, JobID = fileRead.CellInstanceName,
// Sequence = logistics.Sequence.ToString(),
EventName = fileRead.EventName, MesEntity = logistics.MesEntity,
NullData = nullData, ReportFullPath = logistics.ReportFullPath,
JobID = fileRead.CellInstanceName, ProcessJobID = logistics.ProcessJobID,
Sequence = logistics.Sequence.ToString(), MID = logistics.MID,
MesEntity = logistics.MesEntity, //
ReportFullPath = logistics.ReportFullPath, Date = processData.Date,
ProcessJobID = logistics.ProcessJobID, Employee = processData.Engineer,
MID = logistics.MID, Lot = processData.Lot,
// PSN = processData.PSN,
Date = processData.Date, Reactor = processData.Reactor,
Employee = processData.Engineer, Recipe = processData.Recipe,
Lot = processData.Lot, //
PSN = processData.PSN, AutoOptimizeGain = processData.AutoOptimizeGain,
Reactor = processData.Reactor, AutoProbeHeightSet = processData.AutoProbeHeightSet,
Recipe = processData.Recipe, Avg = processData.Avg,
// DataReject = processData.DataReject,
AutoOptimizeGain = processData.AutoOptimizeGain, DLRatio = processData.DLRatio,
AutoProbeHeightSet = processData.AutoProbeHeightSet, Merit = detail.Merit,
Avg = processData.Avg, Pt = detail.Pt,
DataReject = processData.DataReject, R = detail.R,
DLRatio = processData.DLRatio, ResistivitySpec = processData.ResistivitySpec,
Merit = detail.Merit, Rs = detail.Rs,
Pt = detail.Pt, SemiRadial = processData.SemiRadial,
R = detail.R, StdDev = processData.StdDev,
ResistivitySpec = processData.ResistivitySpec, T = detail.T,
Rs = detail.Rs, Temp = processData.Temp,
SemiRadial = processData.SemiRadial, //
StdDev = processData.StdDev, Engineer = processData.Engineer,
T = detail.T, EquipId = processData.EquipId,
Temp = processData.Temp, FileName = processData.FileName,
// HeaderUniqueId = detail.HeaderUniqueId,
Engineer = processData.Engineer, Id = processData.UniqueId,
EquipId = processData.EquipId, Layer = processData.Layer,
FileName = processData.FileName, RDS = processData.RDS,
HeaderUniqueId = detail.HeaderUniqueId, Run = processData.Run,
Id = processData.UniqueId, UniqueId = detail.UniqueId,
Layer = processData.Layer, Zone = processData.Zone
RDS = processData.RDS, };
Run = processData.Run, results.Add(description);
UniqueId = detail.UniqueId,
Zone = processData.Zone
};
results.Add(description);
}
} }
return results;
} }
return results;
}
private Description GetDisplayNames() private Description GetDisplayNames()
{
Description result = new();
return result;
}
private Description GetDefault(IFileRead fileRead, Logistics logistics)
{
Description result = new()
{ {
Description result = new(); Test = -1,
return result; Count = 0,
} Index = -1,
//
private Description GetDefault(IFileRead fileRead, Logistics logistics) EventName = fileRead.EventName,
{ NullData = fileRead.NullData,
Description result = new() JobID = fileRead.CellInstanceName,
{ Sequence = logistics.Sequence.ToString(),
Test = -1, MesEntity = fileRead.MesEntity,
Count = 0, ReportFullPath = logistics.ReportFullPath,
Index = -1, ProcessJobID = logistics.ProcessJobID,
// MID = logistics.MID,
EventName = fileRead.EventName, //
NullData = fileRead.NullData, Date = nameof(Date),
JobID = fileRead.CellInstanceName, Employee = nameof(Employee),
Sequence = logistics.Sequence.ToString(), Lot = nameof(Lot),
MesEntity = fileRead.MesEntity, PSN = nameof(PSN),
ReportFullPath = logistics.ReportFullPath, Reactor = nameof(Reactor),
ProcessJobID = logistics.ProcessJobID, Recipe = nameof(Recipe),
MID = logistics.MID, //
// AutoOptimizeGain = nameof(AutoOptimizeGain),
Date = nameof(Date), AutoProbeHeightSet = nameof(AutoProbeHeightSet),
Employee = nameof(Employee), Avg = nameof(Avg),
Lot = nameof(Lot), DataReject = nameof(DataReject),
PSN = nameof(PSN), DLRatio = nameof(DLRatio),
Reactor = nameof(Reactor), Merit = nameof(Merit),
Recipe = nameof(Recipe), Pt = nameof(Pt),
// R = nameof(R),
AutoOptimizeGain = nameof(AutoOptimizeGain), ResistivitySpec = nameof(ResistivitySpec),
AutoProbeHeightSet = nameof(AutoProbeHeightSet), Rs = nameof(Rs),
Avg = nameof(Avg), SemiRadial = nameof(SemiRadial),
DataReject = nameof(DataReject), StdDev = nameof(StdDev),
DLRatio = nameof(DLRatio), T = nameof(T),
Merit = nameof(Merit), Temp = nameof(Temp),
Pt = nameof(Pt), //
R = nameof(R), Engineer = nameof(Engineer),
ResistivitySpec = nameof(ResistivitySpec), EquipId = nameof(EquipId),
Rs = nameof(Rs), FileName = nameof(FileName),
SemiRadial = nameof(SemiRadial), HeaderUniqueId = nameof(HeaderUniqueId),
StdDev = nameof(StdDev), Id = nameof(Id),
T = nameof(T), Layer = nameof(Layer),
Temp = nameof(Temp), RDS = nameof(RDS),
// Run = nameof(Run),
Engineer = nameof(Engineer), UniqueId = nameof(UniqueId),
EquipId = nameof(EquipId), Zone = nameof(Zone),
FileName = nameof(FileName), };
HeaderUniqueId = nameof(HeaderUniqueId), return result;
Id = nameof(Id),
Layer = nameof(Layer),
RDS = nameof(RDS),
Run = nameof(Run),
UniqueId = nameof(UniqueId),
Zone = nameof(Zone),
};
return result;
}
} }
} }

View File

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

View File

@ -9,137 +9,117 @@ 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)
{ {
_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);
}
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) : void IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception) => Move(extractResults, exception);
base(new Description(), true, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted, hyphenXToArchive, hyphenIsArchive)
{
_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) void IFileRead.WaitForThread() => WaitForThread(thread: null, threadExceptions: null);
{
Move(this, extractResults, exception);
}
void IFileRead.WaitForThread() string IFileRead.GetEventDescription()
{ {
WaitForThread(thread: null, threadExceptions: null); string result = _Description.GetEventDescription();
} return result;
}
string IFileRead.GetEventDescription() List<string> IFileRead.GetHeaderNames()
{ {
string result = _Description.GetEventDescription(); List<string> results = _Description.GetHeaderNames();
return result; return results;
} }
List<string> IFileRead.GetHeaderNames() string[] IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception)
{ {
List<string> results = _Description.GetHeaderNames(); string[] results = Move(extractResults, to, from, resolvedFileLocation, exception);
return results; return results;
} }
string[] IFileRead.Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception) JsonProperty[] IFileRead.GetDefault()
{ {
string[] results = Move(extractResults, to, from, resolvedFileLocation, exception); JsonProperty[] results = _Description.GetDefault(this, _Logistics);
return results; return results;
} }
JsonProperty[] IFileRead.GetDefault() Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement()
{ {
JsonProperty[] results = _Description.GetDefault(this, _Logistics); Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this);
return results; return results;
} }
Dictionary<string, string> IFileRead.GetDisplayNamesJsonElement() List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData)
{ {
Dictionary<string, string> results = _Description.GetDisplayNamesJsonElement(this); List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData);
return results; return results;
} }
List<IDescription> IFileRead.GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData) Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.GetExtractResult(string reportFullPath, string eventName)
{ {
List<IDescription> results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData); Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
return 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, new 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.GetExtractResult(string reportFullPath, string eventName) Tuple<string, Test[], JsonElement[], List<FileInfo>> IFileRead.ReExtract()
{ {
Tuple<string, Test[], JsonElement[], List<FileInfo>> results; Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
if (string.IsNullOrEmpty(eventName)) List<string> headerNames = _Description.GetHeaderNames();
throw new Exception(); Dictionary<string, string> keyValuePairs = _Description.GetDisplayNamesJsonElement(this);
_ReportFullPath = reportFullPath; results = ReExtract(this, headerNames, keyValuePairs);
DateTime dateTime = DateTime.Now; return results;
results = GetExtractResult(reportFullPath, dateTime); }
if (results.Item3 is null)
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(results.Item1, new 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() void IFileRead.CheckTests(Test[] tests, bool extra) => throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
{
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) void IFileRead.Callback(object state) => throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
{
throw new Exception(string.Concat("Not ", nameof(_IsDuplicator)));
}
void IFileRead.MoveArchive() private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime)
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, null, null, new List<FileInfo>());
_Logistics = new Logistics(this, reportFullPath, useSplitForMID: true);
SetFileParameterLotIDToLogisticsMID();
if (reportFullPath.Length < _MinFileLength)
results.Item4.Add(new FileInfo(reportFullPath));
else
{ {
throw new Exception(string.Concat("Not ", nameof(_IsDuplicator))); IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4);
} if (iProcessData is ProcessData processData)
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)
{
Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, null, null, new List<FileInfo>());
_Logistics = new Logistics(this, reportFullPath, useSplitForMID: true);
SetFileParameterLotIDToLogisticsMID();
if (reportFullPath.Length < _MinFileLength)
results.Item4.Add(new FileInfo(reportFullPath));
else
{ {
IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4); string mid = string.Concat(processData.Reactor, "-", processData.RDS, "-", processData.PSN);
if (iProcessData is ProcessData processData) mid = Regex.Replace(mid, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
{ _Logistics.MID = mid;
string mid = string.Concat(processData.Reactor, "-", processData.RDS, "-", processData.PSN); SetFileParameterLotID(mid);
mid = Regex.Replace(mid, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0]; _Logistics.ProcessJobID = processData.Reactor;
_Logistics.MID = mid;
SetFileParameterLotID(mid);
_Logistics.ProcessJobID = processData.Reactor;
}
if (!iProcessData.Details.Any())
throw new Exception(string.Concat("No Data - ", dateTime.Ticks));
results = iProcessData.GetResults(this, _Logistics, results.Item4);
} }
return results; if (!iProcessData.Details.Any())
throw new Exception(string.Concat("No Data - ", dateTime.Ticks));
results = iProcessData.GetResults(this, _Logistics, results.Item4);
} }
return results;
} }
} }

View File

@ -11,442 +11,433 @@ 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 string _Data;
private readonly ILog _Log;
private readonly List<object> _Details;
public string JobID { get; set; }
public string MesEntity { get; set; }
public string AutoOptimizeGain { get; set; }
public string AutoProbeHeightSet { get; set; }
public string Avg { get; set; }
public string DLRatio { get; set; }
public string DataReject { get; set; }
public string Date { get; set; }
public string Employee { get; set; }
public string EquipId { get; set; }
public string Engineer { get; set; }
public string FileName { get; set; }
public string Layer { get; set; }
public string Lot { get; set; }
public string PSN { get; set; }
public string RDS { get; set; }
public string Reactor { get; set; }
public string Recipe { get; set; }
public string ResistivitySpec { get; set; }
public string Run { get; set; }
public string SemiRadial { get; set; }
public string StdDev { get; set; }
public string Temp { get; set; }
public string UniqueId { get; set; }
public string Zone { get; set; }
List<object> Shared.Properties.IProcessData.Details => _Details;
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
{ {
fileInfoCollection.Clear();
_Details = new List<object>();
_I = 0;
_Data = string.Empty;
JobID = logistics.JobID;
MesEntity = logistics.MesEntity;
_Log = LogManager.GetLogger(typeof(ProcessData));
Parse(fileRead, logistics, fileInfoCollection);
}
private int _I; string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors) => throw new Exception(string.Concat("See ", nameof(Parse)));
private string _Data;
private readonly ILog _Log; Tuple<string, Test[], JsonElement[], List<FileInfo>> IProcessData.GetResults(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
private readonly List<object> _Details; {
Tuple<string, Test[], JsonElement[], List<FileInfo>> results;
public string JobID { get; set; } List<Test> tests = new();
public string MesEntity { get; set; } foreach (object item in _Details)
public string AutoOptimizeGain { get; set; } tests.Add(Test.CDE);
public string AutoProbeHeightSet { get; set; } List<IDescription> descriptions = fileRead.GetDescriptions(fileRead, tests, this);
public string Avg { get; set; } if (tests.Count != descriptions.Count)
public string DLRatio { get; set; } throw new Exception();
public string DataReject { get; set; } for (int i = 0; i < tests.Count; i++)
public string Date { get; set; }
public string Employee { get; set; }
public string EquipId { get; set; }
public string Engineer { get; set; }
public string FileName { get; set; }
public string Layer { get; set; }
public string Lot { get; set; }
public string PSN { get; set; }
public string RDS { get; set; }
public string Reactor { get; set; }
public string Recipe { get; set; }
public string ResistivitySpec { get; set; }
public string Run { get; set; }
public string SemiRadial { get; set; }
public string StdDev { get; set; }
public string Temp { get; set; }
public string UniqueId { get; set; }
public string Zone { get; set; }
List<object> Shared.Properties.IProcessData.Details => _Details;
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
{ {
fileInfoCollection.Clear(); if (descriptions[i] is not Description description)
_Details = new List<object>(); throw new Exception();
_I = 0; if (description.Test != (int)tests[i])
_Data = string.Empty;
JobID = logistics.JobID;
MesEntity = logistics.MesEntity;
_Log = LogManager.GetLogger(typeof(ProcessData));
Parse(fileRead, logistics, fileInfoCollection);
}
string IProcessData.GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors)
{
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>> results;
List<Test> tests = new();
foreach (object item in _Details)
tests.Add(Test.CDE);
List<IDescription> descriptions = fileRead.GetDescriptions(fileRead, tests, this);
if (tests.Count != descriptions.Count)
throw new Exception(); throw new Exception();
for (int i = 0; i < tests.Count; i++)
{
if (descriptions[i] is not Description description)
throw new Exception();
if (description.Test != (int)tests[i])
throw new Exception();
}
List<Description> fileReadDescriptions = (from l in descriptions select (Description)l).ToList();
string json = JsonSerializer.Serialize(fileReadDescriptions, fileReadDescriptions.GetType());
JsonElement[] jsonElements = JsonSerializer.Deserialize<JsonElement[]>(json);
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(logistics.Logistics1[0], tests.ToArray(), jsonElements, fileInfoCollection);
return results;
} }
List<Description> fileReadDescriptions = (from l in descriptions select (Description)l).ToList();
string json = JsonSerializer.Serialize(fileReadDescriptions, fileReadDescriptions.GetType());
JsonElement[] jsonElements = JsonSerializer.Deserialize<JsonElement[]>(json);
results = new Tuple<string, Test[], JsonElement[], List<FileInfo>>(logistics.Logistics1[0], tests.ToArray(), jsonElements, fileInfoCollection);
return results;
}
private string GetBefore(string text) private string GetBefore(string text)
{
string str;
string str1;
int num = _Data.IndexOf(text, _I);
if (num <= -1)
{
str = _Data.Substring(_I);
_I = _Data.Length;
str1 = str.Trim();
}
else
{
str = _Data.Substring(_I, num - _I);
_I = num + text.Length;
str1 = str.Trim();
}
return str1;
}
private string GetBefore(string text, bool trim)
{
string str;
string before;
if (!trim)
{ {
string str;
string str1;
int num = _Data.IndexOf(text, _I); int num = _Data.IndexOf(text, _I);
if (num <= -1) if (num <= -1)
{ {
str = _Data.Substring(_I); str = _Data.Substring(_I);
_I = _Data.Length; _I = _Data.Length;
str1 = str.Trim(); before = str;
} }
else else
{ {
str = _Data.Substring(_I, num - _I); str = _Data.Substring(_I, num - _I);
_I = num + text.Length; _I = num + text.Length;
str1 = str.Trim(); before = str;
} }
return str1;
} }
else
private string GetBefore(string text, bool trim)
{ {
string str; before = GetBefore(text);
string before; }
if (!trim) return before;
}
private string GetToEOL() => GetBefore("\n");
private string GetToEOL(bool trim)
{
string str;
str = (!trim ? GetBefore("\n", false) : GetToEOL());
return str;
}
private string GetToken()
{
while (true)
{
if ((_I >= _Data.Length || !IsNullOrWhiteSpace(_Data.Substring(_I, 1))))
break;
_I++;
}
int num = _I;
while (true)
{
if ((num >= _Data.Length || IsNullOrWhiteSpace(_Data.Substring(num, 1))))
break;
num++;
}
string str = _Data.Substring(_I, num - _I);
_I = num;
return str.Trim();
}
private string GetToText(string text)
{
string str = _Data.Substring(_I, _Data.IndexOf(text, _I) - _I).Trim();
return str;
}
private bool IsBlankLine()
{
int num = _Data.IndexOf("\n", _I);
return IsNullOrWhiteSpace((num > -1 ? _Data.Substring(_I, num - _I) : _Data.Substring(_I)));
}
private bool IsNullOrWhiteSpace(string text)
{
bool flag;
int num = 0;
while (true)
{
if (num >= text.Length)
{ {
int num = _Data.IndexOf(text, _I); flag = true;
if (num <= -1) break;
{
str = _Data.Substring(_I);
_I = _Data.Length;
before = str;
}
else
{
str = _Data.Substring(_I, num - _I);
_I = num + text.Length;
before = str;
}
} }
else else if (char.IsWhiteSpace(text[num]))
{ {
before = GetBefore(text);
}
return before;
}
private string GetToEOL()
{
return GetBefore("\n");
}
private string GetToEOL(bool trim)
{
string str;
str = (!trim ? GetBefore("\n", false) : GetToEOL());
return str;
}
private string GetToken()
{
while (true)
{
if ((_I >= _Data.Length || !IsNullOrWhiteSpace(_Data.Substring(_I, 1))))
break;
_I++;
}
int num = _I;
while (true)
{
if ((num >= _Data.Length || IsNullOrWhiteSpace(_Data.Substring(num, 1))))
break;
num++; num++;
} }
string str = _Data.Substring(_I, num - _I);
_I = num;
return str.Trim();
}
private string GetToText(string text)
{
string str = _Data.Substring(_I, _Data.IndexOf(text, _I) - _I).Trim();
return str;
}
private bool IsBlankLine()
{
int num = _Data.IndexOf("\n", _I);
return IsNullOrWhiteSpace((num > -1 ? _Data.Substring(_I, num - _I) : _Data.Substring(_I)));
}
private bool IsNullOrWhiteSpace(string text)
{
bool flag;
int num = 0;
while (true)
{
if (num >= text.Length)
{
flag = true;
break;
}
else if (char.IsWhiteSpace(text[num]))
{
num++;
}
else
{
flag = false;
break;
}
}
return flag;
}
private string PeekNextLine()
{
int num = _I;
string toEOL = GetToEOL();
_I = num;
return toEOL;
}
private void ScanPast(string text)
{
int num = _Data.IndexOf(text, _I);
if (num <= -1)
{
_I = _Data.Length;
}
else else
{ {
_I = num + text.Length; flag = false;
break;
} }
} }
return flag;
}
internal static DateTime GetDateTime(Logistics logistics, string dateTimeText) private string PeekNextLine()
{
int num = _I;
string toEOL = GetToEOL();
_I = num;
return toEOL;
}
private void ScanPast(string text)
{
int num = _Data.IndexOf(text, _I);
if (num <= -1)
{ {
DateTime result; _I = _Data.Length;
string inputDateFormat = "HH:mm MM/dd/yy"; }
if (dateTimeText.Length != inputDateFormat.Length) else
{
_I = num + text.Length;
}
}
internal static DateTime GetDateTime(Logistics logistics, string dateTimeText)
{
DateTime result;
string inputDateFormat = "HH:mm MM/dd/yy";
if (dateTimeText.Length != inputDateFormat.Length)
result = logistics.DateTimeFromSequence;
else
{
if (!DateTime.TryParseExact(dateTimeText, inputDateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTimeParsed))
result = logistics.DateTimeFromSequence; result = logistics.DateTimeFromSequence;
else else
{ {
if (!DateTime.TryParseExact(dateTimeText, inputDateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTimeParsed)) if (dateTimeParsed < logistics.DateTimeFromSequence.AddDays(1) && dateTimeParsed > logistics.DateTimeFromSequence.AddDays(-1))
result = logistics.DateTimeFromSequence; result = dateTimeParsed;
else else
{ result = logistics.DateTimeFromSequence;
if (dateTimeParsed < logistics.DateTimeFromSequence.AddDays(1) && dateTimeParsed > logistics.DateTimeFromSequence.AddDays(-1))
result = dateTimeParsed;
else
result = logistics.DateTimeFromSequence;
}
} }
return result;
} }
return result;
}
private void Parse(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection) private void Parse(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection)
{
if (fileRead is null)
{ }
// Convert the source file to UTF8Encoding format and then back to string for processing. This convertion
// shall eliminate the special HEX characters such as 0x18 "CANCEL" and 0x20 "SPACE" captured via nPort.
string rawText = File.ReadAllText(logistics.ReportFullPath);
UTF8Encoding utf8Encoding = new();
byte[] bytes = utf8Encoding.GetBytes(rawText);
string convertedText = utf8Encoding.GetString(bytes);
// Replaces all control characters with a space, except for the TAB (0x09), LF (0x0A), CR (0x0D), and
// normal ASCII characters, which are valid characters for SharePoint.
string receivedData = Regex.Replace(convertedText, @"[^\u0009\u000A\u000D\u0020-\u007E]", " ");
string log = receivedData;
for (short i = 0; i < short.MaxValue; i++)
{
if (!log.Contains(" "))
break;
log = log.Replace(" ", " ");
}
log = log.Replace(" ", "\t").Replace(": ", "\t").Replace(":\t", "\t");
IEnumerable<string> lines = (from l in log.Split('\r') select l.Trim());
string logFile = Path.ChangeExtension(logistics.ReportFullPath, ".log");
File.WriteAllLines(logFile, lines);
fileInfoCollection.Add(new FileInfo(logFile));
//parse file
string h = string.Empty;
receivedData = receivedData.Replace("\r", "\n").Trim();
_I = 0;
_Data = string.Empty;
if (string.IsNullOrEmpty(receivedData))
throw new Exception("No data!");
Detail detail;
_I = 0;
_Data = receivedData;
ScanPast("RUN:");
Run = GetToEOL();
ScanPast("Recipe:");
Recipe = GetBefore("RESISTIVITY SPEC:");
if (string.IsNullOrEmpty(Recipe))
{ {
if (fileRead is null)
{ }
// Convert the source file to UTF8Encoding format and then back to string for processing. This convertion
// shall eliminate the special HEX characters such as 0x18 "CANCEL" and 0x20 "SPACE" captured via nPort.
string rawText = File.ReadAllText(logistics.ReportFullPath);
UTF8Encoding utf8Encoding = new();
byte[] bytes = utf8Encoding.GetBytes(rawText);
string convertedText = utf8Encoding.GetString(bytes);
// Replaces all control characters with a space, except for the TAB (0x09), LF (0x0A), CR (0x0D), and
// normal ASCII characters, which are valid characters for SharePoint.
string receivedData = Regex.Replace(convertedText, @"[^\u0009\u000A\u000D\u0020-\u007E]", " ");
string log = receivedData;
for (short i = 0; i < short.MaxValue; i++)
{
if (!log.Contains(" "))
break;
log = log.Replace(" ", " ");
}
log = log.Replace(" ", "\t").Replace(": ", "\t").Replace(":\t", "\t");
IEnumerable<string> lines = (from l in log.Split('\r') select l.Trim());
string logFile = Path.ChangeExtension(logistics.ReportFullPath, ".log");
File.WriteAllLines(logFile, lines);
fileInfoCollection.Add(new FileInfo(logFile));
//parse file
string h = string.Empty;
receivedData = receivedData.Replace("\r", "\n").Trim();
_I = 0;
_Data = string.Empty;
if (string.IsNullOrEmpty(receivedData))
throw new Exception("No data!");
Detail detail;
_I = 0; _I = 0;
_Data = receivedData; _Data = receivedData;
ScanPast("RUN:"); ScanPast("RUN:");
Run = GetToEOL(); Run = GetToEOL();
ScanPast("Recipe:"); ScanPast("DEVICE:");
Recipe = GetBefore("RESISTIVITY SPEC:"); Recipe = GetBefore("RESISTIVITY SPEC:");
if (string.IsNullOrEmpty(Recipe)) }
ResistivitySpec = GetToEOL();
ScanPast("EQUIP#:");
EquipId = GetBefore("Engineer:");
Engineer = GetToEOL();
ScanPast("LotID:");
Lot = GetBefore("D.L.RATIO:");
// Remove illegal characters \/:*?"<>| found in the Lot.
Lot = Regex.Replace(Lot, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
DLRatio = GetToEOL();
ScanPast("OPERATOR:");
Employee = GetBefore("TEMP:");
Temp = GetToken();
string dateTimeText = GetToEOL();
DateTime dateTime = GetDateTime(logistics, dateTimeText);
Date = dateTime.ToString();
ScanPast("AutoOptimizeGain =");
AutoOptimizeGain = GetBefore("AutoProbeHeightSet =");
AutoProbeHeightSet = GetToEOL();
ScanPast("DataReject");
DataReject = GetToEOL();
_ = GetToEOL();
FileName = GetToEOL();
_ = GetToEOL();
_ = GetToEOL();
bool check = false;
while (!IsBlankLine())
{
detail = new Detail() { Pt = GetToken() };
if (detail.Pt.Contains("Avg"))
break;
else if (!detail.Pt.Contains(":"))
{ {
_I = 0; detail.R = GetToken();
_Data = receivedData; detail.T = GetToken();
ScanPast("RUN:"); detail.Rs = GetToken();
Run = GetToEOL(); detail.Merit = GetToken();
ScanPast("DEVICE:"); detail.UniqueId = string.Concat("_Point-", _Details.Count + 1);
Recipe = GetBefore("RESISTIVITY SPEC:"); _ = GetToEOL();
} _Details.Add(detail);
ResistivitySpec = GetToEOL();
ScanPast("EQUIP#:");
EquipId = GetBefore("Engineer:");
Engineer = GetToEOL();
ScanPast("LotID:");
Lot = GetBefore("D.L.RATIO:");
// Remove illegal characters \/:*?"<>| found in the Lot.
Lot = Regex.Replace(Lot, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
DLRatio = GetToEOL();
ScanPast("OPERATOR:");
Employee = GetBefore("TEMP:");
Temp = GetToken();
string dateTimeText = GetToEOL();
DateTime dateTime = GetDateTime(logistics, dateTimeText);
Date = dateTime.ToString();
ScanPast("AutoOptimizeGain =");
AutoOptimizeGain = GetBefore("AutoProbeHeightSet =");
AutoProbeHeightSet = GetToEOL();
ScanPast("DataReject");
DataReject = GetToEOL();
GetToEOL();
FileName = GetToEOL();
GetToEOL();
GetToEOL();
bool check = false;
while (!IsBlankLine())
{
detail = new Detail() { Pt = GetToken() };
if (detail.Pt.Contains("Avg"))
break;
else if (!detail.Pt.Contains(":"))
{
detail.R = GetToken();
detail.T = GetToken();
detail.Rs = GetToken();
detail.Merit = GetToken();
detail.UniqueId = string.Concat("_Point-", _Details.Count + 1);
GetToEOL();
_Details.Add(detail);
}
else
{
check = true;
break;
}
}
_I = 0;
_Data = receivedData;
if (!check)
{
ScanPast("Avg =");
Avg = GetToken();
StdDev = GetToken();
ScanPast("SEMI Radial=");
SemiRadial = GetToEOL();
} }
else else
{ {
ScanPast("RsAv "); check = true;
Avg = GetBefore("+/-"); break;
StdDev = GetToken(); }
_Log.Debug($"****ProcessData - RsAv StDev={StdDev}"); }
ScanPast("(Mx+Mn)"); _I = 0;
SemiRadial = GetToken(); _Data = receivedData;
_Log.Debug($"****ProcessData - RsAv SemiRadial={SemiRadial}"); if (!check)
GetToEOL(); {
int num = 0; ScanPast("Avg =");
GetBefore(": "); Avg = GetToken();
for (string i = GetToken(); !string.IsNullOrEmpty(i); i = GetToken()) StdDev = GetToken();
ScanPast("SEMI Radial=");
SemiRadial = GetToEOL();
}
else
{
ScanPast("RsAv ");
Avg = GetBefore("+/-");
StdDev = GetToken();
_Log.Debug($"****ProcessData - RsAv StDev={StdDev}");
ScanPast("(Mx+Mn)");
SemiRadial = GetToken();
_Log.Debug($"****ProcessData - RsAv SemiRadial={SemiRadial}");
_ = GetToEOL();
int num = 0;
_ = GetBefore(": ");
for (string i = GetToken(); !string.IsNullOrEmpty(i); i = GetToken())
{
if (!i.Contains(":"))
{ {
if (!i.Contains(":")) detail = new Detail();
{ int num1 = num + 1;
detail = new Detail(); num = num1;
int num1 = num + 1; _Log.Debug($"****ProcessData - RsAv Point={num1}");
num = num1; detail.Pt = num1.ToString();
_Log.Debug($"****ProcessData - RsAv Point={num1}"); detail.Rs = i;
detail.Pt = num1.ToString(); detail.Merit = GetToken().Replace("|", "");
detail.Rs = i; detail.UniqueId = string.Concat("_Point-", _Details.Count + 1);
detail.Merit = GetToken().Replace("|", ""); _Details.Add(detail);
detail.UniqueId = string.Concat("_Point-", _Details.Count + 1);
_Details.Add(detail);
}
} }
} }
//Id = -1; }
Run = Run.Trim(); //Id = -1;
if (!Run.StartsWith("[") && !Run.EndsWith("]")) Run = Run.Trim();
throw new Exception("Lot summary data is invalid or missing."); if (!Run.StartsWith("[") && !Run.EndsWith("]"))
Run = Run.Replace("[", ""); throw new Exception("Lot summary data is invalid or missing.");
Run = Run.Replace("]", ""); Run = Run.Replace("[", "");
Run = Regex.Replace(Run, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0]; Run = Run.Replace("]", "");
_Log.Debug($"****ParseData - cde.Run:'{Run}'"); Run = Regex.Replace(Run, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0];
if (string.IsNullOrEmpty(Run)) _Log.Debug($"****ParseData - cde.Run:'{Run}'");
throw new Exception("Batch (Run) information does not exist"); if (string.IsNullOrEmpty(Run))
throw new Exception("Batch (Run) information does not exist");
//parse out batch and validate //parse out batch and validate
string[] parsedBatch = Run.Split('-'); string[] parsedBatch = Run.Split('-');
if (parsedBatch.Length >= 1) if (parsedBatch.Length >= 1)
Reactor = parsedBatch[0]; Reactor = parsedBatch[0];
if (parsedBatch.Length >= 2) if (parsedBatch.Length >= 2)
RDS = parsedBatch[1]; RDS = parsedBatch[1];
if (parsedBatch.Length >= 3) if (parsedBatch.Length >= 3)
{
string[] parsedPSN = parsedBatch[2].Split('.');
if (parsedPSN.Length >= 1)
PSN = parsedPSN[0];
if (parsedPSN.Length >= 2)
Layer = parsedPSN[1];
}
if (parsedBatch.Length >= 4)
Zone = parsedBatch[3];
//create filename / unique id
string timeFormat = "yyyyMMddHHmmss";
//fix equip
StringBuilder equipFixed = new();
foreach (char c in EquipId)
{
if (char.IsLetterOrDigit(c) || c == '-' || c == '.')
{ {
string[] parsedPSN = parsedBatch[2].Split('.'); _ = equipFixed.Append(c);
if (parsedPSN.Length >= 1)
PSN = parsedPSN[0];
if (parsedPSN.Length >= 2)
Layer = parsedPSN[1];
} }
if (parsedBatch.Length >= 4) }
Zone = parsedBatch[3]; EquipId = equipFixed.ToString();
_Log.Debug($"****ParseData - cde.EquipId:'{EquipId}'");
//create filename / unique id // The "cde.Run" string is used as part of the SharePoint header unique ID. The "cde.Run" ID is typed
string timeFormat = "yyyyMMddHHmmss"; // at the tool by the users. The characters are not controlled and the user can type any characters like
// "\", "*", ".", " ", etc. Some of these characters are not valid and thus can't be used for the
// SharePoint header unique ID. Therefore, we need to filter out invalid characters and only keep the
// important ones.
//fix equip StringBuilder runFixed = new();
StringBuilder equipFixed = new(); foreach (char c in Run)
foreach (char c in EquipId) {
{ if (char.IsLetterOrDigit(c) || c == '-' || c == '.')
if (char.IsLetterOrDigit(c) || c == '-' || c == '.') _ = runFixed.Append(c);
{ }
equipFixed.Append(c); Run = runFixed.ToString();
}
}
EquipId = equipFixed.ToString();
_Log.Debug($"****ParseData - cde.EquipId:'{EquipId}'");
// The "cde.Run" string is used as part of the SharePoint header unique ID. The "cde.Run" ID is typed UniqueId = string.Concat(EquipId, "_", Run, "_", logistics.DateTimeFromSequence.ToString(timeFormat));
// at the tool by the users. The characters are not controlled and the user can type any characters like foreach (Detail item in _Details)
// "\", "*", ".", " ", etc. Some of these characters are not valid and thus can't be used for the {
// SharePoint header unique ID. Therefore, we need to filter out invalid characters and only keep the item.HeaderUniqueId = UniqueId;
// important ones. item.UniqueId = string.Concat(item, item.UniqueId);
StringBuilder runFixed = new();
foreach (char c in Run)
{
if (char.IsLetterOrDigit(c) || c == '-' || c == '.')
runFixed.Append(c);
}
Run = runFixed.ToString();
UniqueId = string.Concat(EquipId, "_", Run, "_", logistics.DateTimeFromSequence.ToString(timeFormat));
foreach (Detail item in _Details)
{
item.HeaderUniqueId = UniqueId;
item.UniqueId = string.Concat(item, item.UniqueId);
}
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
{
public ConnectionSetting(string name, string value) { }
[System.Runtime.Serialization.DataMemberAttribute] [System.Runtime.Serialization.DataContractAttribute]
public string Name { get; set; } public class ConnectionSetting
[System.Runtime.Serialization.DataMemberAttribute] {
public string Value { get; set; } public ConnectionSetting(string name, string value) { }
}
[System.Runtime.Serialization.DataMemberAttribute]
public string Name { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
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,34 +2,33 @@
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_SEPARATOR = ':';
public const char PLACEHOLDER_IDENTIFIER = '%'; public const string PLACEHOLDER_NOT_AVAILABLE = "NA";
public const char PLACEHOLDER_SEPARATOR = ':'; public const string PLACEHOLDER_ORIGINAL_FILE_NAME = "OriginalFileName";
public const string PLACEHOLDER_NOT_AVAILABLE = "NA"; public const string PLACEHOLDER_ORIGINAL_FILE_EXTENSION = "OriginalFileExtension";
public const string PLACEHOLDER_ORIGINAL_FILE_NAME = "OriginalFileName"; public const string PLACEHOLDER_DATE_TIME = "DateTime";
public const string PLACEHOLDER_ORIGINAL_FILE_EXTENSION = "OriginalFileExtension"; public const string PLACEHOLDER_SUB_FOLDER = "SubFolder";
public const string PLACEHOLDER_DATE_TIME = "DateTime"; public const string PLACEHOLDER_CELL_NAME = "CellName";
public const string PLACEHOLDER_SUB_FOLDER = "SubFolder";
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; }
protected File File { get; } protected File File { get; }
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,134 +2,133 @@
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 const ulong IDLE_EVENT_WAIT_TIME_DEFAULT = 360;
public class FileConnectorConfiguration public const ulong FILE_HANDLE_TIMEOUT_DEFAULT = 15;
[System.Runtime.Serialization.DataMemberAttribute]
public virtual bool? TriggerOnChanged { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual long? PostProcessingRetries { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual bool? CopySourceFolderStructure { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public IfPostProcessingFailsEnum? IfPostProcessingFailsAction { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string AlternateTargetFolder { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public long? FileHandleTimeout { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public bool? DeleteEmptySourceSubFolders { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public long? IdleEventWaitTimeInSeconds { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string FileAgeThreshold { get; set; }
public bool? FolderAgeCheckIndividualSubFolders { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual ZipModeEnum? ZipMode { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public FileAgeFilterEnum? FileAgeFilterMode { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string ZipTargetFileName { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string ZipErrorTargetFileName { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public long? ZipFileSubFolderLevel { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string DefaultPlaceHolderValue { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public bool? UseZip64Mode { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public List<ConnectionSetting> ConnectionSettings { get; set; }
public string SourceDirectoryCloaking { get; set; }
public string FolderAgeThreshold { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual long? FileScanningIntervalInSeconds { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual bool? TriggerOnCreated { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual long? ZipFileTime { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string SourceFileLocation { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string SourceFileFilter { get; set; }
public List<string> SourceFileFilters { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual bool? IncludeSubDirectories { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual FileScanningOptionEnum? FileScanningOption { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string TargetFileLocation { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string ErrorTargetFileLocation { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string TargetFileName { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual long? FileHandleWaitTime { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public IfFileExistEnum? IfFileExistAction { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public long? ConnectionRetryInterval { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public PreProcessingModeEnum? PreProcessingMode { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public PostProcessingModeEnum? PostProcessingMode { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public PostProcessingModeEnum? ErrorPostProcessingMode { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual long? ZipFileAmount { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string ErrorTargetFileName { get; set; }
public void Initialize() => throw new NotImplementedException();
public enum PostProcessingModeEnum
{ {
public const ulong IDLE_EVENT_WAIT_TIME_DEFAULT = 360; None = 0,
public const ulong FILE_HANDLE_TIMEOUT_DEFAULT = 15; Move = 1,
Copy = 2,
[System.Runtime.Serialization.DataMemberAttribute] Rename = 3,
public virtual bool? TriggerOnChanged { get; set; } Zip = 4,
[System.Runtime.Serialization.DataMemberAttribute] Delete = 5,
public virtual long? PostProcessingRetries { get; set; } MoveFolder = 6,
[System.Runtime.Serialization.DataMemberAttribute] CopyFolder = 7,
public virtual bool? CopySourceFolderStructure { get; set; } DeleteFolder = 8
[System.Runtime.Serialization.DataMemberAttribute] }
public IfPostProcessingFailsEnum? IfPostProcessingFailsAction { get; set; } public enum PreProcessingModeEnum
[System.Runtime.Serialization.DataMemberAttribute] {
public string AlternateTargetFolder { get; set; } None = 0,
[System.Runtime.Serialization.DataMemberAttribute] Process = 1
public long? FileHandleTimeout { get; set; } }
[System.Runtime.Serialization.DataMemberAttribute] public enum IfFileExistEnum
public bool? DeleteEmptySourceSubFolders { get; set; } {
[System.Runtime.Serialization.DataMemberAttribute] Overwrite = 0,
public long? IdleEventWaitTimeInSeconds { get; set; } LeaveFiles = 1,
[System.Runtime.Serialization.DataMemberAttribute] Delete = 2
public string FileAgeThreshold { get; set; } }
public bool? FolderAgeCheckIndividualSubFolders { get; set; } public enum IfPostProcessingFailsEnum
[System.Runtime.Serialization.DataMemberAttribute] {
public virtual ZipModeEnum? ZipMode { get; set; } LeaveFiles = 0,
[System.Runtime.Serialization.DataMemberAttribute] Delete = 1
public FileAgeFilterEnum? FileAgeFilterMode { get; set; } }
[System.Runtime.Serialization.DataMemberAttribute] public enum FileScanningOptionEnum
public string ZipTargetFileName { get; set; } {
[System.Runtime.Serialization.DataMemberAttribute] FileWatcher = 0,
public string ZipErrorTargetFileName { get; set; } TimeBased = 1
[System.Runtime.Serialization.DataMemberAttribute] }
public long? ZipFileSubFolderLevel { get; set; } public enum ZipModeEnum
[System.Runtime.Serialization.DataMemberAttribute] {
public string DefaultPlaceHolderValue { get; set; } ZipByAmountOrTime = 0,
[System.Runtime.Serialization.DataMemberAttribute] ZipByFileName = 1,
public bool? UseZip64Mode { get; set; } ZipBySubFolderName = 2
[System.Runtime.Serialization.DataMemberAttribute] }
public List<ConnectionSetting> ConnectionSettings { get; set; } public enum FileAgeFilterEnum
public string SourceDirectoryCloaking { get; set; } {
public string FolderAgeThreshold { get; set; } IgnoreNewer = 0,
[System.Runtime.Serialization.DataMemberAttribute] IgnoreOlder = 1
public virtual long? FileScanningIntervalInSeconds { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual bool? TriggerOnCreated { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual long? ZipFileTime { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string SourceFileLocation { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string SourceFileFilter { get; set; }
public List<string> SourceFileFilters { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual bool? IncludeSubDirectories { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual FileScanningOptionEnum? FileScanningOption { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string TargetFileLocation { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string ErrorTargetFileLocation { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string TargetFileName { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual long? FileHandleWaitTime { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public IfFileExistEnum? IfFileExistAction { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public long? ConnectionRetryInterval { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public PreProcessingModeEnum? PreProcessingMode { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public PostProcessingModeEnum? PostProcessingMode { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public PostProcessingModeEnum? ErrorPostProcessingMode { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual long? ZipFileAmount { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string ErrorTargetFileName { get; set; }
public void Initialize() { throw new NotImplementedException(); }
public enum PostProcessingModeEnum
{
None = 0,
Move = 1,
Copy = 2,
Rename = 3,
Zip = 4,
Delete = 5,
MoveFolder = 6,
CopyFolder = 7,
DeleteFolder = 8
}
public enum PreProcessingModeEnum
{
None = 0,
Process = 1
}
public enum IfFileExistEnum
{
Overwrite = 0,
LeaveFiles = 1,
Delete = 2
}
public enum IfPostProcessingFailsEnum
{
LeaveFiles = 0,
Delete = 1
}
public enum FileScanningOptionEnum
{
FileWatcher = 0,
TimeBased = 1
}
public enum ZipModeEnum
{
ZipByAmountOrTime = 0,
ZipByFileName = 1,
ZipBySubFolderName = 2
}
public enum FileAgeFilterEnum
{
IgnoreNewer = 0,
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 FileConnectorParameterTypeDefinitionProvider() { }
public IEnumerable<ParameterTypeDefinition> GetAllParameterTypeDefinition() { return null; } public class FileConnectorParameterTypeDefinitionProvider
public ParameterTypeDefinition GetParameterTypeDefinition(string name) { return null; } {
} public FileConnectorParameterTypeDefinitionProvider() { }
public IEnumerable<ParameterTypeDefinition> GetAllParameterTypeDefinition() => 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 NotNullAttribute() { }
public sealed class NotNullAttribute : Attribute
{
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,
{ Passive = 1
Active = 0,
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,
{ SingleSession = 1
MultiSession = 0,
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,
{ Serial = 1
HSMS = 0,
Serial = 1
}
} }

View File

@ -1,16 +1,15 @@
namespace Adaptation.PeerGroup.GCL.SecsDriver namespace Adaptation.PeerGroup.GCL.SecsDriver;
public enum SerialBaudRate
{ {
public enum SerialBaudRate Baud9600 = 0,
{ Baud19200 = 1,
Baud9600 = 0, Baud4800 = 2,
Baud19200 = 1, Baud2400 = 3,
Baud4800 = 2, Baud1200 = 4,
Baud2400 = 3, Baud300 = 5,
Baud1200 = 4, Baud150 = 6,
Baud300 = 5, Baud38400 = 7,
Baud150 = 6, Baud57600 = 8,
Baud38400 = 7, Baud115200 = 9
Baud57600 = 8,
Baud115200 = 9
}
} }

View File

@ -4,145 +4,139 @@ 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 Count { get; set; }
public int Index { get; set; }
//
public string EventName { get; set; }
public string NullData { get; set; }
public string JobID { get; set; }
public string Sequence { get; set; }
public string MesEntity { get; set; }
public string ReportFullPath { get; set; }
public string ProcessJobID { get; set; }
public string MID { get; set; }
public string Date { get; set; } //2021-10-23
string IDescription.GetEventDescription() => "File Has been read and parsed";
List<string> IDescription.GetNames(IFileRead fileRead, Logistics logistics)
{ {
List<string> results = new();
IDescription description = GetDefault(fileRead, logistics);
string json = JsonSerializer.Serialize(description, description.GetType());
object @object = JsonSerializer.Deserialize<object>(json);
if (@object is not JsonElement jsonElement)
throw new Exception();
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
results.Add(jsonProperty.Name);
return results;
}
public int Test { get; set; } List<string> IDescription.GetDetailNames()
public int Count { get; set; } {
public int Index { get; set; } List<string> results = new();
// return results;
public string EventName { get; set; } }
public string NullData { get; set; }
public string JobID { get; set; }
public string Sequence { get; set; }
public string MesEntity { get; set; }
public string ReportFullPath { get; set; }
public string ProcessJobID { get; set; }
public string MID { get; set; }
public string Date { get; set; } //2021-10-23
string IDescription.GetEventDescription() List<string> IDescription.GetHeaderNames()
{
List<string> results = new();
return results;
}
IDescription IDescription.GetDisplayNames()
{
Description result = GetDisplayNames();
return result;
}
List<string> IDescription.GetParameterNames()
{
List<string> results = new();
return results;
}
JsonProperty[] IDescription.GetDefault(IFileRead fileRead, Logistics logistics)
{
JsonProperty[] results;
IDescription description = GetDefault(fileRead, logistics);
string json = JsonSerializer.Serialize(description, description.GetType());
object @object = JsonSerializer.Deserialize<object>(json);
results = ((JsonElement)@object).EnumerateObject().ToArray();
return results;
}
List<string> IDescription.GetPairedParameterNames()
{
List<string> results = new();
return results;
}
List<string> IDescription.GetIgnoreParameterNames(Test test)
{
List<string> results = new();
return results;
}
IDescription IDescription.GetDefaultDescription(IFileRead fileRead, Logistics logistics)
{
Description result = GetDefault(fileRead, logistics);
return result;
}
Dictionary<string, string> IDescription.GetDisplayNamesJsonElement(IFileRead fileRead)
{
Dictionary<string, string> results = new();
IDescription description = GetDisplayNames();
string json = JsonSerializer.Serialize(description, description.GetType());
JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
{ {
return "File Has been read and parsed"; if (!results.ContainsKey(jsonProperty.Name))
results.Add(jsonProperty.Name, string.Empty);
if (jsonProperty.Value is JsonElement jsonPropertyValue)
results[jsonProperty.Name] = jsonPropertyValue.ToString();
} }
return results;
}
List<string> IDescription.GetNames(IFileRead fileRead, Logistics logistics) List<IDescription> IDescription.GetDescriptions(IFileRead fileRead, Logistics logistics, List<Test> tests, IProcessData iProcessData)
{
List<IDescription> results = new();
return results;
}
private Description GetDisplayNames()
{
Description result = new();
return result;
}
private Description GetDefault(IFileRead fileRead, Logistics logistics)
{
Description result = new()
{ {
List<string> results = new(); Test = -1,
IDescription description = GetDefault(fileRead, logistics); Count = 0,
string json = JsonSerializer.Serialize(description, description.GetType()); Index = -1,
object @object = JsonSerializer.Deserialize<object>(json); //
if (@object is not JsonElement jsonElement) EventName = fileRead.EventName,
throw new Exception(); NullData = fileRead.NullData,
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject()) JobID = fileRead.CellInstanceName,
results.Add(jsonProperty.Name); Sequence = logistics.Sequence.ToString(),
return results; MesEntity = fileRead.MesEntity,
} ReportFullPath = logistics.ReportFullPath,
ProcessJobID = logistics.ProcessJobID,
List<string> IDescription.GetDetailNames() MID = logistics.MID,
{ Date = logistics.DateTimeFromSequence.ToUniversalTime().ToString("MM/dd/yyyy HH:mm:ss")
List<string> results = new(); };
return results; return result;
}
List<string> IDescription.GetHeaderNames()
{
List<string> results = new();
return results;
}
IDescription IDescription.GetDisplayNames()
{
Description result = GetDisplayNames();
return result;
}
List<string> IDescription.GetParameterNames()
{
List<string> results = new();
return results;
}
JsonProperty[] IDescription.GetDefault(IFileRead fileRead, Logistics logistics)
{
JsonProperty[] results;
IDescription description = GetDefault(fileRead, logistics);
string json = JsonSerializer.Serialize(description, description.GetType());
object @object = JsonSerializer.Deserialize<object>(json);
results = ((JsonElement)@object).EnumerateObject().ToArray();
return results;
}
List<string> IDescription.GetPairedParameterNames()
{
List<string> results = new();
return results;
}
List<string> IDescription.GetIgnoreParameterNames(Test test)
{
List<string> results = new();
return results;
}
IDescription IDescription.GetDefaultDescription(IFileRead fileRead, Logistics logistics)
{
Description result = GetDefault(fileRead, logistics);
return result;
}
Dictionary<string, string> IDescription.GetDisplayNamesJsonElement(IFileRead fileRead)
{
Dictionary<string, string> results = new();
IDescription description = GetDisplayNames();
string json = JsonSerializer.Serialize(description, description.GetType());
JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
{
if (!results.ContainsKey(jsonProperty.Name))
results.Add(jsonProperty.Name, string.Empty);
if (jsonProperty.Value is JsonElement jsonPropertyValue)
results[jsonProperty.Name] = jsonPropertyValue.ToString();
}
return results;
}
List<IDescription> IDescription.GetDescriptions(IFileRead fileRead, Logistics logistics, List<Test> tests, IProcessData iProcessData)
{
List<IDescription> results = new();
return results;
}
private Description GetDisplayNames()
{
Description result = new();
return result;
}
private Description GetDefault(IFileRead fileRead, Logistics logistics)
{
Description result = new()
{
Test = -1,
Count = 0,
Index = -1,
//
EventName = fileRead.EventName,
NullData = fileRead.NullData,
JobID = fileRead.CellInstanceName,
Sequence = logistics.Sequence.ToString(),
MesEntity = fileRead.MesEntity,
ReportFullPath = logistics.ReportFullPath,
ProcessJobID = logistics.ProcessJobID,
MID = logistics.MID,
Date = logistics.DateTimeFromSequence.ToUniversalTime().ToString("MM/dd/yyyy HH:mm:ss")
};
return result;
}
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,223 +1,208 @@
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 string JobID { get; private set; } //CellName
public long Sequence { get; private set; } //Ticks
public DateTime DateTimeFromSequence { get; private set; }
public double TotalSecondsSinceLastWriteTimeFromSequence { get; private set; }
public string MesEntity { get; private set; } //SPC
public string ReportFullPath { get; private set; } //Extract file
public string ProcessJobID { get; set; } //Reactor (duplicate but I want it in the logistics)
public string MID { get; set; } //Lot & Pocket || Lot
public List<string> Tags { get; set; }
public List<string> Logistics1 { get; set; }
public List<Logistics2> Logistics2 { get; set; }
public Logistics(IFileRead fileRead)
{ {
DateTime dateTime = DateTime.Now;
NullData = null;
Sequence = dateTime.Ticks;
DateTimeFromSequence = dateTime;
JobID = fileRead.CellInstanceName;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
MesEntity = DefaultMesEntity(dateTime);
ReportFullPath = string.Empty;
ProcessJobID = nameof(ProcessJobID);
MID = nameof(MID);
Tags = new List<string>();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics2 = new List<Logistics2>();
}
public object NullData { get; private set; } public Logistics(IFileRead fileRead, string reportFullPath, bool useSplitForMID, int? fileInfoLength = null)
public string JobID { get; private set; } //CellName {
public long Sequence { get; private set; } //Ticks if (string.IsNullOrEmpty(fileRead.CellInstanceName))
public DateTime DateTimeFromSequence { get; private set; } throw new Exception();
public double TotalSecondsSinceLastWriteTimeFromSequence { get; private set; } if (string.IsNullOrEmpty(fileRead.MesEntity))
public string MesEntity { get; private set; } //SPC throw new Exception();
public string ReportFullPath { get; private set; } //Extract file NullData = fileRead.NullData;
public string ProcessJobID { get; set; } //Reactor (duplicate but I want it in the logistics) FileInfo fileInfo = new(reportFullPath);
public string MID { get; set; } //Lot & Pocket || Lot DateTime dateTime = fileInfo.LastWriteTime;
public List<string> Tags { get; set; } if (fileInfoLength.HasValue && fileInfo.Length < fileInfoLength.Value)
public List<string> Logistics1 { get; set; } dateTime = dateTime.AddTicks(-1);
public List<Logistics2> Logistics2 { get; set; } JobID = fileRead.CellInstanceName;
Sequence = dateTime.Ticks;
public Logistics(IFileRead fileRead) DateTimeFromSequence = dateTime;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
MesEntity = fileRead.MesEntity;
ReportFullPath = fileInfo.FullName;
ProcessJobID = nameof(ProcessJobID);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.FullName);
if (useSplitForMID)
{
if (fileNameWithoutExtension.IndexOf(".") > -1)
fileNameWithoutExtension = fileNameWithoutExtension.Split('.')[0].Trim();
if (fileNameWithoutExtension.IndexOf("_") > -1)
fileNameWithoutExtension = fileNameWithoutExtension.Split('_')[0].Trim();
if (fileNameWithoutExtension.IndexOf("-") > -1)
fileNameWithoutExtension = fileNameWithoutExtension.Split('-')[0].Trim();
}
MID = string.Concat(fileNameWithoutExtension.Substring(0, 1).ToUpper(), fileNameWithoutExtension.Substring(1).ToLower());
Tags = new List<string>();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics2 = new List<Logistics2>();
}
public Logistics(string reportFullPath, string logistics)
{
string key;
DateTime dateTime;
string[] segments;
Logistics1 = logistics.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();
if (!Logistics1.Any() || !Logistics1[0].StartsWith("LOGISTICS_1"))
{ {
DateTime dateTime = DateTime.Now;
NullData = null; NullData = null;
JobID = "null";
dateTime = new FileInfo(reportFullPath).LastWriteTime;
Sequence = dateTime.Ticks; Sequence = dateTime.Ticks;
DateTimeFromSequence = dateTime; DateTimeFromSequence = dateTime;
JobID = fileRead.CellInstanceName;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds; TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
MesEntity = DefaultMesEntity(dateTime); MesEntity = DefaultMesEntity(dateTime);
ReportFullPath = string.Empty; ReportFullPath = reportFullPath;
ProcessJobID = nameof(ProcessJobID); ProcessJobID = "R##";
MID = nameof(MID); MID = "null";
Tags = new List<string>(); Tags = new List<string>();
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>();
} }
else
public Logistics(IFileRead fileRead, string reportFullPath, bool useSplitForMID, int? fileInfoLength = null)
{ {
if (string.IsNullOrEmpty(fileRead.CellInstanceName)) string logistics1Line1 = Logistics1[0];
throw new Exception(); key = "NULL_DATA=";
if (string.IsNullOrEmpty(fileRead.MesEntity)) if (!logistics1Line1.Contains(key))
throw new Exception(); NullData = null;
NullData = fileRead.NullData; else
FileInfo fileInfo = new(reportFullPath); {
DateTime dateTime = fileInfo.LastWriteTime; segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
if (fileInfoLength.HasValue && fileInfo.Length < fileInfoLength.Value) NullData = segments[1].Split(';')[0];
dateTime = dateTime.AddTicks(-1); }
JobID = fileRead.CellInstanceName; key = "JOBID=";
if (!logistics1Line1.Contains(key))
JobID = "null";
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
JobID = segments[1].Split(';')[0];
}
key = "SEQUENCE=";
if (!logistics1Line1.Contains(key))
dateTime = new FileInfo(reportFullPath).LastWriteTime;
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
if (!long.TryParse(segments[1].Split(';')[0].Split('.')[0], out long sequence) || sequence < new DateTime(1999, 1, 1).Ticks)
dateTime = new FileInfo(reportFullPath).LastWriteTime;
else
dateTime = new DateTime(sequence);
}
Sequence = dateTime.Ticks; Sequence = dateTime.Ticks;
DateTimeFromSequence = dateTime; DateTimeFromSequence = dateTime;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds; TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
MesEntity = fileRead.MesEntity; DateTime lastWriteTime = new FileInfo(reportFullPath).LastWriteTime;
ReportFullPath = fileInfo.FullName; if (TotalSecondsSinceLastWriteTimeFromSequence > 600)
ProcessJobID = nameof(ProcessJobID);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.FullName);
if (useSplitForMID)
{ {
if (fileNameWithoutExtension.IndexOf(".") > -1) if (lastWriteTime != dateTime)
fileNameWithoutExtension = fileNameWithoutExtension.Split('.')[0].Trim(); try
if (fileNameWithoutExtension.IndexOf("_") > -1) { File.SetLastWriteTime(reportFullPath, dateTime); }
fileNameWithoutExtension = fileNameWithoutExtension.Split('_')[0].Trim(); catch (Exception) { }
if (fileNameWithoutExtension.IndexOf("-") > -1)
fileNameWithoutExtension = fileNameWithoutExtension.Split('-')[0].Trim();
} }
MID = string.Concat(fileNameWithoutExtension.Substring(0, 1).ToUpper(), fileNameWithoutExtension.Substring(1).ToLower()); key = "MES_ENTITY=";
Tags = new List<string>(); if (!logistics1Line1.Contains(key))
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics2 = new List<Logistics2>();
}
public Logistics(string reportFullPath, string logistics)
{
string key;
DateTime dateTime;
string[] segments;
Logistics1 = logistics.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();
if (!Logistics1.Any() || !Logistics1[0].StartsWith("LOGISTICS_1"))
{
NullData = null;
JobID = "null";
dateTime = new FileInfo(reportFullPath).LastWriteTime;
Sequence = dateTime.Ticks;
DateTimeFromSequence = dateTime;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
MesEntity = DefaultMesEntity(dateTime); MesEntity = DefaultMesEntity(dateTime);
ReportFullPath = reportFullPath;
ProcessJobID = "R##";
MID = "null";
Tags = new List<string>();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics2 = new List<Logistics2>();
}
else else
{ {
string logistics1Line1 = Logistics1[0]; segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
key = "NULL_DATA="; MesEntity = segments[1].Split(';')[0];
if (!logistics1Line1.Contains(key))
NullData = null;
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
NullData = segments[1].Split(';')[0];
}
key = "JOBID=";
if (!logistics1Line1.Contains(key))
JobID = "null";
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
JobID = segments[1].Split(';')[0];
}
key = "SEQUENCE=";
if (!logistics1Line1.Contains(key))
dateTime = new FileInfo(reportFullPath).LastWriteTime;
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
if (!long.TryParse(segments[1].Split(';')[0].Split('.')[0], out long sequence) || sequence < new DateTime(1999, 1, 1).Ticks)
dateTime = new FileInfo(reportFullPath).LastWriteTime;
else
dateTime = new DateTime(sequence);
}
Sequence = dateTime.Ticks;
DateTimeFromSequence = dateTime;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
DateTime lastWriteTime = new FileInfo(reportFullPath).LastWriteTime;
if (TotalSecondsSinceLastWriteTimeFromSequence > 600)
{
if (lastWriteTime != dateTime)
try
{ File.SetLastWriteTime(reportFullPath, dateTime); }
catch (Exception) { }
}
key = "MES_ENTITY=";
if (!logistics1Line1.Contains(key))
MesEntity = DefaultMesEntity(dateTime);
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
MesEntity = segments[1].Split(';')[0];
}
ReportFullPath = reportFullPath;
key = "PROCESS_JOBID=";
if (!logistics1Line1.Contains(key))
ProcessJobID = "R##";
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
ProcessJobID = segments[1].Split(';')[0];
}
key = "MID=";
if (!logistics1Line1.Contains(key))
MID = "null";
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
MID = segments[1].Split(';')[0];
}
} }
Logistics2 logistics2; ReportFullPath = reportFullPath;
Tags = new List<string>(); key = "PROCESS_JOBID=";
Logistics2 = new List<Logistics2>(); if (!logistics1Line1.Contains(key))
for (int i = 1; i < Logistics1.Count(); i++) ProcessJobID = "R##";
else
{ {
if (Logistics1[i].StartsWith("LOGISTICS_2")) segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
{ ProcessJobID = segments[1].Split(';')[0];
logistics2 = new Logistics2(Logistics1[i]);
Logistics2.Add(logistics2);
}
} }
for (int i = Logistics1.Count() - 1; i > -1; i--) key = "MID=";
if (!logistics1Line1.Contains(key))
MID = "null";
else
{ {
if (Logistics1[i].StartsWith("LOGISTICS_2")) segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
Logistics1.RemoveAt(i); MID = segments[1].Split(';')[0];
} }
} }
Logistics2 logistics2;
public Logistics ShallowCopy() Tags = new List<string>();
Logistics2 = new List<Logistics2>();
for (int i = 1; i < Logistics1.Count; i++)
{ {
return (Logistics)MemberwiseClone(); if (Logistics1[i].StartsWith("LOGISTICS_2"))
{
logistics2 = new Logistics2(Logistics1[i]);
Logistics2.Add(logistics2);
}
} }
for (int i = Logistics1.Count - 1; i > -1; i--)
private string DefaultMesEntity(DateTime dateTime)
{ {
return string.Concat(dateTime.Ticks, "_MES_ENTITY"); if (Logistics1[i].StartsWith("LOGISTICS_2"))
} Logistics1.RemoveAt(i);
internal string GetLotViaMostCommonMethod()
{
return MID.Substring(0, MID.Length - 2);
}
internal string GetPocketNumberViaMostCommonMethod()
{
return MID.Substring(MID.Length - 2);
}
internal void Update(string dateTime, string processJobID, string mid)
{
if (!DateTime.TryParse(dateTime, out DateTime dateTimeCasted))
dateTimeCasted = DateTime.Now;
NullData = null;
//JobID = Description.GetCellName();
Sequence = dateTimeCasted.Ticks;
DateTimeFromSequence = dateTimeCasted;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTimeCasted).TotalSeconds;
//MesEntity = DefaultMesEntity(dateTime);
//ReportFullPath = string.Empty;
ProcessJobID = processJobID;
MID = mid;
Tags = new List<string>();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics2 = new List<Logistics2>();
} }
} }
public Logistics ShallowCopy() => (Logistics)MemberwiseClone();
private static string DefaultMesEntity(DateTime dateTime) => string.Concat(dateTime.Ticks, "_MES_ENTITY");
internal string GetLotViaMostCommonMethod() => MID.Substring(0, MID.Length - 2);
internal string GetPocketNumberViaMostCommonMethod() => MID.Substring(MID.Length - 2);
internal void Update(string dateTime, string processJobID, string mid)
{
if (!DateTime.TryParse(dateTime, out DateTime dateTimeCasted))
dateTimeCasted = DateTime.Now;
NullData = null;
//JobID = Description.GetCellName();
Sequence = dateTimeCasted.Ticks;
DateTimeFromSequence = dateTimeCasted;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTimeCasted).TotalSeconds;
//MesEntity = DefaultMesEntity(dateTime);
//ReportFullPath = string.Empty;
ProcessJobID = processJobID;
MID = mid;
Tags = new List<string>();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics2 = new List<Logistics2>();
}
} }

View File

@ -1,81 +1,78 @@
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 RunNumber { get; private set; }
public string SatelliteGroup { get; private set; }
public string PartNumber { get; private set; }
public string PocketNumber { get; private set; }
public string WaferLot { get; private set; }
public string Recipe { get; private set; }
public Logistics2(string logistics2)
{ {
string key;
public string MID { get; private set; } string[] segments;
public string RunNumber { get; private set; } key = "JOBID=";
public string SatelliteGroup { get; private set; } if (!logistics2.Contains(key))
public string PartNumber { get; private set; } MID = "null";
public string PocketNumber { get; private set; } else
public string WaferLot { get; private set; }
public string Recipe { get; private set; }
public Logistics2(string logistics2)
{ {
string key; segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
string[] segments; MID = segments[1].Split(';')[0];
key = "JOBID="; }
if (!logistics2.Contains(key)) key = "MID=";
MID = "null"; if (!logistics2.Contains(key))
else RunNumber = "null";
{ else
segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); {
MID = segments[1].Split(';')[0]; segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
} RunNumber = segments[1].Split(';')[0];
key = "MID="; }
if (!logistics2.Contains(key)) key = "INFO=";
RunNumber = "null"; if (!logistics2.Contains(key))
else SatelliteGroup = "null";
{ else
segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); {
RunNumber = segments[1].Split(';')[0]; segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
} SatelliteGroup = segments[1].Split(';')[0];
key = "INFO="; }
if (!logistics2.Contains(key)) key = "PRODUCT=";
SatelliteGroup = "null"; if (!logistics2.Contains(key))
else PartNumber = "null";
{ else
segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); {
SatelliteGroup = segments[1].Split(';')[0]; segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
} PartNumber = segments[1].Split(';')[0];
key = "PRODUCT="; }
if (!logistics2.Contains(key)) key = "CHAMBER=";
PartNumber = "null"; if (!logistics2.Contains(key))
else PocketNumber = "null";
{ else
segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); {
PartNumber = segments[1].Split(';')[0]; segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
} PocketNumber = segments[1].Split(';')[0];
key = "CHAMBER="; }
if (!logistics2.Contains(key)) key = "WAFER_ID=";
PocketNumber = "null"; if (!logistics2.Contains(key))
else WaferLot = "null";
{ else
segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); {
PocketNumber = segments[1].Split(';')[0]; segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
} WaferLot = segments[1].Split(';')[0];
key = "WAFER_ID="; }
if (!logistics2.Contains(key)) key = "PPID=";
WaferLot = "null"; if (!logistics2.Contains(key))
else Recipe = "null";
{ else
segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries); {
WaferLot = segments[1].Split(';')[0]; segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
} Recipe = segments[1].Split(';')[0];
key = "PPID=";
if (!logistics2.Contains(key))
Recipe = "null";
else
{
segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
Recipe = segments[1].Split(';')[0];
}
} }
} }
} }

View File

@ -1,25 +1,22 @@
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();
{ List<string> GetDetailNames();
List<string> GetHeaderNames();
string GetEventDescription(); IDescription GetDisplayNames();
List<string> GetDetailNames(); List<string> GetParameterNames();
List<string> GetHeaderNames(); List<string> GetPairedParameterNames();
IDescription GetDisplayNames(); List<string> GetIgnoreParameterNames(Test test);
List<string> GetParameterNames(); List<string> GetNames(IFileRead fileRead, Logistics logistics);
List<string> GetPairedParameterNames(); JsonProperty[] GetDefault(IFileRead fileRead, Logistics logistics);
List<string> GetIgnoreParameterNames(Test test); Dictionary<string, string> GetDisplayNamesJsonElement(IFileRead fileRead);
List<string> GetNames(IFileRead fileRead, Logistics logistics); IDescription GetDefaultDescription(IFileRead fileRead, Logistics logistics);
JsonProperty[] GetDefault(IFileRead fileRead, Logistics logistics); List<IDescription> GetDescriptions(IFileRead fileRead, Logistics logistics, List<Test> tests, IProcessData iProcessData);
Dictionary<string, string> GetDisplayNamesJsonElement(IFileRead fileRead);
IDescription GetDefaultDescription(IFileRead fileRead, Logistics logistics);
List<IDescription> GetDescriptions(IFileRead fileRead, Logistics logistics, List<Test> tests, IProcessData iProcessData);
}
} }

View File

@ -3,24 +3,22 @@ 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 WaitForThread();
{ JsonProperty[] GetDefault();
void MoveArchive(); void Callback(object state);
void WaitForThread(); string GetEventDescription();
JsonProperty[] GetDefault(); List<string> GetHeaderNames();
void Callback(object state); void CheckTests(Test[] tests, bool extra);
string GetEventDescription(); Dictionary<string, string> GetDisplayNamesJsonElement();
List<string> GetHeaderNames(); Tuple<string, Test[], JsonElement[], List<FileInfo>> ReExtract();
void CheckTests(Test[] tests, bool extra); List<IDescription> GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData);
Dictionary<string, string> GetDisplayNamesJsonElement(); void Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception = null);
Tuple<string, Test[], JsonElement[], List<FileInfo>> ReExtract(); Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, string eventName);
List<IDescription> GetDescriptions(IFileRead fileRead, List<Test> tests, IProcessData processData); string[] Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, string to, string from, string resolvedFileLocation, Exception exception);
void Move(Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResults, Exception exception = null);
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);
}
} }

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);
{ Tuple<string, Test[], JsonElement[], List<FileInfo>> GetResults(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection);
string GetCurrentReactor(IFileRead fileRead, Logistics logistics, Dictionary<string, string> reactors);
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 SendHighPriorityEmailMessage(string subject, string body);
void SendLowPriorityEmailMessage(string subject, string body); void SendNormalPriorityEmailMessage(string subject, string body);
void SendHighPriorityEmailMessage(string subject, string body);
void SendNormalPriorityEmailMessage(string subject, string body);
}
} }

View File

@ -1,306 +1,300 @@
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 Enum Enum { get; private set; }
public string HTML { get; private set; }
public string Title { get; private set; }
public string FileName { get; private set; }
public int TestValue { get; private set; }
public string Header { get; private set; }
public string QueryFilter { get; private set; }
public string FileNameWithoutExtension { get; private set; }
public ScopeInfo(Test test, string fileName, string queryFilter = "", string title = "", string html = "")
{ {
Enum = test;
public Test Test { get; private set; } Test = test;
public Enum Enum { get; private set; } HTML = html;
public string HTML { get; private set; } Title = title;
public string Title { get; private set; } FileName = fileName;
public string FileName { get; private set; } TestValue = (int)test;
public int TestValue { get; private set; } Header = string.Empty;
public string Header { get; private set; } QueryFilter = queryFilter;
public string QueryFilter { get; private set; } FileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);
public string FileNameWithoutExtension { get; private set; }
public ScopeInfo(Test test, string fileName, string queryFilter = "", string title = "", string html = "")
{
Enum = test;
Test = test;
HTML = html;
Title = title;
FileName = fileName;
TestValue = (int)test;
Header = string.Empty;
QueryFilter = queryFilter;
FileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);
}
public ScopeInfo(Test test)
{
Enum = test;
Test = test;
TestValue = (int)test;
switch (Test)
{
case Test.AFMRoughness:
FileNameWithoutExtension = "afm_iqs_01";
Header = string.Empty;
QueryFilter = "AFM Roughness";
Title = "AFM";
HTML = @"GaN Epi Data\10 - afm.html";
break;
case Test.BreakdownVoltageCenter:
FileNameWithoutExtension = "bv_iqs_01";
Header = "Reactor;fDate;fRecipeName;Lot;fPocketNumber;g4Scribe;BV Position;BV Value;Tool";
QueryFilter = "Breakdown Voltage";
Title = "Breakdown Voltage-Center";
HTML = @"GaN Epi Data\03 - bv-production.html";
break;
case Test.BreakdownVoltageEdge:
FileNameWithoutExtension = "bv_iqs_01_Edge";
Header = "Reactor;fDate;fRecipeName;Lot;fPocketNumber;g4Scribe;BV Position;BV Value;Tool";
QueryFilter = "Breakdown Voltage - Edge";
Title = "Breakdown Voltage-Edge";
HTML = @"GaN Epi Data\03 - bv-production.html";
break;
case Test.BreakdownVoltageMiddle8in:
FileNameWithoutExtension = "bv_iqs_01_Middle";
Header = "Reactor;fDate;fRecipeName;Lot;fPocketNumber;g4Scribe;BV Position;BV Value;Tool";
QueryFilter = "Breakdown Voltage - Middle";
Title = "Breakdown Voltage-Middle (8 in)";
HTML = @"GaN Epi Data\03 - bv-production.html";
break;
case Test.CV:
FileNameWithoutExtension = "cv_iqs_01";
Header = "Reactor;fDate;fPart;Lot;pocketNumber;g4Scribe;Position;Vp;NdMin;Tool ID;CV Ns;CV Cap";
QueryFilter = "CV_Ns";
Title = "CV";
HTML = @"GaN Epi Data\05 - cv.html";
break;
case Test.MonthlyCV:
FileNameWithoutExtension = "cv_iqs_01";
Header = "Reactor;fDate;fPart;Lot;pocketNumber;g4Scribe;Position;Vp;NdMin;Tool ID;CV Ns;CV Cap";
QueryFilter = "CV_Ns";
Title = "CV Monthly Verification";
HTML = @"Metrology\07 - cv_verif_monthly.html";
break;
case Test.WeeklyCV:
FileNameWithoutExtension = "cv_iqs_01";
Header = "Reactor;fDate;fPart;Lot;pocketNumber;g4Scribe;Position;Vp;NdMin;Tool ID;CV Ns;CV Cap";
QueryFilter = "CV_Ns";
Title = "CV Weekly Verification";
HTML = @"Metrology\16 - cv_verif_weekly.html";
break;
case Test.CandelaKlarfDC:
FileNameWithoutExtension = "candela_iqs_01";
Header = "LotID;OperatorID;RecipeName;CandelaRecipe;WaferID;PocketNumber;RunDate;Epi;SlipLines;Cracks;EpiDef;HazeSpot;SmallLpd;MediumLpd;LargeLpd;Cracks_A;Spirals;Craters;8620 Small;Pits;Tool ID;Defect Count";
QueryFilter = "Candela Cracking";
Title = "Candela";
HTML = @"GaN Epi Data\12 - candela.html";
break;
case Test.CandelaLaser:
FileNameWithoutExtension = "candela_iqs_01";
Header = "LotID;OperatorID;RecipeName;CandelaRecipe;WaferID;PocketNumber;RunDate;Epi;SlipLines;Cracks;EpiDef;HazeSpot;SmallLpd;MediumLpd;LargeLpd;Cracks_A;Spirals;Craters;Pits;Tool ID;Defect Count";
QueryFilter = "Candela Cracking";
Title = "Candela";
HTML = @"GaN Epi Data\12 - candela.html";
break;
case Test.CandelaVerify:
FileNameWithoutExtension = "candela_iqs_01";
Header = string.Concat("LotID;OperatorID;RecipeName;CandelaRecipe;WaferID;PocketNumber;RunDate;RunID;Reactor;", "Slip Lines;Cracks;Epi Def;Haze Spot;Small LPD;Medium LPD;Large LPD;Cracks_A;Spirals;Craters;8620 Small;Pits;Tool ID;Defect Count");
QueryFilter = "Candela Cracking";
Title = "Candela";
HTML = @"GaN Epi Data\12 - candela.html";
break;
case Test.CandelaPSL:
FileNameWithoutExtension = "candela_iqs_01";
Header = string.Empty;
QueryFilter = "102-83nm";
Title = "Candela";
HTML = @"GaN Epi Data\12 - candela.html";
break;
case Test.CandelaProdU:
FileNameWithoutExtension = "candela_iqs_01";
Header = string.Empty;
QueryFilter = "SPE verification";
Title = "Candela";
HTML = @"GaN Epi Data\12 - candela.html";
break;
case Test.Denton:
FileNameWithoutExtension = "denton_iqs_01";
Header = "Tool;fDate;Run;Recipe;Operator;Name;Value";
QueryFilter = "Denton_Voltage_AVG";
Title = "Denton Data";
HTML = @"Support Process\03 - ebeam02_denton_v1.html";
break;
case Test.Hall:
FileNameWithoutExtension = "hall_iqs_01";
Header = "Lot;Tool;TimeDate;RunDate;RunID;Part;Reactor;Scribe;PocketNumber;Tool ID;Name;Value";
QueryFilter = "Hall Rs";
Title = "Hall Data";
HTML = @"GaN Epi Data\04 - hall.html";
break;
case Test.MonthlyHall:
FileNameWithoutExtension = "hall_iqs_01";
Header = "Lot;Tool;TimeDate;RunDate;RunID;Part;Reactor;Scribe;PocketNumber;Tool ID;Name;Value";
QueryFilter = "Hall Rs";
Title = "Hall Monthly Verification";
HTML = @"Metrology\06 - hall_verif_monthly.html";
break;
case Test.WeeklyHall:
FileNameWithoutExtension = "hall_iqs_01";
Header = "Lot;Tool;TimeDate;RunDate;RunID;Part;Reactor;Scribe;PocketNumber;Tool ID;Name;Value";
QueryFilter = "Hall Rs";
Title = "Hall Weekly Verification";
HTML = @"Metrology\15 - hall_verif_weekly.html";
break;
case Test.Lehighton:
FileNameWithoutExtension = "lei_iqs_01";
Header = "Reactor;Date;Recipe;Lot;Pocket;Scribe;Tool;Name;Value";
QueryFilter = "LEI RS Average value";
Title = "Lehighton";
HTML = @"GaN Epi Data\13 - lehighton.html";
break;
case Test.VerificationLehighton:
FileNameWithoutExtension = "___";
Header = "Reactor;Date;Recipe;Lot;Pocket;Scribe;Tool;Name;Value";
QueryFilter = "___";
Title = "LEI Weekly Verification 2 Ohm cm";
HTML = @"Metrology\14 - lei_verif_weekly.html.html";
break;
case Test.Microscope:
FileNameWithoutExtension = string.Empty;
Header = string.Empty;
QueryFilter = "Microscope Center 5x";
Title = "Total Microscope Defects";
HTML = string.Empty;
break;
case Test.RPMXY:
FileNameWithoutExtension = "RPM_Data";
Header = "Lot;Date;Recipe;Reactor;Scribe;Pocket;Tool;Name;Value";
QueryFilter = "Barrier_Composition_RPM_XY";
Title = "RPM XY Data ***&*** View Data";
HTML = @"GaN Epi Data\09 - rpm --- 08 - photoluminescence.html";
break;
case Test.RPMAverage:
FileNameWithoutExtension = "RPMdata-short";
Header = "fProductId;fDate;average;stdDev;fRecipeName;Reactor;g4Scribe;Pocket Number;Tool ID;Recipe From Rpm File";
QueryFilter = "Epi Thickness Mean";
Title = "RPM Average Data";
HTML = @"GaN Epi Data\09 - rpm.html";
break;
case Test.RPMPLRatio:
FileNameWithoutExtension = "PHOTOLUMINESCENCE_data-short";
Header = "fProductId;fDate;g4Scribe;fRecipeName;bandEdge_nm;bandEdge_V;yellowBand_Pmw;yellowBand_nm;yellowBand_V;Reactor;Pocket Number;Tool ID";
QueryFilter = "PL Ratio";
Title = "Photoluminescence: PL Ratio";
HTML = @"GaN Epi Data\08 - photoluminescence.html";
break;
case Test.DailyRPMXY:
FileNameWithoutExtension = "RPM_Data";
Header = "Lot;Date;Recipe;Reactor;Scribe;Pocket;Tool;Name;Value";
QueryFilter = "Barrier_Composition_RPM_XY";
Title = "";
HTML = @"Metrology\?";
break;
case Test.DailyRPMAverage:
FileNameWithoutExtension = "RPMdata-short";
Header = "fProductId;fDate;average;stdDev;fRecipeName;Reactor;g4Scribe;Pocket Number;Tool ID;Recipe From Rpm File";
QueryFilter = "Epi Thickness Mean";
Title = "";
HTML = @"Metrology\?";
break;
case Test.DailyRPMPLRatio:
FileNameWithoutExtension = "PHOTOLUMINESCENCE_data-short";
Header = "fProductId;fDate;g4Scribe;fRecipeName;bandEdge_nm;bandEdge_V;yellowBand_Pmw;yellowBand_nm;yellowBand_V;Reactor;Pocket Number;Tool ID";
QueryFilter = "PL Ratio";
Title = "RPM Daily Verification";
HTML = @"Metrology\17 - rpm_verif_daily.html";
break;
case Test.VerificationRPM:
FileNameWithoutExtension = "PhotoLuminescence_Ver";
Header = "Part;Process;Date;Test;Value";
QueryFilter = "PL Edge Wavelength";
Title = "PL Daily Verification - [PL Edge Wavelength]";
HTML = @"Metrology\18 - photoluminescence_verif_daily.html";
break;
case Test.Photoreflectance:
FileNameWithoutExtension = "photoreflect_iqs_01";
Header = "Lot;Date;Part;Reactor;Scribe;Pocket;Tool;Point;WaferPosition_PR;PR_Peak";
QueryFilter = "PR Barrier Composition";
Title = "Photoreflectance 6 in, Photoreflectance 8 in";
HTML = @"GaN Epi Data\07 - photoreflectance.html";
break;
case Test.UV:
FileNameWithoutExtension = "uv_iqs_01";
Header = string.Empty;
QueryFilter = "UV Broken";
Title = "UV";
HTML = @"GaN Epi Data\15 - uv 2.1.html";
break;
case Test.VpdIcpmsAnalyte:
FileNameWithoutExtension = "VPD_iqs_01";
Header = "Reactor;RunID;RunDate;PartNumber;PocketNumber;WaferScribe;Analyte;Value";
QueryFilter = "Mg";
Title = "VpdIcpmsAnalyteData";
HTML = @"";
break;
case Test.WarpAndBow:
FileNameWithoutExtension = "warp_iqs_01";
Header = "fDate;fRecipeName;fProductId;g4Scribe;warp;bow;tool;Reactor;Pocket ID;bow_range;BowX;BowY;CenterBow";
QueryFilter = "BowCenter";
Title = "Warp and Bow";
HTML = @"GaN Epi Data\14 - warp.html";
break;
case Test.VerificationWarpAndBow:
FileNameWithoutExtension = "warp_ver_iqs_01";
Header = "Part;Process;Date;WaferScribe;totWarp;bow";
QueryFilter = "Bow Calibration";
Title = "6 Inch Warp/Bow Daily Verification, 8 Inch Warp/Bow Daily Verification";
HTML = @"Metrology\19 - warp_cal_daily.html";
break;
case Test.XRDXY:
FileNameWithoutExtension = "xrd_iqs_NEW_01";
Header = "Reactor;fDate;fRecipeName;Lot;pocketNumber;g4Scribe;ToolID;Name;Value;Group";
QueryFilter = "SL Period";
Title = "XRD XY Raw Data Viewer";
HTML = @"GaN Epi Data\11 - xrd.html";
break;
case Test.XRDWeightedAverage:
FileNameWithoutExtension = "xrd_iqs_NEW_01_WtAVG";
Header = "Reactor;fDate;fRecipeName;Lot;pocketNumber;g4Scribe;Name;Value;Group";
//QueryFilter = "Al% Barrier WTAVG";
QueryFilter = "SL Period WTAVG";
Title = "XRD Weighted Average Data";
HTML = @"GaN Epi Data\11 - xrd.html";
break;
case Test.MonthlyXRD:
FileNameWithoutExtension = "xrd_monthly_ver_iqs_01";
Header = "Part;Process;Date;TestName;Value";
QueryFilter = "XRD 2-Theta Position";
Title = "XRD Monthly Verification";
HTML = @"Metrology\03 - xrd_verif_monthly.html";
break;
case Test.WeeklyXRD:
FileNameWithoutExtension = "xrd_weekly_ver_iqs_01";
Header = "Part;Process;Lot;Date;TestName;Value";
QueryFilter = "XRD Weekly AL% Center";
Title = "XRD Weekly Verification";
HTML = @"Metrology\12 - xrd_verif_weekly.html";
break;
case Test.JVXRD:
FileNameWithoutExtension = "xrd_iqs_NEW_01";
Header = "Reactor;fDate;fRecipeName;Lot;pocketNumber;g4Scribe;ToolID;Name;Value;Group";
QueryFilter = "SL Period";
Title = "XRD XY Raw Data Viewer";
HTML = @"GaN Epi Data\11 - xrd.html";
break;
default:
throw new Exception();
}
FileName = string.Concat(FileNameWithoutExtension, ".txt");
}
public ScopeInfo ShallowCopy()
{
return (ScopeInfo)MemberwiseClone();
}
} }
public ScopeInfo(Test test)
{
Enum = test;
Test = test;
TestValue = (int)test;
switch (Test)
{
case Test.AFMRoughness:
FileNameWithoutExtension = "afm_iqs_01";
Header = string.Empty;
QueryFilter = "AFM Roughness";
Title = "AFM";
HTML = @"GaN Epi Data\10 - afm.html";
break;
case Test.BreakdownVoltageCenter:
FileNameWithoutExtension = "bv_iqs_01";
Header = "Reactor;fDate;fRecipeName;Lot;fPocketNumber;g4Scribe;BV Position;BV Value;Tool";
QueryFilter = "Breakdown Voltage";
Title = "Breakdown Voltage-Center";
HTML = @"GaN Epi Data\03 - bv-production.html";
break;
case Test.BreakdownVoltageEdge:
FileNameWithoutExtension = "bv_iqs_01_Edge";
Header = "Reactor;fDate;fRecipeName;Lot;fPocketNumber;g4Scribe;BV Position;BV Value;Tool";
QueryFilter = "Breakdown Voltage - Edge";
Title = "Breakdown Voltage-Edge";
HTML = @"GaN Epi Data\03 - bv-production.html";
break;
case Test.BreakdownVoltageMiddle8in:
FileNameWithoutExtension = "bv_iqs_01_Middle";
Header = "Reactor;fDate;fRecipeName;Lot;fPocketNumber;g4Scribe;BV Position;BV Value;Tool";
QueryFilter = "Breakdown Voltage - Middle";
Title = "Breakdown Voltage-Middle (8 in)";
HTML = @"GaN Epi Data\03 - bv-production.html";
break;
case Test.CV:
FileNameWithoutExtension = "cv_iqs_01";
Header = "Reactor;fDate;fPart;Lot;pocketNumber;g4Scribe;Position;Vp;NdMin;Tool ID;CV Ns;CV Cap";
QueryFilter = "CV_Ns";
Title = "CV";
HTML = @"GaN Epi Data\05 - cv.html";
break;
case Test.MonthlyCV:
FileNameWithoutExtension = "cv_iqs_01";
Header = "Reactor;fDate;fPart;Lot;pocketNumber;g4Scribe;Position;Vp;NdMin;Tool ID;CV Ns;CV Cap";
QueryFilter = "CV_Ns";
Title = "CV Monthly Verification";
HTML = @"Metrology\07 - cv_verif_monthly.html";
break;
case Test.WeeklyCV:
FileNameWithoutExtension = "cv_iqs_01";
Header = "Reactor;fDate;fPart;Lot;pocketNumber;g4Scribe;Position;Vp;NdMin;Tool ID;CV Ns;CV Cap";
QueryFilter = "CV_Ns";
Title = "CV Weekly Verification";
HTML = @"Metrology\16 - cv_verif_weekly.html";
break;
case Test.CandelaKlarfDC:
FileNameWithoutExtension = "candela_iqs_01";
Header = "LotID;OperatorID;RecipeName;CandelaRecipe;WaferID;PocketNumber;RunDate;Epi;SlipLines;Cracks;EpiDef;HazeSpot;SmallLpd;MediumLpd;LargeLpd;Cracks_A;Spirals;Craters;8620 Small;Pits;Tool ID;Defect Count";
QueryFilter = "Candela Cracking";
Title = "Candela";
HTML = @"GaN Epi Data\12 - candela.html";
break;
case Test.CandelaLaser:
FileNameWithoutExtension = "candela_iqs_01";
Header = "LotID;OperatorID;RecipeName;CandelaRecipe;WaferID;PocketNumber;RunDate;Epi;SlipLines;Cracks;EpiDef;HazeSpot;SmallLpd;MediumLpd;LargeLpd;Cracks_A;Spirals;Craters;Pits;Tool ID;Defect Count";
QueryFilter = "Candela Cracking";
Title = "Candela";
HTML = @"GaN Epi Data\12 - candela.html";
break;
case Test.CandelaVerify:
FileNameWithoutExtension = "candela_iqs_01";
Header = string.Concat("LotID;OperatorID;RecipeName;CandelaRecipe;WaferID;PocketNumber;RunDate;RunID;Reactor;", "Slip Lines;Cracks;Epi Def;Haze Spot;Small LPD;Medium LPD;Large LPD;Cracks_A;Spirals;Craters;8620 Small;Pits;Tool ID;Defect Count");
QueryFilter = "Candela Cracking";
Title = "Candela";
HTML = @"GaN Epi Data\12 - candela.html";
break;
case Test.CandelaPSL:
FileNameWithoutExtension = "candela_iqs_01";
Header = string.Empty;
QueryFilter = "102-83nm";
Title = "Candela";
HTML = @"GaN Epi Data\12 - candela.html";
break;
case Test.CandelaProdU:
FileNameWithoutExtension = "candela_iqs_01";
Header = string.Empty;
QueryFilter = "SPE verification";
Title = "Candela";
HTML = @"GaN Epi Data\12 - candela.html";
break;
case Test.Denton:
FileNameWithoutExtension = "denton_iqs_01";
Header = "Tool;fDate;Run;Recipe;Operator;Name;Value";
QueryFilter = "Denton_Voltage_AVG";
Title = "Denton Data";
HTML = @"Support Process\03 - ebeam02_denton_v1.html";
break;
case Test.Hall:
FileNameWithoutExtension = "hall_iqs_01";
Header = "Lot;Tool;TimeDate;RunDate;RunID;Part;Reactor;Scribe;PocketNumber;Tool ID;Name;Value";
QueryFilter = "Hall Rs";
Title = "Hall Data";
HTML = @"GaN Epi Data\04 - hall.html";
break;
case Test.MonthlyHall:
FileNameWithoutExtension = "hall_iqs_01";
Header = "Lot;Tool;TimeDate;RunDate;RunID;Part;Reactor;Scribe;PocketNumber;Tool ID;Name;Value";
QueryFilter = "Hall Rs";
Title = "Hall Monthly Verification";
HTML = @"Metrology\06 - hall_verif_monthly.html";
break;
case Test.WeeklyHall:
FileNameWithoutExtension = "hall_iqs_01";
Header = "Lot;Tool;TimeDate;RunDate;RunID;Part;Reactor;Scribe;PocketNumber;Tool ID;Name;Value";
QueryFilter = "Hall Rs";
Title = "Hall Weekly Verification";
HTML = @"Metrology\15 - hall_verif_weekly.html";
break;
case Test.Lehighton:
FileNameWithoutExtension = "lei_iqs_01";
Header = "Reactor;Date;Recipe;Lot;Pocket;Scribe;Tool;Name;Value";
QueryFilter = "LEI RS Average value";
Title = "Lehighton";
HTML = @"GaN Epi Data\13 - lehighton.html";
break;
case Test.VerificationLehighton:
FileNameWithoutExtension = "___";
Header = "Reactor;Date;Recipe;Lot;Pocket;Scribe;Tool;Name;Value";
QueryFilter = "___";
Title = "LEI Weekly Verification 2 Ohm cm";
HTML = @"Metrology\14 - lei_verif_weekly.html.html";
break;
case Test.Microscope:
FileNameWithoutExtension = string.Empty;
Header = string.Empty;
QueryFilter = "Microscope Center 5x";
Title = "Total Microscope Defects";
HTML = string.Empty;
break;
case Test.RPMXY:
FileNameWithoutExtension = "RPM_Data";
Header = "Lot;Date;Recipe;Reactor;Scribe;Pocket;Tool;Name;Value";
QueryFilter = "Barrier_Composition_RPM_XY";
Title = "RPM XY Data ***&*** View Data";
HTML = @"GaN Epi Data\09 - rpm --- 08 - photoluminescence.html";
break;
case Test.RPMAverage:
FileNameWithoutExtension = "RPMdata-short";
Header = "fProductId;fDate;average;stdDev;fRecipeName;Reactor;g4Scribe;Pocket Number;Tool ID;Recipe From Rpm File";
QueryFilter = "Epi Thickness Mean";
Title = "RPM Average Data";
HTML = @"GaN Epi Data\09 - rpm.html";
break;
case Test.RPMPLRatio:
FileNameWithoutExtension = "PHOTOLUMINESCENCE_data-short";
Header = "fProductId;fDate;g4Scribe;fRecipeName;bandEdge_nm;bandEdge_V;yellowBand_Pmw;yellowBand_nm;yellowBand_V;Reactor;Pocket Number;Tool ID";
QueryFilter = "PL Ratio";
Title = "Photoluminescence: PL Ratio";
HTML = @"GaN Epi Data\08 - photoluminescence.html";
break;
case Test.DailyRPMXY:
FileNameWithoutExtension = "RPM_Data";
Header = "Lot;Date;Recipe;Reactor;Scribe;Pocket;Tool;Name;Value";
QueryFilter = "Barrier_Composition_RPM_XY";
Title = "";
HTML = @"Metrology\?";
break;
case Test.DailyRPMAverage:
FileNameWithoutExtension = "RPMdata-short";
Header = "fProductId;fDate;average;stdDev;fRecipeName;Reactor;g4Scribe;Pocket Number;Tool ID;Recipe From Rpm File";
QueryFilter = "Epi Thickness Mean";
Title = "";
HTML = @"Metrology\?";
break;
case Test.DailyRPMPLRatio:
FileNameWithoutExtension = "PHOTOLUMINESCENCE_data-short";
Header = "fProductId;fDate;g4Scribe;fRecipeName;bandEdge_nm;bandEdge_V;yellowBand_Pmw;yellowBand_nm;yellowBand_V;Reactor;Pocket Number;Tool ID";
QueryFilter = "PL Ratio";
Title = "RPM Daily Verification";
HTML = @"Metrology\17 - rpm_verif_daily.html";
break;
case Test.VerificationRPM:
FileNameWithoutExtension = "PhotoLuminescence_Ver";
Header = "Part;Process;Date;Test;Value";
QueryFilter = "PL Edge Wavelength";
Title = "PL Daily Verification - [PL Edge Wavelength]";
HTML = @"Metrology\18 - photoluminescence_verif_daily.html";
break;
case Test.Photoreflectance:
FileNameWithoutExtension = "photoreflect_iqs_01";
Header = "Lot;Date;Part;Reactor;Scribe;Pocket;Tool;Point;WaferPosition_PR;PR_Peak";
QueryFilter = "PR Barrier Composition";
Title = "Photoreflectance 6 in, Photoreflectance 8 in";
HTML = @"GaN Epi Data\07 - photoreflectance.html";
break;
case Test.UV:
FileNameWithoutExtension = "uv_iqs_01";
Header = string.Empty;
QueryFilter = "UV Broken";
Title = "UV";
HTML = @"GaN Epi Data\15 - uv 2.1.html";
break;
case Test.VpdIcpmsAnalyte:
FileNameWithoutExtension = "VPD_iqs_01";
Header = "Reactor;RunID;RunDate;PartNumber;PocketNumber;WaferScribe;Analyte;Value";
QueryFilter = "Mg";
Title = "VpdIcpmsAnalyteData";
HTML = @"";
break;
case Test.WarpAndBow:
FileNameWithoutExtension = "warp_iqs_01";
Header = "fDate;fRecipeName;fProductId;g4Scribe;warp;bow;tool;Reactor;Pocket ID;bow_range;BowX;BowY;CenterBow";
QueryFilter = "BowCenter";
Title = "Warp and Bow";
HTML = @"GaN Epi Data\14 - warp.html";
break;
case Test.VerificationWarpAndBow:
FileNameWithoutExtension = "warp_ver_iqs_01";
Header = "Part;Process;Date;WaferScribe;totWarp;bow";
QueryFilter = "Bow Calibration";
Title = "6 Inch Warp/Bow Daily Verification, 8 Inch Warp/Bow Daily Verification";
HTML = @"Metrology\19 - warp_cal_daily.html";
break;
case Test.XRDXY:
FileNameWithoutExtension = "xrd_iqs_NEW_01";
Header = "Reactor;fDate;fRecipeName;Lot;pocketNumber;g4Scribe;ToolID;Name;Value;Group";
QueryFilter = "SL Period";
Title = "XRD XY Raw Data Viewer";
HTML = @"GaN Epi Data\11 - xrd.html";
break;
case Test.XRDWeightedAverage:
FileNameWithoutExtension = "xrd_iqs_NEW_01_WtAVG";
Header = "Reactor;fDate;fRecipeName;Lot;pocketNumber;g4Scribe;Name;Value;Group";
//QueryFilter = "Al% Barrier WTAVG";
QueryFilter = "SL Period WTAVG";
Title = "XRD Weighted Average Data";
HTML = @"GaN Epi Data\11 - xrd.html";
break;
case Test.MonthlyXRD:
FileNameWithoutExtension = "xrd_monthly_ver_iqs_01";
Header = "Part;Process;Date;TestName;Value";
QueryFilter = "XRD 2-Theta Position";
Title = "XRD Monthly Verification";
HTML = @"Metrology\03 - xrd_verif_monthly.html";
break;
case Test.WeeklyXRD:
FileNameWithoutExtension = "xrd_weekly_ver_iqs_01";
Header = "Part;Process;Lot;Date;TestName;Value";
QueryFilter = "XRD Weekly AL% Center";
Title = "XRD Weekly Verification";
HTML = @"Metrology\12 - xrd_verif_weekly.html";
break;
case Test.JVXRD:
FileNameWithoutExtension = "xrd_iqs_NEW_01";
Header = "Reactor;fDate;fRecipeName;Lot;pocketNumber;g4Scribe;ToolID;Name;Value;Group";
QueryFilter = "SL Period";
Title = "XRD XY Raw Data Viewer";
HTML = @"GaN Epi Data\11 - xrd.html";
break;
default:
throw new Exception();
}
FileName = string.Concat(FileNameWithoutExtension, ".txt");
}
public ScopeInfo ShallowCopy() => (ScopeInfo)MemberwiseClone();
} }

View File

@ -1,22 +1,19 @@
namespace Adaptation.Shared.Metrology namespace Adaptation.Shared.Metrology;
public partial class WS
{ {
public class Attachment
public partial class WS
{ {
public class Attachment
public string UniqueId { get; set; }
public string DestinationFileName { get; set; }
public string SourceFileName { get; set; }
public Attachment(string uniqueId, string destinationFileName, string sourceFileName)
{ {
UniqueId = uniqueId;
public string UniqueId { get; set; } DestinationFileName = destinationFileName;
public string DestinationFileName { get; set; } SourceFileName = sourceFileName;
public string SourceFileName { get; set; }
public Attachment(string uniqueId, string destinationFileName, string sourceFileName)
{
UniqueId = uniqueId;
DestinationFileName = destinationFileName;
SourceFileName = sourceFileName;
}
} }
} }

View File

@ -1,33 +1,27 @@
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
{ {
// this class represents the response from the Inbound API endpoint
public partial class WS public class Results
{ {
// this class represents the response from the Inbound API endpoint // true or false if data was written to the database
public class Results public bool Success { get; set; }
{
// true or false if data was written to the database
public bool Success { get; set; }
// if true, contains ID of the Header record in the database // if true, contains ID of the Header record in the database
public long HeaderID { get; set; } public long HeaderID { get; set; }
// if false, this collection will contain a list of errors // if false, this collection will contain a list of errors
public List<string> Errors { get; set; } public List<string> Errors { get; set; }
// this collection will contain a list of warnings, they will not prevent data from being saved // this collection will contain a list of warnings, they will not prevent data from being saved
public List<string> Warnings { get; set; } public List<string> Warnings { get; set; }
// this is just a helper function to make displaying the results easier
public override string ToString()
{
return JsonSerializer.Serialize(this, GetType());
}
}
// this is just a helper function to make displaying the results easier
public override string ToString() => JsonSerializer.Serialize(this, GetType());
} }
} }

View File

@ -4,124 +4,119 @@ 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)
{ {
Results results = new();
public static Tuple<string, Results> SendData(string url, object payload, int timeoutSeconds = 120) string resultsJson = string.Empty;
try
{ {
Results results = new Results(); string json = JsonSerializer.Serialize(payload, payload.GetType());
string resultsJson = string.Empty; if (string.IsNullOrEmpty(url) || !url.Contains(":") || !url.Contains("."))
try throw new Exception("Invalid URL");
using (HttpClient httpClient = new())
{ {
string json = JsonSerializer.Serialize(payload, payload.GetType());
if (string.IsNullOrEmpty(url) || !url.Contains(":") || !url.Contains("."))
throw new Exception("Invalid URL");
using (HttpClient httpClient = new HttpClient())
{
httpClient.Timeout = new TimeSpan(0, 0, 0, timeoutSeconds, 0);
HttpRequestMessage httpRequestMessage = new HttpRequestMessage
{
RequestUri = new Uri(url),
Method = HttpMethod.Post,
Content = new StringContent(json, Encoding.UTF8, "application/json")
};
HttpResponseMessage httpResponseMessage = httpClient.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseContentRead).Result;
resultsJson = httpResponseMessage.Content.ReadAsStringAsync().Result;
results = JsonSerializer.Deserialize<Results>(resultsJson);
}
if (!results.Success)
results.Errors.Add(results.ToString());
}
catch (Exception e)
{
Exception exception = e;
StringBuilder stringBuilder = new StringBuilder();
while (!(exception is null))
{
stringBuilder.AppendLine(exception.Message);
exception = exception.InnerException;
}
if (results.Errors is null)
results.Errors = new List<string>();
results.Errors.Add(stringBuilder.ToString());
}
return new Tuple<string, Results>(resultsJson, results);
}
// this method is a wrapper for attaching a file to either a header or data record
// URL is the same URL used for SendData, ex: http://localhost/api/inbound/CDE
// attachToHeaderId is the ID returned by SendData
// attachToDataUniqueId is the string unique ID for the data record, aka the Title of the Sharepoint list entry
// fileContents is a byte array with the contents of the file
// fileName is which attachment this is, image.pdf, data.pdf, data.txt, header.pdf, etc
// timeoutSeconds is configured as the request timeout
// this method will either succeed or throw an exception
// also, this has been made synchronous
public static void AttachFile(string url, long attachToHeaderId, string attachToDataUniqueId, byte[] fileContents, string fileName, int timeoutSeconds = 60)
{
using (HttpClient httpClient = new HttpClient())
{
string requestUrl = url + "/attachment?headerid=" + attachToHeaderId.ToString();
if (!string.IsNullOrWhiteSpace(attachToDataUniqueId))
{
requestUrl += "&datauniqueid=";
requestUrl += System.Net.WebUtility.UrlEncode(attachToDataUniqueId);
}
requestUrl += "&filename="; // this is just so the web server log shows the filename
requestUrl += System.Net.WebUtility.UrlEncode(fileName);
httpClient.Timeout = new TimeSpan(0, 0, 0, timeoutSeconds, 0); httpClient.Timeout = new TimeSpan(0, 0, 0, timeoutSeconds, 0);
HttpRequestMessage httpRequestMessage = new()
MultipartFormDataContent multipartFormDataContent = new MultipartFormDataContent(); {
ByteArrayContent byteArrayContent = new ByteArrayContent(fileContents); RequestUri = new Uri(url),
byteArrayContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream"); Method = HttpMethod.Post,
Content = new StringContent(json, Encoding.UTF8, "application/json")
multipartFormDataContent.Add(byteArrayContent, "attachment", fileName); };
HttpResponseMessage httpResponseMessage = httpClient.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseContentRead).Result;
HttpResponseMessage httpResponseMessage = httpClient.PostAsync(requestUrl, multipartFormDataContent).Result; resultsJson = httpResponseMessage.Content.ReadAsStringAsync().Result;
results = JsonSerializer.Deserialize<Results>(resultsJson);
if (httpResponseMessage.IsSuccessStatusCode)
return;
string resultBody = httpResponseMessage.Content.ReadAsStringAsync().Result;
throw new Exception("Attachment failed: " + resultBody);
} }
if (!results.Success)
results.Errors.Add(results.ToString());
} }
catch (Exception e)
public static void AttachFiles(string url, long headerID, List<Attachment> headerAttachments = null, List<Attachment> dataAttachments = null)
{ {
try Exception exception = e;
StringBuilder stringBuilder = new();
while (exception is not null)
{ {
if (!(headerAttachments is null)) _ = stringBuilder.AppendLine(exception.Message);
{ exception = exception.InnerException;
foreach (Attachment attachment in headerAttachments)
AttachFile(url, headerID, "", System.IO.File.ReadAllBytes(attachment.SourceFileName), attachment.DestinationFileName);
}
if (!(dataAttachments is null))
{
foreach (Attachment attachment in dataAttachments)
AttachFile(url, headerID, attachment.UniqueId, System.IO.File.ReadAllBytes(attachment.SourceFileName), attachment.DestinationFileName);
}
//MessageBox.Show(r.ToString());
}
catch (Exception e)
{
Exception exception = e;
StringBuilder stringBuilder = new StringBuilder();
while (!(exception is null))
{
stringBuilder.AppendLine(exception.Message);
exception = exception.InnerException;
}
//MessageBox.Show(msgs.ToString(), "Exception", //MessageBoxButtons.OK, //MessageBoxIcon.Error);
throw new Exception(stringBuilder.ToString());
} }
if (results.Errors is null)
results.Errors = new List<string>();
results.Errors.Add(stringBuilder.ToString());
} }
return new Tuple<string, Results>(resultsJson, results);
}
// this method is a wrapper for attaching a file to either a header or data record
// URL is the same URL used for SendData, ex: http://localhost/api/inbound/CDE
// attachToHeaderId is the ID returned by SendData
// attachToDataUniqueId is the string unique ID for the data record, aka the Title of the Sharepoint list entry
// fileContents is a byte array with the contents of the file
// fileName is which attachment this is, image.pdf, data.pdf, data.txt, header.pdf, etc
// timeoutSeconds is configured as the request timeout
// this method will either succeed or throw an exception
// also, this has been made synchronous
public static void AttachFile(string url, long attachToHeaderId, string attachToDataUniqueId, byte[] fileContents, string fileName, int timeoutSeconds = 60)
{
using HttpClient httpClient = new();
string requestUrl = url + "/attachment?headerid=" + attachToHeaderId.ToString();
if (!string.IsNullOrWhiteSpace(attachToDataUniqueId))
{
requestUrl += "&datauniqueid=";
requestUrl += System.Net.WebUtility.UrlEncode(attachToDataUniqueId);
}
requestUrl += "&filename="; // this is just so the web server log shows the filename
requestUrl += System.Net.WebUtility.UrlEncode(fileName);
httpClient.Timeout = new TimeSpan(0, 0, 0, timeoutSeconds, 0);
MultipartFormDataContent multipartFormDataContent = new();
ByteArrayContent byteArrayContent = new(fileContents);
byteArrayContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
multipartFormDataContent.Add(byteArrayContent, "attachment", fileName);
HttpResponseMessage httpResponseMessage = httpClient.PostAsync(requestUrl, multipartFormDataContent).Result;
if (httpResponseMessage.IsSuccessStatusCode)
return;
string resultBody = httpResponseMessage.Content.ReadAsStringAsync().Result;
throw new Exception("Attachment failed: " + resultBody);
}
public static void AttachFiles(string url, long headerID, List<Attachment> headerAttachments = null, List<Attachment> dataAttachments = null)
{
try
{
if (headerAttachments is not null)
{
foreach (Attachment attachment in headerAttachments)
AttachFile(url, headerID, "", System.IO.File.ReadAllBytes(attachment.SourceFileName), attachment.DestinationFileName);
}
if (dataAttachments is not null)
{
foreach (Attachment attachment in dataAttachments)
AttachFile(url, headerID, attachment.UniqueId, System.IO.File.ReadAllBytes(attachment.SourceFileName), attachment.DestinationFileName);
}
//MessageBox.Show(r.ToString());
}
catch (Exception e)
{
Exception exception = e;
StringBuilder stringBuilder = new();
while (exception is not null)
{
_ = stringBuilder.AppendLine(exception.Message);
exception = exception.InnerException;
}
//MessageBox.Show(msgs.ToString(), "Exception", //MessageBoxButtons.OK, //MessageBoxIcon.Error);
throw new Exception(stringBuilder.ToString());
}
} }
} }

View File

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

View File

@ -7,420 +7,405 @@ 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 enum SearchFor
{ {
EquipmentIntegration = 1,
BusinessIntegration = 2,
SystemExport = 3,
Archive = 4
}
public const string RecordStart = "RECORD_START"; public static string GetPDSFText(IFileRead fileRead, Logistics logistics, JsonElement[] jsonElements, string logisticsText)
{
public enum SearchFor string result;
if (!jsonElements.Any())
result = string.Empty;
else
{ {
EquipmentIntegration = 1, int columns = 0;
BusinessIntegration = 2, List<string> lines;
SystemExport = 3, string endOffset = "E#######T";
Archive = 4 string dataOffset = "D#######T";
} string headerOffset = "H#######T";
string format = "MM/dd/yyyy HH:mm:ss";
public static string GetPDSFText(IFileRead fileRead, Logistics logistics, JsonElement[] jsonElements, string logisticsText) 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();
string result; _ = stringBuilder.Append("\"Time\"").Append('\t');
if (!jsonElements.Any()) _ = stringBuilder.Append("\"A_LOGISTICS\"").Append('\t');
result = string.Empty; _ = stringBuilder.Append("\"B_LOGISTICS\"").Append('\t');
else for (int i = 0; i < jsonElements.Length;)
{ {
int columns = 0; foreach (JsonProperty jsonProperty in jsonElements[0].EnumerateObject())
List<string> lines;
string endOffset = "E#######T";
string dataOffset = "D#######T";
string headerOffset = "H#######T";
string format = "MM/dd/yyyy HH:mm:ss";
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();
stringBuilder.Append("\"Time\"").Append('\t');
stringBuilder.Append("\"A_LOGISTICS\"").Append('\t');
stringBuilder.Append("\"B_LOGISTICS\"").Append('\t');
for (int i = 0; i < jsonElements.Length;)
{ {
foreach (JsonProperty jsonProperty in jsonElements[0].EnumerateObject()) columns += 1;
{ _ = stringBuilder.Append("\"").Append(jsonProperty.Name).Append("\"").Append('\t');
columns += 1;
stringBuilder.Append("\"").Append(jsonProperty.Name).Append("\"").Append('\t');
}
break;
} }
stringBuilder.Remove(stringBuilder.Length - 1, 1); break;
}
_ = stringBuilder.Remove(stringBuilder.Length - 1, 1);
lines.Add(stringBuilder.ToString());
for (int i = 0; i < jsonElements.Length; i++)
{
_ = stringBuilder.Clear();
_ = stringBuilder.Append("0.1").Append('\t');
_ = stringBuilder.Append("1").Append('\t');
_ = stringBuilder.Append("2").Append('\t');
foreach (JsonProperty jsonProperty in jsonElements[i].EnumerateObject())
_ = stringBuilder.Append(jsonProperty.Value).Append('\t');
_ = stringBuilder.Remove(stringBuilder.Length - 1, 1);
lines.Add(stringBuilder.ToString()); lines.Add(stringBuilder.ToString());
for (int i = 0; i < jsonElements.Length; i++)
{
stringBuilder.Clear();
stringBuilder.Append("0.1").Append('\t');
stringBuilder.Append("1").Append('\t');
stringBuilder.Append("2").Append('\t');
foreach (JsonProperty jsonProperty in jsonElements[i].EnumerateObject())
stringBuilder.Append(jsonProperty.Value).Append('\t');
stringBuilder.Remove(stringBuilder.Length - 1, 1);
lines.Add(stringBuilder.ToString());
}
lines.Add(string.Concat("NUM_DATA_ROWS ", jsonElements.Length.ToString().PadLeft(9, '0')));
lines.Add(string.Concat("NUM_DATA_COLUMNS ", (columns + 3).ToString().PadLeft(9, '0')));
lines.Add("DELIMITER ;");
lines.Add(string.Concat("START_TIME_FORMAT ", format));
lines.Add(string.Concat("START_TIME ", logistics.DateTimeFromSequence.ToString(format))); //12/26/2019 15:22:44
lines.Add(string.Concat("LOGISTICS_COLUMN", '\t', "A_LOGISTICS"));
lines.Add(string.Concat("LOGISTICS_COLUMN", '\t', "B_LOGISTICS"));
if (!string.IsNullOrEmpty(logisticsText))
lines.Add(logisticsText);
else
{
lines.Add(string.Concat("LOGISTICS_1", '\t', "A_CHAMBER=;A_INFO=", fileRead.EventName, ";A_INFO2=", fileRead.EquipmentType, ";A_JOBID=", fileRead.CellInstanceName, ";A_MES_ENTITY=", fileRead.MesEntity, ";A_MID=", logistics.MID, ";A_NULL_DATA=", fileRead.NullData, ";A_PPID=NO_PPID;A_PROCESS_JOBID=", logistics.ProcessJobID, ";A_PRODUCT=;A_SEQUENCE=", logistics.Sequence, ";A_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");
}
stringBuilder.Clear();
foreach (string line in lines)
stringBuilder.AppendLine(line);
result = stringBuilder.ToString();
result = result.Replace(headerOffset, result.IndexOf("NUM_DATA_ROWS").ToString().PadLeft(9, '0')).
Replace(dataOffset, result.IndexOf('"').ToString().PadLeft(9, '0')).
Replace(endOffset, result.Length.ToString().PadLeft(9, '0'));
} }
return result; lines.Add(string.Concat("NUM_DATA_ROWS ", jsonElements.Length.ToString().PadLeft(9, '0')));
} lines.Add(string.Concat("NUM_DATA_COLUMNS ", (columns + 3).ToString().PadLeft(9, '0')));
lines.Add("DELIMITER ;");
public static Tuple<string, string[], string[]> GetLogisticsColumnsAndBody(string reportFullPath, string[] lines = null) lines.Add(string.Concat("START_TIME_FORMAT ", format));
{ lines.Add(string.Concat("START_TIME ", logistics.DateTimeFromSequence.ToString(format))); //12/26/2019 15:22:44
string segment; lines.Add(string.Concat("LOGISTICS_COLUMN", '\t', "A_LOGISTICS"));
List<string> body = new(); lines.Add(string.Concat("LOGISTICS_COLUMN", '\t', "B_LOGISTICS"));
StringBuilder logistics = new(); if (!string.IsNullOrEmpty(logisticsText))
if (lines is null) lines.Add(logisticsText);
lines = File.ReadAllLines(reportFullPath);
string[] segments;
if (lines.Length < 7)
segments = new string[] { };
else
segments = lines[6].Trim().Split('\t');
List<string> columns = new();
for (int c = 0; c < segments.Length; c++)
{
segment = segments[c].Substring(1, segments[c].Length - 2);
if (!columns.Contains(segment))
columns.Add(segment);
else
{
for (short i = 1; i < short.MaxValue; i++)
{
segment = string.Concat(segment, "_", i);
if (!columns.Contains(segment))
{
columns.Add(segment);
break;
}
}
}
}
bool lookForLogistics = false;
for (int r = 7; r < lines.Count(); r++)
{
if (lines[r].StartsWith("NUM_DATA_ROWS"))
lookForLogistics = true;
if (!lookForLogistics)
{
body.Add(lines[r]);
continue;
}
if (lines[r].StartsWith("LOGISTICS_1"))
{
for (int i = r; i < lines.Count(); i++)
{
if (lines[r].StartsWith("END_HEADER"))
break;
logistics.AppendLine(lines[i]);
}
break;
}
}
return new Tuple<string, string[], string[]>(logistics.ToString(), columns.ToArray(), body.ToArray());
}
public static JsonElement[] GetArray(Tuple<string, string[], string[]> pdsf, bool lookForNumbers = false)
{
JsonElement[] results;
string logistics = pdsf.Item1;
string[] columns = pdsf.Item2;
string[] bodyLines = pdsf.Item3;
if (!bodyLines.Any() || !bodyLines[0].Contains('\t'))
results = JsonSerializer.Deserialize<JsonElement[]>("[]");
else else
{ {
string value; lines.Add(string.Concat("LOGISTICS_1", '\t', "A_CHAMBER=;A_INFO=", fileRead.EventName, ";A_INFO2=", fileRead.EquipmentType, ";A_JOBID=", fileRead.CellInstanceName, ";A_MES_ENTITY=", fileRead.MesEntity, ";A_MID=", logistics.MID, ";A_NULL_DATA=", fileRead.NullData, ";A_PPID=NO_PPID;A_PROCESS_JOBID=", logistics.ProcessJobID, ";A_PRODUCT=;A_SEQUENCE=", logistics.Sequence, ";A_WAFER_ID=;"));
string[] segments; 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=;"));
StringBuilder stringBuilder = new(); lines.Add("END_HEADER");
foreach (string bodyLine in bodyLines)
{
stringBuilder.Append('{');
segments = bodyLine.Trim().Split('\t');
if (!lookForNumbers)
{
for (int c = 1; c < segments.Length; c++)
{
value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\");
stringBuilder.Append('"').Append(columns[c]).Append("\":\"").Append(value).Append("\",");
}
}
else
{
for (int c = 1; c < segments.Length; c++)
{
value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\");
if (string.IsNullOrEmpty(value))
stringBuilder.Append('"').Append(columns[c]).Append("\":").Append(value).Append("null,");
else if (value.All(char.IsDigit))
stringBuilder.Append('"').Append(columns[c]).Append("\":").Append(value).Append(",");
else
stringBuilder.Append('"').Append(columns[c]).Append("\":\"").Append(value).Append("\",");
}
}
stringBuilder.Remove(stringBuilder.Length - 1, 1);
stringBuilder.AppendLine("},");
}
stringBuilder.Remove(stringBuilder.Length - 3, 3);
results = JsonSerializer.Deserialize<JsonElement[]>(string.Concat("[", stringBuilder, "]"));
} }
return results; _ = stringBuilder.Clear();
foreach (string line in lines)
_ = stringBuilder.AppendLine(line);
result = stringBuilder.ToString();
result = result.Replace(headerOffset, result.IndexOf("NUM_DATA_ROWS").ToString().PadLeft(9, '0')).
Replace(dataOffset, result.IndexOf('"').ToString().PadLeft(9, '0')).
Replace(endOffset, result.Length.ToString().PadLeft(9, '0'));
} }
return result;
}
public static Dictionary<string, List<string>> GetDictionary(Tuple<string, string[], string[]> pdsf) public static Tuple<string, string[], string[]> GetLogisticsColumnsAndBody(string reportFullPath, string[] lines = null)
{
string segment;
List<string> body = new();
StringBuilder logistics = new();
if (lines is null)
lines = File.ReadAllLines(reportFullPath);
string[] segments;
if (lines.Length < 7)
segments = new string[] { };
else
segments = lines[6].Trim().Split('\t');
List<string> columns = new();
for (int c = 0; c < segments.Length; c++)
{ {
Dictionary<string, List<string>> results = new(); segment = segments[c].Substring(1, segments[c].Length - 2);
if (!columns.Contains(segment))
columns.Add(segment);
else
{
for (short i = 1; i < short.MaxValue; i++)
{
segment = string.Concat(segment, "_", i);
if (!columns.Contains(segment))
{
columns.Add(segment);
break;
}
}
}
}
bool lookForLogistics = false;
for (int r = 7; r < lines.Count(); r++)
{
if (lines[r].StartsWith("NUM_DATA_ROWS"))
lookForLogistics = true;
if (!lookForLogistics)
{
body.Add(lines[r]);
continue;
}
if (lines[r].StartsWith("LOGISTICS_1"))
{
for (int i = r; i < lines.Count(); i++)
{
if (lines[r].StartsWith("END_HEADER"))
break;
_ = logistics.AppendLine(lines[i]);
}
break;
}
}
return new Tuple<string, string[], string[]>(logistics.ToString(), columns.ToArray(), body.ToArray());
}
public static JsonElement[] GetArray(Tuple<string, string[], string[]> pdsf, bool lookForNumbers = false)
{
JsonElement[] results;
string logistics = pdsf.Item1;
string[] columns = pdsf.Item2;
string[] bodyLines = pdsf.Item3;
if (!bodyLines.Any() || !bodyLines[0].Contains('\t'))
results = JsonSerializer.Deserialize<JsonElement[]>("[]");
else
{
string value;
string[] segments; string[] segments;
string[] columns = pdsf.Item2; StringBuilder stringBuilder = new();
string[] bodyLines = pdsf.Item3;
foreach (string column in columns)
results.Add(column, new List<string>());
foreach (string bodyLine in bodyLines) foreach (string bodyLine in bodyLines)
{ {
segments = bodyLine.Split('\t'); _ = stringBuilder.Append('{');
for (int c = 1; c < segments.Length; c++) segments = bodyLine.Trim().Split('\t');
if (!lookForNumbers)
{ {
if (c >= columns.Length) for (int c = 1; c < segments.Length; c++)
continue;
results[columns[c]].Add(segments[c]);
}
}
return results;
}
public static Tuple<string, Dictionary<Test, Dictionary<string, List<string>>>> GetTestDictionary(Tuple<string, string[], string[]> pdsf)
{
Dictionary<Test, Dictionary<string, List<string>>> results = new();
string testColumn = nameof(Test);
Dictionary<string, List<string>> keyValuePairs = GetDictionary(pdsf);
if (!keyValuePairs.ContainsKey(testColumn))
throw new Exception();
int min;
int max;
Test testKey;
List<string> vs;
string columnKey;
Dictionary<Test, List<int>> tests = new();
for (int i = 0; i < keyValuePairs[testColumn].Count; i++)
{
if (Enum.TryParse(keyValuePairs[testColumn][i], out Test test))
{
if (!results.ContainsKey(test))
{ {
tests.Add(test, new List<int>()); value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\");
results.Add(test, new Dictionary<string, List<string>>()); _ = stringBuilder.Append('"').Append(columns[c]).Append("\":\"").Append(value).Append("\",");
} }
tests[test].Add(i);
} }
} else
foreach (KeyValuePair<Test, List<int>> testKeyValuePair in tests)
{
testKey = testKeyValuePair.Key;
min = testKeyValuePair.Value.Min();
max = testKeyValuePair.Value.Max() + 1;
foreach (KeyValuePair<string, List<string>> keyValuePair in keyValuePairs)
results[testKey].Add(keyValuePair.Key, new List<string>());
foreach (KeyValuePair<string, List<string>> keyValuePair in keyValuePairs)
{ {
vs = keyValuePair.Value; for (int c = 1; c < segments.Length; c++)
columnKey = keyValuePair.Key;
for (int i = min; i < max; i++)
{ {
if (vs.Count > i) value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\");
results[testKey][columnKey].Add(vs[i]); if (string.IsNullOrEmpty(value))
_ = stringBuilder.Append('"').Append(columns[c]).Append("\":").Append(value).Append("null,");
else if (value.All(char.IsDigit))
_ = stringBuilder.Append('"').Append(columns[c]).Append("\":").Append(value).Append(",");
else else
results[testKey][columnKey].Add(string.Empty); _ = stringBuilder.Append('"').Append(columns[c]).Append("\":\"").Append(value).Append("\",");
} }
} }
_ = stringBuilder.Remove(stringBuilder.Length - 1, 1);
_ = stringBuilder.AppendLine("},");
} }
return new Tuple<string, Dictionary<Test, Dictionary<string, List<string>>>>(pdsf.Item1, results); _ = stringBuilder.Remove(stringBuilder.Length - 3, 3);
results = JsonSerializer.Deserialize<JsonElement[]>(string.Concat("[", stringBuilder, "]"));
} }
return results;
}
private static string GetString(SearchFor searchFor, bool addSpaces, char separator = ' ') public static Dictionary<string, List<string>> GetDictionary(Tuple<string, string[], string[]> pdsf)
{
Dictionary<string, List<string>> results = new();
string[] segments;
string[] columns = pdsf.Item2;
string[] bodyLines = pdsf.Item3;
foreach (string column in columns)
results.Add(column, new List<string>());
foreach (string bodyLine in bodyLines)
{ {
if (!addSpaces) segments = bodyLine.Split('\t');
return string.Concat(((int)searchFor).ToString().PadLeft(2, '0'), searchFor); for (int c = 1; c < segments.Length; c++)
else
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 = ' ')
{
return GetString(SearchFor.EquipmentIntegration, addSpaces, separator);
}
public static string BusinessIntegration(bool addSpaces = true, char separator = ' ')
{
return GetString(SearchFor.BusinessIntegration, addSpaces, separator);
}
public static string SystemExport(bool addSpaces = true, char separator = ' ')
{
return GetString(SearchFor.SystemExport, addSpaces, separator);
}
public static string Archive(bool addSpaces = true, char 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)
{
StringBuilder result = new();
if (ignoreParameterNames is null)
ignoreParameterNames = new List<string>();
if (useDateTimeFromSequence && !string.IsNullOrEmpty(format))
throw new Exception();
else if (!useDateTimeFromSequence && string.IsNullOrEmpty(format))
throw new Exception();
string nullData;
const string columnDate = "Date";
const string columnTime = "Time";
const string firstDuplicate = "_1";
result.AppendLine(scopeInfo.Header);
StringBuilder line = new();
if (logistics.NullData is null)
nullData = string.Empty;
else
nullData = logistics.NullData.ToString();
int count = (from l in keyValuePairs select l.Value.Count).Min();
for (int r = 0; r < count; r++)
{ {
line.Clear(); if (c >= columns.Length)
line.Append("!");
foreach (KeyValuePair<string, List<string>> keyValuePair in keyValuePairs)
{
if (!names.Contains(keyValuePair.Key))
continue;
if (ignoreParameterNames.Contains(keyValuePair.Key))
continue;
if (pairedParameterNames.Contains(keyValuePair.Key))
{
if (string.IsNullOrEmpty(keyValuePair.Value[r]) || keyValuePair.Value[r] == nullData)
continue;
else
result.Append(line).Append(keyValuePair.Key).Append(';').AppendLine(keyValuePair.Value[r]);
}
else
{
if (useDateTimeFromSequence && keyValuePair.Key == columnDate)
line.Append(logistics.DateTimeFromSequence.ToString(dateFormat));
else if (useDateTimeFromSequence && keyValuePair.Key == columnTime)
line.Append(logistics.DateTimeFromSequence.ToString(timeFormat));
else if (!useDateTimeFromSequence && keyValuePair.Key == columnDate && keyValuePair.Value[r].Length == format.Length)
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)
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)
line.Append(nullData);
else
line.Append(keyValuePair.Value[r]);
line.Append(';');
}
}
if (!pairedParameterNames.Any())
{
line.Remove(line.Length - 1, 1);
result.AppendLine(line.ToString());
}
}
return result.ToString();
}
public static List<string> PDSFToFixedWidth(string reportFullPath)
{
List<string> results = new();
if (!File.Exists(reportFullPath))
throw new Exception();
int[] group;
string line;
int startsAt = 0;
string[] segments;
int? currentGroup = null;
char inputSeperator = '\t';
char outputSeperator = '\t';
List<int> vs = new();
List<int[]> groups = new();
string[] lines = File.ReadAllLines(reportFullPath);
StringBuilder stringBuilder = new();
for (int i = 0; i < lines.Length; i++)
{
if (string.IsNullOrEmpty(lines[i]))
continue; continue;
segments = lines[i].Split(inputSeperator); results[columns[c]].Add(segments[c]);
if (currentGroup is null) }
currentGroup = segments.Length; }
if (segments.Length != currentGroup) return results;
}
public static Tuple<string, Dictionary<Test, Dictionary<string, List<string>>>> GetTestDictionary(Tuple<string, string[], string[]> pdsf)
{
Dictionary<Test, Dictionary<string, List<string>>> results = new();
string testColumn = nameof(Test);
Dictionary<string, List<string>> keyValuePairs = GetDictionary(pdsf);
if (!keyValuePairs.ContainsKey(testColumn))
throw new Exception();
int min;
int max;
Test testKey;
List<string> vs;
string columnKey;
Dictionary<Test, List<int>> tests = new();
for (int i = 0; i < keyValuePairs[testColumn].Count; i++)
{
if (Enum.TryParse(keyValuePairs[testColumn][i], out Test test))
{
if (!results.ContainsKey(test))
{ {
currentGroup = segments.Length; tests.Add(test, new List<int>());
groups.Add(new int[] { startsAt, i - 1 }); results.Add(test, new Dictionary<string, List<string>>());
startsAt = i; }
tests[test].Add(i);
}
}
foreach (KeyValuePair<Test, List<int>> testKeyValuePair in tests)
{
testKey = testKeyValuePair.Key;
min = testKeyValuePair.Value.Min();
max = testKeyValuePair.Value.Max() + 1;
foreach (KeyValuePair<string, List<string>> keyValuePair in keyValuePairs)
results[testKey].Add(keyValuePair.Key, new List<string>());
foreach (KeyValuePair<string, List<string>> keyValuePair in keyValuePairs)
{
vs = keyValuePair.Value;
columnKey = keyValuePair.Key;
for (int i = min; i < max; i++)
{
if (vs.Count > i)
results[testKey][columnKey].Add(vs[i]);
else
results[testKey][columnKey].Add(string.Empty);
} }
} }
if (startsAt == lines.Length - 1 && lines[0].Split(inputSeperator).Length != currentGroup) }
groups.Add(new int[] { lines.Length - 1, lines.Length - 1 }); return new Tuple<string, Dictionary<Test, Dictionary<string, List<string>>>>(pdsf.Item1, results);
for (int g = 0; g < groups.Count; g++) }
private static string GetString(SearchFor searchFor, bool addSpaces, char separator = ' ')
{
if (!addSpaces)
return string.Concat(((int)searchFor).ToString().PadLeft(2, '0'), searchFor);
else
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 = ' ') => GetString(SearchFor.EquipmentIntegration, addSpaces, separator);
public static string BusinessIntegration(bool addSpaces = true, char separator = ' ') => GetString(SearchFor.BusinessIntegration, addSpaces, separator);
public static string SystemExport(bool addSpaces = true, char separator = ' ') => GetString(SearchFor.SystemExport, addSpaces, separator);
public static string Archive(bool addSpaces = true, char separator = ' ') => 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)
{
StringBuilder result = new();
if (ignoreParameterNames is null)
ignoreParameterNames = new List<string>();
if (useDateTimeFromSequence && !string.IsNullOrEmpty(format))
throw new Exception();
else if (!useDateTimeFromSequence && string.IsNullOrEmpty(format))
throw new Exception();
string nullData;
const string columnDate = "Date";
const string columnTime = "Time";
const string firstDuplicate = "_1";
_ = result.AppendLine(scopeInfo.Header);
StringBuilder line = new();
if (logistics.NullData is null)
nullData = string.Empty;
else
nullData = logistics.NullData.ToString();
int count = (from l in keyValuePairs select l.Value.Count).Min();
for (int r = 0; r < count; r++)
{
_ = line.Clear();
_ = line.Append("!");
foreach (KeyValuePair<string, List<string>> keyValuePair in keyValuePairs)
{ {
vs.Clear(); if (!names.Contains(keyValuePair.Key))
group = groups[g]; continue;
line = lines[group[0]]; if (ignoreParameterNames.Contains(keyValuePair.Key))
continue;
if (pairedParameterNames.Contains(keyValuePair.Key))
{
if (string.IsNullOrEmpty(keyValuePair.Value[r]) || keyValuePair.Value[r] == nullData)
continue;
else
_ = result.Append(line).Append(keyValuePair.Key).Append(';').AppendLine(keyValuePair.Value[r]);
}
else
{
if (useDateTimeFromSequence && keyValuePair.Key == columnDate)
_ = line.Append(logistics.DateTimeFromSequence.ToString(dateFormat));
else if (useDateTimeFromSequence && keyValuePair.Key == columnTime)
_ = line.Append(logistics.DateTimeFromSequence.ToString(timeFormat));
else if (!useDateTimeFromSequence && keyValuePair.Key == columnDate && keyValuePair.Value[r].Length == format.Length)
_ = 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)
_ = 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)
_ = line.Append(nullData);
else
_ = line.Append(keyValuePair.Value[r]);
_ = line.Append(';');
}
}
if (!pairedParameterNames.Any())
{
_ = line.Remove(line.Length - 1, 1);
_ = result.AppendLine(line.ToString());
}
}
return result.ToString();
}
public static List<string> PDSFToFixedWidth(string reportFullPath)
{
List<string> results = new();
if (!File.Exists(reportFullPath))
throw new Exception();
int[] group;
string line;
int startsAt = 0;
string[] segments;
int? currentGroup = null;
char inputSeperator = '\t';
char outputSeperator = '\t';
List<int> vs = new();
List<int[]> groups = new();
string[] lines = File.ReadAllLines(reportFullPath);
StringBuilder stringBuilder = new();
for (int i = 0; i < lines.Length; i++)
{
if (string.IsNullOrEmpty(lines[i]))
continue;
segments = lines[i].Split(inputSeperator);
if (currentGroup is null)
currentGroup = segments.Length;
if (segments.Length != currentGroup)
{
currentGroup = segments.Length;
groups.Add(new int[] { startsAt, i - 1 });
startsAt = i;
}
}
if (startsAt == lines.Length - 1 && lines[0].Split(inputSeperator).Length != currentGroup)
groups.Add(new int[] { lines.Length - 1, lines.Length - 1 });
for (int g = 0; g < groups.Count; g++)
{
vs.Clear();
group = groups[g];
line = lines[group[0]];
segments = line.Split(inputSeperator);
for (int s = 0; s < segments.Length; s++)
vs.Add(segments[s].Length);
for (int i = group[0]; i <= group[1]; i++)
{
line = lines[i];
segments = line.Split(inputSeperator); segments = line.Split(inputSeperator);
for (int s = 0; s < segments.Length; s++) for (int s = 0; s < segments.Length; s++)
vs.Add(segments[s].Length);
for (int i = group[0]; i <= group[1]; i++)
{ {
line = lines[i]; if (vs[s] < segments[s].Length)
segments = line.Split(inputSeperator); vs[s] = segments[s].Length;
for (int s = 0; s < segments.Length; s++)
{
if (vs[s] < segments[s].Length)
vs[s] = segments[s].Length;
}
} }
stringBuilder.Clear();
for (int s = 0; s < segments.Length; s++)
stringBuilder.Append((s + 1).ToString().PadLeft(vs[s], ' ')).Append(outputSeperator);
stringBuilder.Remove(stringBuilder.Length - 1, 1);
results.Add(stringBuilder.ToString());
for (int i = group[0]; i <= group[1]; i++)
{
line = lines[i];
stringBuilder.Clear();
segments = line.Split(inputSeperator);
for (int s = 0; s < segments.Length; s++)
stringBuilder.Append(segments[s].PadLeft(vs[s], ' ')).Append(outputSeperator);
stringBuilder.Remove(stringBuilder.Length - 1, 1);
results.Add(stringBuilder.ToString());
}
results.Add(string.Empty);
} }
return results; _ = stringBuilder.Clear();
for (int s = 0; s < segments.Length; s++)
_ = stringBuilder.Append((s + 1).ToString().PadLeft(vs[s], ' ')).Append(outputSeperator);
_ = stringBuilder.Remove(stringBuilder.Length - 1, 1);
results.Add(stringBuilder.ToString());
for (int i = group[0]; i <= group[1]; i++)
{
line = lines[i];
_ = stringBuilder.Clear();
segments = line.Split(inputSeperator);
for (int s = 0; s < segments.Length; s++)
_ = stringBuilder.Append(segments[s].PadLeft(vs[s], ' ')).Append(outputSeperator);
_ = stringBuilder.Remove(stringBuilder.Length - 1, 1);
results.Add(stringBuilder.ToString());
}
results.Add(string.Empty);
} }
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 Count { get; }
int Index { get; }
int Test { get; }
int Count { get; }
int Index { get; }
}
} }

View File

@ -1,20 +1,17 @@
namespace Adaptation.Shared.Properties namespace Adaptation.Shared.Properties;
public interface IFileRead
{ {
bool IsEvent { get; }
public interface IFileRead string NullData { get; }
{ string MesEntity { get; }
bool IsEvent { get; } bool IsEAFHosted { get; }
string NullData { get; } string EventName { get; }
string MesEntity { get; } string EquipmentType { get; }
bool IsEAFHosted { get; } string ReportFullPath { get; }
string EventName { get; } string CellInstanceName { get; }
string EquipmentType { get; } string ExceptionSubject { get; }
string ReportFullPath { get; } bool UseCyclicalForDescription { get; }
string CellInstanceName { get; } string CellInstanceConnectionName { get; }
string ExceptionSubject { get; } string ParameterizedModelObjectDefinitionType { get; }
bool UseCyclicalForDescription { get; }
string CellInstanceConnectionName { get; }
string ParameterizedModelObjectDefinitionType { get; }
}
} }

View File

@ -1,25 +1,22 @@
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 string JobID { get; } //CellName
public long Sequence { get; } //Ticks
public object NullData { get; } public DateTime DateTimeFromSequence { get; }
public string JobID { get; } //CellName public double TotalSecondsSinceLastWriteTimeFromSequence { get; }
public long Sequence { get; } //Ticks public string MesEntity { get; } //SPC
public DateTime DateTimeFromSequence { get; } public string ReportFullPath { get; } //Extract file
public double TotalSecondsSinceLastWriteTimeFromSequence { get; } public string ProcessJobID { get; set; } //Reactor (duplicate but I want it in the logistics)
public string MesEntity { get; } //SPC public string MID { get; set; } //Lot & Pocket || Lot
public string ReportFullPath { get; } //Extract file public List<string> Tags { get; set; }
public string ProcessJobID { get; set; } //Reactor (duplicate but I want it in the logistics) public List<string> Logistics1 { get; set; }
public string MID { get; set; } //Lot & Pocket || Lot public List<Logistics2> Logistics2 { get; set; }
public List<string> Tags { get; set; }
public List<string> Logistics1 { get; set; }
public List<Logistics2> Logistics2 { get; set; }
}
} }

View File

@ -1,17 +1,14 @@
namespace Adaptation.Shared.Properties namespace Adaptation.Shared.Properties;
public interface ILogistics2
{ {
public interface ILogistics2 public string MID { get; }
{ public string RunNumber { get; }
public string SatelliteGroup { get; }
public string MID { get; } public string PartNumber { get; }
public string RunNumber { get; } public string PocketNumber { get; }
public string SatelliteGroup { get; } public string WaferLot { get; }
public string PartNumber { get; } public string Recipe { get; }
public string PocketNumber { get; }
public string WaferLot { 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,20 +1,17 @@
using System; using System;
namespace Adaptation.Shared.Properties namespace Adaptation.Shared.Properties;
public interface IScopeInfo
{ {
public interface IScopeInfo Enum Enum { get; }
{ string HTML { get; }
string Title { get; }
Enum Enum { get; } string FileName { get; }
string HTML { get; } int TestValue { get; }
string Title { get; } string Header { get; }
string FileName { get; } string QueryFilter { get; }
int TestValue { get; } string FileNameWithoutExtension { get; }
string Header { get; }
string QueryFilter { get; }
string FileNameWithoutExtension { get; }
}
} }

View File

@ -1,57 +1,58 @@
namespace Adaptation.Shared namespace Adaptation.Shared;
public enum Test
{ {
AFMRoughness = 34,
public enum Test BioRadQS408M = 25,
{ BioRadStratus = 26,
AFMRoughness = 34, BreakdownVoltageCenter = 0,
BioRadQS408M = 25, BreakdownVoltageEdge = 1,
BioRadStratus = 26, BreakdownVoltageMiddle8in = 2,
BreakdownVoltageCenter = 0, CandelaKlarfDC = 6,
BreakdownVoltageEdge = 1, CandelaLaser = 36,
BreakdownVoltageMiddle8in = 2, CandelaProdU = 39,
CandelaKlarfDC = 6, CandelaPSL = 38,
CandelaLaser = 36, CandelaVerify = 37,
CandelaProdU = 39, CDE = 24,
CandelaPSL = 38, CV = 3,
CandelaVerify = 37, DailyRPMAverage = 19,
CDE = 24, DailyRPMPLRatio = 20,
CV = 3, DailyRPMXY = 18,
DailyRPMAverage = 19, Denton = 9,
DailyRPMPLRatio = 20, DiffusionLength = 45,
DailyRPMXY = 18, GRATXTCenter = 51,
Denton = 9, GRATXTEdge = 52, //Largest
DiffusionLength = 45, GrowthRateXML = 50,
Hall = 10, Hall = 10,
HgCV = 23, HgCV = 23,
Lehighton = 13, JVXRD = 47,
Microscope = 46, Lehighton = 13,
MonthlyCV = 4, LogbookCAC = 49,
MonthlyHall = 11, Microscope = 46,
MonthlyXRD = 32, MonthlyCV = 4,
Photoreflectance = 22, MonthlyHall = 11,
PlatoA = 48, //Largest MonthlyXRD = 32,
RPMAverage = 16, Photoreflectance = 22,
RPMPLRatio = 17, PlatoA = 48,
RPMXY = 15, RPMAverage = 16,
SP1 = 8, RPMPLRatio = 17,
Tencor = 7, RPMXY = 15,
UV = 35, SP1 = 8,
VerificationLehighton = 14, Tencor = 7,
VerificationRPM = 21, UV = 35,
VerificationWarpAndBow = 29, VerificationLehighton = 14,
VpdIcpmsAnalyte = 27, VerificationRPM = 21,
WarpAndBow = 28, VerificationWarpAndBow = 29,
WeeklyCV = 5, VpdIcpmsAnalyte = 27,
WeeklyHall = 12, WarpAndBow = 28,
WeeklyXRD = 33, WeeklyCV = 5,
WeeklyXRDAIcomp = 40, WeeklyHall = 12,
WeeklyXRDFWHM002 = 41, WeeklyXRD = 33,
WeeklyXRDFWHM105 = 42, WeeklyXRDAIcomp = 40,
WeeklyXRDSLStks = 43, WeeklyXRDFWHM002 = 41,
WeeklyXRDXRR = 44, WeeklyXRDFWHM105 = 42,
XRDWeightedAverage = 31, WeeklyXRDSLStks = 43,
JVXRD = 47, WeeklyXRDXRR = 44,
XRDXY = 30 XRDWeightedAverage = 31,
} XRDXY = 30,
} }

View File

@ -5,51 +5,46 @@ 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 CDE2() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false)
public class CDE2 : EAFLoggingUnitTesting
{ {
if (EAFLoggingUnitTesting is null)
throw new Exception();
}
private static CDE2 _EAFLoggingUnitTesting; public CDE2(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false)
internal static CDE2 EAFLoggingUnitTesting => _EAFLoggingUnitTesting; {
}
public CDE2() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false) [ClassInitialize]
{ public static void ClassInitialize(TestContext testContext)
if (_EAFLoggingUnitTesting is null) {
throw new Exception(); if (EAFLoggingUnitTesting is null)
} EAFLoggingUnitTesting = new CDE2(testContext);
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize"));
string[] fileNameAndText = EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName);
File.WriteAllText(fileNameAndText[0], fileNameAndText[1]);
File.WriteAllText(fileNameAndText[2], fileNameAndText[3]);
}
public CDE2(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false) [ClassCleanup()]
{ public static void ClassCleanup()
} {
if (EAFLoggingUnitTesting.Logger is not null)
[ClassInitialize] EAFLoggingUnitTesting.Logger.LogInformation("Cleanup");
public static void ClassInitialize(TestContext testContext) if (EAFLoggingUnitTesting is not null)
{ EAFLoggingUnitTesting.Dispose();
if (_EAFLoggingUnitTesting is null) }
_EAFLoggingUnitTesting = new CDE2(testContext);
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize"));
string[] fileNameAndText = _EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName);
File.WriteAllText(fileNameAndText[0], fileNameAndText[1]);
File.WriteAllText(fileNameAndText[2], fileNameAndText[3]);
}
[ClassCleanup()]
public static void ClassCleanup()
{
if (!(_EAFLoggingUnitTesting.Logger is null))
_EAFLoggingUnitTesting.Logger.LogInformation("Cleanup");
if (!(_EAFLoggingUnitTesting is null))
_EAFLoggingUnitTesting.Dispose();
}
[TestMethod]
public void Staging__v2_36_1__CDE2__()
{
}
[TestMethod]
public void Staging__v2_36_1__CDE2__()
{
} }
} }

View File

@ -7,60 +7,55 @@ 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 CDE3_EQPT() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false)
public class CDE3_EQPT : EAFLoggingUnitTesting
{ {
if (EAFLoggingUnitTesting is null)
throw new Exception();
}
private static CDE3_EQPT _EAFLoggingUnitTesting; public CDE3_EQPT(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false)
internal static CDE3_EQPT EAFLoggingUnitTesting => _EAFLoggingUnitTesting; {
}
public CDE3_EQPT() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false) [ClassInitialize]
{ public static void ClassInitialize(TestContext testContext)
if (_EAFLoggingUnitTesting is null) {
throw new Exception(); if (EAFLoggingUnitTesting is null)
} EAFLoggingUnitTesting = new CDE3_EQPT(testContext);
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize"));
string[] fileNameAndText = EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName);
File.WriteAllText(fileNameAndText[0], fileNameAndText[1]);
File.WriteAllText(fileNameAndText[2], fileNameAndText[3]);
}
public CDE3_EQPT(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false) [ClassCleanup()]
{ public static void ClassCleanup()
} {
if (EAFLoggingUnitTesting.Logger is not null)
[ClassInitialize] EAFLoggingUnitTesting.Logger.LogInformation("Cleanup");
public static void ClassInitialize(TestContext testContext) if (EAFLoggingUnitTesting is not null)
{ EAFLoggingUnitTesting.Dispose();
if (_EAFLoggingUnitTesting is null) }
_EAFLoggingUnitTesting = new CDE3_EQPT(testContext);
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize"));
string[] fileNameAndText = _EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName);
File.WriteAllText(fileNameAndText[0], fileNameAndText[1]);
File.WriteAllText(fileNameAndText[2], fileNameAndText[3]);
}
[ClassCleanup()]
public static void ClassCleanup()
{
if (!(_EAFLoggingUnitTesting.Logger is null))
_EAFLoggingUnitTesting.Logger.LogInformation("Cleanup");
if (!(_EAFLoggingUnitTesting is null))
_EAFLoggingUnitTesting.Dispose();
}
[TestMethod]
public void Staging__v2_36_1__CDE3_EQPT__DownloadRsMFile()
{
string check = "WafrMeas.log|.RsM";
MethodBase methodBase = new StackFrame().GetMethod();
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
string[] fileNameAndJson = _EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
IFileRead fileRead = _EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
}
[TestMethod]
public void Staging__v2_36_1__CDE3_EQPT__DownloadRsMFile()
{
string check = "WafrMeas.log|.RsM";
MethodBase methodBase = new StackFrame().GetMethod();
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
string[] fileNameAndJson = EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
IFileRead fileRead = EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
} }
} }

View File

@ -7,60 +7,55 @@ 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 CDE3() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false)
public class CDE3 : EAFLoggingUnitTesting
{ {
if (EAFLoggingUnitTesting is null)
throw new Exception();
}
private static CDE3 _EAFLoggingUnitTesting; public CDE3(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false)
internal static CDE3 EAFLoggingUnitTesting => _EAFLoggingUnitTesting; {
}
public CDE3() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false) [ClassInitialize]
{ public static void ClassInitialize(TestContext testContext)
if (_EAFLoggingUnitTesting is null) {
throw new Exception(); if (EAFLoggingUnitTesting is null)
} EAFLoggingUnitTesting = new CDE3(testContext);
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize"));
string[] fileNameAndText = EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName);
File.WriteAllText(fileNameAndText[0], fileNameAndText[1]);
File.WriteAllText(fileNameAndText[2], fileNameAndText[3]);
}
public CDE3(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false) [ClassCleanup()]
{ public static void ClassCleanup()
} {
if (EAFLoggingUnitTesting.Logger is not null)
[ClassInitialize] EAFLoggingUnitTesting.Logger.LogInformation("Cleanup");
public static void ClassInitialize(TestContext testContext) if (EAFLoggingUnitTesting is not null)
{ EAFLoggingUnitTesting.Dispose();
if (_EAFLoggingUnitTesting is null) }
_EAFLoggingUnitTesting = new CDE3(testContext);
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize"));
string[] fileNameAndText = _EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName);
File.WriteAllText(fileNameAndText[0], fileNameAndText[1]);
File.WriteAllText(fileNameAndText[2], fileNameAndText[3]);
}
[ClassCleanup()]
public static void ClassCleanup()
{
if (!(_EAFLoggingUnitTesting.Logger is null))
_EAFLoggingUnitTesting.Logger.LogInformation("Cleanup");
if (!(_EAFLoggingUnitTesting is null))
_EAFLoggingUnitTesting.Dispose();
}
[TestMethod]
public void Staging__v2_36_1__CDE3__RsM()
{
string check = "*.RsM";
MethodBase methodBase = new StackFrame().GetMethod();
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
string[] fileNameAndJson = _EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
IFileRead fileRead = _EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
}
[TestMethod]
public void Staging__v2_36_1__CDE3__RsM()
{
string check = "*.RsM";
MethodBase methodBase = new StackFrame().GetMethod();
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
string[] fileNameAndJson = EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
IFileRead fileRead = EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
} }
} }

View File

@ -10,51 +10,46 @@ 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 CDE5() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false)
public class CDE5 : EAFLoggingUnitTesting
{ {
if (EAFLoggingUnitTesting is null)
throw new Exception();
}
private static CDE5 _EAFLoggingUnitTesting; public CDE5(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false)
internal static CDE5 EAFLoggingUnitTesting => _EAFLoggingUnitTesting; {
}
public CDE5() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false) [ClassInitialize]
{ public static void ClassInitialize(TestContext testContext)
if (_EAFLoggingUnitTesting is null) {
throw new Exception(); if (EAFLoggingUnitTesting is null)
} EAFLoggingUnitTesting = new CDE5(testContext);
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize"));
string[] fileNameAndText = EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName);
File.WriteAllText(fileNameAndText[0], fileNameAndText[1]);
File.WriteAllText(fileNameAndText[2], fileNameAndText[3]);
}
public CDE5(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false) [ClassCleanup()]
{ public static void ClassCleanup()
} {
if (EAFLoggingUnitTesting.Logger is not null)
[ClassInitialize] EAFLoggingUnitTesting.Logger.LogInformation("Cleanup");
public static void ClassInitialize(TestContext testContext) if (EAFLoggingUnitTesting is not null)
{ EAFLoggingUnitTesting.Dispose();
if (_EAFLoggingUnitTesting is null) }
_EAFLoggingUnitTesting = new CDE5(testContext);
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize"));
string[] fileNameAndText = _EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName);
File.WriteAllText(fileNameAndText[0], fileNameAndText[1]);
File.WriteAllText(fileNameAndText[2], fileNameAndText[3]);
}
[ClassCleanup()]
public static void ClassCleanup()
{
if (!(_EAFLoggingUnitTesting.Logger is null))
_EAFLoggingUnitTesting.Logger.LogInformation("Cleanup");
if (!(_EAFLoggingUnitTesting is null))
_EAFLoggingUnitTesting.Dispose();
}
[TestMethod]
public void Staging__v2_36_1__CDE5__()
{
}
[TestMethod]
public void Staging__v2_36_1__CDE5__()
{
} }
} }

View File

@ -7,172 +7,167 @@ 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 MET08RESIMAPCDE() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false)
public class MET08RESIMAPCDE : EAFLoggingUnitTesting
{ {
if (EAFLoggingUnitTesting is null)
throw new Exception();
}
private static MET08RESIMAPCDE _EAFLoggingUnitTesting; public MET08RESIMAPCDE(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false)
internal static MET08RESIMAPCDE EAFLoggingUnitTesting => _EAFLoggingUnitTesting; {
}
public MET08RESIMAPCDE() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false) [ClassInitialize]
{ public static void ClassInitialize(TestContext testContext)
if (_EAFLoggingUnitTesting is null) {
throw new Exception(); if (EAFLoggingUnitTesting is null)
} EAFLoggingUnitTesting = new MET08RESIMAPCDE(testContext);
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize"));
string[] fileNameAndText = EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName);
File.WriteAllText(fileNameAndText[0], fileNameAndText[1]);
File.WriteAllText(fileNameAndText[2], fileNameAndText[3]);
}
public MET08RESIMAPCDE(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType, skipEquipmentDictionary: false) [ClassCleanup()]
{ public static void ClassCleanup()
} {
if (EAFLoggingUnitTesting.Logger is not null)
EAFLoggingUnitTesting.Logger.LogInformation("Cleanup");
if (EAFLoggingUnitTesting is not null)
EAFLoggingUnitTesting.Dispose();
}
[ClassInitialize] [TestMethod]
public static void ClassInitialize(TestContext testContext) public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE()
{ {
if (_EAFLoggingUnitTesting is null) string check = "~IsXToOpenInsightMetrologyViewer";
_EAFLoggingUnitTesting = new MET08RESIMAPCDE(testContext); MethodBase methodBase = new StackFrame().GetMethod();
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize")); EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
string[] fileNameAndText = _EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName); string[] fileNameAndJson = EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
File.WriteAllText(fileNameAndText[0], fileNameAndText[1]); Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndText[2], fileNameAndText[3]); File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
} IFileRead fileRead = EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
}
[ClassCleanup()] [TestMethod]
public static void ClassCleanup() public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_()
{ {
if (!(_EAFLoggingUnitTesting.Logger is null)) string check = "~IsXToIQSSi";
_EAFLoggingUnitTesting.Logger.LogInformation("Cleanup"); MethodBase methodBase = new StackFrame().GetMethod();
if (!(_EAFLoggingUnitTesting is null)) EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
_EAFLoggingUnitTesting.Dispose(); string[] fileNameAndJson = EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
} Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
IFileRead fileRead = EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
}
[TestMethod] [TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE() public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE__()
{ {
string check = "~IsXToOpenInsightMetrologyViewer"; 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]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_() public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE___()
{ {
string check = "~IsXToIQSSi"; 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]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE__() public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE____()
{ {
string check = "~IsXToOpenInsight"; 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]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE___() public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_____()
{ {
string check = "~IsXToOpenInsightMetrologyViewerAttachments"; 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]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE____() public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE______()
{ {
string check = "~IsXToAPC"; 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]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_____() public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_______()
{ {
string check = "~IsXToSPaCe"; 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]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE______()
{
string check = "~IsXToArchive";
MethodBase methodBase = new StackFrame().GetMethod();
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
string[] fileNameAndJson = _EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
IFileRead fileRead = _EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
}
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_______()
{
string check = "~IsArchive";
MethodBase methodBase = new StackFrame().GetMethod();
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
string[] fileNameAndJson = _EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
IFileRead fileRead = _EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
}
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE________()
{
string check = "~IsDummy";
MethodBase methodBase = new StackFrame().GetMethod();
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
string[] fileNameAndJson = _EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
IFileRead fileRead = _EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
}
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE________()
{
string check = "~IsDummy";
MethodBase methodBase = new StackFrame().GetMethod();
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
string[] fileNameAndJson = EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);
Assert.IsTrue(fileNameAndJson[1].Contains(check));
File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);
IFileRead fileRead = EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);
Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
} }
} }

View File

@ -8,30 +8,24 @@ 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]
public class CDE3_EQPT
{ {
[TestClass] private static CreateSelfDescription.Staging.v2_36_1.CDE3_EQPT _CDE3_EQPT;
public class CDE3_EQPT
[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{ {
CreateSelfDescription.Staging.v2_36_1.CDE3_EQPT.ClassInitialize(testContext);
private static CreateSelfDescription.Staging.v2_36_1.CDE3_EQPT _CDE3_EQPT; _CDE3_EQPT = CreateSelfDescription.Staging.v2_36_1.CDE3_EQPT.EAFLoggingUnitTesting;
[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
CreateSelfDescription.Staging.v2_36_1.CDE3_EQPT.ClassInitialize(testContext);
_CDE3_EQPT = CreateSelfDescription.Staging.v2_36_1.CDE3_EQPT.EAFLoggingUnitTesting;
}
[TestMethod]
public void Staging__v2_36_1__CDE3_EQPT__DownloadRsMFile()
{
_CDE3_EQPT.Staging__v2_36_1__CDE3_EQPT__DownloadRsMFile();
}
} }
[TestMethod]
public void Staging__v2_36_1__CDE3_EQPT__DownloadRsMFile() => _CDE3_EQPT.Staging__v2_36_1__CDE3_EQPT__DownloadRsMFile();
} }
// dotnet build --runtime win-x64 // dotnet build --runtime win-x64

View File

@ -8,48 +8,44 @@ 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]
public class CDE3
{ {
[TestClass] private static CreateSelfDescription.Staging.v2_36_1.CDE3 _CDE3;
public class CDE3
[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{ {
CreateSelfDescription.Staging.v2_36_1.CDE3.ClassInitialize(testContext);
_CDE3 = CreateSelfDescription.Staging.v2_36_1.CDE3.EAFLoggingUnitTesting;
}
private static CreateSelfDescription.Staging.v2_36_1.CDE3 _CDE3; [TestMethod]
public void Staging__v2_36_1__CDE3__RsM() => _CDE3.Staging__v2_36_1__CDE3__RsM();
[ClassInitialize] [TestMethod]
public static void ClassInitialize(TestContext testContext) public void Staging__v2_36_1__CDE3__RsM643047560320000000__Normal()
{ {
CreateSelfDescription.Staging.v2_36_1.CDE3.ClassInitialize(testContext); DateTime dateTime;
_CDE3 = CreateSelfDescription.Staging.v2_36_1.CDE3.EAFLoggingUnitTesting; string check = "*.RsM";
} _CDE3.Staging__v2_36_1__CDE3__RsM();
MethodBase methodBase = new StackFrame().GetMethod();
[TestMethod] string[] variables = _CDE3.AdaptationTesting.GetVariables(methodBase, check);
public void Staging__v2_36_1__CDE3__RsM() Tuple<string, string[], string[]> pdsf = Helpers.Metrology.GetLogisticsColumnsAndBody(variables[2], variables[4]);
{ IFileRead fileRead = _CDE3.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false);
_CDE3.Staging__v2_36_1__CDE3__RsM(); Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResult = fileRead.ReExtract();
} Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1));
Assert.IsTrue(extractResult.Item3.Length > 0, "extractResult Array Length check!");
[TestMethod] Assert.IsNotNull(extractResult.Item4);
public void Staging__v2_36_1__CDE3__RsM643047560320000000__Normal() Logistics logistics = new(fileRead);
{ dateTime = Adaptation.FileHandlers.RsM.ProcessData.GetDateTime(logistics, string.Empty);
DateTime dateTime; Assert.IsTrue(dateTime == logistics.DateTimeFromSequence);
string check = "*.RsM"; dateTime = Adaptation.FileHandlers.RsM.ProcessData.GetDateTime(logistics, "00:13 09/27/38");
_CDE3.Staging__v2_36_1__CDE3__RsM(); Assert.IsTrue(dateTime == logistics.DateTimeFromSequence);
MethodBase methodBase = new StackFrame().GetMethod(); string logBody = @"
string[] variables = _CDE3.AdaptationTesting.GetVariables(methodBase, check);
Tuple<string, string[], string[]> pdsf = Helpers.Metrology.GetLogisticsColumnsAndBody(variables[2], variables[4]);
IFileRead fileRead = _CDE3.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false);
Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResult = fileRead.ReExtract();
Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1));
Assert.IsTrue(extractResult.Item3.Length > 0, "extractResult Array Length check!");
Assert.IsNotNull(extractResult.Item4);
Logistics logistics = new Logistics(fileRead);
dateTime = Adaptation.FileHandlers.RsM.ProcessData.GetDateTime(logistics, string.Empty);
Assert.IsTrue(dateTime == logistics.DateTimeFromSequence);
dateTime = Adaptation.FileHandlers.RsM.ProcessData.GetDateTime(logistics, "00:13 09/27/38");
Assert.IsTrue(dateTime == logistics.DateTimeFromSequence);
string logBody = @"
RUN [59-478796-3978.1] RUN [59-478796-3978.1]
Recipe LSL_6in \ WACKER2 RESISTIVITY SPEC Recipe LSL_6in \ WACKER2 RESISTIVITY SPEC
EQUIP# ResMap Engineer Engineer EQUIP# ResMap Engineer Engineer
@ -66,25 +62,23 @@ pt# R Th Rs[Ohm/sq@T] Merit
5 -65.0 -44.5 577.0866 69.79 5 -65.0 -44.5 577.0866 69.79
Avg = 577.2195 0.58% SEMI Radial= 0.81% 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!");
Tuple<string, string[], string[]> pdsfNew = Helpers.Metrology.GetLogisticsColumnsAndBody(fileRead, logistics, extractResult, pdsf);
Helpers.Metrology.CompareSave(variables[5], pdsf, pdsfNew);
Assert.IsTrue(pdsf.Item1 == pdsfNew.Item1, "Item1 check!");
string[] json = Helpers.Metrology.GetItem2(pdsf, pdsfNew);
Helpers.Metrology.CompareSaveJSON(variables[5], json);
Assert.IsTrue(json[0] == json[1], "Item2 check!");
string[] join = Helpers.Metrology.GetItem3(pdsf, pdsfNew);
Helpers.Metrology.CompareSaveTSV(variables[5], join);
Assert.IsTrue(join[0] == join[1], "Item3 (Join) check!");
Helpers.Metrology.UpdatePassDirectory(variables[2]);
} }
Assert.IsTrue(logBodyCheck, "Log Body doesn't match!");
Tuple<string, string[], string[]> pdsfNew = Helpers.Metrology.GetLogisticsColumnsAndBody(fileRead, logistics, extractResult, pdsf);
Helpers.Metrology.CompareSave(variables[5], pdsf, pdsfNew);
Assert.IsTrue(pdsf.Item1 == pdsfNew.Item1, "Item1 check!");
string[] json = Helpers.Metrology.GetItem2(pdsf, pdsfNew);
Helpers.Metrology.CompareSaveJSON(variables[5], json);
Assert.IsTrue(json[0] == json[1], "Item2 check!");
string[] join = Helpers.Metrology.GetItem3(pdsf, pdsfNew);
Helpers.Metrology.CompareSaveTSV(variables[5], join);
Assert.IsTrue(join[0] == join[1], "Item3 (Join) check!");
Helpers.Metrology.UpdatePassDirectory(variables[2]);
} }
} }

View File

@ -8,104 +8,74 @@ 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]
public class MET08RESIMAPCDE
{ {
[TestClass] private static CreateSelfDescription.Staging.v2_36_1.MET08RESIMAPCDE _MET08RESIMAPCDE;
public class MET08RESIMAPCDE
[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{ {
CreateSelfDescription.Staging.v2_36_1.MET08RESIMAPCDE.ClassInitialize(testContext);
private static CreateSelfDescription.Staging.v2_36_1.MET08RESIMAPCDE _MET08RESIMAPCDE; _MET08RESIMAPCDE = CreateSelfDescription.Staging.v2_36_1.MET08RESIMAPCDE.EAFLoggingUnitTesting;
[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
CreateSelfDescription.Staging.v2_36_1.MET08RESIMAPCDE.ClassInitialize(testContext);
_MET08RESIMAPCDE = CreateSelfDescription.Staging.v2_36_1.MET08RESIMAPCDE.EAFLoggingUnitTesting;
}
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE()
{
_MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE();
}
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE637710931421087642__Normal()
{
string check = "~IsXToOpenInsightMetrologyViewer";
MethodBase methodBase = new StackFrame().GetMethod();
_MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE();
string[] variables = _MET08RESIMAPCDE.AdaptationTesting.GetVariables(methodBase, check);
Tuple<string, string[], string[]> pdsf = Helpers.Metrology.GetLogisticsColumnsAndBody(variables[2], variables[4]);
IFileRead fileRead = _MET08RESIMAPCDE.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false);
Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResult = fileRead.ReExtract();
Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1));
Assert.IsTrue(extractResult.Item3.Length > 0, "extractResult Array Length check!");
Assert.IsNotNull(extractResult.Item4);
Logistics logistics = new Logistics(fileRead);
Tuple<string, string[], string[]> pdsfNew = Helpers.Metrology.GetLogisticsColumnsAndBody(fileRead, logistics, extractResult, pdsf);
Helpers.Metrology.CompareSave(variables[5], pdsf, pdsfNew);
Assert.IsTrue(pdsf.Item1 == pdsfNew.Item1, "Item1 check!");
string[] json = Helpers.Metrology.GetItem2(pdsf, pdsfNew);
Helpers.Metrology.CompareSaveJSON(variables[5], json);
Assert.IsTrue(json[0] == json[1], "Item2 check!");
string[] join = Helpers.Metrology.GetItem3(pdsf, pdsfNew);
Helpers.Metrology.CompareSaveTSV(variables[5], join);
Assert.IsTrue(join[0] == join[1], "Item3 (Join) check!");
Helpers.Metrology.UpdatePassDirectory(variables[2]);
}
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_()
{
_MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_();
}
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE__()
{
_MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE__();
}
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE___()
{
_MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE___();
}
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE____()
{
_MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE____();
}
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_____()
{
_MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_____();
}
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE______()
{
_MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE______();
}
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_______()
{
_MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_______();
}
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE________()
{
_MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE________();
}
} }
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE() => _MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE();
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE637710931421087642__Normal()
{
string check = "~IsXToOpenInsightMetrologyViewer";
MethodBase methodBase = new StackFrame().GetMethod();
_MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE();
string[] variables = _MET08RESIMAPCDE.AdaptationTesting.GetVariables(methodBase, check);
Tuple<string, string[], string[]> pdsf = Helpers.Metrology.GetLogisticsColumnsAndBody(variables[2], variables[4]);
IFileRead fileRead = _MET08RESIMAPCDE.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false);
Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResult = fileRead.ReExtract();
Assert.IsFalse(string.IsNullOrEmpty(extractResult?.Item1));
Assert.IsTrue(extractResult.Item3.Length > 0, "extractResult Array Length check!");
Assert.IsNotNull(extractResult.Item4);
Logistics logistics = new(fileRead);
Tuple<string, string[], string[]> pdsfNew = Helpers.Metrology.GetLogisticsColumnsAndBody(fileRead, logistics, extractResult, pdsf);
Helpers.Metrology.CompareSave(variables[5], pdsf, pdsfNew);
Assert.IsTrue(pdsf.Item1 == pdsfNew.Item1, "Item1 check!");
string[] json = Helpers.Metrology.GetItem2(pdsf, pdsfNew);
Helpers.Metrology.CompareSaveJSON(variables[5], json);
Assert.IsTrue(json[0] == json[1], "Item2 check!");
string[] join = Helpers.Metrology.GetItem3(pdsf, pdsfNew);
Helpers.Metrology.CompareSaveTSV(variables[5], join);
Assert.IsTrue(join[0] == join[1], "Item3 (Join) check!");
Helpers.Metrology.UpdatePassDirectory(variables[2]);
}
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_() => _MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_();
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE__() => _MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE__();
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE___() => _MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE___();
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE____() => _MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE____();
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_____() => _MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_____();
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE______() => _MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE______();
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_______() => _MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE_______();
[TestMethod]
public void Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE________() => _MET08RESIMAPCDE.Staging__v2_36_1__MET08RESIMAPCDE__MET08RESIMAPCDE________();
} }
// dotnet build --runtime win-x64 // dotnet build --runtime win-x64

View File

@ -9,152 +9,148 @@ 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)
{ {
Tuple<string, string[], string[]> results;
results = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(fileFullName);
Assert.IsFalse(string.IsNullOrEmpty(results.Item1));
Assert.IsTrue(results.Item2.Length > 0, "Column check");
Assert.IsTrue(results.Item3.Length > 0, "Body check");
return results;
}
internal static Tuple<string, string[], string[]> GetLogisticsColumnsAndBody(string fileFullName) internal static Tuple<string, string[], string[]> GetLogisticsColumnsAndBody(string searchDirectory, string searchPattern)
{
Tuple<string, string[], string[]> results;
if (searchPattern.Length > 3 && !searchPattern.Contains('*') && File.Exists(searchPattern))
results = GetLogisticsColumnsAndBody(searchPattern);
else
{ {
Tuple<string, string[], string[]> results; string[] pdsfFiles;
results = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(fileFullName); pdsfFiles = Directory.GetFiles(searchDirectory, searchPattern, SearchOption.TopDirectoryOnly);
Assert.IsFalse(string.IsNullOrEmpty(results.Item1)); if (!pdsfFiles.Any())
Assert.IsTrue(results.Item2.Length > 0, "Column check"); _ = Process.Start("explorer.exe", searchDirectory);
Assert.IsTrue(results.Item3.Length > 0, "Body check"); Assert.IsTrue(pdsfFiles.Any(), "GetFiles check");
return results; results = GetLogisticsColumnsAndBody(pdsfFiles[0]);
} }
Assert.IsFalse(string.IsNullOrEmpty(results.Item1));
Assert.IsTrue(results.Item2.Length > 0, "Column check");
Assert.IsTrue(results.Item3.Length > 0, "Body check");
return results;
}
internal static Tuple<string, string[], string[]> GetLogisticsColumnsAndBody(string searchDirectory, string searchPattern) internal static Tuple<string, string[], string[]> GetLogisticsColumnsAndBody(IFileRead fileRead, Logistics logistics, Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResult, Tuple<string, string[], string[]> pdsf)
{ {
Tuple<string, string[], string[]> results; Tuple<string, string[], string[]> results;
if (searchPattern.Length > 3 && !searchPattern.Contains('*') && File.Exists(searchPattern)) string text = ProcessDataStandardFormat.GetPDSFText(fileRead, logistics, extractResult.Item3, logisticsText: pdsf.Item1);
results = GetLogisticsColumnsAndBody(searchPattern); string[] lines = text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
else results = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(logistics.ReportFullPath, lines);
{ Assert.IsFalse(string.IsNullOrEmpty(results.Item1));
string[] pdsfFiles; Assert.IsTrue(results.Item2.Length > 0, "Column check");
pdsfFiles = Directory.GetFiles(searchDirectory, searchPattern, SearchOption.TopDirectoryOnly); Assert.IsTrue(results.Item3.Length > 0, "Body check");
if (!pdsfFiles.Any()) return results;
Process.Start("explorer.exe", searchDirectory); }
Assert.IsTrue(pdsfFiles.Any(), "GetFiles check");
results = GetLogisticsColumnsAndBody(pdsfFiles[0]);
}
Assert.IsFalse(string.IsNullOrEmpty(results.Item1));
Assert.IsTrue(results.Item2.Length > 0, "Column check");
Assert.IsTrue(results.Item3.Length > 0, "Body check");
return results;
}
internal static Tuple<string, string[], string[]> GetLogisticsColumnsAndBody(IFileRead fileRead, Logistics logistics, Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResult, Tuple<string, string[], string[]> pdsf) internal static string[] GetItem2(Tuple<string, string[], string[]> pdsf, Tuple<string, string[], string[]> pdsfNew)
{ {
Tuple<string, string[], string[]> results; JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
string text = ProcessDataStandardFormat.GetPDSFText(fileRead, logistics, extractResult.Item3, logisticsText: pdsf.Item1); string jsonOld = JsonSerializer.Serialize(pdsf.Item2, pdsf.Item2.GetType(), jsonSerializerOptions);
string[] lines = text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); string jsonNew = JsonSerializer.Serialize(pdsfNew.Item2, pdsfNew.Item2.GetType(), jsonSerializerOptions);
results = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(logistics.ReportFullPath, lines); return new string[] { jsonOld, jsonNew };
Assert.IsFalse(string.IsNullOrEmpty(results.Item1)); }
Assert.IsTrue(results.Item2.Length > 0, "Column check");
Assert.IsTrue(results.Item3.Length > 0, "Body check");
return results;
}
internal static string[] GetItem2(Tuple<string, string[], string[]> pdsf, Tuple<string, string[], string[]> pdsfNew) internal static string[] GetItem3(Tuple<string, string[], string[]> pdsf, Tuple<string, string[], string[]> pdsfNew)
{ {
JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions() { WriteIndented = true }; string joinOld = string.Join(Environment.NewLine, from l in pdsf.Item3 select string.Join('\t', from t in l.Split('\t') where !t.Contains(@"\\") select t));
string jsonOld = JsonSerializer.Serialize(pdsf.Item2, pdsf.Item2.GetType(), jsonSerializerOptions); string joinNew = string.Join(Environment.NewLine, from l in pdsfNew.Item3 select string.Join('\t', from t in l.Split('\t') where !t.Contains(@"\\") select t));
string jsonNew = JsonSerializer.Serialize(pdsfNew.Item2, pdsfNew.Item2.GetType(), jsonSerializerOptions); return new string[] { joinOld, joinNew };
return new string[] { jsonOld, jsonNew }; }
}
internal static string[] GetItem3(Tuple<string, string[], string[]> pdsf, Tuple<string, string[], string[]> pdsfNew) internal static void UpdatePassDirectory(string searchDirectory)
{
DateTime dateTime = DateTime.Now;
try
{ Directory.SetLastWriteTime(searchDirectory, dateTime); }
catch (System.Exception) { }
string ticksDirectory = Path.GetDirectoryName(searchDirectory);
try
{ Directory.SetLastWriteTime(ticksDirectory, dateTime); }
catch (System.Exception) { }
string[] directories = Directory.GetDirectories(searchDirectory, "*", SearchOption.TopDirectoryOnly);
foreach (string directory in directories)
{ {
string joinOld = string.Join(Environment.NewLine, from l in pdsf.Item3 select string.Join('\t', from t in l.Split('\t') where !t.Contains(@"\\") select t));
string joinNew = string.Join(Environment.NewLine, from l in pdsfNew.Item3 select string.Join('\t', from t in l.Split('\t') where !t.Contains(@"\\") select t));
return new string[] { joinOld, joinNew };
}
internal static void UpdatePassDirectory(string searchDirectory)
{
DateTime dateTime = DateTime.Now;
try try
{ Directory.SetLastWriteTime(searchDirectory, dateTime); } { Directory.SetLastWriteTime(directory, dateTime); }
catch (System.Exception) { } catch (System.Exception) { }
string ticksDirectory = Path.GetDirectoryName(searchDirectory);
try
{ Directory.SetLastWriteTime(ticksDirectory, dateTime); }
catch (System.Exception) { }
string[] directories = Directory.GetDirectories(searchDirectory, "*", SearchOption.TopDirectoryOnly);
foreach (string directory in directories)
{
try
{ Directory.SetLastWriteTime(directory, dateTime); }
catch (System.Exception) { }
}
} }
}
internal static string GetFileName(MethodBase methodBase) internal static string GetFileName(MethodBase methodBase)
{
string result;
string connectionName;
string seperator = "__";
string connectionNameAndTicks;
string[] segments = methodBase.Name.Split(new string[] { seperator }, StringSplitOptions.None);
string environment = segments[0];
string rawVersionName = segments[1];
string equipmentTypeDirectory = segments[2];
string ticks = DateTime.Now.Ticks.ToString();
string comment = segments[segments.Length - 1];
string versionName = segments[1].Replace('_', '.');
string before = string.Concat(environment, seperator, rawVersionName, seperator, equipmentTypeDirectory, seperator);
string after = methodBase.Name.Substring(before.Length);
if (after.Length < ticks.Length)
{ {
string result; connectionName = after;
string connectionName;
string seperator = "__";
string connectionNameAndTicks;
string[] segments = methodBase.Name.Split(new string[] { seperator }, StringSplitOptions.None);
string environment = segments[0];
string rawVersionName = segments[1];
string equipmentTypeDirectory = segments[2];
string ticks = DateTime.Now.Ticks.ToString();
string comment = segments[segments.Length - 1];
string versionName = segments[1].Replace('_', '.');
string before = string.Concat(environment, seperator, rawVersionName, seperator, equipmentTypeDirectory, seperator);
string after = methodBase.Name.Substring(before.Length);
if (after.Length < ticks.Length)
{
connectionName = after;
connectionNameAndTicks = ticks;
}
else
{
connectionNameAndTicks = after.Substring(0, after.Length - 2 - comment.Length);
connectionName = connectionNameAndTicks.Substring(0, connectionNameAndTicks.Length - ticks.Length);
ticks = connectionNameAndTicks.Substring(connectionName.Length);
}
result = Path.Combine(environment, equipmentTypeDirectory, versionName, $"{environment}__{rawVersionName}__{equipmentTypeDirectory}__{connectionName}", ticks, $"{connectionName.Replace('_', '-')}.json");
if (result.Contains('/'))
result = string.Concat('/', result);
else
result = string.Concat('\\', result);
return result;
} }
else
internal static void CompareSaveTSV(string textFileDirectory, string[] join)
{ {
if (join[0] != join[1]) connectionNameAndTicks = after.Substring(0, after.Length - 2 - comment.Length);
{ connectionName = connectionNameAndTicks.Substring(0, connectionNameAndTicks.Length - ticks.Length);
Process.Start("explorer.exe", textFileDirectory); ticks = connectionNameAndTicks.Substring(connectionName.Length);
File.WriteAllText(Path.Combine(textFileDirectory, "0.tsv"), join[0]);
File.WriteAllText(Path.Combine(textFileDirectory, "1.tsv"), join[1]);
}
} }
result = Path.Combine(environment, equipmentTypeDirectory, versionName, $"{environment}__{rawVersionName}__{equipmentTypeDirectory}__{connectionName}", ticks, $"{connectionName.Replace('_', '-')}.json");
if (result.Contains('/'))
result = string.Concat('/', result);
else
result = string.Concat('\\', result);
return result;
}
internal static void CompareSaveJSON(string textFileDirectory, string[] json) internal static void CompareSaveTSV(string textFileDirectory, string[] join)
{
if (join[0] != join[1])
{ {
if (json[0] != json[1]) _ = Process.Start("explorer.exe", textFileDirectory);
{ File.WriteAllText(Path.Combine(textFileDirectory, "0.tsv"), join[0]);
Process.Start("explorer.exe", textFileDirectory); File.WriteAllText(Path.Combine(textFileDirectory, "1.tsv"), join[1]);
File.WriteAllText(Path.Combine(textFileDirectory, "0.json"), json[0]);
File.WriteAllText(Path.Combine(textFileDirectory, "1.json"), json[1]);
}
} }
}
internal static void CompareSave(string textFileDirectory, Tuple<string, string[], string[]> pdsf, Tuple<string, string[], string[]> pdsfNew) internal static void CompareSaveJSON(string textFileDirectory, string[] json)
{
if (json[0] != json[1])
{ {
if (pdsf.Item1 != pdsfNew.Item1) _ = Process.Start("explorer.exe", textFileDirectory);
{ File.WriteAllText(Path.Combine(textFileDirectory, "0.json"), json[0]);
Process.Start("explorer.exe", textFileDirectory); File.WriteAllText(Path.Combine(textFileDirectory, "1.json"), json[1]);
File.WriteAllText(Path.Combine(textFileDirectory, "0.dat"), pdsf.Item1);
File.WriteAllText(Path.Combine(textFileDirectory, "1.dat"), pdsfNew.Item1);
}
} }
}
internal static void CompareSave(string textFileDirectory, Tuple<string, string[], string[]> pdsf, Tuple<string, string[], string[]> pdsfNew)
{
if (pdsf.Item1 != pdsfNew.Item1)
{
_ = Process.Start("explorer.exe", textFileDirectory);
File.WriteAllText(Path.Combine(textFileDirectory, "0.dat"), pdsf.Item1);
File.WriteAllText(Path.Combine(textFileDirectory, "1.dat"), pdsfNew.Item1);
}
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +1,24 @@
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;
public AdaptationTesting AdaptationTesting => _AdaptationTesting;
public EAFLoggingUnitTesting(TestContext testContext, Type declaringType, bool skipEquipmentDictionary) :
base(testContext, declaringType)
{ {
if (testContext is null || declaringType is null)
protected readonly AdaptationTesting _AdaptationTesting; _AdaptationTesting = null;
else
public AdaptationTesting AdaptationTesting => _AdaptationTesting; _AdaptationTesting = new AdaptationTesting(testContext, skipEquipmentDictionary);
public EAFLoggingUnitTesting(TestContext testContext, Type declaringType, bool skipEquipmentDictionary) :
base(testContext, declaringType)
{
if (testContext is null || declaringType is null)
_AdaptationTesting = null;
else
_AdaptationTesting = new AdaptationTesting(testContext, skipEquipmentDictionary);
}
public new void Dispose()
{
base.Dispose();
}
} }
public new void Dispose() => base.Dispose();
} }

View File

@ -2,170 +2,167 @@ 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
{ {
LinuxDevelopment,
LinuxProduction,
LinuxStaging,
OSXDevelopment,
OSXProduction,
OSXStaging,
WindowsDevelopment,
WindowsProduction,
WindowsStaging
}
public enum Name public bool DebuggerWasAttachedDuringConstructor { get; private set; }
public bool Development { get; private set; }
public bool Linux { get; private set; }
public bool OSX { get; private set; }
public bool Production { get; private set; }
public bool Staging { get; private set; }
public bool Windows { get; private set; }
public string Profile { get; private set; }
public string AppSettingsFileName { get; private set; }
public string ASPNetCoreEnvironment { get; private set; }
public IsEnvironment(string testCategory)
{
if (testCategory.EndsWith(".json"))
{ {
LinuxDevelopment, Production = testCategory == "appsettings.json";
LinuxProduction, Staging = testCategory.EndsWith(nameof(Staging));
LinuxStaging,
OSXDevelopment,
OSXProduction,
OSXStaging,
WindowsDevelopment,
WindowsProduction,
WindowsStaging
}
public bool DebuggerWasAttachedDuringConstructor { get; private set; }
public bool Development { get; private set; }
public bool Linux { get; private set; }
public bool OSX { get; private set; }
public bool Production { get; private set; }
public bool Staging { get; private set; }
public bool Windows { get; private set; }
public string Profile { get; private set; }
public string AppSettingsFileName { get; private set; }
public string ASPNetCoreEnvironment { get; private set; }
public IsEnvironment(string testCategory)
{
if (testCategory.EndsWith(".json"))
{
Production = testCategory == "appsettings.json";
Staging = testCategory.EndsWith(nameof(Staging));
OSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
Development = testCategory.EndsWith(nameof(Development));
Linux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
Windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
}
else
{
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
OSX = !string.IsNullOrEmpty(testCategory) && testCategory.StartsWith(nameof(OSX));
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
Linux = !string.IsNullOrEmpty(testCategory) && testCategory.StartsWith(nameof(Linux));
Staging = !string.IsNullOrEmpty(testCategory) && testCategory.EndsWith(nameof(Staging));
Windows = !string.IsNullOrEmpty(testCategory) && testCategory.StartsWith(nameof(Windows));
Production = !string.IsNullOrEmpty(testCategory) && testCategory.EndsWith(nameof(Production));
Development = !string.IsNullOrEmpty(testCategory) && testCategory.EndsWith(nameof(Development));
}
Profile = GetProfile();
AppSettingsFileName = GetAppSettingsFileName(processesCount: null);
}
public IsEnvironment(bool isDevelopment, bool isStaging, bool isProduction)
{
Staging = isStaging;
Production = isProduction;
Development = isDevelopment;
OSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX); OSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
Development = testCategory.EndsWith(nameof(Development));
Linux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux); Linux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached; DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
Windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); Windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
Profile = GetProfile();
AppSettingsFileName = GetAppSettingsFileName(processesCount: null);
} }
else
public IsEnvironment(int? processesCount, bool nullASPNetCoreEnvironmentIsDevelopment, bool nullASPNetCoreEnvironmentIsProduction)
{ {
OSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
Linux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached; DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
Windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); OSX = !string.IsNullOrEmpty(testCategory) && testCategory.StartsWith(nameof(OSX));
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
if (nullASPNetCoreEnvironmentIsDevelopment && nullASPNetCoreEnvironmentIsProduction) Linux = !string.IsNullOrEmpty(testCategory) && testCategory.StartsWith(nameof(Linux));
throw new Exception(); Staging = !string.IsNullOrEmpty(testCategory) && testCategory.EndsWith(nameof(Staging));
else if (string.IsNullOrEmpty(ASPNetCoreEnvironment) && nullASPNetCoreEnvironmentIsProduction) Windows = !string.IsNullOrEmpty(testCategory) && testCategory.StartsWith(nameof(Windows));
Production = true; Production = !string.IsNullOrEmpty(testCategory) && testCategory.EndsWith(nameof(Production));
else if (string.IsNullOrEmpty(ASPNetCoreEnvironment) && nullASPNetCoreEnvironmentIsDevelopment) Development = !string.IsNullOrEmpty(testCategory) && testCategory.EndsWith(nameof(Development));
Development = true;
else if (string.IsNullOrEmpty(ASPNetCoreEnvironment) && !nullASPNetCoreEnvironmentIsDevelopment && !nullASPNetCoreEnvironmentIsProduction)
throw new Exception();
else
{
Staging = ASPNetCoreEnvironment is not null && ASPNetCoreEnvironment.EndsWith(nameof(Staging));
Production = ASPNetCoreEnvironment is not null && ASPNetCoreEnvironment.EndsWith(nameof(Production));
Development = ASPNetCoreEnvironment is not null && ASPNetCoreEnvironment.EndsWith(nameof(Development));
}
Profile = GetProfile();
AppSettingsFileName = GetAppSettingsFileName(processesCount);
} }
Profile = GetProfile();
AppSettingsFileName = GetAppSettingsFileName(processesCount: null);
}
private string GetProfile() public IsEnvironment(bool isDevelopment, bool isStaging, bool isProduction)
{
Staging = isStaging;
Production = isProduction;
Development = isDevelopment;
OSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
Linux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
Windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
Profile = GetProfile();
AppSettingsFileName = GetAppSettingsFileName(processesCount: null);
}
public IsEnvironment(int? processesCount, bool nullASPNetCoreEnvironmentIsDevelopment, bool nullASPNetCoreEnvironmentIsProduction)
{
OSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
Linux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
Windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
if (nullASPNetCoreEnvironmentIsDevelopment && nullASPNetCoreEnvironmentIsProduction)
throw new Exception();
else if (string.IsNullOrEmpty(ASPNetCoreEnvironment) && nullASPNetCoreEnvironmentIsProduction)
Production = true;
else if (string.IsNullOrEmpty(ASPNetCoreEnvironment) && nullASPNetCoreEnvironmentIsDevelopment)
Development = true;
else if (string.IsNullOrEmpty(ASPNetCoreEnvironment) && !nullASPNetCoreEnvironmentIsDevelopment && !nullASPNetCoreEnvironmentIsProduction)
throw new Exception();
else
{ {
string result; Staging = ASPNetCoreEnvironment is not null && ASPNetCoreEnvironment.EndsWith(nameof(Staging));
if (Windows && Production) Production = ASPNetCoreEnvironment is not null && ASPNetCoreEnvironment.EndsWith(nameof(Production));
result = nameof(Production); Development = ASPNetCoreEnvironment is not null && ASPNetCoreEnvironment.EndsWith(nameof(Development));
else if (Windows && Staging) }
result = nameof(Staging); Profile = GetProfile();
else if (Windows && Development) AppSettingsFileName = GetAppSettingsFileName(processesCount);
result = nameof(Development); }
else if (Linux && Production)
result = nameof(Name.LinuxProduction); private string GetProfile()
else if (Linux && Staging) {
result = nameof(Name.LinuxStaging); string result;
else if (Linux && Development) if (Windows && Production)
result = nameof(Name.LinuxDevelopment); result = nameof(Production);
else if (OSX && Production) else if (Windows && Staging)
result = nameof(Name.OSXProduction); result = nameof(Staging);
else if (OSX && Staging) else if (Windows && Development)
result = nameof(Name.OSXStaging); result = nameof(Development);
else if (OSX && Development) else if (Linux && Production)
result = nameof(Name.OSXDevelopment); result = nameof(Name.LinuxProduction);
else if (Linux && Staging)
result = nameof(Name.LinuxStaging);
else if (Linux && Development)
result = nameof(Name.LinuxDevelopment);
else if (OSX && Production)
result = nameof(Name.OSXProduction);
else if (OSX && Staging)
result = nameof(Name.OSXStaging);
else if (OSX && Development)
result = nameof(Name.OSXDevelopment);
else
throw new Exception();
return result;
}
private string GetAppSettingsFileName(int? processesCount)
{
string result;
if (Production)
{
if (processesCount is null)
result = "appsettings.json";
else
result = $"appsettings.{processesCount}.json";
}
else
{
string environment;
if (Staging)
environment = nameof(Staging);
else if (Development)
environment = nameof(Development);
else else
throw new Exception(); throw new Exception();
return result; if (processesCount is null)
} result = $"appsettings.{environment}.json";
private string GetAppSettingsFileName(int? processesCount)
{
string result;
if (Production)
{
if (processesCount is null)
result = "appsettings.json";
else
result = $"appsettings.{processesCount}.json";
}
else else
{ result = $"appsettings.{environment}.{processesCount}.json";
string environment;
if (Staging)
environment = nameof(Staging);
else if (Development)
environment = nameof(Development);
else
throw new Exception();
if (processesCount is null)
result = $"appsettings.{environment}.json";
else
result = $"appsettings.{environment}.{processesCount}.json";
}
return result;
}
public static string GetEnvironmentName(IsEnvironment isEnvironment)
{
string result;
if (isEnvironment.Windows)
result = nameof(IsEnvironment.Windows);
else if (isEnvironment.Linux)
result = nameof(IsEnvironment.Linux);
else if (isEnvironment.OSX)
result = nameof(IsEnvironment.OSX);
else
throw new Exception();
return result;
} }
return result;
}
public static string GetEnvironmentName(IsEnvironment isEnvironment)
{
string result;
if (isEnvironment.Windows)
result = nameof(IsEnvironment.Windows);
else if (isEnvironment.Linux)
result = nameof(IsEnvironment.Linux);
else if (isEnvironment.OSX)
result = nameof(IsEnvironment.OSX);
else
throw new Exception();
return result;
} }
} }

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