Configuration

Integrating via

The Portos eKasa Servis application stores its settings in a JSON text file. If your application should use the same settings, load this file and pass its content to the constructor of the Client class. The service technician then edits the settings in Portos eKasa Servis and your application picks them up.

Loading the configuration file in your application

  1. Build the file path The settings.json file in the default working directory NineDigit/Portos.eKasa under Environment.SpecialFolder.CommonApplicationData.
  2. Load the configuration With the JsonClientConfigurationFileDataSource reader and its Load() method.
  3. Pass it to the client To the constructor of the Client class, see Library instantiation.
// path to the default working directory that contains the configuration file
string ekasaWorkingDirectoryPath = Path.Combine(
  Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
  "NineDigit",
  "Portos.eKasa");

// full path to the configuration file
string configurationFilePath = Path.Combine(ekasaWorkingDirectoryPath, "settings.json");

// create the configuration reader
IDataSource<ClientConfiguration> configurationDataSource = new JsonClientConfigurationFileDataSource(configurationFilePath);

// load the content of the configuration file into the configuration object,
// if the file does not exist, the default configuration is used
ClientConfiguration configuration = configurationDataSource.Load() ?? new ClientConfiguration();

// pass the configuration object to the client constructor,
// the client then uses the same settings as the Portos eKasa Servis application
Client client = new Client(configuration);

CommonApplicationData is the default working directory on Windows. On macOS and Linux it is /etc/NineDigit/Portos.eKasa, because CommonApplicationData is not writable on macOS. EKasaPath.AppDataDirectoryPath returns the path for the current platform:

string configurationFilePath = Path.Combine(EKasaPath.AppDataDirectoryPath, "settings.json");
Configuration file Load() returns The client uses
exists the loaded configuration the Portos eKasa Servis settings
does not exist null the default configuration (new ClientConfiguration())

Namespaces and NuGet package

Class Namespace
JsonClientConfigurationFileDataSource NineDigit.eKasa.Configuration.DataSources
IDataSource<T> NineDigit.eKasa.Configuration.DataSources
ClientConfiguration NineDigit.eKasa

Since version 8 these classes are part of the NineDigit.eKasa NuGet package; in older versions they were in the separate NineDigit.eKasa.Configuration package.

Editing another configuration file in Portos eKasa Servis

To edit a different configuration file in the Portos eKasa Servis application, change the path to it:

  1. Open the menu Click the menu button in the upper right corner of the application.
  2. Choose Nastavenia aplikácie In the menu, select Nastavenia aplikácie (Application settings).
  3. Enter the path Enter the path to the configuration file, or locate it with the browse button.

Next steps

Esc

↑↓ selectEnter openEsc close

Chýba vám niečo v dokumentácii?

Napíšte nám, s čím potrebujete pomôcť. Ozveme sa do pár hodín.

Údaje použijeme len na odpoveď. Viac v ochrane osobných údajov.