diff --git a/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationController.cs b/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationController.cs index 4bd3751c..50e0f5ff 100644 --- a/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationController.cs +++ b/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationController.cs @@ -31,6 +31,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"; @@ -56,7 +57,7 @@ namespace ZUGFeRDRESTService.Controllers private List _ValidationErrors; private List _AllowedLanguageCodes; - private string _UserLanguageCode = "de-DE"; + private string _UserLanguageCode = GERMAN; private const int MAX_FILE_SIZE_DEFAULT = 25; @@ -65,10 +66,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 _propertyMap = new Dictionary(); private readonly List _propertyMapList = new List(); private readonly List _RecjectionMessageList = new List(); @@ -86,7 +86,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"); @@ -390,7 +390,11 @@ namespace ZUGFeRDRESTService.Controllers // 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); + var substituteText = this.GetLabelText("Ablehnungscode", _UserLanguageCode); + substituteText = string.IsNullOrEmpty(substituteText) ? "Ablehnungscode" : substituteText; + substituteText = substituteText + ": " + rejectionCodeNumber; + + oMessage = Regex.Replace(oMessage, "@REJECTION_CODE", substituteText, RegexOptions.IgnoreCase); } // Determine if any errors should be sent in the response @@ -533,7 +537,12 @@ namespace ZUGFeRDRESTService.Controllers if (!string.IsNullOrEmpty(oRejectionItem) && oReturnValue.Contains("@REJECTION_CODE", StringComparison.OrdinalIgnoreCase)) { var rejectionCodeNumber = GetRejectionCodeNumber(oRejectionItem); - oReturnValue = Regex.Replace(oReturnValue, "@REJECTION_CODE", "Ablehnungscode: " + rejectionCodeNumber, RegexOptions.IgnoreCase); + + var substituteText = this.GetLabelText("Ablehnungscode", _UserLanguageCode); + substituteText = string.IsNullOrEmpty(substituteText) ? "Ablehnungscode" : substituteText; + substituteText = substituteText + ": " + rejectionCodeNumber; + + oReturnValue = Regex.Replace(oReturnValue, "@REJECTION_CODE", substituteText, RegexOptions.IgnoreCase); } break; @@ -932,6 +941,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)