Skip to content
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.8.3</Version>
<Version>10.8.4</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>Ecom Provider</Title>
<Description>Ecom Provider</Description>
Expand Down
34 changes: 27 additions & 7 deletions src/EcomDestinationWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,10 +1134,9 @@ public void Write(Dictionary<string, object> row, Mapping mapping, bool discardD
case "EcomDetails":
WriteDetails(row, columnMappings, dataRow);
break;
case "EcomAssortmentPermissions":
if (!WriteAssortments(row, columnMappings, dataRow))
case "EcomAssortmentPermissions":
if (!WriteAssortments(row, columnMappings, dataRow, mappingColumns, mapping))
{
DataRowsToWrite[GetTableName(mapping.DestinationTable.Name, mapping)].Add(RowAutoId++.ToString(), new List<DataRow>() { dataRow });
return;
}
break;
Expand Down Expand Up @@ -1638,7 +1637,7 @@ private string HandleProductId(Dictionary<string, object> row, Mapping mapping,
return productID;
}

private bool WriteAssortments(Dictionary<string, object> row, Dictionary<string, ColumnMapping> columnMappings, DataRow dataRow)
private bool WriteAssortments(Dictionary<string, object> row, Dictionary<string, ColumnMapping> columnMappings, DataRow dataRow, ColumnMappingCollection mappingColumns, Mapping mapping)
{
ColumnMapping? assortmentIdColumn = null;
if (columnMappings.TryGetValue("AssortmentPermissionAssortmentID", out assortmentIdColumn))
Expand Down Expand Up @@ -1674,10 +1673,31 @@ private bool WriteAssortments(Dictionary<string, object> row, Dictionary<string,
userIDs.AddRange(ExistingUsers.Select("AccessUserID='" + id.Replace("'", "''") + "'").Select(r => Converter.ToString(r["AccessUserID"])));
}
}
foreach (string userID in userIDs.Distinct())
userIDs = userIDs.Distinct().ToList();
if (userIDs.Count > 0)
{
dataRow["AssortmentPermissionAssortmentID"] = assortmentID;
dataRow["AssortmentPermissionAccessUserID"] = userID;
if (userIDs.Count > 1)
{
if (duplicateRowsHandler is not null && duplicateRowsHandler.IsRowDuplicate(mappingColumns.Where(cm => cm.Active), mapping, dataRow, row))
{
return false;
}
var rows = new List<DataRow>();
foreach (string userID in userIDs)
{
DataRow relation = GetDataTableNewRow("EcomAssortmentPermissions");
relation["AssortmentPermissionAssortmentID"] = assortmentID;
relation["AssortmentPermissionAccessUserID"] = userID;
rows.Add(relation);
}
DataRowsToWrite[dataRow.Table.TableName].Add(RowAutoId++.ToString(), rows);
}
else
{
dataRow["AssortmentPermissionAssortmentID"] = assortmentID;
dataRow["AssortmentPermissionAccessUserID"] = userIDs[0];
return true;
}
}
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/EcomProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@
Table? ecomAssortmentPermissionsTable = tables?.Find(t => t.Name == "EcomAssortmentPermissions");
if (ecomAssortmentPermissionsTable != null)
{
ecomAssortmentPermissionsTable.AddColumn(new SqlColumn(("AssortmentPermissionCustomerNumber"), typeof(string), SqlDbType.NVarChar, ecomAssortmentPermissionsTable, -1, false, false, true));
ecomAssortmentPermissionsTable.AddColumn(new SqlColumn(("AssortmentPermissionExternalID"), typeof(string), SqlDbType.NVarChar, ecomAssortmentPermissionsTable, -1, false, false, true));
ecomAssortmentPermissionsTable.AddColumn(new SqlColumn(("AssortmentPermissionCustomerNumber"), typeof(string), SqlDbType.NVarChar, ecomAssortmentPermissionsTable, -1, false, true, true));
ecomAssortmentPermissionsTable.AddColumn(new SqlColumn(("AssortmentPermissionExternalID"), typeof(string), SqlDbType.NVarChar, ecomAssortmentPermissionsTable, -1, false, true, true));
}

return result;
Expand Down Expand Up @@ -604,7 +604,7 @@
case "RepositoriesIndexUpdate":
if (node.HasChildNodes)
{
RepositoriesIndexUpdate = node.FirstChild?.Value ?? "";

Check warning on line 607 in src/EcomProvider.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

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

Check warning on line 607 in src/EcomProvider.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'EcomProvider.RepositoriesIndexUpdate' is obsolete: 'Use Job.RepositoriesIndexSettings'
}
break;
case "DeleteProductsAndGroupForSpecificLanguage":
Expand Down Expand Up @@ -705,7 +705,7 @@
xmlTextWriter.WriteElementString("DefaultLanguage", DefaultLanguage);
xmlTextWriter.WriteElementString("UpdateOnlyExistingProducts", UpdateOnlyExistingProducts.ToString(CultureInfo.CurrentCulture));
xmlTextWriter.WriteElementString("UseStrictPrimaryKeyMatching", UseStrictPrimaryKeyMatching.ToString(CultureInfo.CurrentCulture));
xmlTextWriter.WriteElementString("RepositoriesIndexUpdate", RepositoriesIndexUpdate);

Check warning on line 708 in src/EcomProvider.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'EcomProvider.RepositoriesIndexUpdate' is obsolete: 'Use Job.RepositoriesIndexSettings'
xmlTextWriter.WriteElementString("UpdateOnlyExistingRecords", UpdateOnlyExistingRecords.ToString(CultureInfo.CurrentCulture));
xmlTextWriter.WriteElementString("DeleteIncomingItems", DeleteIncomingItems.ToString(CultureInfo.CurrentCulture));
xmlTextWriter.WriteElementString("DiscardDuplicates", DiscardDuplicates.ToString(CultureInfo.CurrentCulture));
Expand Down Expand Up @@ -1067,15 +1067,15 @@

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

Check warning on line 1070 in src/EcomProvider.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'EcomProvider.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 1076 in src/EcomProvider.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

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

Check warning on line 1078 in src/EcomProvider.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'EcomProvider.RepositoriesIndexUpdate' is obsolete: 'Use Job.RepositoriesIndexSettings'
job.Save();
}
}
Expand Down Expand Up @@ -1116,7 +1116,7 @@
languagesDataAdapter.Fill(dataSet);
foreach (DataRow row in dataSet.Tables[0].Rows)
{
options.Add(new(row["ShopName"].ToString(), row["shopID"]));

Check warning on line 1119 in src/EcomProvider.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

Possible null reference argument for parameter 'label' in 'ParameterOption.ParameterOption(string label, object value)'.
}
return options;
}
Expand All @@ -1131,7 +1131,7 @@
languagesDataAdapter.Fill(languageDataSet);
foreach (DataRow row in languageDataSet.Tables[0].Rows)
{
options.Add(new(row["LanguageName"].ToString(), row["LanguageID"]));

Check warning on line 1134 in src/EcomProvider.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

Possible null reference argument for parameter 'label' in 'ParameterOption.ParameterOption(string label, object value)'.
}
return options;
}
Expand All @@ -1145,7 +1145,7 @@
}


IEnumerable<string> IParameterVisibility.GetHiddenParameterNames(string parameterName, object parameterValue)

Check warning on line 1148 in src/EcomProvider.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

Nullability of reference types in type of parameter 'parameterValue' doesn't match implemented member 'IEnumerable<string> IParameterVisibility.GetHiddenParameterNames(string parameterName, object? parameterValue)' (possibly because of nullability attributes).

Check warning on line 1148 in src/EcomProvider.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

Nullability of reference types in type of parameter 'parameterValue' doesn't match implemented member 'IEnumerable<string> IParameterVisibility.GetHiddenParameterNames(string parameterName, object? parameterValue)' (possibly because of nullability attributes).
{
var result = new List<string>();
switch (parameterName)
Expand Down
Loading