Ready to test
This commit is contained in:
@ -1,67 +1,63 @@
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
|
||||
namespace Shared
|
||||
namespace Shared;
|
||||
|
||||
public class FilePathGeneratorInfo
|
||||
{
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
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)
|
||||
{
|
||||
ReportFullPath = reportFullPath;
|
||||
IsErrorFile = isErrorFile;
|
||||
if (originalFilePathGenerator is null || !(originalFilePathGenerator is FilePathGenerator))
|
||||
{
|
||||
FirstDirectory = string.Empty;
|
||||
ResolvedFileLocation = string.Empty;
|
||||
To = string.Empty;
|
||||
From = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
string directorySeparatorChar = Path.DirectorySeparatorChar.ToString();
|
||||
FilePathGenerator original = (FilePathGenerator)originalFilePathGenerator;
|
||||
FilePathGenerator filePathGenerator = new FilePathGenerator(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 null) && fileParameter.Count == 1 && To.Contains(original.FileConnectorConfiguration.DefaultPlaceHolderValue))
|
||||
{
|
||||
foreach (var 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);
|
||||
}
|
||||
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