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

removed local rowsAffected so it now uses the one from BaseSqlWriter … #39

Merged
merged 2 commits into from
Jul 30, 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.5.0</Version>
<Version>10.6.0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>User Provider</Title>
<Description>User Provider</Description>
Expand All @@ -23,7 +23,7 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dynamicweb.DataIntegration" Version="10.5.0" />
<PackageReference Include="Dynamicweb.DataIntegration" Version="10.6.3" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>
</Project>
8 changes: 0 additions & 8 deletions src/UserDestinationWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ internal class UserDestinationWriter : BaseSqlWriter
private List<int> MappingsWithUpdateUsersByCustomerNumberMode = new List<int>();
private TableCollection _schemaTables = null;

/// <summary>
/// Return rows affected
/// </summary>
internal int RowsAffected
{
get; private set;
}

public UserDestinationWriter(Job job, SqlConnection connection,
bool removeMissingUsers, bool generateUserPasswords, bool encryptUserPasswords, bool removeMissingGroups, bool UseEmailForUsername,
string userKeyField, string mailSubject, string senderEmail, string emailTemplate, bool allowEmail, string destinationGroup, bool deleteOnlyFromGroupsThatAreImportedTo, ILogger logger,
Expand Down
13 changes: 9 additions & 4 deletions src/UserProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using Dynamicweb.Extensibility.AddIns;
using Dynamicweb.Extensibility.Editors;
using Dynamicweb.Logging;
using Dynamicweb.Security.Permissions;
using Dynamicweb.Security.UserManagement;
using Dynamicweb.Security.UserManagement.Common.SystemFields;
using Microsoft.CodeAnalysis;
using System;
Expand Down Expand Up @@ -255,6 +253,7 @@
UserKeyField = "Auto";
DiscardDuplicates = false;
}

public override Schema GetOriginalSourceSchema()
{
List<string> tablestToKeep = new() { "AccessUser", "AccessUserAddress", "AccessUserSecondaryRelation" };
Expand Down Expand Up @@ -477,7 +476,7 @@
case "RepositoriesIndexUpdate":
if (node.HasChildNodes)
{
RepositoriesIndexUpdate = node.FirstChild.Value;

Check warning on line 479 in src/UserProvider.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'UserProvider.RepositoriesIndexUpdate' is obsolete: 'Use Job.RepositoriesIndexSettings'
}
break;
case "SkipFailingRows":
Expand Down Expand Up @@ -540,7 +539,7 @@
xmlTextWriter.WriteElementString("DeleteOnlyFromGroupsThatAreImportedTo", DeleteOnlyFromGroupsThatAreImportedTo.ToString(CultureInfo.CurrentCulture));
xmlTextWriter.WriteElementString("DiscardDuplicates", DiscardDuplicates.ToString(CultureInfo.CurrentCulture));
xmlTextWriter.WriteElementString("ImportUsersBelongExactlyImportGroups", ImportUsersBelongExactlyImportGroups.ToString(CultureInfo.CurrentCulture));
xmlTextWriter.WriteElementString("RepositoriesIndexUpdate", RepositoriesIndexUpdate);

Check warning on line 542 in src/UserProvider.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'UserProvider.RepositoriesIndexUpdate' is obsolete: 'Use Job.RepositoriesIndexSettings'
xmlTextWriter.WriteElementString("SkipFailingRows", SkipFailingRows.ToString(CultureInfo.CurrentCulture));
GetSchema().SaveAsXml(xmlTextWriter);
}
Expand Down Expand Up @@ -568,7 +567,7 @@
DeleteOnlyFromGroupsThatAreImportedTo = newProvider.DeleteOnlyFromGroupsThatAreImportedTo;
DiscardDuplicates = newProvider.DiscardDuplicates;
ImportUsersBelongExactlyImportGroups = newProvider.ImportUsersBelongExactlyImportGroups;
RepositoriesIndexUpdate = newProvider.RepositoriesIndexUpdate;

Check warning on line 570 in src/UserProvider.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'UserProvider.RepositoriesIndexUpdate' is obsolete: 'Use Job.RepositoriesIndexSettings'

Check warning on line 570 in src/UserProvider.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'UserProvider.RepositoriesIndexUpdate' is obsolete: 'Use Job.RepositoriesIndexSettings'
SkipFailingRows = newProvider.SkipFailingRows;
SqlConnectionString = newProvider.SqlConnectionString;
ManualConnectionString = newProvider.ManualConnectionString;
Expand Down Expand Up @@ -706,8 +705,10 @@
while (!reader.IsDone())
{
sourceRow = reader.GetNext();
ProcessInputRow(mapping, sourceRow);
Writer.Write(sourceRow, mapping, discardDuplicates);
if (ProcessInputRow(sourceRow, mapping))
{
Writer.Write(sourceRow, mapping, discardDuplicates);
}
}
}
}
Expand All @@ -720,6 +721,7 @@
sqlTransaction.Commit();
Writer.SendUserPasswords();
MoveRepositoriesIndexToJob(job);
TotalRowsAffected += Writer.RowsAffected;
}
catch (Exception ex)
{
Expand Down Expand Up @@ -748,6 +750,9 @@

if (sqlTransaction != null)
sqlTransaction.Rollback();

TotalRowsAffected = 0;

return false;
}
finally
Expand Down Expand Up @@ -871,15 +876,15 @@

private void MoveRepositoriesIndexToJob(Job job)
{
if (!string.IsNullOrEmpty(RepositoriesIndexUpdate))

Check warning on line 879 in src/UserProvider.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'UserProvider.RepositoriesIndexUpdate' is obsolete: 'Use Job.RepositoriesIndexSettings'
{
char[] separator = [','];
// if the provider already have RepositoriesIndexUpdate set, then we move them to the job, and set the add-in to string.empty
if (job.RepositoriesIndexSettings?.RepositoriesIndexes?.Count == 0)
{
job.RepositoriesIndexSettings = new RepositoriesIndexSettings(new Collection<string>([.. RepositoriesIndexUpdate.Split(separator, StringSplitOptions.RemoveEmptyEntries)]));

Check warning on line 885 in src/UserProvider.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'UserProvider.RepositoriesIndexUpdate' is obsolete: 'Use Job.RepositoriesIndexSettings'
}
RepositoriesIndexUpdate = string.Empty;

Check warning on line 887 in src/UserProvider.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'UserProvider.RepositoriesIndexUpdate' is obsolete: 'Use Job.RepositoriesIndexSettings'
job.Save();
}
}
Expand Down
Loading