Skip to content

Commit

Permalink
Merge pull request #30 from dynamicweb/mss/19895
Browse files Browse the repository at this point in the history
added logic for setting rowsAffected and handling of empty values for…
  • Loading branch information
frederik5480 authored Jul 30, 2024
2 parents 68467ef + 326b3bf commit daa44ec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/Dynamicweb.DataIntegration.Providers.SqlProvider.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.0.11</Version>
<Version>10.6.0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>SQL Provider</Title>
<Description>SQL Provider</Description>
Expand All @@ -14,7 +14,7 @@
<Copyright>Copyright © 2023 Dynamicweb Software A/S</Copyright>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IncludeSymbols>true</IncludeSymbols>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
Expand All @@ -23,7 +23,7 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dynamicweb.DataIntegration" Version="10.0.19" />
<PackageReference Include="Dynamicweb.DataIntegration" Version="10.6.3" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>
</Project>
16 changes: 13 additions & 3 deletions src/SQLProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public SqlTransaction Transaction
{
get { return _transaction ?? (_transaction = Connection.BeginTransaction("SQLProviderTransaction")); }
}

public SqlProvider()
{
}
Expand Down Expand Up @@ -302,6 +303,7 @@ public override string ValidateDestinationSettings()
}
return "";
}

public override string ValidateSourceSettings()
{
try
Expand Down Expand Up @@ -424,7 +426,6 @@ public override void OverwriteDestinationSchemaToOriginal()
Connection.Close();
}


protected void CommitTransaction()
{
if (_transaction != null)
Expand Down Expand Up @@ -476,8 +477,10 @@ public override bool RunJob(Job job)
while (!reader.IsDone())
{
sourceRow = reader.GetNext();
ProcessInputRow(mapping, sourceRow);
writer.Write(sourceRow);
if (ProcessInputRow(sourceRow, mapping))
{
writer.Write(sourceRow);
}
}
writer.FinishWriting();
writers.Add(writer);
Expand All @@ -495,7 +498,10 @@ public override bool RunJob(Job job)
System.Diagnostics.Debug.WriteLine(DateTime.Now + ": Moving data to main table: " + writer.Mapping.DestinationTable.Name);
int rowsAffected = writer.MoveDataToMainTable(Transaction);
if (rowsAffected > 0)
{
Logger.Log($"The number of rows affected: {rowsAffected} in the {writer.Mapping.DestinationTable.Name} table");
TotalRowsAffected += rowsAffected;
}
}
else
{
Expand All @@ -510,7 +516,10 @@ public override bool RunJob(Job job)
long rowsAffected = writer.DeleteRowsNotInSourceFromMainTable("");
System.Diagnostics.Debug.WriteLine(DateTime.Now + ": excess data Removed from table: " + writer.Mapping.DestinationTable.Name);
if (rowsAffected > 0)
{
Logger.Log($"The number of deleted rows: {rowsAffected} for the destination {writer.Mapping.DestinationTable.Name} table mapping");
TotalRowsAffected += rowsAffected;
}
}
}
CommitTransaction();
Expand Down Expand Up @@ -540,6 +549,7 @@ public override bool RunJob(Job job)
Logger.Log("Import job failed: " + msg);
}
RollbackTransaction();
TotalRowsAffected = 0;
return false;
}
finally
Expand Down

0 comments on commit daa44ec

Please sign in to comment.