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
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
HumanReadableRegexFileNames
Start of Human Readable File Names of the Adapter.
protected virtual List<string> HumanReadableRegexFileNames { 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
Version
public virtual Version Version { get; }
Property Value
Methods
Execute(FileReaderContext)
Internal method
public FileReaderResult Execute(FileReaderContext context)
Parameters
contextFileReaderContextFileReaderContext
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
contextFileReaderContextFileReaderContext
Returns
- List<IFileContent>
List of human readable files
GetRelatedContentRequests(FileReaderContext)
public virtual List<RelatedContentRequest> GetRelatedContentRequests(FileReaderContext context)
Parameters
contextFileReaderContext
Returns
GetRelatedContentRequestsFromOptions(FileReaderContext)
protected List<RelatedContentRequest> GetRelatedContentRequestsFromOptions(FileReaderContext context)
Parameters
contextFileReaderContext
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
TransformStringToDateTime(FileReaderContext, string)
This method is deprecated, use
TransformStringToDateTime(value) instead
protected DateTime TransformStringToDateTime(FileReaderContext context, string value)
Parameters
contextFileReaderContextFileReaderContext
valuestringDate 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
contextFileReaderContextFileReaderContext
Returns
- AdapterValidationResult
AdapterValidationResult