ZUGFeRD Service/WebService: Lesen/Auswertung neue Config-Schalter. GDPicture-Lizenz-Abfrage

This commit is contained in:
PitzM 2025-01-10 10:50:35 +01:00
parent 64c9f14ec9
commit c6756e13aa
11 changed files with 103 additions and 52 deletions

View File

@ -5,6 +5,7 @@ Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Interfaces Imports DigitalData.Modules.Interfaces
Imports DigitalData.Modules.Jobs Imports DigitalData.Modules.Jobs
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Config
Public Class Form1 Public Class Form1
Private _logConfig As LogConfig Private _logConfig As LogConfig
@ -12,6 +13,8 @@ Public Class Form1
Private _firebird As Firebird Private _firebird As Firebird
Private _mssql As MSSQLServer Private _mssql As MSSQLServer
Private _zugferd As ZUGFeRDInterface Private _zugferd As ZUGFeRDInterface
Private _GDPictureVersion As String
Private _GDPictureLizenz As String
Private PropertyMap As New Dictionary(Of String, XmlItemProperty) Private PropertyMap As New Dictionary(Of String, XmlItemProperty)
@ -23,7 +26,10 @@ Public Class Form1
_logger = _logConfig.GetLogger() _logger = _logConfig.GetLogger()
_mssql = New MSSQLServer(_logConfig, My.Settings.MSSQL_CONNECTIONSTRING) _mssql = New MSSQLServer(_logConfig, My.Settings.MSSQL_CONNECTIONSTRING)
_zugferd = New ZUGFeRDInterface(_logConfig, "kG1Qf9PwmqgR8aDmIW2zI_ebj48RzqAJegRxcystEmkbTGQqfkNBdFOXIb6C_A00Ra8zZkrHdfjqzOPXK7kgkF2YDhvrqKfqh4WDug2vOt0qO31IommzkANSuLjZ4zmraoubyEVd25rE3veQ2h_j7tGIoH_LyIHmy24GaXsxdG0yCzIBMdiLbMMMDwcPY-809KeZ83Grv76OVhFvcbBWyYc251vou1N-kGg5_ZlHDgfWoY85gTLRxafjD3KS_i9ARW4BMiy36y8n7UP2jN8kGRnW_04ubpFtfjJqvtsrP_J9D0x7bqV8xtVtT5JI6dpKsVTiMgDCrIcoFSo5gCC1fw9oUopX4TDCkBQttO4-WHBlOeq9dG5Yb0otonVmJKaQA2tP6sMR-lZDs3ql_WI9t91yPWgpssrJUxSHDd27_LMTH_owJIqkF3NOJd9mYQuAv22oNKFYbH8e41pVKb8cT33Y9CgcQ_sy6YDA5PTuIRi67mjKge_nD9rd0IN213Ir9M_EFWqg9e4haWzIdHXQUo0md70kVhPX4UIH_BKJnxEEnFfoFRNMh77bB0N4jkcBEHPl-ghOERv8dOztf4vCnNpzzWvcLD2cqWIm6THy8XGGq9h4hp8aEreRleSMwv9QQAC7mjLwhQ1rBYkpUHlpTjhTLnMwHknl6HH0Z6zzmsgkRKVyfquv94Pd7QbQfZrRka0ss_48pf9p8hAywEn81Q==", New ZUGFeRDInterface.ZugferdOptions) _GDPictureVersion = "11.2024"
_GDPictureLizenz = ConfigDbFunct.GetProductLicense("GDPICTURE", _GDPictureVersion, _logConfig, My.Settings.MSSQL_CONNECTIONSTRING)
_zugferd = New ZUGFeRDInterface(_logConfig, _GDPictureLizenz, New ZUGFeRDInterface.ZugferdOptions)
End Sub End Sub
Private Function LoadPropertyMapFor(Args As WorkerArgs) Private Function LoadPropertyMapFor(Args As WorkerArgs)

View File

@ -48,6 +48,10 @@
<OptionInfer>On</OptionInfer> <OptionInfer>On</OptionInfer>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="DigitalData.Modules.Config, Version=1.2.2.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\DDModules\Config\bin\Debug\DigitalData.Modules.Config.dll</HintPath>
</Reference>
<Reference Include="DigitalData.Modules.Database, Version=2.3.1.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="DigitalData.Modules.Database, Version=2.3.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\DDModules\Database\bin\Debug\DigitalData.Modules.Database.dll</HintPath> <HintPath>..\..\DDModules\Database\bin\Debug\DigitalData.Modules.Database.dll</HintPath>

View File

@ -2,23 +2,30 @@
Public Property Custom As New CustomConfig Public Property Custom As New CustomConfig
Public Property MSSQLConnectionString As String = "" Public Property MSSQLConnectionString As String = ""
Public Property MSSQLEmailOutAccountID As String = 1 Public Property MSSQLEmailOutAccountID As String = 1
Public Property PORTAL_NAME As String = "WISAG-Portal" Public Property PORTAL_NAME As String = "WISAG-Portal"
Public Property JobInterval As Integer = 10 Public Property JobInterval As Integer = 10
Public Property ExceptionEmailAddress As String = "wisag-flow@digitaldata.works" Public Property ExceptionEmailAddress As String = "wisag-flow@digitaldata.works"
Public Property Debug As Boolean = False Public Property Debug As Boolean = False
Public Property WatchDirectory As String = String.Empty Public Property WatchDirectory As String = String.Empty
Public Property SuccessDirectory As String = String.Empty
Public Property ErrorDirectory As String = String.Empty
Public Property OriginalEmailDirectory As String = String.Empty
Public Property RejectedEmailDirectory As String = String.Empty
Public Property AttachmentsSubDirectory As String = String.Empty
Public Property NonZugferdDirectory As String = String.Empty
Public Property SuccessDirectory As String = String.Empty
Public Property ErrorDirectory As String = String.Empty
Public Property OriginalEmailDirectory As String = String.Empty
Public Property RejectedEmailDirectory As String = String.Empty
Public Property AttachmentsSubDirectory As String = String.Empty
Public Property NonZugferdDirectory As String = String.Empty
Public Class CustomConfig Public Class CustomConfig
''' <summary> ''' <summary>
@ -49,9 +56,21 @@
''' </summary> ''' </summary>
Public Property RejectionTemplateId As Integer = 0 Public Property RejectionTemplateId As Integer = 0
''' <summary>
''' Enthält die Version des GDPicture Modules,
''' für das der Lizenzschlüssel aus TBDD_3RD_PARTY_MODULES
''' gelesen werden soll.
''' </summary>
Public Property GDPictureVersion As String = ""
Public Property AllowFacturX As Boolean = False Public Property AllowFacturX As Boolean = False
Public Property AllowXRechnung As Boolean = False Public Property AllowXRechnung As Boolean = False
Public Property AllowZugferd10 As Boolean = True Public Property AllowZugferd10 As Boolean = True
Public Property AllowZugferd2x As Boolean = True Public Property AllowZugferd2x As Boolean = True
Public Property AllowPeppolBISBill3x As Boolean = False
End Class End Class
End Class End Class

View File

@ -52,7 +52,9 @@ Public Class ThreadRunner
.AllowXRechnung = _config.Config.Custom.AllowXRechnung, .AllowXRechnung = _config.Config.Custom.AllowXRechnung,
.AllowZugferd10 = _config.Config.Custom.AllowZugferd10, .AllowZugferd10 = _config.Config.Custom.AllowZugferd10,
.AllowZugferd2x = _config.Config.Custom.AllowZugferd2x, .AllowZugferd2x = _config.Config.Custom.AllowZugferd2x,
.RejectionTemplateId = _config.Config.Custom.RejectionTemplateId .AllowPeppolBISBill3x = _config.Config.Custom.AllowPeppolBISBill3x,
.RejectionTemplateId = _config.Config.Custom.RejectionTemplateId,
.GDPictureVersion = _config.Config.Custom.GDPictureVersion
} }
oArgs = LoadFolderConfig(oArgs) oArgs = LoadFolderConfig(oArgs)
@ -64,6 +66,7 @@ Public Class ThreadRunner
_logger.Debug("MaxAttachmentSizeInMegaBytes: [{0}]", oArgs.MaxAttachmentSizeInMegaBytes) _logger.Debug("MaxAttachmentSizeInMegaBytes: [{0}]", oArgs.MaxAttachmentSizeInMegaBytes)
_logger.Debug("MinFileAgeInMinutes: [{0}]", oArgs.MinFileAgeInMinutes) _logger.Debug("MinFileAgeInMinutes: [{0}]", oArgs.MinFileAgeInMinutes)
_logger.Debug("RejectionTemplateId: [{0}]", oArgs.RejectionTemplateId) _logger.Debug("RejectionTemplateId: [{0}]", oArgs.RejectionTemplateId)
_logger.Debug("GDPictureVersion: [{0}]", oArgs.GDPictureVersion)
_jobArguments = oArgs _jobArguments = oArgs

View File

@ -3,19 +3,30 @@
public class Config public class Config
{ {
public string Name { get; set; } public string Name { get; set; }
public string LogPath { get; set; } public string LogPath { get; set; }
public string MSSQLConnectionString { get; set; } public string MSSQLConnectionString { get; set; }
public string MaxFileSizeInMegabytes { get; set; } public string MaxFileSizeInMegabytes { get; set; }
public string GDPictureVersion { get; set; }
public ZugferdConfig Zugferd { get; set; } public ZugferdConfig Zugferd { get; set; }
} }
public class ZugferdConfig public class ZugferdConfig
{ {
public bool AllowFacturX { get; set; } = false; public bool AllowFacturX { get; set; } = false;
public bool AllowXRechnung { get; set; } = false; public bool AllowXRechnung { get; set; } = false;
public bool AllowZugferd10 { get; set; } = true; public bool AllowZugferd10 { get; set; } = true;
public bool AllowZugferd2x { get; set; } = true; public bool AllowZugferd2x { get; set; } = true;
public bool AllowPeppolBISBill3x { get; set; } = false;
} }
} }

View File

@ -40,6 +40,9 @@ namespace ZUGFeRDRESTService.Controllers
private bool _AllowXRechnung; private bool _AllowXRechnung;
private bool _AllowZugferd2x; private bool _AllowZugferd2x;
private bool _AllowZugferd10; private bool _AllowZugferd10;
private bool _AllowPeppolBISBill3x;
private string _GDPictureVersion;
public ValidationController(ILogging logging, IDatabase database, IConfiguration Config) public ValidationController(ILogging logging, IDatabase database, IConfiguration Config)
{ {
@ -49,21 +52,22 @@ namespace ZUGFeRDRESTService.Controllers
_logger.Debug("Validation Controller initializing"); _logger.Debug("Validation Controller initializing");
_database = database;
var oGDPictureKey = database.GetGDPictureKey();
var oPropertyMap = database.GetPropertyMap();
// Read config file and assign all option flags related to // Read config file and assign all option flags related to
// - Zugferd files // - Zugferd files
// - Filesizes // - Filesizes
ParseConfig(Config); ParseConfig(Config);
_database = database;
var oGDPictureKey = database.GetGDPictureKey();
var oPropertyMap = database.GetPropertyMap();
_zugferd = new ZUGFeRDInterface(_logConfig, oGDPictureKey, new ZugferdOptions() _zugferd = new ZUGFeRDInterface(_logConfig, oGDPictureKey, new ZugferdOptions()
{ {
AllowFacturX_Filename = _AllowFacturX, AllowFacturX_Filename = _AllowFacturX,
AllowXRechnung_Filename = _AllowXRechnung, AllowXRechnung_Filename = _AllowXRechnung,
AllowZugferd_1_0_Schema = _AllowZugferd10, AllowZugferd_1_0_Schema = _AllowZugferd10,
AllowZugferd_2_x_Schema = _AllowZugferd2x AllowZugferd_2_x_Schema = _AllowZugferd2x,
AllowPeppol_3017_Schema = _AllowPeppolBISBill3x
}); });
_props = new PropertyValues(_logConfig); _props = new PropertyValues(_logConfig);
@ -115,6 +119,19 @@ namespace ZUGFeRDRESTService.Controllers
_AllowZugferd10 = true; _AllowZugferd10 = true;
} }
if (!bool.TryParse(oZugferdConfig["AllowPeppolBISBill3x"], out _AllowPeppolBISBill3x))
{
_logger.Info("Configuration AllowPeppolBISBill3x was not set. Using default value [{0}]", false);
_AllowPeppolBISBill3x = false;
}
_GDPictureVersion = oAppConfig["GDPictureVersion"];
if (string.IsNullOrEmpty(_GDPictureVersion))
{
_logger.Info("Configuration GDPictureVersion was not set. Using default value [string.Empty]");
_GDPictureVersion = string.Empty;
}
if (!int.TryParse(oAppConfig["MaxFileSizeInMegabytes"], out _MaxFileSizeInMegabytes)) if (!int.TryParse(oAppConfig["MaxFileSizeInMegabytes"], out _MaxFileSizeInMegabytes))
{ {
_logger.Info("Configuration MaxFileSizeInMegabytes was not set. Using default value [{0}]", MAX_FILE_SIZE_DEFAULT); _logger.Info("Configuration MaxFileSizeInMegabytes was not set. Using default value [{0}]", MAX_FILE_SIZE_DEFAULT);
@ -238,12 +255,17 @@ namespace ZUGFeRDRESTService.Controllers
}; };
// Determine if any errors should be sent in the response // Determine if any errors should be sent in the response
List<string> oErrors = ex.ErrorType switch var oErrors = new List<string>();
switch (ex.ErrorType)
{ {
// Errors contains the list of missing fields case ErrorType.MissingProperties:
ErrorType.MissingProperties => oPropertyResult.MissingProperties, oErrors.AddRange(from item in oPropertyResult.MissingProperties
_ => new List<string>() select item.Description);
}; break;
default:
break;
}
_logger.Info($"Responding with message: [{oMessage}]"); _logger.Info($"Responding with message: [{oMessage}]");
return new ValidationResponse() return new ValidationResponse()

View File

@ -1,14 +1,10 @@
using System; using DigitalData.Modules.Database;
using DigitalData.Modules.Interfaces;
using DigitalData.Modules.Config;
using Microsoft.Extensions.Configuration;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Data.SqlClient; using DigitalData.Modules.Logging;
using System.Linq;
using System.Threading.Tasks;
using DigitalData.Modules.Database;
using DigitalData.Modules.Interfaces;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
namespace ZUGFeRDRESTService namespace ZUGFeRDRESTService
{ {
@ -18,6 +14,11 @@ namespace ZUGFeRDRESTService
private string _gdPictureKey = null; private string _gdPictureKey = null;
private Dictionary<string, XmlItemProperty> _propertyMap = null; private Dictionary<string, XmlItemProperty> _propertyMap = null;
private LogConfig _logConfig = null;
private string _connString;
private string _GDPictureVersion;
private const string QUERY_GET_GDPICTURE_KEY = "SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE'"; private const string QUERY_GET_GDPICTURE_KEY = "SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE'";
private const string QUERY_GET_PROPERTY_MAP = "SELECT * FROM TBDD_ZUGFERD_XML_ITEMS WHERE ACTIVE = 1 ORDER BY XML_PATH"; private const string QUERY_GET_PROPERTY_MAP = "SELECT * FROM TBDD_ZUGFERD_XML_ITEMS WHERE ACTIVE = 1 ORDER BY XML_PATH";
@ -25,12 +26,14 @@ namespace ZUGFeRDRESTService
public Database(ILogging Logging, IConfiguration Config) public Database(ILogging Logging, IConfiguration Config)
{ {
var oLogConfig = Logging.LogConfig; _logConfig = Logging.LogConfig;
var oLogger = Logging.LogConfig.GetLogger(); var oLogger = Logging.LogConfig.GetLogger();
var oAppConfig = Config.GetSection("Config"); var oAppConfig = Config.GetSection("Config");
_connString = oAppConfig["MSSQLConnectionString"];
_GDPictureVersion = oAppConfig["GDPictureVersion"];
oLogger.Debug("Establishing MSSQL Database connection.."); oLogger.Debug("Establishing MSSQL Database connection..");
MSSQL = new MSSQLServer(oLogConfig, oAppConfig["MSSQLConnectionString"]); MSSQL = new MSSQLServer(_logConfig, _connString);
oLogger.Debug("MSSQL Connection: [{0}]", MSSQL.CurrentConnectionString); oLogger.Debug("MSSQL Connection: [{0}]", MSSQL.CurrentConnectionString);
@ -39,8 +42,7 @@ namespace ZUGFeRDRESTService
public string GetGDPictureKey() public string GetGDPictureKey()
{ {
if (_gdPictureKey == null) _gdPictureKey = ConfigDbFunct.GetProductLicense("GDPICTURE", _GDPictureVersion, _logConfig, _connString);
_gdPictureKey = MSSQL.GetScalarValue(QUERY_GET_GDPICTURE_KEY).ToString();
return _gdPictureKey; return _gdPictureKey;
} }

View File

@ -1,7 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace ZUGFeRDRESTService namespace ZUGFeRDRESTService
{ {

View File

@ -1,14 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NLog.Web;
using DigitalData.Modules.Logging;
using System.Reflection;
namespace ZUGFeRDRESTService namespace ZUGFeRDRESTService
{ {

View File

@ -1,15 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using System;
namespace ZUGFeRDRESTService namespace ZUGFeRDRESTService
{ {

View File

@ -22,8 +22,10 @@
"AllowZugferd10": true, "AllowZugferd10": true,
"AllowZugferd2x": false, "AllowZugferd2x": false,
"AllowFacturX": false, "AllowFacturX": false,
"AllowXRechnung": false "AllowXRechnung": false,
"AllowPeppolBISBill3x": false
}, },
"MaxFileSizeInMegabytes": 25 "GDPictureVersion": "",
"MaxFileSizeInMegabytes": 25
} }
} }