Compare commits

...

4 Commits

9 changed files with 120 additions and 79 deletions

View File

@ -32,9 +32,48 @@ Public Class Form1
_zugferd = New ZUGFeRDInterface(_logConfig, _GDPictureLizenz, New ZUGFeRDInterface.ZugferdOptions)
End Sub
Private Function LoadPropertyMapFor(Args As WorkerArgs)
'Private Function LoadPropertyMapFor(Args As WorkerArgs)
' Try
' Args.PropertyMap.Clear()
' Dim oSQL As String = $"SELECT * FROM TBDD_ZUGFERD_XML_ITEMS WHERE ACTIVE = 1 ORDER BY XML_PATH"
' Dim oResult As DataTable = _mssql.GetDatatable(oSQL)
' For Each oRow As DataRow In oResult.Rows
' Dim xmlPath As String = oRow.Item("XML_PATH")
' Dim tableName = oRow.Item("TABLE_NAME")
' Dim tableColumn = oRow.Item("TABLE_COLUMN")
' Dim description = oRow.Item("DESCRIPTION")
' Dim isRequired = oRow.Item("IS_REQUIRED")
' Dim isGrouped = oRow.Item("IS_GROUPED")
' Dim groupScope = oRow.Item("GROUP_SCOPE")
' Dim specification = oRow.Item("SPECIFICATION")
' Dim oItemType = oRow.Item("ITEM_TYPE")
' Dim oEN16931_ID = oRow.Item("EN16931_ID")
' Args.PropertyMap.Add(xmlPath, New XmlItemProperty() With {
' .Description = description,
' .TableName = tableName,
' .TableColumn = tableColumn,
' .IsRequired = isRequired,
' .IsGrouped = isGrouped,
' .GroupScope = groupScope,
' .Specification = specification,
' .ItemType = oItemType,
' .EN16931_ID = oEN16931_ID
' })
' Next
' Return Args
' Catch ex As Exception
' _logger.Error(ex)
' Return Args
' End Try
'End Function
Private Function LoadPropertyMapListFor(Args As WorkerArgs)
Try
Args.PropertyMap.Clear()
Args.PropertyMapList.Clear()
Dim oSQL As String = $"SELECT * FROM TBDD_ZUGFERD_XML_ITEMS WHERE ACTIVE = 1 ORDER BY XML_PATH"
Dim oResult As DataTable = _mssql.GetDatatable(oSQL)
@ -51,7 +90,8 @@ Public Class Form1
Dim oItemType = oRow.Item("ITEM_TYPE")
Dim oEN16931_ID = oRow.Item("EN16931_ID")
Args.PropertyMap.Add(xmlPath, New XmlItemProperty() With {
Args.PropertyMapList.Add(New XmlItemProperty() With {
.XMLPath = xmlPath,
.Description = description,
.TableName = tableName,
.TableColumn = tableColumn,
@ -97,7 +137,7 @@ Public Class Form1
.RejectionTemplateId = 1,
.MinFileAgeInMinutes = 1
}
args = LoadPropertyMapFor(args)
args = LoadPropertyMapListFor(args)
Dim job As New ImportZUGFeRDFiles(_logConfig, _mssql)
@ -145,9 +185,10 @@ Public Class Form1
.AttachmentsSubDirectory = "Attachments",
.RejectionTemplateId = 1,
.MinFileAgeInMinutes = 1,
.AllowPeppolBISBill3x = True
.AllowPeppolBISBill3x = True,
.AllowZugferd23x = True
}
args = LoadPropertyMapFor(args)
args = LoadPropertyMapListFor(args)
Dim job As New ImportZUGFeRDFiles(_logConfig, _mssql)
@ -168,7 +209,7 @@ Public Class Form1
.AllowXRechnung = True,
.AllowPeppolBISBill3x = True
}
oArgs = LoadPropertyMapFor(oArgs)
oArgs = LoadPropertyMapListFor(oArgs)
Try
If oDialogResult = DialogResult.OK Then
@ -186,9 +227,9 @@ Public Class Form1
oSpecification = ZUGFeRDInterface.ZUGFERD_SPEC_DEFAULT
End If
Dim oPropertyMap = oArgs.PropertyMap.
Where(Function(kv) kv.Value.Specification = oSpecification).
ToDictionary(Function(kv) kv.Key, Function(kv) kv.Value)
Dim oPropertyMap = oArgs.PropertyMapList.
Where(Function(kv) kv.Specification = oSpecification).
ToDictionary(Function(kv) kv.XMLPath, Function(kv) kv)
Dim oResult2 = _zugferd.PropertyValues.CheckPropertyValues(oResult.SchemaObject, oPropertyMap, "test")

View File

@ -71,6 +71,8 @@
Public Property AllowZugferd2x As Boolean = True
Public Property AllowZugferd23x As Boolean = True
Public Property AllowPeppolBISBill3x As Boolean = False
End Class
End Class

View File

@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("Digital Data")>
<Assembly: AssemblyProduct("DDZUGFeRDService")>
<Assembly: AssemblyCopyright("Copyright © 2025")>
<Assembly: AssemblyTrademark("2.9.2.0")>
<Assembly: AssemblyTrademark("2.9.3.0")>
<Assembly: ComVisible(False)>
@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("2.9.2.0")>
<Assembly: AssemblyFileVersion("2.9.2.0")>
<Assembly: AssemblyVersion("2.9.3.0")>
<Assembly: AssemblyFileVersion("2.9.3.0")>

View File

@ -52,13 +52,14 @@ Public Class ThreadRunner
.AllowXRechnung = _config.Config.Custom.AllowXRechnung,
.AllowZugferd10 = _config.Config.Custom.AllowZugferd10,
.AllowZugferd2x = _config.Config.Custom.AllowZugferd2x,
.AllowZugferd23x = _config.Config.Custom.AllowZugferd23x,
.AllowPeppolBISBill3x = _config.Config.Custom.AllowPeppolBISBill3x,
.RejectionTemplateId = _config.Config.Custom.RejectionTemplateId,
.GDPictureVersion = _config.Config.Custom.GDPictureVersion
}
oArgs = LoadFolderConfig(oArgs)
oArgs = LoadPropertyMap(oArgs)
oArgs = LoadPropertyMapListFor(oArgs)
_logger.Debug("Custom Options:")
_logger.Debug("ExceptionEmailAddress: [{0}]", oArgs.ExceptionEmailAddress)
@ -171,36 +172,44 @@ Public Class ThreadRunner
Return pArgs
End Function
Private Function LoadPropertyMap(pArgs As WorkerArgs) As WorkerArgs
Dim oSQL As String = $"SELECT * FROM TBDD_ZUGFERD_XML_ITEMS WHERE ACTIVE = 1 ORDER BY XML_PATH"
Dim oResult As DataTable = _mssql.GetDatatable(oSQL)
Private Function LoadPropertyMapListFor(Args As WorkerArgs) As WorkerArgs
Try
Args.PropertyMapList.Clear()
For Each oRow As DataRow In oResult.Rows
Dim oXmlPath As String = oRow.Item("XML_PATH")
Dim oTableName = oRow.Item("TABLE_NAME")
Dim oTableColumn = oRow.Item("TABLE_COLUMN")
Dim oDescription = oRow.Item("DESCRIPTION")
Dim oIsRequired = oRow.Item("IS_REQUIRED")
Dim oIsGrouped = oRow.Item("IS_GROUPED")
Dim oGroupScope = oRow.Item("GROUP_SCOPE")
Dim oSpecification = oRow.Item("SPECIFICATION")
Dim oItemType = oRow.Item("ITEM_TYPE")
Dim oEN16931Value = oRow.Item("EN16931_ID")
Dim oSQL As String = $"SELECT * FROM TBDD_ZUGFERD_XML_ITEMS WHERE ACTIVE = 1 ORDER BY XML_PATH"
Dim oResult As DataTable = _mssql.GetDatatable(oSQL)
pArgs.PropertyMap.Add(oXmlPath, New XmlItemProperty() With {
.Description = oDescription,
.TableName = oTableName,
.TableColumn = oTableColumn,
.IsRequired = oIsRequired,
.IsGrouped = oIsGrouped,
.GroupScope = oGroupScope,
.Specification = oSpecification,
.XMLPath = oXmlPath.Replace(".Value", ""),
.ItemType = oItemType,
.EN16931_ID = oEN16931Value
})
Next
For Each oRow As DataRow In oResult.Rows
Dim xmlPath As String = oRow.Item("XML_PATH")
Dim tableName = oRow.Item("TABLE_NAME")
Dim tableColumn = oRow.Item("TABLE_COLUMN")
Dim description = oRow.Item("DESCRIPTION")
Dim isRequired = oRow.Item("IS_REQUIRED")
Dim isGrouped = oRow.Item("IS_GROUPED")
Dim groupScope = oRow.Item("GROUP_SCOPE")
Dim specification = oRow.Item("SPECIFICATION")
Dim oItemType = oRow.Item("ITEM_TYPE")
Dim oEN16931_ID = oRow.Item("EN16931_ID")
Return pArgs
Args.PropertyMapList.Add(New XmlItemProperty() With {
.XMLPath = xmlPath,
.Description = description,
.TableName = tableName,
.TableColumn = tableColumn,
.IsRequired = isRequired,
.IsGrouped = isGrouped,
.GroupScope = groupScope,
.Specification = specification,
.ItemType = oItemType,
.EN16931_ID = oEN16931_ID
})
Next
Return Args
Catch ex As Exception
_logger.Error(ex)
Return Args
End Try
End Function
End Class

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