Compare commits
6 Commits
538e2fcde1
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 4cfc8cd46b | |||
| dc56d783b3 | |||
| 25e0eddfdb | |||
| 64ae4e9c76 | |||
| 6936d45209 | |||
| 7173c89b77 |
@@ -82,7 +82,7 @@ Public Class GridBuilder
|
||||
ToList()
|
||||
|
||||
For Each oDateCol In oDateColumns
|
||||
SetDateTimeColumn(oDateCol)
|
||||
SetDateTimeColumn(oDateCol, "g")
|
||||
Next
|
||||
End Sub
|
||||
|
||||
@@ -96,19 +96,61 @@ Public Class GridBuilder
|
||||
ToList()
|
||||
|
||||
For Each oDateCol In oDateColumns
|
||||
SetDateTimeColumn(oDateCol)
|
||||
SetDateTimeColumn(oDateCol, "g")
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Sub SetDateTimeColumn(pColumn As GridColumn)
|
||||
''' <summary>
|
||||
''' Applies a proper datetime format string to all columns of the view.
|
||||
''' </summary>
|
||||
''' <remarks>The view's columns need to be loaded for this to work!</remarks>
|
||||
Public Sub SetDateTimeColumns(pView As GridView, pFormatString As String)
|
||||
If pView.Columns Is Nothing Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oDateColumns = pView.Columns.AsEnumerable.
|
||||
Where(Function(column As GridColumn) column.ColumnType = GetType(Date)).
|
||||
ToList()
|
||||
|
||||
For Each oDateCol In oDateColumns
|
||||
SetDateTimeColumn(oDateCol, pFormatString)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Public Sub SetDateTimeColumns(pTreeList As TreeList, pFormatString As String)
|
||||
If pTreeList.Columns Is Nothing Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oDateColumns = pTreeList.Columns.AsEnumerable.
|
||||
Where(Function(column As TreeListColumn) column.ColumnType = GetType(Date)).
|
||||
ToList()
|
||||
|
||||
For Each oDateCol In oDateColumns
|
||||
SetDateTimeColumn(oDateCol, pFormatString)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Sub SetDateTimeColumn(pColumn As GridColumn, pFormatString As String)
|
||||
|
||||
If String.IsNullOrEmpty(pFormatString) Then
|
||||
pFormatString = "g"
|
||||
End If
|
||||
|
||||
pColumn.DisplayFormat.FormatType = FormatType.Custom
|
||||
pColumn.DisplayFormat.FormatString = "g"
|
||||
pColumn.DisplayFormat.FormatString = pFormatString
|
||||
pColumn.DisplayFormat.Format = DateTimeFormatInfo.CurrentInfo
|
||||
End Sub
|
||||
|
||||
Private Sub SetDateTimeColumn(pColumn As TreeListColumn)
|
||||
Private Sub SetDateTimeColumn(pColumn As TreeListColumn, pFormatString As String)
|
||||
|
||||
If String.IsNullOrEmpty(pFormatString) Then
|
||||
pFormatString = "g"
|
||||
End If
|
||||
|
||||
pColumn.Format.FormatType = FormatType.Custom
|
||||
pColumn.Format.FormatString = "g"
|
||||
pColumn.Format.FormatString = pFormatString
|
||||
pColumn.Format.Format = DateTimeFormatInfo.CurrentInfo
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
|
||||
<Assembly: AssemblyCompany("Digital Data GmbH, Heuchelheim")>
|
||||
<Assembly: AssemblyProduct("DigitalData.Common")>
|
||||
<Assembly: AssemblyCopyright("")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
<Assembly: AssemblyTrademark("2.7.1.0")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("2.7.0.0")>
|
||||
<Assembly: AssemblyFileVersion("2.7.0.0")>
|
||||
<Assembly: AssemblyVersion("2.7.1.0")>
|
||||
<Assembly: AssemblyFileVersion("2.7.1.0")>
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
using DigitalData.Modules.Interfaces;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.VisualStudio.Web.CodeGeneration.Contracts.Messaging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml.Linq;
|
||||
using static DigitalData.Modules.Interfaces.Exceptions;
|
||||
@@ -29,6 +32,7 @@ namespace ZUGFeRDRESTService.Controllers
|
||||
public const string VALIDATION_SUCCESS = "VALIDATION SUCCESS";
|
||||
public const string REFERENCES_Rejection_30001 = "REFERENCES_Rejection_30001";
|
||||
public const string REFERENCES_Rejection_30002 = "REFERENCES_Rejection_30002";
|
||||
public const string REFERENCES_Rejection_30002_1 = "REFERENCES_Rejection_30002_1";
|
||||
public const string REFERENCES_Rejection_30003_1 = "REFERENCES_Rejection_30003_1";
|
||||
public const string REFERENCES_Rejection_30003_2 = "REFERENCES_Rejection_30003_2";
|
||||
public const string REFERENCES_Rejection_30003_3 = "REFERENCES_Rejection_30003_3";
|
||||
@@ -47,7 +51,14 @@ namespace ZUGFeRDRESTService.Controllers
|
||||
public const string REFERENCES_Rejection_30012 = "REFERENCES_Rejection_30012";
|
||||
public const string AMOUNT_CALC_REJECTION = "AMOUNT_CALC_REJECTION";
|
||||
|
||||
public const string GERMAN = "de-DE";
|
||||
public const string ENGLISH = "en-US";
|
||||
public const string FRENCH = "fr-FR";
|
||||
public const string SPAIN = "es-ES";
|
||||
|
||||
private List<string> _ValidationErrors;
|
||||
private List<string> _AllowedLanguageCodes;
|
||||
private string _UserLanguageCode = GERMAN;
|
||||
|
||||
private const int MAX_FILE_SIZE_DEFAULT = 25;
|
||||
|
||||
@@ -56,10 +67,9 @@ namespace ZUGFeRDRESTService.Controllers
|
||||
|
||||
private readonly DigitalData.Modules.Logging.LogConfig _logConfig;
|
||||
private readonly DigitalData.Modules.Logging.Logger _logger;
|
||||
private readonly DigitalData.Modules.Filesystem.File _file;
|
||||
//private readonly DigitalData.Modules.Filesystem.File _file;
|
||||
|
||||
private readonly PropertyValues _props;
|
||||
//private readonly Dictionary<string, XmlItemProperty> _propertyMap = new Dictionary<string, XmlItemProperty>();
|
||||
private readonly List<XmlItemProperty> _propertyMapList = new List<XmlItemProperty>();
|
||||
private readonly List<RejectionStringRow> _RecjectionMessageList = new List<RejectionStringRow>();
|
||||
|
||||
@@ -77,7 +87,7 @@ namespace ZUGFeRDRESTService.Controllers
|
||||
{
|
||||
_logConfig = logging.LogConfig;
|
||||
_logger = _logConfig.GetLogger();
|
||||
_file = new DigitalData.Modules.Filesystem.File(_logConfig);
|
||||
//_file = new DigitalData.Modules.Filesystem.File(_logConfig);
|
||||
|
||||
_logger.Debug("Validation Controller initializing");
|
||||
|
||||
@@ -128,6 +138,14 @@ namespace ZUGFeRDRESTService.Controllers
|
||||
AMOUNT_CALC_REJECTION
|
||||
};
|
||||
|
||||
_AllowedLanguageCodes = new List<string>()
|
||||
{
|
||||
GERMAN,
|
||||
ENGLISH,
|
||||
FRENCH,
|
||||
SPAIN,
|
||||
};
|
||||
|
||||
_logger.Debug("Validation Controller initialized!");
|
||||
}
|
||||
|
||||
@@ -191,14 +209,59 @@ namespace ZUGFeRDRESTService.Controllers
|
||||
/// </summary>
|
||||
/// <param name="file">This parameter's name needs to correspond to the html form's file-input name</param>
|
||||
/// <param name="user_id">This is the email address which the user supplied</param>
|
||||
/// <param name="language_id">This is language code which the user supplied (en-US, de-DE)</param>
|
||||
[HttpPost]
|
||||
public ValidationResponse Post(IFormFile file, string user_id)
|
||||
//public ValidationResponse Post(IFormFile file, StringContent user_id, StringContent language_id = null)
|
||||
public ValidationResponse Post(IFormCollection collection)
|
||||
{
|
||||
_logger.Info("Start processing request to ValidationController");
|
||||
|
||||
ZugferdResult oZugferdResult = null;
|
||||
CheckPropertyValuesResult oPropertyResult = new CheckPropertyValuesResult();
|
||||
|
||||
var oUserId = string.Empty; // user_id == null ? string.Empty : user_id.ToString();
|
||||
var oLanguageId = GERMAN; // language_id == null ? GERMAN : language_id.ToString();
|
||||
|
||||
IFormFile file = collection.Files[0];
|
||||
|
||||
foreach (var keyItem in collection.Keys)
|
||||
{
|
||||
if (keyItem == "user_id")
|
||||
{
|
||||
oUserId = collection[keyItem];
|
||||
}
|
||||
else if (keyItem == "language_id")
|
||||
{
|
||||
oLanguageId = collection[keyItem];
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(oUserId))
|
||||
{
|
||||
_logger.Info("UserID set to [{0}].", oUserId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Info("UserID is empty!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(oLanguageId))
|
||||
{
|
||||
_logger.Info("Language code was empty. Set to default 'de-DE'");
|
||||
// DEFAULT-Sprache = Deutsch de-DE
|
||||
_UserLanguageCode = GERMAN;
|
||||
}
|
||||
else if (_AllowedLanguageCodes.Contains(oLanguageId))
|
||||
{
|
||||
_logger.Info("Language code is allowed. Set to [{0}].", oLanguageId);
|
||||
_UserLanguageCode = oLanguageId;
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Info("Language code was unknown: [{0}]. Set to default 'de-DE'", oLanguageId);
|
||||
_UserLanguageCode = GERMAN;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using Stream oStream = file.OpenReadStream();
|
||||
@@ -325,12 +388,6 @@ namespace ZUGFeRDRESTService.Controllers
|
||||
oMessage = Regex.Replace(oMessage, "@REPLACE_PARAM2", ex.Param2, RegexOptions.IgnoreCase);
|
||||
}
|
||||
|
||||
// Der REJECTION-Code wird in alle Meldungen eingefügt.
|
||||
if (!string.IsNullOrEmpty(rejectionCodeNumber) && oMessage.Contains("@REJECTION_CODE", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
oMessage = Regex.Replace(oMessage, "@REJECTION_CODE", "Ablehnungscode: " + rejectionCodeNumber, RegexOptions.IgnoreCase);
|
||||
}
|
||||
|
||||
// Determine if any errors should be sent in the response
|
||||
switch (ex.ErrorCode)
|
||||
{
|
||||
@@ -467,13 +524,6 @@ namespace ZUGFeRDRESTService.Controllers
|
||||
oReturnValue = oDbMessage;
|
||||
}
|
||||
|
||||
// Der REJECTION-Code wird in alle Meldungen eingefügt.
|
||||
if (!string.IsNullOrEmpty(oRejectionItem) && oReturnValue.Contains("@REJECTION_CODE", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var rejectionCodeNumber = GetRejectionCodeNumber(oRejectionItem);
|
||||
oReturnValue = Regex.Replace(oReturnValue, "@REJECTION_CODE", "Ablehnungscode: " + rejectionCodeNumber, RegexOptions.IgnoreCase);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -611,7 +661,7 @@ namespace ZUGFeRDRESTService.Controllers
|
||||
return oReplaceParam1;
|
||||
}
|
||||
|
||||
public string GetMessageId()
|
||||
private string GetMessageId()
|
||||
{
|
||||
return $"{Guid.NewGuid()}@{MESSAGEID_DOMAIN}";
|
||||
}
|
||||
@@ -772,7 +822,7 @@ namespace ZUGFeRDRESTService.Controllers
|
||||
return oDataTable;
|
||||
}
|
||||
|
||||
public bool DeleteExistingPropertyValues(string pMessageId)
|
||||
private bool DeleteExistingPropertyValues(string pMessageId)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -816,18 +866,15 @@ namespace ZUGFeRDRESTService.Controllers
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Ermittelt die Ausgabe-nachricht für einen Fehlercode
|
||||
/// </summary>
|
||||
public string GetRejectionMessage(string pErrorCode)
|
||||
private string GetRejectionMessage(string pErrorCode)
|
||||
{
|
||||
_logger.Info("GetRejectionMessage() - errorCode.ToString(): '" + pErrorCode.ToString() + "'");
|
||||
|
||||
if (_RecjectionMessageList == null) return string.Empty;
|
||||
|
||||
// Sprache wird man vielleicht mal auswählen können
|
||||
var language = "de-DE";
|
||||
var searchTitle = string.Empty;
|
||||
|
||||
if (pErrorCode.Contains("2000"))
|
||||
@@ -844,15 +891,43 @@ namespace ZUGFeRDRESTService.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
// else-Fall muss noch geklärt werden.
|
||||
searchTitle = "AMOUNT_CALC_REJECTION_Web";
|
||||
searchTitle = "ZUGFERD_Rejection_20006_Web";
|
||||
}
|
||||
|
||||
var messageItem = _RecjectionMessageList.Where(i => i.Title.Equals(searchTitle, StringComparison.OrdinalIgnoreCase) && i.Language.Equals(language, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
||||
if (messageItem != null)
|
||||
// Sprachgenauen Text suchen.
|
||||
var messageItem = _RecjectionMessageList.Where(i => i.Title.Equals(searchTitle, StringComparison.OrdinalIgnoreCase) &&
|
||||
i.Language.Equals(_UserLanguageCode, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
||||
|
||||
if (messageItem == null &&
|
||||
!_UserLanguageCode.Equals(GERMAN, StringComparison.OrdinalIgnoreCase)) {
|
||||
|
||||
_logger.Info("GetRejectionMessage() - Es wurde kein passender Text für die Sprache [{0}] gefunden.", _UserLanguageCode);
|
||||
|
||||
// Wenn kein sprachgenauer Text vorliegt, hole den deutschen Text.
|
||||
messageItem = _RecjectionMessageList.Where(i => i.Title.Equals(searchTitle, StringComparison.OrdinalIgnoreCase) &&
|
||||
i.Language.Equals(GERMAN, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (messageItem != null && !string.IsNullOrEmpty(pErrorCode))
|
||||
{
|
||||
_logger.Info("GetRejectionMessage() - messageItem: '" + messageItem.String1 + "'");
|
||||
return messageItem.String1;
|
||||
var resultText = string.Empty;
|
||||
|
||||
// Der REJECTION-Code wird in allen Meldungen ausgetauscht.
|
||||
if (messageItem.String1.Contains("@REJECTION_CODE", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var substituteText = this.GetLabelText("Ablehnungscode", _UserLanguageCode);
|
||||
substituteText = string.IsNullOrEmpty(substituteText) ? "Ablehnungscode" : substituteText;
|
||||
substituteText = substituteText + ": " + pErrorCode;
|
||||
|
||||
resultText = Regex.Replace(messageItem.String1, "@REJECTION_CODE", substituteText, RegexOptions.IgnoreCase);
|
||||
}
|
||||
else
|
||||
{
|
||||
resultText = messageItem.String1;
|
||||
}
|
||||
|
||||
_logger.Info("GetRejectionMessage() - messageItem: '" + resultText + "'");
|
||||
return resultText;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -861,6 +936,15 @@ namespace ZUGFeRDRESTService.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
private string GetLabelText(string pLabel, string pLanguage)
|
||||
{
|
||||
// Sprachgenauen Text suchen.
|
||||
var messageItem = _RecjectionMessageList.Where(i => i.Title.Equals(pLabel, StringComparison.OrdinalIgnoreCase) &&
|
||||
i.Language.Equals(pLanguage, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
||||
|
||||
return messageItem != null ? messageItem.String1 : string.Empty;
|
||||
}
|
||||
|
||||
private string GetRejectionCodeNumber(ErrorCodes rejectionCode)
|
||||
{
|
||||
switch (rejectionCode)
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
<input type="email" name="user_id" required />
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label>Sprachcode (de-DE etc.):</label>
|
||||
<input type="text" name="language_id" value="de-DE" required />
|
||||
</p>
|
||||
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user