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

added IParameterVisibility so the provider now hides the add-ins for … #29

Merged
merged 1 commit into from
Mar 12, 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.19</Version>
<Version>10.0.20</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>Ecom Provider</Title>
<Description>Ecom Provider</Description>
Expand Down
40 changes: 30 additions & 10 deletions src/EcomProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
namespace Dynamicweb.DataIntegration.Providers.EcomProvider;

[AddInName("Dynamicweb.DataIntegration.Providers.Provider"), AddInLabel("Ecom Provider"), AddInDescription("Ecom provider"), AddInIgnore(false)]
public class EcomProvider : BaseSqlProvider, IParameterOptions
public class EcomProvider : BaseSqlProvider, IParameterOptions, IParameterVisibility
{
private Schema Schema;
private bool IsFirstJobRun = true;
Expand Down Expand Up @@ -131,13 +131,7 @@ public string DefaultLanguage
{
if (defaultLanguage == null)
{
SqlCommand sqlCommand = new SqlCommand("select top(1) ecomlanguages.LanguageID from ecomlanguages where ecomlanguages.languageisdefault=1", Connection);
if (Connection.State == ConnectionState.Closed)
Connection.Open();
var result = sqlCommand.ExecuteReader();
if (result.Read())
defaultLanguage = (string)result["LanguageID"];
result.Close();
defaultLanguage = Ecommerce.Services.Languages.GetDefaultLanguageId();
}
return defaultLanguage;
}
Expand Down Expand Up @@ -942,7 +936,7 @@ public override bool RunJob(Job job)
var columnMappings = mapping.GetColumnMappings();

if (mapping.Active && columnMappings.Count > 0)
{
{
if (!string.IsNullOrEmpty(Shop))
{
string destinationColumnNameForShopId = MappingExtensions.GetShopIdColumnName(mapping.DestinationTable.Name);
Expand All @@ -953,7 +947,7 @@ public override bool RunJob(Job job)
shopColumnMapping.ScriptType = ScriptType.Constant;
shopColumnMapping.ScriptValue = Shop;
}
}
}

if (IsFirstJobRun)
{
Expand Down Expand Up @@ -1144,5 +1138,31 @@ private SqlCommand GetOpenConnection()
Connection.Open();
return sqlCommand;
}


IEnumerable<string> IParameterVisibility.GetHiddenParameterNames(string parameterName, object parameterValue)
{
var result = new List<string>();
switch (parameterName)
{
case "Default Language":
if (string.IsNullOrEmpty(defaultLanguage) || defaultLanguage.Equals(Ecommerce.Services.Languages.GetDefaultLanguageId(), StringComparison.OrdinalIgnoreCase))
result.Add("Default Language");
break;
case "Source language":
if (string.IsNullOrEmpty(SourceLanguage))
result.Add("Source language");
break;
case "Shop":
if (string.IsNullOrEmpty(Shop))
result.Add("Shop");
break;
case "Source shop":
if (string.IsNullOrEmpty(SourceShop))
result.Add("Source shop");
break;
}
return result;
}
}

Loading