From 47f8f8b93e3156904307ed6141fa38144059cbf5 Mon Sep 17 00:00:00 2001 From: MatthiasSort Date: Thu, 2 Nov 2023 10:24:29 +0100 Subject: [PATCH] Rollback new logic for GetSqlSourceSchema and bump version to 10.0.9 --- ...aIntegration.Providers.EcomProvider.csproj | 2 +- src/EcomProvider.cs | 27 +++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/Dynamicweb.DataIntegration.Providers.EcomProvider.csproj b/src/Dynamicweb.DataIntegration.Providers.EcomProvider.csproj index 1c7fc61..4cc25e2 100644 --- a/src/Dynamicweb.DataIntegration.Providers.EcomProvider.csproj +++ b/src/Dynamicweb.DataIntegration.Providers.EcomProvider.csproj @@ -1,6 +1,6 @@  - 10.0.8 + 10.0.9 1.0.0.0 Ecom Provider Ecom Provider diff --git a/src/EcomProvider.cs b/src/EcomProvider.cs index 23e5379..63cdbe7 100644 --- a/src/EcomProvider.cs +++ b/src/EcomProvider.cs @@ -2,12 +2,8 @@ using Dynamicweb.DataIntegration.Integration; using Dynamicweb.DataIntegration.Integration.Interfaces; using Dynamicweb.DataIntegration.ProviderHelpers; -using Dynamicweb.Environment; -using Dynamicweb.Extensibility; using Dynamicweb.Extensibility.AddIns; using Dynamicweb.Extensibility.Editors; -using Dynamicweb.Indexing; -using Dynamicweb.Indexing.Repositories; using Dynamicweb.Logging; using Microsoft.CodeAnalysis; using System; @@ -97,9 +93,9 @@ public string RelatedProductGroupsBy } public bool GetRelatedProductGroupsByName { get; set; } - + private string defaultLanguage = null; - [AddInParameter("Default Language"), AddInParameterEditor(typeof(DropDownParameterEditor), "none=true;Tooltip=Set the default language for the imported products"), AddInParameterGroup("Destination"), AddInParameterOrder(10)] + [AddInParameter("Default Language"), AddInParameterEditor(typeof(DropDownParameterEditor), "none=true;Tooltip=Set the default language for the imported products"), AddInParameterGroup("Destination"), AddInParameterOrder(10)] public string DefaultLanguage { get @@ -213,9 +209,9 @@ public override Schema GetOriginalSourceSchema() return GetSchema(false); } - private Schema GetDynamicwebSourceSchema(IEnumerable tableNames) + private Schema GetDynamicwebSourceSchema() { - Schema result = GetSqlSourceSchema(Connection, tableNames); + Schema result = GetSqlSourceSchema(Connection); //set key for AccessUserTable if (UserKeyField != null) { @@ -264,12 +260,21 @@ private Schema GetDynamicwebSourceSchema(IEnumerable tableNames) /// public Schema GetSchema(bool getForDestination) { + Schema result = GetDynamicwebSourceSchema(); List tablestToKeep = new() { "EcomProducts", "EcomManufacturers", "EcomGroups", "EcomVariantGroups", "EcomVariantsOptions", "EcomProductsRelated", "EcomProductItems", "EcomStockUnit", "EcomDetails","EcomProductCategoryFieldValue", "EcomLanguages", "EcomPrices", "EcomAssortmentGroupRelations", "EcomAssortmentPermissions", "EcomAssortmentProductRelations", "EcomAssortments", "EcomAssortmentShopRelations", "EcomVariantOptionsProductRelation"}; - Schema result = GetDynamicwebSourceSchema(tablestToKeep); - + List tablesToRemove = new(); + foreach (Table table in result.GetTables()) + { + if (!tablestToKeep.Contains(table.Name)) + tablesToRemove.Add(table); + } + foreach (Table table in tablesToRemove) + { + result.RemoveTable(table); + } foreach (Table table in result.GetTables()) { switch (table.Name) @@ -957,7 +962,7 @@ private IEnumerable GetDefaultLanguageOptions() var sqlCommand = GetOpenConnection(); var languagesDataAdapter = new SqlDataAdapter("SELECT LanguageID, LanguageCode2, LanguageName FROM EcomLanguages", sqlCommand.Connection); _ = new SqlCommandBuilder(languagesDataAdapter); - var languageDataSet = new DataSet(); + var languageDataSet = new DataSet(); languagesDataAdapter.Fill(languageDataSet); foreach (DataRow row in languageDataSet.Tables[0].Rows) {