Class EbicsFileName
Holds the information of a file name structured according to the recommendations for EBICS files inside of a ZIP container.
public class EbicsFileName : IComparable<EbicsFileName>
- Inheritance
-
EbicsFileName
- Implements
- Inherited Members
Remarks
This implementation is based on the DK specification "Datenformate" which lays out the
structured format of a file name of XML files contained in a ZIP container as
JJJJ-MM-TT_CCC_X...X.xml
. This includes the creation date JJJJ-MM-TT
,
and the order type CCC
, separated by underscores. Depending on the order type
additional information X...X
may follow.
For account related files the additional information contains an account specification
as JJJJ-MM-TT_CCC_K...K_WWW_AAAAAA_X...X.xml
. Including an account K...K
,
a currency WWW
, a sequence identifier AAAAAA
, and optional additional
information X...X
.
In either case the file type suffix may be different than .xml
.
Some example file names from the DK specification:
2018-01-08_C53_DE87200500001234567890_EUR_000001.xml
2018-01-08_C53_20050000.1234567890_EUR_000001.xml
2018-01-08_C53_BANKDEFF123.1234567890_EUR_000001.xml
2018-01-08_C86_BANKDEFFXXX_KUNDEABC000001.xml
2018-01-08_BKA_DE87200500001234567890_EUR_000021.pdf
2018-02-23_BKI_DE87200500001234567890_EUR_000001_WPA.pdf
2020-11-06_C53_DE70720500000002168235_EUR_20-00118.xml
Some real world examples:
2021-03-11_C53_70040041.0664453800EUR_EUR_054305.xml
2021-03-30_C53_DE29201304005005001184_EUR_314441.xml
2021-03-31_BKA_DE29201304005005001184_EUR_000002_KA0114800638.pdf
Some swiss real world examples, which obviously do not follow these rules at all:
2021031113628496_6300CAMT053_2021031200223147_0.XML
2021022213472694_6300CAMT053_2021022300320003_0.XML
The EbicsFileSpooler uses this basic format for payment initiation files stored in its BOX_OUTBOX, too. The structure is according to:
2021-02-07_CCT_X...X.xml
2021-02-07_CDD_X...X.xml
2021-02-07_CIP_X...X.xml
2021-02-07_AZV_X...X.dta
The date part must match the creation date inside of the payment initiation xml.
The X...X part should match the message identification element inside of the payment
initiation xml. The order type is always the "plain" order type and never the
container or SRZ order type. These would be generated on the fly during transmission.
An actual file system file that a EbicsFileName references, may have its content encrypted by the EbicsFileSpooler. If so, the actual file system file name has an additional ENCRYPTEDFILENAMESUFFIX appended to it. See IsEncrypted.
A file may be marked as hidden by prefixing it with a single dot. Hidden files are not returned by directory queries, except when explicitly asked for.
Now (04.10.2022-) also parses "Aareal-style" EBICS-FileNames. So far we identified the following pattern:
<Partner?>_B<Datum>_EKO_<?>_<IBAN>_<Auszugsnummer>_<Blattnummer>.pdf
Währung: always "EUR" by definition Datum: yyyyMMdd EKO -> synonym for "BKA" Auszugsnummer -> SequenceID Blattnummer -> AdditionalInfo
Sample(s): E0055343_B20220729_EKO_00000110244_DE70720500000002168235_00023_01.pdf
Constructors
EbicsFileName(string, bool, bool)
public EbicsFileName(string sFileName, bool fIsHidden = false, bool fIsEncrypted = false)
Parameters
sFileName
stringThe file name with file type suffix, but usually without path and without ENCRYPTEDFILENAMESUFFIX or other decoration. These are added automatically, when needed.
fIsHidden
boolIf the instance shall refer to a hidden file, that is, a file with a leading dot, then this must be
true
.fIsEncrypted
boolIf the instance shall refer to an encrypted file, that is, a file with the additional ENCRYPTEDFILENAMESUFFIX, then this must be
true
.
Remarks
If the given sFileName
includes a leading dot, then it is
removed and fIsHidden
is assumed to be true
, regardless
of the actual parameter value.
If the given sFileName
includes the
ENCRYPTEDFILENAMESUFFIX, then it is removed and
fIsEncrypted
is assumed to be true
, regardless of the
actual parameter value.
Fields
ENCRYPTEDFILENAMESUFFIX
This additional suffix is appended to the original file name when the file content is encrypted by the file spooler.
public const string ENCRYPTEDFILENAMESUFFIX = ".cryptd"
Field Value
Properties
Account
Optional account specification, if included in the file name. This is null
if not present in the file name.
public EbicsAccountInfo Account { get; }
Property Value
Remarks
The account specification always includes an account currency.
AdditionalInfo
public string[] AdditionalInfo { get; }
Property Value
- string[]
ByteSize
Optional size of the file in bytes. This is zero, if it is not known.
public long ByteSize { get; }
Property Value
Date
The mandatory creation date part from the file name.
public DateTime Date { get; }
Property Value
Remarks
This is always a valid date and is never DateTime.MinValue.
FileName
The complete file name with file type suffix (usually .xml
), but without any
file system path information, and without additional suffixes.
public string FileName { get; }
Property Value
Remarks
This is never null
or an empty string. This file name does not include the
ENCRYPTEDFILENAMESUFFIX, even when the file system file it was
created from, did include this suffix.
- See Also
FileNameWithoutSuffix
public string FileNameWithoutSuffix { get; }
Property Value
FileSystemFileName
The complete file system file name.
public string FileSystemFileName { get; }
Property Value
IsEncrypted
Flag that indicates that the actual file system file is encrypted by the spooler.
public bool IsEncrypted { get; }
Property Value
Remarks
The value is derived from the presence of the ENCRYPTEDFILENAMESUFFIX by the ParseFileName(string, EbicsFileNameStyle) method.
IsHidden
File was prefixed with a single dot.
public bool IsHidden { get; }
Property Value
OrderType
The mandatory order type part from the file name.
public string OrderType { get; }
Property Value
Remarks
This is never null, or empty, or an invalid order type specification.
SequenceID
public string SequenceID { get; }
Property Value
Suffix
The file name suffix including the period ".". This is the real file type suffix and never ENCRYPTEDFILENAMESUFFIX, even when the file system file it was created from, did include this suffix.
public string Suffix { get; set; }
Property Value
Methods
BuildFileName(SepaDocument, string, string, string[])
Creates a correct EBICS file name for a given CAMT document.
public static EbicsFileName BuildFileName(SepaDocument aCamtDocument, string sOrderType, string sSuffix, string[] vsAdditionalInfo = null)
Parameters
aCamtDocument
SepaDocumentThe CAMT document to create an EBICS file name for. This must not be
null
. In order to be able to create a conforming EBICS file name, this document must contain a single Statement object, only.sOrderType
stringsSuffix
stringThe file name extension including the leading dot character. This must be provided. Lower case characters are recommended.
vsAdditionalInfo
string[]Optional AdditionalInfo to be added to the filename.
Returns
Exceptions
- ArgumentNullException
The parameter
aCamtDocument
wasnull
.- ArgumentException
The document did not contain a single Statement element.
BuildFileName(SepaDocument, string[])
Creates a correct EBICS file name for a given CAMT document.
public static EbicsFileName BuildFileName(SepaDocument aDocument, string[] vsAdditionalInfo = null)
Parameters
aDocument
SepaDocumentThe PAIN or CAMT document to create an EBICS file name for. This must not be
null
. In order to be able to create a conforming EBICS file name, this document must contain a single Statement object, only.vsAdditionalInfo
string[]Optional AdditionalInfo to be added to the filename.
Returns
Exceptions
- ArgumentNullException
The parameter
aDocument
wasnull
.- ArgumentException
The document did not contain a single Statement element.
BuildFileName(DateTime, string, EbicsAccountInfo, string, string[], string)
public static EbicsFileName BuildFileName(DateTime tDate, string sOrderType, EbicsAccountInfo aAccount, string sSequenceID, string[] vsAdditionalInfo, string sSuffix)
Parameters
tDate
DateTimeThe file creation date. This should match any creation date data field that might be contained inside of the file referenced.
sOrderType
stringThe base order type that would be used to transfer this file. This must not be
null
.aAccount
EbicsAccountInfoOptional account specification. May be
null
if not needed. Must include a currency, if given. If an account is given, the parametersSequenceID
must be provided, too.sSequenceID
stringSequence ID to make this file unique for the given
tDate
andaAccount
. Must be provided, if aaAccount
is provided. Must benull
, ifaAccount
isnull
, too.vsAdditionalInfo
string[]Optional additional info fields appended at the end of the file name. May be
null
.sSuffix
stringThe file name extension including the leading dot character. This must be provided. Lower case characters are recommended.
Returns
BuildFileName(DateTime, string, string[], string)
public static EbicsFileName BuildFileName(DateTime tDate, string sOrderType, string[] vsAdditionalInfo, string sSuffix)
Parameters
tDate
DateTimesOrderType
stringvsAdditionalInfo
string[]sSuffix
stringValue for the file name Suffix.
Returns
Clone()
Creates a duplicate of this file name.
public EbicsFileName Clone()
Returns
CompareTo(EbicsFileName)
public int CompareTo(EbicsFileName aOtherFileName)
Parameters
aOtherFileName
EbicsFileName
Returns
ParseFileName(string, EbicsFileNameStyle)
public static EbicsFileName ParseFileName(string sFileName, EbicsFileNameStyle nFileNameStyle = EbicsFileNameStyle.Unknown)
Parameters
sFileName
stringThe file name to be parsed. If this contains path information, it is removed before parsing. If this file name has the additional ENCRYPTEDFILENAMESUFFIX, then it will be removed and the flag IsEncrypted will be set in the returned EbicsFileName.
nFileNameStyle
EbicsFileNameStyleIndicates whether account information is expected in the file name, or not. If Unknown, then an assumption is made based on the order type extracted from the file name.
Returns
Remarks
Now (04.10.2022-) also parses "Aareal-Style" EBICS-FileNames (see class documentation for details).
Exceptions
- ArgumentNullException
- ArgumentException
The given
sFileName
is empty or contains invalid path characters.
ToString()
public override string ToString()