ZUGFeRD REST Service: "Ablehnungscode" mehrsprachige Ausgabe
This commit is contained in:
@@ -31,6 +31,7 @@ namespace ZUGFeRDRESTService.Controllers
|
|||||||
public const string VALIDATION_SUCCESS = "VALIDATION SUCCESS";
|
public const string VALIDATION_SUCCESS = "VALIDATION SUCCESS";
|
||||||
public const string REFERENCES_Rejection_30001 = "REFERENCES_Rejection_30001";
|
public const string REFERENCES_Rejection_30001 = "REFERENCES_Rejection_30001";
|
||||||
public const string REFERENCES_Rejection_30002 = "REFERENCES_Rejection_30002";
|
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_1 = "REFERENCES_Rejection_30003_1";
|
||||||
public const string REFERENCES_Rejection_30003_2 = "REFERENCES_Rejection_30003_2";
|
public const string REFERENCES_Rejection_30003_2 = "REFERENCES_Rejection_30003_2";
|
||||||
public const string REFERENCES_Rejection_30003_3 = "REFERENCES_Rejection_30003_3";
|
public const string REFERENCES_Rejection_30003_3 = "REFERENCES_Rejection_30003_3";
|
||||||
@@ -56,7 +57,7 @@ namespace ZUGFeRDRESTService.Controllers
|
|||||||
|
|
||||||
private List<string> _ValidationErrors;
|
private List<string> _ValidationErrors;
|
||||||
private List<string> _AllowedLanguageCodes;
|
private List<string> _AllowedLanguageCodes;
|
||||||
private string _UserLanguageCode = "de-DE";
|
private string _UserLanguageCode = GERMAN;
|
||||||
|
|
||||||
private const int MAX_FILE_SIZE_DEFAULT = 25;
|
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.LogConfig _logConfig;
|
||||||
private readonly DigitalData.Modules.Logging.Logger _logger;
|
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 PropertyValues _props;
|
||||||
//private readonly Dictionary<string, XmlItemProperty> _propertyMap = new Dictionary<string, XmlItemProperty>();
|
|
||||||
private readonly List<XmlItemProperty> _propertyMapList = new List<XmlItemProperty>();
|
private readonly List<XmlItemProperty> _propertyMapList = new List<XmlItemProperty>();
|
||||||
private readonly List<RejectionStringRow> _RecjectionMessageList = new List<RejectionStringRow>();
|
private readonly List<RejectionStringRow> _RecjectionMessageList = new List<RejectionStringRow>();
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ namespace ZUGFeRDRESTService.Controllers
|
|||||||
{
|
{
|
||||||
_logConfig = logging.LogConfig;
|
_logConfig = logging.LogConfig;
|
||||||
_logger = _logConfig.GetLogger();
|
_logger = _logConfig.GetLogger();
|
||||||
_file = new DigitalData.Modules.Filesystem.File(_logConfig);
|
//_file = new DigitalData.Modules.Filesystem.File(_logConfig);
|
||||||
|
|
||||||
_logger.Debug("Validation Controller initializing");
|
_logger.Debug("Validation Controller initializing");
|
||||||
|
|
||||||
@@ -390,7 +390,11 @@ namespace ZUGFeRDRESTService.Controllers
|
|||||||
// Der REJECTION-Code wird in alle Meldungen eingefügt.
|
// Der REJECTION-Code wird in alle Meldungen eingefügt.
|
||||||
if (!string.IsNullOrEmpty(rejectionCodeNumber) && oMessage.Contains("@REJECTION_CODE", StringComparison.OrdinalIgnoreCase))
|
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
|
// 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))
|
if (!string.IsNullOrEmpty(oRejectionItem) && oReturnValue.Contains("@REJECTION_CODE", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
var rejectionCodeNumber = GetRejectionCodeNumber(oRejectionItem);
|
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;
|
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)
|
private string GetRejectionCodeNumber(ErrorCodes rejectionCode)
|
||||||
{
|
{
|
||||||
switch (rejectionCode)
|
switch (rejectionCode)
|
||||||
|
|||||||
Reference in New Issue
Block a user