This section gives information about the setup and configuration features of the AMIgo controls.

Setup and Configuration controls and methods

AMIgo offers several high level controls that allows to retrieve, edit and update the configuration files used by Asterisk. These controls are named with prefix AMIgoSetup. The AMIgoSetupPanel control group most setup controls into a tab control to form a full featured setup / configuration panel.

A Configuration file and a DialPlan editor controls are also available.

The AMI_Client component offers several methods to get and update configuration files and higher level methods to create / update users, queues, agents, conferences etc.

Note
See: AMI_Client Members for the list.

Configuration model and the Asterisk GUI

AMIgo uses and supports the configuration model introduced by the Asterisk GUI, which allocates a ranges of extensions for the different PBX elements and store these in the guipreferences.conf configuration file.

The Asterisk GUI assigns extensions range for: Users (Extensions), Queues, Conferences, Ring Groups and Voicemail groups. AMIgo adds two new items to this: Agents and Applications. These extensions range will be used to write the dialplan instructions. Each element is written in a different context and these context are include in the 'default' context.

If the guipreferences.conf file exists this will be used. Otherwise a default extension range will be proposed. You can edit and save this from the 'General' tab of the Setup panel. The extension can be set to a size of 3 or 4 digits.

Caution

Make sure that the extensions range do not overlap.

Using the Dictionaries

AMIgo uses generic Lists of Dictionary to store and manipulate the configuration information that is retrieved from the Asterisk configuration files:

public List<Dictionary<string, string>>

This is a list of Dictionary which contains the configuration information in the form of key / Value pair. Each section or context in a given configuration file is contained in a dictionary in the list. Each of these dictionary has a "FileName" and a "Category" keys which identify the file and context / section.

These dictionary lists are available as AMI_Client public fields. See:

AMI_Client Fields, See also: _AgentsConfigList()()()(), _AgentsConfigList()()()(), _ConferencesConfigList()()()(), _ExtensionsConfigList()()()(), _QueuesConfigList()()()(), _UsersConfigList()()()()

Use the GetDicoIndexInList(List<(Of <<'(Dictionary<(Of <<'(String, String>)>>)>)>>), String) method to get the index of a given category / context from a Dictionary List.

Use the GetValueFromDictionaryList(List<(Of <<'(Dictionary<(Of <<'(String, String>)>>)>)>>), String, String, String%) method to get the value of a given category / context and Key name from a Dictionary List.

You can use the foreach keyword and KeyValuePair object to read the key / values from the dictionary

CopyC#
1if ((index = GetDicoIndexInList(_ExtensionsConfigList, "default")) != -1)
2{
3  string key = "", value = "";
4  foreach (KeyValuePair<string, string> kvp in _ExtensionsConfigList[index])
5  {
6    key = kvp.Key;
7    value = kvp.Value
8  }
9}

Getting the config files

Several method with name starting with ConfigGet allows to retreive and parse various configuration file into the Dictionary Lists used internally by AMIgo.

These method will generate a ConfigFileReadEvent()()()() after the config file has been received and parsed. The Dictionary List is then available through the public fields.

If the AutoGetConfig property is set to true (default), the configuration for the users, queues, agents and conferences will be retreived after login and the Dictionary Lists will contains the configuration information for the currently connected system

Configuration file editor

The AMIgoConfigEditor Panel and Form controls allows to display, edit and update the configuration file.

Use the ConfigGetFile(String) method to retrieve a file. Once the file has been read a GetConfigEvent()()()() will be triggered and the GetConfigEventArgs will contains the FileName and the content of the config file as an array of strings.

The example below show how to get a file and open it in the AMIgo editor control in a form.

CopyC#
 1private void buttonGetConfig_Click(object sender, EventArgs e)
 2{
 3  if (AMI_ClientInstance != null)
 4    AMI_ClientInstance.ConfigGetFile("asterisk.conf");
 5}
 6public void GetConfigEventHandler(object sender, GetConfigEventArgs ev)
 7{
 8  if (AMI_ClientInstance != null)
 9    AMI_ClientInstance.ConfigOpenEditor(ev.filename, ev.strings);
10}

DialPlan Editor

The AMIgo dialplan editor allows to display and edit the dialplan. It display a list of the current contexts in a panel which allows to select fthe context for display and edition. This editor allows to insert lines anywhere in a context.

To use the dialplan editor, drop a AMIgoConfigEditorPanel in a container or create a new AMIgoConfigEditorForm.