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

Re-added old override GetColumns() & GetFromTables() so it can handle… #27

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.0.18</Version>
<Version>10.0.19</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>User Provider</Title>
<Description>User Provider</Description>
Expand Down
44 changes: 44 additions & 0 deletions src/UserSourceReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Globalization;
using System.Linq;

namespace Dynamicweb.DataIntegration.Providers.UserProvider;

Expand Down Expand Up @@ -160,11 +161,11 @@
conditionalsSql += " AND ";
if (mapping.SourceTable.Name == "AccessUserGroup")
{
conditionalsSql += string.Format("[AccessUser].[AccessUserType] NOT IN ({0})", string.Join(",", User.GetUserTypes(true)));

Check warning on line 164 in src/UserSourceReader.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'User.GetUserTypes(bool, bool)' is obsolete: 'Do not use'

Check warning on line 164 in src/UserSourceReader.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'User.GetUserTypes(bool, bool)' is obsolete: 'Do not use'
}
else
{
conditionalsSql += string.Format("[AccessUser].[AccessUserType] IN ({0})", string.Join(",", User.GetUserTypes(true)));

Check warning on line 168 in src/UserSourceReader.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'User.GetUserTypes(bool, bool)' is obsolete: 'Do not use'

Check warning on line 168 in src/UserSourceReader.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'User.GetUserTypes(bool, bool)' is obsolete: 'Do not use'
}
}
if (mapping.SourceTable.Name == "SystemFieldValue")
Expand All @@ -176,6 +177,49 @@
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)
Expand Down
Loading