diff --git a/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationController.cs b/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationController.cs
index 2e625d83..fb4e33be 100644
--- a/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationController.cs
+++ b/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationController.cs
@@ -87,8 +87,6 @@ namespace ZUGFeRDRESTService.Controllers
{
_logConfig = logging.LogConfig;
_logger = _logConfig.GetLogger();
- //_file = new DigitalData.Modules.Filesystem.File(_logConfig);
-
_logger.Debug("Validation Controller initializing");
// Read config file and assign all option flags related to
@@ -211,7 +209,6 @@ namespace ZUGFeRDRESTService.Controllers
/// This is the email address which the user supplied
/// This is language code which the user supplied (en-US, de-DE)
[HttpPost]
- //public ValidationResponse Post(IFormFile file, StringContent user_id, StringContent language_id = null)
public ValidationResponse Post(IFormCollection collection)
{
_logger.Info("Start processing request to ValidationController");
@@ -219,8 +216,8 @@ namespace ZUGFeRDRESTService.Controllers
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();
+ var oUserId = string.Empty;
+ var oLanguageId = GERMAN;
IFormFile file = collection.Files[0];
@@ -422,16 +419,54 @@ namespace ZUGFeRDRESTService.Controllers
// Der gesamte Ausgabetext muss anhand des ErrorCodes ermittelt werden
string oMessage = this.GetRejectionMessage(rejectionCodeNumber);
- List oErrors = ex.ValidationErrors.Select(e =>
- {
- return $"Element '{e.ElementName}' mit Wert '{e.ElementValue}': {e.ErrorMessageDE}";
- }).ToList();
+ // Wenn es ValidationErrors gibt, werden diese nun übersetzt und in eine Liste übertragen werden
+ var mainText = GetTextByToken("ItemValueText");
+ var resultList = new List();
+ foreach (var errorItem in ex.ValidationErrors)
+ {
+ var resultString = mainText;
+
+ if (!string.IsNullOrEmpty(errorItem.ElementName))
+ {
+ // replace @ITEM_NAME => e.ElementName
+ resultString = resultString.Replace("@ITEM_NAME", errorItem.ElementName, StringComparison.OrdinalIgnoreCase);
+ }
+
+ if (!string.IsNullOrEmpty(errorItem.ElementValue))
+ {
+ // replace ITEM_VALUE => e.ElementValue
+ resultString = resultString.Replace("@ITEM_VALUE", errorItem.ElementValue, StringComparison.OrdinalIgnoreCase);
+ }
+
+ var itemErrorText = GetTextByToken(errorItem.ErrorMessageToken);
+ if (!string.IsNullOrEmpty(itemErrorText))
+ {
+ // attach itemErrorText
+ resultString += " " + itemErrorText;
+ }
+
+ _logger.Debug($"resultString: [{resultString}]");
+ resultList.Add(resultString);
+ }
+
+ // wenn ergebnisse vorliegen, in html transformieren und anhängen
+ if (resultList.Count > 0)
+ {
+ var htmlResultString = "";
+ foreach (var resultItem in resultList)
+ {
+ htmlResultString += " - " + resultItem + "
" + Environment.NewLine;
+ }
+ htmlResultString += "
";
+
+ oMessage += " " + htmlResultString;
+ }
+
return new ValidationResponse()
{
status = RESPONSE_ERROR,
- message = oMessage,
- errors = oErrors
+ message = oMessage
};
}
catch (Exception ex)
@@ -450,6 +485,39 @@ namespace ZUGFeRDRESTService.Controllers
}
}
+ ///
+ /// Holt sprachgenauen Text anhand eines Titel-Tokens
+ ///
+ ///
+ private string GetTextByToken(string tokenValue)
+ {
+ RejectionStringRow stringRow = null;
+
+ if (!string.IsNullOrEmpty(tokenValue))
+ {
+ stringRow = _RecjectionMessageList.Where(i => i.Title.Equals(tokenValue, StringComparison.OrdinalIgnoreCase) &&
+ i.Language.Equals(_UserLanguageCode, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
+
+ if (stringRow == null &&
+ !_UserLanguageCode.Equals(GERMAN, StringComparison.OrdinalIgnoreCase))
+ {
+ // Wenn kein sprachgenauer Text vorliegt, hole den deutschen Text.
+ stringRow = _RecjectionMessageList.Where(i => i.Title.Equals(tokenValue, StringComparison.OrdinalIgnoreCase) &&
+ i.Language.Equals(GERMAN, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
+ }
+ }
+
+ string retValue = string.Empty;
+
+ if (stringRow != null)
+ {
+ retValue = !string.IsNullOrEmpty(stringRow.String1) ? stringRow.String1.Trim() : string.Empty;
+ }
+
+ _logger.Debug($"Token [{tokenValue}] - String1 [{retValue}]");
+ return retValue;
+ }
+
///
/// Hier wird eine externe Prozedur gerufen, PRCUST_INV_CHECK_FROM_PORTAL,
/// die das Ergebnis der Referenzpruefung liefert.
@@ -975,16 +1043,5 @@ namespace ZUGFeRDRESTService.Controllers
return "20010";
}
}
-
- private string GetRejectionCodeNumber(string rejectionCode)
- {
- if (rejectionCode.StartsWith("REFERENCES_Rejection_"))
- {
- var retValue = rejectionCode.Replace("REFERENCES_Rejection_", "");
- return retValue;
- }
-
- return rejectionCode;
- }
}
}