Skip to content

Commit

Permalink
chore: update SSH.NET package to version 2024.1.0 and enhance FlatFil…
Browse files Browse the repository at this point in the history
…eDefinition with LinePreProcessor support
  • Loading branch information
Stephane Royer committed Nov 14, 2024
1 parent 0f6e568 commit db671df
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Paillave.Etl.Sftp/Paillave.Etl.Sftp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="7.0.0" allowedVersions="6.0.0" />
<PackageReference Include="SSH.NET" Version="2020.0.2" />
<PackageReference Include="SSH.NET" Version="2024.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Paillave.Etl\Paillave.Etl.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion src/Paillave.Etl.Sftp/SftpFileValueProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected override void Provide(Action<IFileValue> pushFileValue, SftpAdapterCon
pushFileValue(new SftpFileValue(connectionParameters, folder, file.Name, this.Code, this.Name, this.ConnectionName));
}
}
private Renci.SshNet.Sftp.SftpFile[] GetFileList(SftpAdapterConnectionParameters connectionParameters, SftpAdapterProviderParameters providerParameters)
private Renci.SshNet.Sftp.ISftpFile[] GetFileList(SftpAdapterConnectionParameters connectionParameters, SftpAdapterProviderParameters providerParameters)
{
var folder = string.IsNullOrWhiteSpace(connectionParameters.RootFolder) ? (providerParameters.SubFolder ?? "") : Path.Combine(connectionParameters.RootFolder, providerParameters.SubFolder ?? "");
var connectionInfo = connectionParameters.CreateConnectionInfo();
Expand Down
7 changes: 7 additions & 0 deletions src/Paillave.Etl.TextFile/FlatFileDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class FlatFileDefinition<T>
private bool _respectHeaderCase = false;

public int FirstLinesToIgnore { get; private set; }
public Func<string,string>? LinePreProcessor { get; set; }

private IEnumerable<string> GetDefaultColumnNames()
{
return _fieldDefinitions.Select((i, idx) => new { Name = i.ColumnName ?? i.PropertyInfo.Name, DefinedPosition = i.Position, FallbackPosition = idx })
Expand Down Expand Up @@ -51,6 +53,11 @@ public FlatFileDefinition<T> IgnoreFirstLines(int firstLinesToIgnore)
FirstLinesToIgnore = firstLinesToIgnore;
return this;
}
public FlatFileDefinition<T> WithLinePreProcessor(Func<string,string> linePreProcessor)
{
LinePreProcessor = linePreProcessor;
return this;
}
public FlatFileDefinition<T> WithMap(Expression<Func<IFieldMapper, T>> expression)
{
MapperVisitor vis = new MapperVisitor();
Expand Down
5 changes: 4 additions & 1 deletion src/Paillave.Etl.TextFile/FlatFileValuesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ public override void PushValues(IFileValue input, Action<TOut> push, Cancellatio
{
if (cancellationToken.IsCancellationRequested) break;
string line = sr.ReadLine();

if (_args.Mapping.LinePreProcessor != null)
{
line = _args.Mapping.LinePreProcessor(line);
}
if (index == _args.Mapping.FirstLinesToIgnore)
{
lineSerializer = _args.Mapping.GetSerializer(line);
Expand Down
2 changes: 1 addition & 1 deletion src/SharedSettings.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<Version>2.1.33-beta</Version>
<Version>2.1.34-beta</Version>
<PackageIcon>NugetIcon.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Authors>Stéphane Royer</Authors>
Expand Down

0 comments on commit db671df

Please sign in to comment.