diff --git a/BMECat.net/BMECat.net.csproj b/BMECat.net/BMECat.net.csproj
index e04b3f6..0bcba73 100644
--- a/BMECat.net/BMECat.net.csproj
+++ b/BMECat.net/BMECat.net.csproj
@@ -5,7 +5,7 @@
Stephan Stapel, stephan@s2-industries.com
Apache-2.0
https://github.com/stephanstapel/BMECat.net
- 4.1.0
+ 4.2.0
Stephan Stapel, s2 industries, 2023
README.md
https://github.com/stephanstapel/BMECat.net
@@ -14,7 +14,7 @@
BMECat.net is a .net open source library that allows you to read and write BMEcat descriptions would be a software component that provides developers with a set of tools and functionalities to manipulate BMEcat files programmatically. This library would enable software applications to easily integrate BMEcat support, allowing for the efficient exchange of product information between different systems and partners. Developers could use this library to parse, create, and modify BMEcat documents, accessing product data in a standardized and structured way. Overall, this library would simplify the development of software applications that rely on BMEcat for product information exchange.
True
snupkg
- 4.1.0.0
+ 4.2.0.0
true
s2industries.BMECat.net
BMECat.net.snk
diff --git a/BMECat.net/BMECatReader12.cs b/BMECat.net/BMECatReader12.cs
index 6d97db8..85bc29c 100644
--- a/BMECat.net/BMECatReader12.cs
+++ b/BMECat.net/BMECatReader12.cs
@@ -128,6 +128,41 @@ internal async static Task LoadAsync(Stream inputStream, BMECatE
mutex.ReleaseMutex();
});
+ // -- map catalog group assignments to products
+ Dictionary> _mappingsMap = new Dictionary>();
+
+ XmlNodeList articleToCatalogGroupMapNodes = doc.DocumentElement.SelectNodes("/BMECAT/T_NEW_CATALOG/ARTICLE_TO_CATALOGGROUP_MAP", nsmgr);
+ Parallel.ForEach(articleToCatalogGroupMapNodes.Cast(), /* new ParallelOptions() { MaxDegreeOfParallelism = 1 }, */
+ async (XmlNode articleToCatalogGroupMapNode) =>
+ {
+ string articleId = XmlUtils.nodeAsString(articleToCatalogGroupMapNode, "./ART_ID", nsmgr);
+
+ mutex.WaitOne();
+ if (!_mappingsMap.ContainsKey(articleId))
+ {
+ _mappingsMap.Add(articleId, new List());
+ }
+
+ _mappingsMap[articleId].Add(new ProductCatalogGroupMapping()
+ {
+ /**
+ * @todo read optional SUPPLIER_IDREF sub structure
+ */
+
+ CatalogGroupId = XmlUtils.nodeAsString(articleToCatalogGroupMapNode, "./CATALOG_GROUP_ID", nsmgr),
+ Order = XmlUtils.nodeAsInt(articleToCatalogGroupMapNode, "./ARTICLE_TO_CATALOGGROUP_MAP_ORDER", nsmgr)
+ });
+ mutex.ReleaseMutex();
+ });
+
+ foreach(Product p in retval.Products)
+ {
+ if (_mappingsMap.ContainsKey(p.No))
+ {
+ p.ProductCatalogGroupMappings = _mappingsMap[p.No];
+ }
+ }
+
return retval;
} // !LoadAsync()
diff --git a/BMECat.net/BMECatReader2005.cs b/BMECat.net/BMECatReader2005.cs
index c7e6ae0..875797f 100644
--- a/BMECat.net/BMECatReader2005.cs
+++ b/BMECat.net/BMECatReader2005.cs
@@ -226,6 +226,51 @@ internal async static Task LoadAsync(Stream inputStream, BMECatE
mutex.ReleaseMutex();
});
+ // -- map catalog group assignments to products
+ Dictionary> _mappingsMap = new Dictionary>();
+
+ // according to the specifiction, ARTICLE_TO_CATALOGGROUP_MAP is still possible with BMECat 2005
+ XmlNodeList productToCatalogGroupMapNodes = doc.DocumentElement.SelectNodes("/bmecat:BMECAT/bmecat:T_NEW_CATALOG/bmecat:ARTICLE_TO_CATALOGGROUP_MAP", nsmgr);
+ string IdSelector = "./bmecat:ART_ID";
+ string mapOrderSelector = "./bmecat:ARTICLE_TO_CATALOGGROUP_MAP_ORDER";
+ if ((productToCatalogGroupMapNodes == null) || (productToCatalogGroupMapNodes.Count == 0))
+ {
+ productToCatalogGroupMapNodes = doc.DocumentElement.SelectNodes("/bmecat:BMECAT/bmecat:T_NEW_CATALOG/bmecat:PRODUCT_TO_CATALOGGROUP_MAP", nsmgr);
+ IdSelector = "./bmecat:PROD_ID";
+ mapOrderSelector = "./bmecat:PRODUCT_TO_CATALOGGROUP_MAP_ORDER";
+ }
+
+ Parallel.ForEach(productToCatalogGroupMapNodes.Cast(), /* new ParallelOptions() { MaxDegreeOfParallelism = 1 }, */
+ async (XmlNode productToCatalogGroupMapNode) =>
+ {
+ string productId = XmlUtils.nodeAsString(productToCatalogGroupMapNode, IdSelector, nsmgr);
+
+ mutex.WaitOne();
+ if (!_mappingsMap.ContainsKey(productId))
+ {
+ _mappingsMap.Add(productId, new List());
+ }
+
+ _mappingsMap[productId].Add(new ProductCatalogGroupMapping()
+ {
+ /**
+ * @todo read optional SUPPLIER_IDREF sub structure
+ */
+
+ CatalogGroupId = XmlUtils.nodeAsString(productToCatalogGroupMapNode, "./bmecat:CATALOG_GROUP_ID", nsmgr),
+ Order = XmlUtils.nodeAsInt(productToCatalogGroupMapNode, mapOrderSelector, nsmgr)
+ });
+ mutex.ReleaseMutex();
+ });
+
+ foreach (Product p in retval.Products)
+ {
+ if (_mappingsMap.ContainsKey(p.No))
+ {
+ p.ProductCatalogGroupMappings = _mappingsMap[p.No];
+ }
+ }
+
Task.WaitAll();
return retval;
diff --git a/BMECat.net/Product.cs b/BMECat.net/Product.cs
index 2c34b6b..c280338 100644
--- a/BMECat.net/Product.cs
+++ b/BMECat.net/Product.cs
@@ -59,6 +59,8 @@ public Product()
public List References { get; set; } = new List();
public EDXF EDXF { get; set; }
public List> ExtendedInformation { get; set; } = new List>();
+ public List ProductCatalogGroupMappings { get; set; } = new List();
+
public Feature GetFeature(string featureName, bool ignoreCase = true, Feature defaultValue = null)
diff --git a/BMECat.net/ProductCatalogGroupMapping.cs b/BMECat.net/ProductCatalogGroupMapping.cs
new file mode 100644
index 0000000..9b87ddc
--- /dev/null
+++ b/BMECat.net/ProductCatalogGroupMapping.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace BMECat.net
+{
+ public class ProductCatalogGroupMapping
+ {
+ public string CatalogGroupId { get; set; }
+ public int? Order { get; set; }
+ }
+}