CargoReader Component
Properties Methods Events Config Settings Errors
The CargoReader component is optimized for Cargo-IMP documents, providing a simple way to parse Cargo-IMP documents.
Syntax
nsoftware.IPWorksEDITranslator.Cargoreader
Remarks
The component allows you to parse a Cargo-IMP message. Below are example steps:
- First, use LoadSchema to load a schema file into the component. (Only necessary when preserving document structure).
- Open a Cargo-IMP message or stream by setting input via SetInputStream, InputFile or InputData.
- Call the Parse method to parse the message.
- When parsing is complete, you can retrieve the parsed values from the Values collection.
During parsing, the component performs basic validation of the incoming document. If validation fails, a warning is generated (fired as an event).
Schemas are written in JSON format:
{
"name": "FSU",
"desc": "FSU MESSAGE",
"children": {
"1": {
"desc": "Standard Message Identification",
"children": {
"1.1": {
"desc": "Standard Message Identifier",
"value": "FSU"
},
"1.2": {
"value": "/"
},
"1.3": {
"desc": "Message Type Version Number",
"format": "n[...3]"
},
"1.4": {
"value": "\r\n"
}
}
},
"2": {
...
For example schemas and questions, please contact support@nsoftware.com.
Property List
The following is the full list of the properties of the component with short descriptions. Click on the links for further details.
Errors | A collection of errors that occurred when parsing the Cargo-IMP messages. |
InputData | The data to parse. |
InputFile | The file to parse. |
Values | Collection of values after parsing the Cargo-Imp messages. |
Method List
The following is the full list of the methods of the component with short descriptions. Click on the links for further details.
Config | Sets or retrieves a configuration setting. |
LoadSchema | Loads a schema file describing a Message type. |
Parse | Parse the specified input data. |
Reset | Resets the component. |
SetInputStream | Sets the stream from which the component will read the data to parse. |
Event List
The following is the full list of the events fired by the component with short descriptions. Click on the links for further details.
Error | Fired when information is available about errors during data delivery. |
ResolveSchema | Fires whenever a new Cargo-Imp message is encountered and no schema is found for it. |
Config Settings
The following is a list of config settings for the component with short descriptions. Click on the links for further details.
CloseStreamAfterProcessing | Specifies whether or not the InputStream should be closed after processing. |
BuildInfo | Information about the product's build. |
GUIAvailable | Whether or not a message loop is available for processing events. |
LicenseInfo | Information about the current license. |
MaskSensitive | Whether sensitive data is masked in log messages. |
UseFIPSCompliantAPI | Tells the component whether or not to use FIPS certified APIs. |
UseInternalSecurityAPI | Whether or not to use the system security libraries or an internal implementation. |
Errors Property (CargoReader Component)
A collection of errors that occurred when parsing the Cargo-IMP messages.
Syntax
public CargoErrorList Errors { get; }
Public ReadOnly Property Errors As CargoErrorList
Remarks
This property is populated with error information. After calling Parse, check this property to determine if any errors occurred while parsing the message. If there are any errors present, the Values collection will likely be incorrect.
This property is read-only and not available at design time.
Please refer to the CargoError type for a complete list of fields.InputData Property (CargoReader Component)
The data to parse.
Syntax
Default Value
""
Remarks
This property specifies the data to be parsed.
Input Properties
The component will determine the source of the input based on which properties are set.
The order in which the input properties are checked is as follows:
- SetInputStream
- InputFile
- InputData
InputFile Property (CargoReader Component)
The file to parse.
Syntax
Default Value
""
Remarks
This property specifies the file to be processed. Set this property to the full or relative path to the file which will be processed.
Input Properties
The component will determine the source of the input based on which properties are set.
The order in which the input properties are checked is as follows:
- SetInputStream
- InputFile
- InputData
This property is not available at design time.
Values Property (CargoReader Component)
Collection of values after parsing the Cargo-Imp messages.
Syntax
public CargoValueList Values { get; }
Public ReadOnly Property Values As CargoValueList
Remarks
This property will be populated with the values from the Cargo-IMP message after parsing is complete.
This property is read-only and not available at design time.
Please refer to the CargoValue type for a complete list of fields.Config Method (CargoReader Component)
Sets or retrieves a configuration setting.
Syntax
Remarks
Config is a generic method available in every component. It is used to set and retrieve configuration settings for the component.
These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the component, access to these internal properties is provided through the Config method.
To set a configuration setting named PROPERTY, you must call Config("PROPERTY=VALUE"), where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).
To read (query) the value of a configuration setting, you must call Config("PROPERTY"). The value will be returned as a string.
LoadSchema Method (CargoReader Component)
Loads a schema file describing a Message type.
Syntax
public void LoadSchema(string fileName); Async Version public async Task LoadSchema(string fileName); public async Task LoadSchema(string fileName, CancellationToken cancellationToken);
Public Sub LoadSchema(ByVal FileName As String) Async Version Public Sub LoadSchema(ByVal FileName As String) As Task Public Sub LoadSchema(ByVal FileName As String, cancellationToken As CancellationToken) As Task
Remarks
This method parses the File and loads it into an internal schema list.
If the schema file does not exist or cannot be parsed as an Cargo-IMP schema, the component throws an exception.
Schemas are written in JSON format:
{
"name": "FSU",
"desc": "FSU MESSAGE",
"children": {
"1": {
"desc": "Standard Message Identification",
"children": {
"1.1": {
"desc": "Standard Message Identifier",
"value": "FSU"
},
"1.2": {
"value": "/"
},
"1.3": {
"desc": "Message Type Version Number",
"format": "n[...3]"
},
"1.4": {
"value": "\r\n"
}
}
},
"2": {
...
For example schemas and questions, please contact support@nsoftware.com.
Parse Method (CargoReader Component)
Parse the specified input data.
Syntax
public void Parse(); Async Version public async Task Parse(); public async Task Parse(CancellationToken cancellationToken);
Public Sub Parse() Async Version Public Sub Parse() As Task Public Sub Parse(cancellationToken As CancellationToken) As Task
Remarks
This method parses the input data specified by SetOutputStream, InputFile or InputData.
Input Properties
The component will determine the source of the input based on which properties are set.
The order in which the input properties are checked is as follows:
When a valid source is found the search stops.Reset Method (CargoReader Component)
Resets the component.
Syntax
public void Reset(); Async Version public async Task Reset(); public async Task Reset(CancellationToken cancellationToken);
Public Sub Reset() Async Version Public Sub Reset() As Task Public Sub Reset(cancellationToken As CancellationToken) As Task
Remarks
When called, the component initializes itself to its default state.
SetInputStream Method (CargoReader Component)
Sets the stream from which the component will read the data to parse.
Syntax
public void SetInputStream(System.IO.Stream inputStream); Async Version public async Task SetInputStream(System.IO.Stream inputStream); public async Task SetInputStream(System.IO.Stream inputStream, CancellationToken cancellationToken);
Public Sub SetInputStream(ByVal InputStream As System.IO.Stream) Async Version Public Sub SetInputStream(ByVal InputStream As System.IO.Stream) As Task Public Sub SetInputStream(ByVal InputStream As System.IO.Stream, cancellationToken As CancellationToken) As Task
Remarks
This method sets the stream from which the component will read the data to parse.
Input Properties
The component will determine the source of the input based on which properties are set.
The order in which the input properties are checked is as follows:
When a valid source is found the search stops.Error Event (CargoReader Component)
Fired when information is available about errors during data delivery.
Syntax
public event OnErrorHandler OnError; public delegate void OnErrorHandler(object sender, CargoreaderErrorEventArgs e); public class CargoreaderErrorEventArgs : EventArgs { public int ErrorCode { get; } public string Description { get; } }
Public Event OnError As OnErrorHandler Public Delegate Sub OnErrorHandler(sender As Object, e As CargoreaderErrorEventArgs) Public Class CargoreaderErrorEventArgs Inherits EventArgs Public ReadOnly Property ErrorCode As Integer Public ReadOnly Property Description As String End Class
Remarks
The Error event is fired in case of exceptional conditions during message processing. Normally the component throws an exception.
The ErrorCode parameter contains an error code, and the Description parameter contains a textual description of the error. For a list of valid error codes and their descriptions, please refer to the Error Codes section.
ResolveSchema Event (CargoReader Component)
Fires whenever a new Cargo-Imp message is encountered and no schema is found for it.
Syntax
public event OnResolveSchemaHandler OnResolveSchema; public delegate void OnResolveSchemaHandler(object sender, CargoreaderResolveSchemaEventArgs e); public class CargoreaderResolveSchemaEventArgs : EventArgs { public string MessageIdentifier { get; } public string Version { get; } }
Public Event OnResolveSchema As OnResolveSchemaHandler Public Delegate Sub OnResolveSchemaHandler(sender As Object, e As CargoreaderResolveSchemaEventArgs) Public Class CargoreaderResolveSchemaEventArgs Inherits EventArgs Public ReadOnly Property MessageIdentifier As String Public ReadOnly Property Version As String End Class
Remarks
The ResolveSchema event will fire when a the component encounters a new Cargo-IMP message, but it finds no schema corresponding to it already loaded.
MessageIdentifier contains the message type, such as "FWB" or "FSU".
Version contains the version of the schema used by the message.
When processing this event, the caller can use LoadSchema() to load a new schema into the component that can be used to parse the transaction.
CargoError Type
This type contains the details of an error that occurred while parsing a Cargo-IMP message.
Remarks
The fields below provide information about the error.
Fields
Description
string (read-only)
Default Value: "0"
The description of current error.
Line
int (read-only)
Default Value: 0
The text line where the error occurred.
Offset
int (read-only)
Default Value: 0
The text offset where the error occurred.
Position
int (read-only)
Default Value: 0
The text position where the error occurred.
CargoValue Type
A value parsed from a Cargo-Imp message.
Remarks
The fields below provide information about the value.
Fields
Description
string (read-only)
Default Value: "0"
The description of current value.
Level
int (read-only)
Default Value: 0
The level of the value within the message. The elements in the message are grouped by levels where: Level 1 is the Text Element Level Level 2 is the Data Group Level Level 3 is the Data Element Level Each element is allocated a numeric reference within the Cargo-IMP Message. For example, a ULD Description might be: 4. ULD Description Level 1 4.1 Total Number of ULDs Level 2 4.2 ULD Identification Level 2 4.2.1 ULD Type Level 3 4.2.2 ULD Serial Number Level 3 4.2.3 ULD Owner Code Level 3 4.3 ULD Position Restriction Indicator Level 2 4.4 Weight of ULD Level 2 4.4.1 Weight Code Level 3 4.4.2 Weight Level 3
Line
int (read-only)
Default Value: 0
The text line of the current value.
Name
string (read-only)
Default Value: "0"
The name of the element. This will be a string like "1", "1.2", or "1.2.2", and is defined in the schema file.
Offset
int (read-only)
Default Value: 0
The text offset of the current value.
Position
int (read-only)
Default Value: 0
The text position of the current value.
Value
string (read-only)
Default Value: "0"
The value of the element.
Config Settings (CargoReader Component)
The component accepts one or more of the following configuration settings. Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the component, access to these internal properties is provided through the Config method.CARGOREADER Config Settings
Base Config Settings
In some non-GUI applications, an invalid message loop may be discovered that will result in errant behavior. In these cases, setting GUIAvailable to false will ensure that the component does not attempt to process external events.
- Product: The product the license is for.
- Product Key: The key the license was generated from.
- License Source: Where the license was found (e.g., RuntimeLicense, License File).
- License Type: The type of license installed (e.g., Royalty Free, Single Server).
- Last Valid Build: The last valid build number for which the license will work.
This setting only works on these components: AS3Receiver, AS3Sender, Atom, Client(3DS), FTP, FTPServer, IMAP, OFTPClient, SSHClient, SCP, Server(3DS), Sexec, SFTP, SFTPServer, SSHServer, TCPClient, TCPServer.
FIPS mode can be enabled by setting the UseFIPSCompliantAPI configuration setting to true. This is a static setting which applies to all instances of all components of the toolkit within the process. It is recommended to enable or disable this setting once before the component has been used to establish a connection. Enabling FIPS while an instance of the component is active and connected may result in unexpected behavior.
For more details please see the FIPS 140-2 Compliance article.
Note: This setting is only applicable on Windows.
Note: Enabling FIPS-compliance requires a special license; please contact sales@nsoftware.com for details.
Setting this configuration setting to true tells the component to use the internal implementation instead of using the system security libraries.
On Windows, this setting is set to false by default. On Linux/macOS, this setting is set to true by default.
If using the .NET Standard Library, this setting will be true on all platforms. The .NET Standard library does not support using the system security libraries.
Note: This setting is static. The value set is applicable to all components used in the application.
When this value is set, the product's system dynamic link library (DLL) is no longer required as a reference, as all unmanaged code is stored in that file.
Trappable Errors (CargoReader Component)
CargoReader Errors
1000 Invalid schema file. | |
1001 No schema found. | |
1002 Schema format error. | |
1003 Line or message was too long. | |
1004 Failed to parse the message version. | |
1005 Element is not in the schema file or is not a simple element. | |
1006 Could not find the element. |