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 : AdapterBase
- 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
HumanReadableFileCount
Number of Human Readable Files.
protected virtual int HumanReadableFileCount { get; }
Property Value
HumanReadableFileExtensions
Human Readable File Extensions of the Adapter.
protected virtual List<string> HumanReadableFileExtensions { get; }
Property Value
HumanReadableStartFileNames
Start of Human Readable File Names of the Adapter.
protected virtual List<string> HumanReadableStartFileNames { get; }
Property Value
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
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
Methods
Execute(FileReaderContext, bool)
Internal method
public FileReaderResult Execute(FileReaderContext context, bool useFileCreationTime = false)
Parameters
contextFileReaderContextFileReaderContext
useFileCreationTimeboolShould the file creationTime always be used as the report date time?
Returns
- FileReaderResult
AdapterValidationResult
GetHumanReadableFilePath(FileReaderContext)
Get the human-readable file path. Can be overridden with a user defined function. Can be used together with GetHumanReadableFilePaths, but it is recommended to only use one of the methods.
protected virtual string GetHumanReadableFilePath(FileReaderContext context)
Parameters
contextFileReaderContextFileReaderContext
Returns
- string
Human readable file
GetHumanReadableFilePaths(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<string> GetHumanReadableFilePaths(FileReaderContext context)
Parameters
contextFileReaderContextFileReaderContext
Returns
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
contextFileReaderContextFileReaderContext
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
contextFileReaderContextFileReaderContext
Returns
- AdapterReadResult
AdapterReadResult
ReadWithHumanReadableFiles(FileReaderContext, AdapterReadResult, IEnumerable<string>)
ReadWithHumanReadableFiles can be implemented by the Adapter class. This method is called after the Read method, it contains not only the context but also the AdapterReadResult of the Read method and the detected and/or configured HumanReadableFilePaths. The AdapterReadResult can be extended and has to be returned fully.
protected virtual AdapterReadResult ReadWithHumanReadableFiles(FileReaderContext context, AdapterReadResult adapterReadResult, IEnumerable<string> humanReadableFilePaths)
Parameters
contextFileReaderContextFileReaderContext
adapterReadResultAdapterReadResultAdapterReadResult
humanReadableFilePathsIEnumerable<string>Loaded human readable file paths
Returns
- AdapterReadResult
AdapterReadResult
Validate(FileReaderContext)
Internal method
public AdapterValidationResult Validate(FileReaderContext context)
Parameters
contextFileReaderContextFileReaderContext
Returns
- AdapterValidationResult
AdapterValidationResult