Table of Contents

Class ApiConnector

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

The Api Adapter class is the base for all MQC API Connectors

public abstract class ApiConnector : AdapterBase, IFormProvider
Inheritance
ApiConnector
Implements
Derived
Inherited Members

Properties

DataSource

The Data Source of the Adapter. If a report file contains data from multiple data sources, this property has to be to "Unknown" and the DataSource of each AdapterData object has to be defined. DataSource should be "Undefined", if only files are downloaded.

public override string DataSource { get; }

Property Value

string

Methods

CheckAvailable(ApiConnectorContext)

CheckAvailable must be implemented by the Api Adapter class. This method is called to show a warning for configured but unavailable data sources in the UI.

public abstract bool CheckAvailable(ApiConnectorContext context)

Parameters

context ApiConnectorContext

ApiConnectorContext

Returns

bool

boolean (is the api available/accessible)

CheckModified(ApiConnectorContext)

CheckModified must be implemented by the Api Adapter class. This method is called by the local and server side monitoring, to check if the data sources should be updated.

public abstract bool CheckModified(ApiConnectorContext context)

Parameters

context ApiConnectorContext

ApiConnectorContext

Returns

bool

boolean (are there any changes)

ConfigureForm(IForm, string[])

ConfigureForm can be implemented by an API adapter. It is used to modify the FormSchema of the Add/Edit DataSource dialog for the AdapterConfiguration depending on the values entered (e.g. to make options or input fields visible and/or deactivate them based on a correct API request). It is called for the initial creation of the FormSchema with all fields as modified and when a field that was enabled by RefreshOnModified has been changed by the user. This method should also validate the configuration, not if the schema is valid, but if the values are usable (e.g. if the api is accessible and the authentification is valid).

public virtual FormError[] ConfigureForm(IForm form, string[] modifiedFields)

Parameters

form IForm

IForm, the AdapterConfiguration

modifiedFields string[]

Array of the modified fields as string (Form-Subfields as field.field or field.index.field)

Returns

FormError[]

Array of FormError, if a validation failed

Download(ApiConnectorContext)

Download can be implemented by the Api Adapter class. At least one of Download and Read must be implemented. The implementation of this method should access the configured API, download and save files to the context.DownloadPath directory and return a AdapterDownloadResult.

protected virtual AdapterDownloadResult Download(ApiConnectorContext context)

Parameters

context ApiConnectorContext

ApiConnectorContext

Returns

AdapterDownloadResult

AdapterDownloadResult

Execute(ApiConnectorContext)

Internal method

public ApiConnectorResult Execute(ApiConnectorContext context)

Parameters

context ApiConnectorContext

ApiConnectorContext

Returns

ApiConnectorResult

ApiConnectorResult

PreviewForm(IForm, string, out int)

PreviewForm can be implemented by an API Connector. It is used to load the Preview, if one was defined in the AdapterConfiguration. Based on the focused form field, the Preview is shown in the Dialog and provides the ability to load by clicking on a button. This button click calls this method. Based on the configuration and the preview type, the api should load the relevant data, limited to ~100 for better performance, and a array of FormPreview should be returned.

public virtual FormPreview[] PreviewForm(IForm form, string preview, out int totalCount)

Parameters

form IForm

IForm, the AdapterConfiguration

preview string

The preview type (string)

totalCount int

Output of totalCount, if 0 shown as ? in the preview dialog

Returns

FormPreview[]

Array of FormPreview, to show Title and optionally Description and DateTime

Read(ApiConnectorContext)

Read can be implemented by the Api Adapter class. At least one of Download and Read must be implemented. The implementation of this method should access the configured API, create AdapterData, AdapterMeasures and/or AdapterFindings and return a AdapterReadResult.

protected virtual AdapterReadResult Read(ApiConnectorContext context)

Parameters

context ApiConnectorContext

ApiConnectorContext

Returns

AdapterReadResult

AdapterReadResult