Skip to content

Commit

Permalink
Merge pull request #34 from dynamicweb/dbe/21761-Tablemapping-sorting
Browse files Browse the repository at this point in the history
Tablemapping sorting
  • Loading branch information
frederik5480 authored Nov 26, 2024
2 parents 00885ce + 9d07055 commit 9303fe1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/Dynamicweb.DataIntegration.Providers.OrderProvider.csproj
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 @@ private SqlConnection Connection
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 @@ Schema ISource.GetSchema()

public OrderProvider(XmlNode xmlNode)
{
InitTableRelations();

foreach (XmlNode node in xmlNode.ChildNodes)
{
switch (node.Name)
Expand Down Expand Up @@ -304,38 +313,9 @@ public OrderProvider()
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

0 comments on commit 9303fe1

Please sign in to comment.