ZUGFeRDRESTService: Add specification, add logging

This commit is contained in:
Jonathan Jenne 2023-02-28 14:34:46 +01:00
parent 81eac3043a
commit f6fc6fe7dc

View File

@ -14,6 +14,7 @@ namespace ZUGFeRDRESTService
{ {
public class Database: IDatabase public class Database: IDatabase
{ {
private DigitalData.Modules.Logging.Logger _Logger = null;
private string _gdPictureKey = null; private string _gdPictureKey = null;
private Dictionary<string, XmlItemProperty> _propertyMap = null; private Dictionary<string, XmlItemProperty> _propertyMap = null;
@ -42,6 +43,8 @@ namespace ZUGFeRDRESTService
oLogger.Debug("MSSQL Connection: [{0}]", MSSQL.CurrentConnectionString); oLogger.Debug("MSSQL Connection: [{0}]", MSSQL.CurrentConnectionString);
oLogger.Debug("Firebird Connection: [{0}]", Firebird.ConnectionString); oLogger.Debug("Firebird Connection: [{0}]", Firebird.ConnectionString);
_Logger = oLogger;
} }
public string GetGDPictureKey() public string GetGDPictureKey()
@ -52,12 +55,16 @@ namespace ZUGFeRDRESTService
return _gdPictureKey; return _gdPictureKey;
} }
public Dictionary<String, XmlItemProperty> GetPropertyMap() public Dictionary<string, XmlItemProperty> GetPropertyMap()
{ {
if (_propertyMap == null) if (_propertyMap == null)
{ {
_Logger.Debug("Property map does not exist, creating.");
_propertyMap = new Dictionary<string, XmlItemProperty>(); _propertyMap = new Dictionary<string, XmlItemProperty>();
var oDatatable = Firebird.GetDatatable(string.Format(QUERY_GET_PROPERTY_MAP, "DEFAULT")); var oDatatable = Firebird.GetDatatable(QUERY_GET_PROPERTY_MAP);
_Logger.Debug("Datatable Rows: [{0}]", oDatatable.Rows);
foreach (DataRow oRow in oDatatable.Rows) foreach (DataRow oRow in oDatatable.Rows)
{ {
@ -68,10 +75,16 @@ namespace ZUGFeRDRESTService
TableColumn = oRow["TABLE_COLUMN"].ToString(), TableColumn = oRow["TABLE_COLUMN"].ToString(),
GroupScope = oRow["GROUP_SCOPE"].ToString(), GroupScope = oRow["GROUP_SCOPE"].ToString(),
IsRequired = (bool)oRow["IS_REQUIRED"], IsRequired = (bool)oRow["IS_REQUIRED"],
IsGrouped = (bool)oRow["IS_GROUPED"] IsGrouped = (bool)oRow["IS_GROUPED"],
Specification = oRow["SPECIFICATION"].ToString()
}); });
} }
} } else
{
_Logger.Debug("Property map already exists, returning.");
}
_Logger.Debug("Returning Property Map with [{0}] entries.", _propertyMap.Count);
return _propertyMap; return _propertyMap;
} }