From b5f2e60aa2fcc92ddefb81f2c23f79ab0e3ba7cd Mon Sep 17 00:00:00 2001 From: Dmitriy Benyuk Date: Thu, 16 Nov 2023 12:51:04 +0200 Subject: [PATCH] 13436-LogHowManyRecordsWereImported --- ...aIntegration.Providers.EcomProvider.csproj | 4 ++-- src/EcomDestinationWriter.cs | 22 ++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/Dynamicweb.DataIntegration.Providers.EcomProvider.csproj b/src/Dynamicweb.DataIntegration.Providers.EcomProvider.csproj index 98866fc..36e7b6a 100644 --- a/src/Dynamicweb.DataIntegration.Providers.EcomProvider.csproj +++ b/src/Dynamicweb.DataIntegration.Providers.EcomProvider.csproj @@ -1,6 +1,6 @@  - 10.0.10 + 10.0.11 1.0.0.0 Ecom Provider Ecom Provider @@ -23,7 +23,7 @@ snupkg - + diff --git a/src/EcomDestinationWriter.cs b/src/EcomDestinationWriter.cs index e1ec96b..ccb97fc 100644 --- a/src/EcomDestinationWriter.cs +++ b/src/EcomDestinationWriter.cs @@ -2641,7 +2641,9 @@ public void DeleteExcessFromMainTable(string shop, SqlTransaction transaction, s { sqlCommand.Transaction = transaction; string extraConditions = GetDeleteFromSpecificLanguageExtraCondition(mapping, tempTablePrefix, languageId); - DeleteExcessFromMainTable(mapping, extraConditions, sqlCommand, tempTablePrefix, removeMissingAfterImportDestinationTablesOnly); + var rowsAffected = DeleteExcessFromMainTable(sqlCommand, mapping, extraConditions, tempTablePrefix, removeMissingAfterImportDestinationTablesOnly); + if (rowsAffected > 0) + logger.Log($"The number of deleted rows: {rowsAffected} for the destination {mapping.DestinationTable.Name} table mapping"); } else if (!(mapping.DestinationTable.Name == "EcomGroups" && !_removeFromEcomGroups) && !(mapping.DestinationTable.Name == "EcomVariantGroups" && !_removeFromEcomVariantGroups)) { @@ -2653,11 +2655,15 @@ public void DeleteExcessFromMainTable(string shop, SqlTransaction transaction, s sqlCommand.Transaction = transaction; if (mapping.DestinationTable.Name == "EcomProducts" && deactivateMissing) { - DeactivateMissingProductsInMainTable(mapping, sqlCommand, shop, _defaultLanguageId, hideDeactivatedProducts); + var rowsAffected = DeactivateMissingProductsInMainTable(mapping, sqlCommand, shop, _defaultLanguageId, hideDeactivatedProducts); + if (rowsAffected > 0) + logger.Log($"The number of the deactivated product rows: {rowsAffected}"); } else if (removeMissingAfterImport || removeMissingAfterImportDestinationTablesOnly) { - DeleteExcessFromMainTable(mapping, GetExtraConditions(mapping, shop, null), sqlCommand, tempTablePrefix, removeMissingAfterImportDestinationTablesOnly); + var rowsAffected = DeleteExcessFromMainTable(sqlCommand, mapping, GetExtraConditions(mapping, shop, null), tempTablePrefix, removeMissingAfterImportDestinationTablesOnly); + if (rowsAffected > 0) + logger.Log($"The number of deleted rows: {rowsAffected} for the destination {mapping.DestinationTable.Name} table mapping"); } } } @@ -2672,7 +2678,9 @@ public void DeleteExistingFromMainTable(string shop, SqlTransaction transaction, string tempTablePrefix = "TempTableForBulkImport" + mapping.GetId(); if (HasRowsToImport(mapping, out tempTablePrefix)) { - DeleteExistingFromMainTable(mapping, GetExtraConditions(mapping, shop, languageId), sqlCommand, tempTablePrefix); + var rowsAffected = DeleteExistingFromMainTable(sqlCommand, mapping, GetExtraConditions(mapping, shop, languageId), tempTablePrefix); + if (rowsAffected > 0) + logger.Log($"The number of deleted rows: {rowsAffected} for the destination {mapping.DestinationTable.Name} table mapping"); } } } @@ -2864,7 +2872,11 @@ private void MoveDataToMainTable(Mapping mapping, string tempTablePrefix, SqlTra if (timeout < 360) timeout = 360; sqlCommand.CommandTimeout = timeout; - sqlCommand.ExecuteNonQuery(); + var rowsAffected = sqlCommand.ExecuteNonQuery(); + if (rowsAffected > 0) + { + logger.Log($"The number of rows affected: {rowsAffected} in the {mapping.DestinationTable.Name} table"); + } } catch (Exception ex) {