From 6edd2344a8e62b8467ebb3b0f9d8a7e7fedcbaf5 Mon Sep 17 00:00:00 2001 From: Matthias Sebastian Sort Date: Fri, 19 Apr 2024 13:11:08 +0200 Subject: [PATCH] Re-added old override GetColumns() & GetFromTables() so it can handle Groups & asome column stuff on Address --- ...aIntegration.Providers.UserProvider.csproj | 2 +- src/UserSourceReader.cs | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/Dynamicweb.DataIntegration.Providers.UserProvider.csproj b/src/Dynamicweb.DataIntegration.Providers.UserProvider.csproj index 3c78dc6..9a86eb0 100644 --- a/src/Dynamicweb.DataIntegration.Providers.UserProvider.csproj +++ b/src/Dynamicweb.DataIntegration.Providers.UserProvider.csproj @@ -1,6 +1,6 @@  - 10.0.18 + 10.0.19 1.0.0.0 User Provider User Provider diff --git a/src/UserSourceReader.cs b/src/UserSourceReader.cs index 2848e2e..c409e4d 100644 --- a/src/UserSourceReader.cs +++ b/src/UserSourceReader.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Data.SqlClient; using System.Globalization; +using System.Linq; namespace Dynamicweb.DataIntegration.Providers.UserProvider; @@ -176,6 +177,49 @@ private string GetWhereSql() return conditionalsSql; } + protected override string GetColumns() + { + string result = string.Empty; + if (mapping.SourceTable != null && (mapping.SourceTable.Name == "AccessUserGroup" || mapping.SourceTable.Name == "AccessUserAddress")) + { + if (mapping.SourceTable.Name == "AccessUserGroup") + { + result = mapping.GetColumnMappings().Aggregate("", + (current, fm) => (fm.SourceColumn != null) ? + current + "[" + UserProvider.GetOriginalColumnNameForGroups(fm.SourceColumn.Name) + "] AS [" + fm.SourceColumn.Name + "], " : current); + } + else + { + result = mapping.GetColumnMappings().Aggregate("", (current, fm) => (fm.SourceColumn != null) ? + current + (fm.SourceColumn.Name == "AccessUserAddressUserID" ? "CAST([AccessUserAddressUserID] AS NVARCHAR) AS [AccessUserAddressUserID], " : "[" + fm.SourceColumn.Name + "], ") + : current); + } + result = result.Substring(0, result.Length - 2); + } + else + { + return base.GetColumns(); + } + return result; + } + + protected override string GetFromTables() + { + string result = "[" + mapping.SourceTable.SqlSchema + "].[" + mapping.SourceTable.Name + "] "; + switch (mapping.SourceTable.Name) + { + case "AccessUserAddress": + result = result + " INNER JOIN [AccessUser] on [AccessUserAddress].[AccessUserAddressUserID] = [AccessUser].[AccessUserID]"; + break; + case "AccessUserGroup": + result = "[" + mapping.SourceTable.SqlSchema + "].[AccessUser] "; + break; + default: + break; + } + return result; + } + internal static void UpdateExportedDataInDb(SqlConnection connection) { if (_tableNameWhereSqlDictionary.Keys.Count > 0)