ZUGFeRD WEB Service: Auswertung der XML-Konfiguration geändert & ZUGFeRD 2.3.x-Anpassungen

This commit is contained in:
PitzM 2025-07-23 11:54:46 +02:00
parent a40fbe31f9
commit 0b1838282b
5 changed files with 26 additions and 37 deletions

View File

@ -25,6 +25,8 @@
public bool AllowZugferd2x { get; set; } = true;
public bool AllowZugferd23x { get; set; } = true;
public bool AllowPeppolBISBill3x { get; set; } = false;
}

View File

@ -35,12 +35,14 @@ namespace ZUGFeRDRESTService.Controllers
private readonly DigitalData.Modules.Filesystem.File _file;
private readonly PropertyValues _props;
private readonly Dictionary<string, XmlItemProperty> _propertyMap = new Dictionary<string, XmlItemProperty>();
//private readonly Dictionary<string, XmlItemProperty> _propertyMap = new Dictionary<string, XmlItemProperty>();
private readonly List<XmlItemProperty> _propertyMapList = new List<XmlItemProperty>();
private int _MaxFileSizeInMegabytes;
private bool _AllowFacturX;
private bool _AllowXRechnung;
private bool _AllowZugferd2x;
private bool _AllowZugferd23x;
private bool _AllowZugferd10;
private bool _AllowPeppolBISBill3x;
@ -61,7 +63,7 @@ namespace ZUGFeRDRESTService.Controllers
_database = database;
var oGDPictureKey = database.GetGDPictureKey();
var oPropertyMap = database.GetPropertyMap();
var oPropertyMapList = database.GetPropertyMapList();
_zugferd = new ZUGFeRDInterface(_logConfig, oGDPictureKey, new ZugferdOptions()
{
@ -69,31 +71,12 @@ namespace ZUGFeRDRESTService.Controllers
AllowXRechnung_Filename = _AllowXRechnung,
AllowZugferd_1_0_Schema = _AllowZugferd10,
AllowZugferd_2_x_Schema = _AllowZugferd2x,
AllowZugferd_2_3_x_Schema = _AllowZugferd23x,
AllowPeppol_3_x_Schema = _AllowPeppolBISBill3x
});
_props = new PropertyValues(_logConfig);
_logger.Debug("Property Map initial: [{0}] entries found.", oPropertyMap.Count);
if (_AllowZugferd10 == true)
_propertyMap = oPropertyMap.
Where(kv => kv.Value.Specification == ZUGFERD_SPEC_10 || kv.Value.Specification == ZUGFERD_SPEC_DEFAULT).
Concat(_propertyMap).
ToDictionary(kv => kv.Key, kv => kv.Value);
if (_AllowZugferd2x == true)
_propertyMap = oPropertyMap.
Where(kv => kv.Value.Specification == ZUGFERD_SPEC_2x).
Concat(_propertyMap).
ToDictionary(kv => kv.Key, kv => kv.Value);
if (_AllowPeppolBISBill3x == true)
_propertyMap = oPropertyMap.
Where(kv => kv.Value.Specification == UBL_SPEC_21).
Concat(_propertyMap).
ToDictionary(kv => kv.Key, kv => kv.Value);
_logger.Debug("Property Map filtered: [{0}] entries found.", _propertyMap.Count);
_logger.Debug("Property Map list initial: [{0}] entries found.", oPropertyMapList.Count);
_logger.Debug("Validation Controller initialized!");
}
@ -194,7 +177,7 @@ namespace ZUGFeRDRESTService.Controllers
_logger.Info("Detected Specification was: [{0}]", oZugferdResult.Specification);
var oFilteredPropertyMap = _zugferd.FilterPropertyMap(_propertyMap, oZugferdResult.Specification);
var oFilteredPropertyMap = _zugferd.FilterPropertyMap(_propertyMapList, oZugferdResult.Specification);
if (oFilteredPropertyMap.Count == 0)
{

View File

@ -13,7 +13,7 @@ namespace ZUGFeRDRESTService
{
private DigitalData.Modules.Logging.Logger _Logger = null;
private string _gdPictureKey = null;
private Dictionary<string, XmlItemProperty> _propertyMap = null;
private List<XmlItemProperty> _propertyMapList = null;
private LogConfig _logConfig = null;
private string _connString;
@ -48,21 +48,22 @@ namespace ZUGFeRDRESTService
return _gdPictureKey;
}
public Dictionary<string, XmlItemProperty> GetPropertyMap()
public List<XmlItemProperty> GetPropertyMapList()
{
if (_propertyMap == null)
if (_propertyMapList == null)
{
_Logger.Debug("Property map does not exist, creating.");
_Logger.Debug("Property map list does not exist, creating.");
_propertyMap = new Dictionary<string, XmlItemProperty>();
_propertyMapList = new List<XmlItemProperty>();
var oDatatable = MSSQL.GetDatatable(QUERY_GET_PROPERTY_MAP);
_Logger.Debug("Datatable Rows: [{0}]", oDatatable.Rows);
foreach (DataRow oRow in oDatatable.Rows)
{
_propertyMap.Add(oRow["XML_PATH"].ToString(), new XmlItemProperty()
_propertyMapList.Add(new XmlItemProperty()
{
XMLPath = oRow["XML_PATH"].ToString(),
Description = oRow["DESCRIPTION"].ToString(),
TableName = oRow["TABLE_NAME"].ToString(),
TableColumn = oRow["TABLE_COLUMN"].ToString(),
@ -74,14 +75,15 @@ namespace ZUGFeRDRESTService
EN16931_ID = oRow["EN16931_ID"] != null ? oRow["EN16931_ID"].ToString() : "-"
});
}
} else
}
else
{
_Logger.Debug("Property map already exists, returning.");
_Logger.Debug("Property map list already exists, returning.");
}
_Logger.Debug("Returning Property Map with [{0}] entries.", _propertyMap.Count);
_Logger.Debug("Returning Property Map list with [{0}] entries.", _propertyMapList.Count);
return _propertyMap;
return _propertyMapList;
}
}
}

View File

@ -10,6 +10,7 @@ namespace ZUGFeRDRESTService
public MSSQLServer MSSQL { get; set; }
public string GetGDPictureKey();
public Dictionary<String, XmlItemProperty> GetPropertyMap();
public List<XmlItemProperty> GetPropertyMapList();
}
}

View File

@ -21,6 +21,7 @@
"Zugferd": {
"AllowZugferd10": true,
"AllowZugferd2x": false,
"AllowZugferd23x": false,
"AllowFacturX": false,
"AllowXRechnung": false,
"AllowPeppolBISBill3x": false