Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tablemapping sorting #34

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.8.4</Version>
<Version>10.9.0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>Order Provider</Title>
<Description>Order Provider</Description>
Expand All @@ -23,7 +23,7 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dynamicweb.DataIntegration" Version="10.8.0" />
<PackageReference Include="Dynamicweb.DataIntegration" Version="10.9.4" />
<PackageReference Include="Dynamicweb.Ecommerce" Version="10.8.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>
Expand Down
42 changes: 11 additions & 31 deletions src/OrderProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,18 @@
set { connection = value; }
}

private void InitTableRelations()
{
TableRelations.Clear();
TableRelations.Add("EcomOrderLines", ["EcomOrders"]);
}

public OrderProvider(string connectionString)
{
SqlConnectionString = connectionString;
Connection = new SqlConnection(connectionString);
DiscardDuplicates = false;
InitTableRelations();
}

public override void LoadSettings(Job job)
Expand Down Expand Up @@ -163,6 +170,8 @@

public OrderProvider(XmlNode xmlNode)
{
InitTableRelations();

foreach (XmlNode node in xmlNode.ChildNodes)
{
switch (node.Name)
Expand Down Expand Up @@ -304,38 +313,9 @@
public override ISourceReader GetReader(Mapping mapping)
{
return new OrderSourceReader(mapping, Connection, ExportNotExportedOrders, ExportOnlyOrdersWithoutExtID, DoNotExportCarts);
}

public override void OrderTablesInJob(Job job, bool isSourceLookup)
{
MappingCollection tables = new MappingCollection();

var mappings = GetMappingsByName(job.Mappings, "EcomOrders", isSourceLookup);
if (mappings != null)
{
tables.AddRange(mappings);
}
}

mappings = GetMappingsByName(job.Mappings, "EcomOrderLines", isSourceLookup);
if (mappings != null)
{
tables.AddRange(mappings);
}

mappings = GetMappingsByName(job.Mappings, "EcomOrderLineFields", isSourceLookup);
if (mappings != null)
{
tables.AddRange(mappings);
}

mappings = GetMappingsByName(job.Mappings, "EcomOrderLineFieldGroupRelation", isSourceLookup);
if (mappings != null)
{
tables.AddRange(mappings);
}

job.Mappings = tables;
}
public override void OrderTablesInJob(Job job, bool isSource) => OrderTablesByRelations(job, isSource);

internal static List<Mapping> GetMappingsByName(MappingCollection collection, string name, bool isSourceLookup)
{
Expand Down Expand Up @@ -789,7 +769,7 @@
}
}

private string GetValue(ColumnMapping? columnMapping, Dictionary<string, object> row)

Check warning on line 772 in src/OrderProvider.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 772 in src/OrderProvider.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
string result = null;
if (columnMapping != null && (columnMapping.HasScriptWithValue || row.ContainsKey(columnMapping.SourceColumn.Name)))
Expand Down