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

Added virtual fields OrderDeliveryAddressExternalId, OrderDeliveryAdd… #37

Closed
wants to merge 7 commits into from
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.9.0</Version>
<Version>10.11.0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>Order Provider</Title>
<Description>Order Provider</Description>
Expand All @@ -23,8 +23,8 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dynamicweb.DataIntegration" Version="10.9.4" />
<PackageReference Include="Dynamicweb.Ecommerce" Version="10.8.0" />
<PackageReference Include="Dynamicweb.DataIntegration" Version="10.11.0" />
<PackageReference Include="Dynamicweb.Ecommerce" Version="10.11.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>
</Project>
19 changes: 9 additions & 10 deletions src/OrderDestinationWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,19 @@ public OrderDestinationWriter(Mapping mapping, SqlConnection connection, ILogger
SkipFailingRows = skipFailingRows;
DiscardDuplicates = discardDuplicates;
TempTablePrefix = $"TempTableForBulkImport{mapping.GetId()}";
SqlBulkCopier = new SqlBulkCopy(connection);
SqlBulkCopier.DestinationTableName = mapping.DestinationTable.Name + TempTablePrefix;
SqlBulkCopier.BulkCopyTimeout = 0;
SqlBulkCopier = new SqlBulkCopy(connection)
{
DestinationTableName = mapping.DestinationTable.Name + TempTablePrefix,
BulkCopyTimeout = 0
};
Initialize();
if (connection.State != ConnectionState.Open)
connection.Open();
}

public new void Initialize()
{
List<SqlColumn> destColumns = new();
List<SqlColumn> destColumns = [];
var columnMappings = Mapping.GetColumnMappings();
foreach (ColumnMapping columnMapping in columnMappings.DistinctBy(obj => obj.DestinationColumn.Name))
{
Expand Down Expand Up @@ -112,9 +114,9 @@ internal int MoveDataToMainTable(SqlTransaction sqlTransaction, bool updateOnlyE
// if 10k write table to db, empty table
if (TableToWrite.Rows.Count >= 1000)
{
RowsToWriteCount = RowsToWriteCount + TableToWrite.Rows.Count;
RowsToWriteCount += TableToWrite.Rows.Count;
SkippedFailedRowsCount = SqlBulkCopierWriteToServer(SqlBulkCopier, TableToWrite, SkipFailingRows, Mapping, Logger);
RowsToWriteCount = RowsToWriteCount - SkippedFailedRowsCount;
RowsToWriteCount -= SkippedFailedRowsCount;
TableToWrite.Clear();
if (RowsToWriteCount >= LastLogRowsCount + 10000)
{
Expand All @@ -131,9 +133,6 @@ internal int MoveDataToMainTable(SqlTransaction sqlTransaction, bool updateOnlyE
SqlCommand.CommandText = "if exists (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'" + text + "') AND type in (N'U')) drop table " + text;
SqlCommand.ExecuteNonQuery();
((IDisposable)SqlBulkCopier).Dispose();
if (duplicateRowsHandler != null)
{
duplicateRowsHandler.Dispose();
}
duplicateRowsHandler?.Dispose();
}
}
Loading
Loading