Skip to content

Commit

Permalink
rehandle do and add pdf & bloomberg
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane Royer committed Jan 25, 2022
1 parent 3521f52 commit ee8b530
Show file tree
Hide file tree
Showing 45 changed files with 1,381 additions and 237 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
<None Include="../NugetIcon.png" Pack="true" Visible="false" PackagePath="" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FastMember" Version="1.5.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.8" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="5.0.8" />
<PackageReference Include="system.data.sqlclient" Version="4.8.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="6.0.1" />
<PackageReference Include="system.data.sqlclient" Version="4.8.3" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions src/Paillave.Etl.Autofac/Paillave.Etl.Autofac.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
</ItemGroup>

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Autofac" Version="6.2.0" />
<PackageReference Include="Autofac" Version="6.3.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Paillave.Etl\Paillave.Etl.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using Paillave.Etl.TextFile;
using System.Linq.Expressions;
using Paillave.Etl.Core.Mapping;

namespace Paillave.Etl.TextFile
namespace Paillave.Etl.Bloomberg
{
public class BloombergResult<TParsed>
{
Expand All @@ -23,19 +26,19 @@ public class BloombergValuesProviderArgs<TParsed>
}
public static class BloombergValuesProvider
{
public static BloombergValuesProvider<TParsed> Create<TParsed>(FlatFileDefinition<TParsed> mapping)
public static BloombergValuesProvider<TParsed> Create<TParsed>(Expression<Func<IFieldMapper, TParsed>> expression)
{
return new BloombergValuesProvider<TParsed>(new BloombergValuesProviderArgs<TParsed>
{
Mapping = mapping,
Mapping = new FlatFileDefinition<TParsed>().WithMap(expression).IsColumnSeparated('|'),
});
}
}
public class BloombergValuesProvider<TParsed> : ValuesProviderBase<IFileValue, BloombergResult<TParsed>>
{
private readonly BloombergValuesProviderArgs<TParsed> _args;
public BloombergValuesProvider(BloombergValuesProviderArgs<TParsed> args) => _args = args;
public override ProcessImpact PerformanceImpact => ProcessImpact.Heavy;
public override ProcessImpact PerformanceImpact => ProcessImpact.Average;
public override ProcessImpact MemoryFootPrint => ProcessImpact.Light;
private enum FileReadState
{
Expand Down Expand Up @@ -71,7 +74,7 @@ public override void PushValues(IFileValue input, Action<BloombergResult<TParsed
else if (line == "START-OF-DATA")
{
currentState = FileReadState.Data;
lineSerializer = _args.Mapping.IsColumnSeparated('|').GetSerializer(columnCollection);
lineSerializer = _args.Mapping.GetSerializer(columnCollection);
}
break;
case FileReadState.Fields:
Expand Down
33 changes: 33 additions & 0 deletions src/Paillave.Etl.Bloomberg/Paillave.Etl.Bloomberg.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EtlNet.Bloomberg</PackageId>
<Version>2.0.5</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://paillave.github.io/Etl.Net/</PackageProjectUrl>
<PackageTags>ETL .net core SSIS reactive text file bloomberg</PackageTags>
<Product>ETL.net bloomberg files extensions</Product>
<PackageIcon>NugetIcon.png</PackageIcon>
<Description>Extensions for Etl.Net to read bloomberg response files</Description>
<LangVersion>latest</LangVersion>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<None Include="../../README.md" Pack="true" PackagePath=""/>
<None Include="../NugetIcon.png" Pack="true" Visible="false" PackagePath="" />
</ItemGroup>

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Paillave.Etl\Paillave.Etl.csproj" />
<ProjectReference Include="..\Paillave.Etl.TextFile\Paillave.Etl.TextFile.csproj" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions src/Paillave.Etl.Dropbox/Paillave.Etl.Dropbox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Dropbox.Api" Version="6.10.3" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="5.0.0" />
<PackageReference Include="Dropbox.Api" Version="6.22.0" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="6.0.0" />
</ItemGroup>

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
</ItemGroup>

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FastMember" Version="1.5.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.8" />
<PackageReference Include="system.data.sqlclient" Version="4.8.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.1" />
<PackageReference Include="system.data.sqlclient" Version="4.8.3" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Paillave.Etl.ExcelFile/Paillave.Etl.ExcelFile.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</ItemGroup>

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<None Include="../NugetIcon.png" Pack="true" Visible="false" PackagePath="" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

Expand Down Expand Up @@ -47,8 +47,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="5.0.2" />
<PackageReference Include="Terminal.Gui" Version="1.1.1" />
<PackageReference Include="System.Text.Json" Version="6.0.1" />
<PackageReference Include="Terminal.Gui" Version="1.4.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Paillave.Etl.FileSystem/Paillave.Etl.FileSystem.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</ItemGroup>

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</ItemGroup>

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
Expand All @@ -31,7 +31,7 @@

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NJsonSchema" Version="10.4.5" />
<PackageReference Include="NJsonSchema" Version="10.6.6" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions src/Paillave.Etl.Ftp/Paillave.Etl.Ftp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
</ItemGroup>

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Paillave.Etl\Paillave.Etl.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentFTP" Version="34.0.1" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="5.0.0" />
<PackageReference Include="FluentFTP" Version="36.1.0" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="6.0.0" />
</ItemGroup>

</Project>
8 changes: 4 additions & 4 deletions src/Paillave.Etl.Mail/Paillave.Etl.Mail.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="MailKit" Version="2.13.0" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="5.0.0" />
<PackageReference Include="MimeTypes" Version="2.2.0">
<PackageReference Include="MailKit" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="6.0.0" />
<PackageReference Include="MimeTypes" Version="2.2.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
36 changes: 36 additions & 0 deletions src/Paillave.Etl.Pdf/Paillave.Etl.Pdf.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Paillave.EtlNet.Pdf</PackageId>
<Version>2.0.5</Version>
<Authors>Stéphane Royer</Authors>
<Company></Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://paillave.github.io/Etl.Net/</PackageProjectUrl>
<PackageTags>ETL .net core SSIS reactive Pdf file</PackageTags>
<Product>ETL.net PDF files extensions</Product>
<PackageIcon>NugetIcon.png</PackageIcon>
<Description>Pdf files extensions for Etl.Net</Description>
<PackageReleaseNotes>
extensions for Etl.Net to deal with PDF files
</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup>
<None Include="../NugetIcon.png" Pack="true" Visible="false" PackagePath="" />
</ItemGroup>

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="PdfPig" Version="0.1.5" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Paillave.Pdf\Paillave.Pdf.csproj" />
<ProjectReference Include="..\Paillave.Etl\Paillave.Etl.csproj" />
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions src/Paillave.Etl.Pdf/PdfFile.Stream.ex.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Paillave.Etl.Core;
using System;

namespace Paillave.Etl.Pdf
{
public static class PdfFileEx
{
public static IStream<PdfContent> CrossApplyPdfContent(this IStream<IFileValue> stream, string name, Func<PdfRowsValuesProviderArgs, PdfRowsValuesProviderArgs> argsBuilder, bool noParallelisation = false)
=> stream.CrossApply(name, new PdfRowsValuesProvider(argsBuilder(new PdfRowsValuesProviderArgs())), noParallelisation);
}
}
74 changes: 74 additions & 0 deletions src/Paillave.Etl.Pdf/PdfRowsValuesProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using Paillave.Etl.Core;
using System.Collections.Generic;
using System.Threading;
// using Paillave.Etl.ValuesProviders;
using Paillave.Pdf;

namespace Paillave.Etl.Pdf
{
public class PdfRowsValuesProviderArgs
{
public IList<TextTemplate> PatternsToIgnore { get; } = new List<TextTemplate>();
public IList<HeadersSetup> HeadersSetups { get; } = new List<HeadersSetup>();
public PdfRowsValuesProviderArgs AddHeadersSetup(HeadersSetup headersSetup)
{
this.HeadersSetups.Add(headersSetup);
return this;
}
public PdfRowsValuesProviderArgs AddIgnore(Func<TextTemplate, TextTemplate> templateBuilder)
{
this.PatternsToIgnore.Add(templateBuilder(new TextTemplate()));
return this;
}
}
public abstract class PdfContent
{
protected PdfContent(List<string> section, int pageNumber, IFileValue fileValue)
=> (Section, PageNumber, FileValue) = (section, pageNumber, fileValue);
public List<string> Section { get; }
public int PageNumber { get; }
public IFileValue FileValue { get; }
}
public class PdfHeader : PdfContent
{
public PdfHeader(IFileValue fileValue, List<string> section, int pageNumber) : base(section, pageNumber, fileValue) { }
}
public class PdfTable : PdfContent
{
public List<List<List<string>>> Table { get; }
public PdfTable(IFileValue fileValue, List<string> section, int pageNumber, List<List<List<string>>> table) : base(section, pageNumber, fileValue) => (Table) = (table);
}
public class PdfTextLine : PdfContent
{
public string Text { get; }
public int LineNumber { get; }
public PdfTextLine(IFileValue fileValue, List<string> section, int pageNumber, int lineNumber, string text) : base(section, pageNumber, fileValue) => (Text, LineNumber) = (text, lineNumber);
}
public class PdfRowsValuesProvider : ValuesProviderBase<IFileValue, PdfContent>
{
private readonly PdfRowsValuesProviderArgs _args;
public PdfRowsValuesProvider(PdfRowsValuesProviderArgs args) => _args = args;
public override ProcessImpact PerformanceImpact => ProcessImpact.Heavy;
public override ProcessImpact MemoryFootPrint => ProcessImpact.Heavy;
public override void PushValues(IFileValue input, Action<PdfContent> push, CancellationToken cancellationToken, IDependencyResolver resolver, IInvoker invoker)
{
var stream = input.GetContent();
stream.Seek(0, System.IO.SeekOrigin.Begin);
using (var pdfReader = new PdfReader(stream, this._args.PatternsToIgnore, this._args.HeadersSetups))
pdfReader.Read(new PdfProcessor(push, input));
}
private class PdfProcessor : IPdfProcessor
{
private readonly Action<PdfContent> _push;
private readonly IFileValue _fileValue;
public PdfProcessor(Action<PdfContent> push, IFileValue fileValue) => (_push, _fileValue) = (push, fileValue);
public void ProcessLine(string text, int pageNumber, int lineNumber, int lineNumberInParagraph, int lineNumberInPage, List<string> section)
=> _push(new PdfTextLine(_fileValue, section, pageNumber, lineNumber, text));
public void ProcessTable(List<List<List<string>>> table, int pageNumber, List<string> section)
=> _push(new PdfTable(_fileValue, section, pageNumber, table));
public void ProcessHeader(List<string> section, int pageNumber)
=> _push(new PdfHeader(_fileValue, section, pageNumber));
}
}
}
4 changes: 2 additions & 2 deletions src/Paillave.Etl.Sftp/Paillave.Etl.Sftp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="6.0.0" />
<PackageReference Include="SSH.NET" Version="2020.0.1" />
</ItemGroup>

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit ee8b530

Please sign in to comment.