Click or drag to resize

How to develop an ImportType

The Import tab in the Data Manager View lets user to import external data files. However it can be quite a challange using these external data as the data format vary from source to source.

The ImportType scripts overcomes these challanges by letting the user to define how these external data files will be parsed and imported into ArthaChitra.

Main methods

Once user chooses the necessary importType script from the comboBox located in the Import tab in the Data Manager view, and click on Import, a choose file dialog will pop up. Once user selects the necessary files and click on Open, ArthaChitra will start parsing the files.

ArthaChitra internally will loop through the selected file one by one. When a new file is being read it will call the OnNextFile(String). This method will also pass the full name of the file which is to be parsed.

ArthaChitra will then internally calls the GetNextInstrument method. User have to define for which instrument the data is being parsed for. If no instrument can be parsed, ArthaChitra will skip to the next selected file. If a suitable instrument is available then ArthaChitra will proceed to parse the data for that instrument.

User have to define how the data will be parsed in the GetNextDataPoint method. The OnNextDataPoint method returns a nullable bool. If the data is successfully parsed then user should return true. This way ArthaChitra will parse the next data point. If no data can be parsed however there are still valid data points in the file then user should return null. This way ArthaChitra wont try to append any data however will still carry on reading the file. Once all the data has been consumed user must return false so that ArthaChitra can exit and call the next available file (if any).

Once all the data is read ArthaChitra will call the OnFileEnd method and will move to the next selected file if avaialable (and will call the OnNextFile method again and repeat the process).

OnStateChanged

The OnStateChanged method is called whenever the State of the script is changed. The various states which the ImportType script have are:

  • Initialize - when the ImportType class is created.
  • Finalize - When the script encounters an error or is being finalized (disposed off). All clear up codes should be placed here.
protected override void OnStateChange()
 {
     //your code here
 }

Please refer here to know more