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 log4net; using Microsoft.Extensions.Configuration; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Text.Json; namespace Adaptation.FileHandlers.MapEafDrives { public class FileRead : Shared.FileRead, IFileRead { private readonly AppSettings _AppSettings; public FileRead(ISMTP smtp, Dictionary fileParameter, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, IList modelObjectParameters, string equipmentDictionaryName, Dictionary> dummyRuns, bool useCyclicalForDescription, bool isEAFHosted, int hyphenXToArchive, int hyphenIsArchive) : base(new Description(), true, smtp, fileParameter, cellInstanceName, cellInstanceConnectionName, fileConnectorConfiguration, equipmentTypeName, parameterizedModelObjectDefinitionType, modelObjectParameters, equipmentDictionaryName, dummyRuns, useCyclicalForDescription, isEAFHosted, hyphenXToArchive, hyphenIsArchive) { _MinFileLength = 10; _NullData = string.Empty; _Logistics = new Logistics(this); if (_FileParameter is null) throw new Exception(cellInstanceConnectionName); if (_ModelObjectParameterDefinitions is null) throw new Exception(cellInstanceConnectionName); if (isEAFHosted) { ILog log = LogManager.GetLogger(typeof(FileRead)); IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: Debugger.IsAttached, nullASPNetCoreEnvironmentIsProduction: !Debugger.IsAttached); IConfigurationBuilder configurationBuilder = new ConfigurationBuilder() .AddEnvironmentVariables() .AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true); IConfigurationRoot configurationRoot = configurationBuilder.Build(); _AppSettings = new AppSettings(); configurationRoot.Bind(_AppSettings); Drive.MapEafDrives(log, _AppSettings); } } void IFileRead.Move(Tuple> extractResults, Exception exception) { Move(this, extractResults, exception); } void IFileRead.WaitForThread() { WaitForThread(thread: null, threadExceptions: null); } string IFileRead.GetEventDescription() { string result = _Description.GetEventDescription(); return result; } List IFileRead.GetHeaderNames() { List results = _Description.GetHeaderNames(); return results; } string[] IFileRead.Move(Tuple> 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 IFileRead.GetDisplayNamesJsonElement() { Dictionary results = _Description.GetDisplayNamesJsonElement(this); return results; } List IFileRead.GetDescriptions(IFileRead fileRead, List tests, IProcessData processData) { List results = _Description.GetDescriptions(fileRead, _Logistics, tests, processData); return results; } Tuple> IFileRead.GetExtractResult(string reportFullPath, string eventName) { Tuple> 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>(results.Item1, new Test[] { }, JsonSerializer.Deserialize("[]"), results.Item4); if (results.Item3.Length > 0 && _IsEAFHosted) WritePDSF(this, results.Item3); UpdateLastTicksDuration(DateTime.Now.Ticks - dateTime.Ticks); return results; } Tuple> IFileRead.ReExtract() { Tuple> results; List headerNames = _Description.GetHeaderNames(); Dictionary 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) { throw new Exception(string.Concat("Not ", nameof(_IsDuplicator))); } private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) { Tuple> results = new(string.Empty, null, null, new List()); if (reportFullPath is null) { } if (dateTime == DateTime.MinValue) { } return results; } } }