2023-01-24
This commit is contained in:
.gitignore
.vscode
Adaptation
.editorconfigMESAFIBACKLOG.Tests.csprojappsettings.Development.jsonappsettings.jsonpackage.json
.vscode
Eaf
Core
EquipmentCore
Control
AutoGenerated
ChangeDataCollectionHandler.csDataCollectionRequest.csEquipmentEvent.csEquipmentException.csEquipmentSelfDescription.csGetParameterValuesHandler.csIConnectionControl.csIDataTracingHandler.csIEquipmentCommandService.csIEquipmentControl.csIEquipmentSelfDescriptionBuilder.csIPackage.csISelfDescriptionLookup.csIVirtualParameterValuesHandler.csSetParameterValuesHandler.csTraceRequest.cs
IEquipmentDataCollection.csIPackageSource.csDataCollection
Reporting
SelfDescription
ElementDescription
ParameterTypes
Management
ConfigurationData
CellAutomation
Semiconductor
CellInstances
FileHandlers
APC
Archive
CellInstanceConnectionName.csConvertExcelToJson
Dummy
IQSSi
MoveMatchingFiles
OpenInsight
OpenInsightMetrologyViewer
OpenInsightMetrologyViewerAttachments
Processed
SPaCe
json
Ifx
Eaf
Common
Configuration
EquipmentConnector
File
Component
Configuration
SelfDescription
Infineon
Monitoring
PeerGroup
GCL
Shared
Duplicator
FileRead.csLogistics.csLogistics2.csMethods
Metrology
ParameterType.csProcessDataStandardFormat.csProperties
Test.cs_Tests
CreateSelfDescription
Staging
v2.43.0
Extract
Staging
v2.43.0
Shared
AdaptationTesting.csEAFLoggingUnitTesting.csIsEnvironment.cs
Log
ConsoleLogger.csConsoleProvider.csDebugLogger.csDebugProvider.csFeedbackLogger.csFeedbackProvider.csIFeedback.csLog.cs
LoggingUnitTesting.csMethodBaseName.csPasteSpecialXml
UnitTesting.csStatic
FileHandlers
MESAFIBACKLOG.csprojProperties
README.mdShared
63
Shared/FilePathGeneratorInfo.cs
Normal file
63
Shared/FilePathGeneratorInfo.cs
Normal file
@ -0,0 +1,63 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Shared;
|
||||
|
||||
public class FilePathGeneratorInfo
|
||||
{
|
||||
|
||||
public string To { get; protected set; }
|
||||
public string From { get; protected set; }
|
||||
public bool IsErrorFile { get; protected set; }
|
||||
public string SubFolderPath { get; protected set; }
|
||||
public string FirstDirectory { get; protected set; }
|
||||
public string ReportFullPath { get; protected set; }
|
||||
public string ResolvedFileLocation { get; protected set; }
|
||||
|
||||
public FilePathGeneratorInfo(object originalFilePathGenerator, string reportFullPath, bool isErrorFile, System.Collections.Generic.Dictionary<string, string> fileParameter)
|
||||
{
|
||||
ReportFullPath = reportFullPath;
|
||||
IsErrorFile = isErrorFile;
|
||||
if (originalFilePathGenerator is null || originalFilePathGenerator is not FilePathGenerator original)
|
||||
{
|
||||
FirstDirectory = string.Empty;
|
||||
ResolvedFileLocation = string.Empty;
|
||||
To = string.Empty;
|
||||
From = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
string directorySeparatorChar = Path.DirectorySeparatorChar.ToString();
|
||||
FilePathGenerator filePathGenerator = new(original.FileConnectorConfiguration, reportFullPath, isErrorFile);
|
||||
SubFolderPath = filePathGenerator.GetSubFolderPath();
|
||||
if (string.IsNullOrEmpty(SubFolderPath))
|
||||
FirstDirectory = SubFolderPath;
|
||||
else
|
||||
FirstDirectory = SubFolderPath.Split(Path.DirectorySeparatorChar)[0];
|
||||
ResolvedFileLocation = filePathGenerator.GetTargetFolder();
|
||||
if (string.IsNullOrEmpty(ResolvedFileLocation) && string.IsNullOrEmpty(SubFolderPath))
|
||||
To = string.Empty;
|
||||
else if (string.IsNullOrEmpty(SubFolderPath))
|
||||
To = ResolvedFileLocation;
|
||||
else
|
||||
To = string.Concat(ResolvedFileLocation.Replace(SubFolderPath, string.Empty), Path.DirectorySeparatorChar, FirstDirectory);
|
||||
#if (true)
|
||||
if (string.IsNullOrEmpty(original.FileConnectorConfiguration.DefaultPlaceHolderValue))
|
||||
original.FileConnectorConfiguration.DefaultPlaceHolderValue = "NA";
|
||||
if (fileParameter is not null && fileParameter.Count == 1 && To.Contains(original.FileConnectorConfiguration.DefaultPlaceHolderValue))
|
||||
{
|
||||
foreach (System.Collections.Generic.KeyValuePair<string, string> keyValuePair in fileParameter)
|
||||
To = To.Replace(string.Concat(original.FileConnectorConfiguration.DefaultPlaceHolderValue), keyValuePair.Value);
|
||||
}
|
||||
#endif
|
||||
if (original.FileConnectorConfiguration.SourceFileLocation.EndsWith(directorySeparatorChar))
|
||||
From = string.Concat(original.FileConnectorConfiguration.SourceFileLocation, FirstDirectory);
|
||||
else
|
||||
From = string.Concat(original.FileConnectorConfiguration.SourceFileLocation, Path.DirectorySeparatorChar, FirstDirectory);
|
||||
if (From.EndsWith(directorySeparatorChar) && !To.EndsWith(directorySeparatorChar))
|
||||
To = string.Concat(To, Path.DirectorySeparatorChar);
|
||||
else if (To.EndsWith(directorySeparatorChar) && !From.EndsWith(directorySeparatorChar))
|
||||
To = To.Remove(To.Length - 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user