This generator read a file, split the file into items and launch an event on each item. This generator use a splitter class, this class knwon how to split and interpret the format of the file. By default three splitters are available :
- DelimitedFileToEventSplitter: to read delimited file (like CSV : Comma Separated Value), it's a file containing an event on each line and properties of event separated by sequence of characters (like tabulation, comma, ...). It use a RecordEvent class.
- FixedFileToEventSplitter : to read fixed or structured file, it's a file containing an event on one or more lines. Each line have properties based on characters position and each kind of line can be identified by sequence of first characters. It use a RecordEvent class.
- XMLFileToEventSplitter : to read XML files. It use a XMLEvent class.
See Service Configuration for detailled information to configure your service. You must declare this generator with the <generator> section inside the <generators> section. It will looks like :
<generator name="MyGeneratorName" type="LeCouteauSuisse.Components.FileToEventGenerator,
LeCouteauSuisseComponents, Version=1.0.0.2, Culture=neutral, PublicKeyToken=8d1037c5df6d5bd0">
This component have some parameters inside the section <settings>. Each parameter is written with a <setting> section.
Key name | Mandatory | Default value | Description |
type | Yes | | The splitter class, assembly file name, version, culture, public key token. |
path | Yes | | The directory to monitor, in standard or Universal Naming Convention (UNC) notation. |
fileFilter | No | *.* | The type of files to watch. For example, "*.txt" watches for changes to all text files. |
includeSubdirectories | No | false | Sets a value (true or false) indicating whether subdirectories within the specified path should be monitored. |
internalBufferSize | No | 8192 | Sets the size of the internal buffer. |
Specific settings for DelimitedFileToEventSplitter |
headerLines | No | 0 | Number of header lines to ignore. |
headerLineWithColumnsName | No | 0 | The line number having the column name. |
footerLines | No | 0 | Number of footer lines to ignore. |
ignoreEmptyLine | No | true | True to ignore empty lines. |
ignorePrefixLine | No | | Ignore lines starting with this value. Compare strings using culture-sensitive ignoring the case of the strings being compared. |
encoding | No | The value of Encoding.Default of the Framework | The encoding of the file to read. See System.Text.Encoding, name of encoding like ASCII, utf-32, ... |
lineSeparator | No | The value of Environment.NewLine of the Framework | Characters to identify a new line. |
columnSeparator | No | Tabulation value '\t' | Characters to identify a new column. |
columnEnclosure | No | | Characters at the begining and the end of the column to ignore column separator characters inside the value of the column. |
escape | No | | Characters preceding a column enclosure characters to consider column enclosure characters has part of the value. |
data | No | | Private data you want to add to each event generated. |
Specific settings for FixedFileToEventSplitter |
headerLines | No | 0 | Number of header lines to ignore. |
footerLines | No | 0 | Number of footer lines to ignore. |
ignoreEmptyLine | No | true | True to ignore empty lines. |
lineSeparator | No | The value of Environment.NewLine of the Framework | Characters to identify a new line. |
masterRecord | Yes | | List of key setting name of each master record separated by a comma. |
allRecord | Yes | | List of key setting name of each record separated by a comma. |
a record name | Yes | | The description of a record (see bellow). |
data | No | | Private data you want to add to each event generated. |
Specific settings for XMLFileToEventSplitter |
xpath | Yes | | The XPath to select all event in the document |
data | No | | Private data you want to add to each event generated. |
Description of a record
The FixedFileToEventSplitter is used to split a line of a file into fields based by characters position inside the line. It can handle different kind of lines inside the same file (example you can have lines describing a client, and lines describing a supplier, the format of these lines are different). A group of consecutive lines must be grouped to have sense, the first line of this group is named a master record. When a master record is detected all consecutive lines until the next master record are grouped inside the same event (example : you have a line describing an invoice followed by lines describing items of the invoice. Invoice line is a master record and item must be grouped with this invoice).
To describe a record you must add a setting, the key of this setting must be add to the allRecord setting, and if this record is the first of a group of lines it must be added to the masterRecord setting.
A description of a record is composed of several informations. All informations are separated by comma :
{decription of the record},{prefix of record},{length of field}[,{length of field}]
The first information is a description of the record, the second describe the prefix of record, all other are length of each fields. Two method are used to detect the kind of a line, the first method test the first characters of the line, the second method test the length of the line. To have a prefixed record you must set the 'P' (ASCII code 80) character followed by the prefix of the line inside the prefix information, leave the prefix information empty if you want to test the line by length.