Table of Contents

Class FileReader

Namespace
MES.MQC.DataSourceLibrary.Adapters
Assembly
MES.MQC.DataSourceLibrary.dll

The FileAdapter class is the base for all MQC File Readers.

public abstract class FileReader : DataAdapterBase
Inheritance
FileReader
Derived
Inherited Members

Properties

FileExtensions

File Extensions of the Adapter. This property has to be defined and must have at least one file extension. The Adapter is only used for FilePaths with the defined file extensions. The IsValid method is not called unless the file extension matches.

public abstract List<string> FileExtensions { get; }

Property Value

List<string>

HumanReadableFileCount

Number of Human Readable Files.

protected virtual int HumanReadableFileCount { get; }

Property Value

int

HumanReadableFileExtensions

Human Readable File Extensions of the Adapter.

protected virtual List<string> HumanReadableFileExtensions { get; }

Property Value

List<string>

HumanReadableRegexFileNames

Start of Human Readable File Names of the Adapter.

protected virtual List<string> HumanReadableRegexFileNames { get; }

Property Value

List<string>

Priority

Priority of the Adapter. The execution order of all adapters depend on the defined priorities. The higher the priority the earlier the adapter is validated and executed. The default priority for Base Adapters is between 10-110, Custom Adapters should define a priority of 200 or higher if they should be executed before the base adapters. If two adapters have the same priority, the order is depending on the name of the adapter.

public virtual int Priority { get; }

Property Value

int

ReportDateTimeExpected

Is it expected to get a reportDateTime in the report? If this is false the ReportDateTime is the CreationDate of the file without a warning.

protected virtual bool ReportDateTimeExpected { get; }

Property Value

bool

Version

public virtual Version Version { get; }

Property Value

Version

Methods

Execute(FileReaderContext)

Internal method

public FileReaderResult Execute(FileReaderContext context)

Parameters

context FileReaderContext

FileReaderContext

Returns

FileReaderResult

AdapterValidationResult

GetHumanReadableContents(FileReaderContext)

Get the human-readable file paths. Can be overridden with a user defined function. Can be used together with GetHumanReadableFilePath, but it is recommended to only use one of the methods.

protected virtual List<IFileContent> GetHumanReadableContents(FileReaderContext context)

Parameters

context FileReaderContext

FileReaderContext

Returns

List<IFileContent>

List of human readable files

GetRelatedContentRequests(FileReaderContext)

public virtual List<RelatedContentRequest> GetRelatedContentRequests(FileReaderContext context)

Parameters

context FileReaderContext

Returns

List<RelatedContentRequest>

GetRelatedContentRequestsFromOptions(FileReaderContext)

protected List<RelatedContentRequest> GetRelatedContentRequestsFromOptions(FileReaderContext context)

Parameters

context FileReaderContext

Returns

List<RelatedContentRequest>

IsValid(FileReaderContext)

IsValid has to be implemented by the Adapter class. The method is called when the file extensions match. If the file extension is unique, this method can just return true, otherwise it should check if the file should be imported by the adapter. If true is returned, the current adapter is executed and the Read method is called. No other adapter is checked afterward.

protected abstract bool IsValid(FileReaderContext context)

Parameters

context FileReaderContext

FileReaderContext

Returns

bool

boolean (is this the correct adapter to read the file?)

Read(FileReaderContext)

Read has to be implemented by the Adapter class. This method is called when the file extensions match and isValid returns true, no other adapter is called. The data of the file should be read and returned as a AdapterReadResult.

protected abstract AdapterReadResult Read(FileReaderContext context)

Parameters

context FileReaderContext

FileReaderContext

Returns

AdapterReadResult

AdapterReadResult

TransformStringToDateTime(FileReaderContext, string)

This method is deprecated, use

TransformStringToDateTime(value)
instead
protected DateTime TransformStringToDateTime(FileReaderContext context, string value)

Parameters

context FileReaderContext

FileReaderContext

value string

Date as string

Returns

DateTime

Datetime transformed from the string or the creation date, if string was not a valid datetime

Validate(FileReaderContext)

Internal method

public AdapterValidationResult Validate(FileReaderContext context)

Parameters

context FileReaderContext

FileReaderContext

Returns

AdapterValidationResult

AdapterValidationResult