Access Topal via API
The IManager interface is a first interface with which you start your work. It gives you the possibility to receive, delete, or save and edit data.
All the functionality is encapsulated under the manager class, which connects to the server (in case of a network installation) or starts the standalone server
(in case of a standalone installation), depending on the kind of installation. The first thing you do after creation is login to the Topal System. To start working with
All the functionality is encapsulated under the manager class, which connects to the server (in case of a network installation) or starts the standalone server
(in case of a standalone installation), depending on the kind of installation. The first thing you do after creation is login to the Topal System. To start working with
accounting you have to set the current client, fiscal year and VAT periods. Fiscal year and VAT period are global variables for a given client. The loading of any list with Manager Class will provide you with current client instances. When you create a transaction, it will be inserted in the current fiscal year, so the date of the document should correspond with the beginning and end of a fiscal year. When you logout from the Topal System, the last client used and the fiscal year will be stored. When you log in again you can set the current client manually or use the defaults. If you want to use the defaults, you need to set UseDefaults property to true before login. Usually, in order to refresh any list of instance, you have to call methods, which start with Load. In most cases, it is enough to have all information about instances within this list, but some instances have a link to other instances. For example, the ITransaction interface has a posting list. When you call the LoadTrasanctions method, you will receive only base information about transactions like document number, transaction type etc. If you want to load the whole transaction, you have to call LoadTransaction methods that provides you with transaction with linked posting.
To call LoadTransaction you have to refresh the whole transaction list, but if you know the document number, you can use FindTransaction method where you have to define the document number of needed transaction. Similar methods (approach) are available for all “complex” interfaces, which have a link to other interface(s) – IInvoice, IParty.
To call LoadTransaction you have to refresh the whole transaction list, but if you know the document number, you can use FindTransaction method where you have to define the document number of needed transaction. Similar methods (approach) are available for all “complex” interfaces, which have a link to other interface(s) – IInvoice, IParty.
Example Code
The main object to access Topal's resources via API is the Manager object. A developer will gain full control of all resources by accessing the instance
of the Manager object.
of the Manager object.
IManager manager = new Manager();
Dim Manager
Set Manager = CreateObject("TopalServerAPI.Manager") 'Create Topal API COM object
Having created the manager object as stated in the previous section, your now in the position to connect to the Topal Server
The Topal Server the IP address or DNS name of the system, where Topal Server is running on, must be configured (e.g. "Maverick" or "192.168.100.21").
You are also able to access Topal via “localhost” or “127.0.0.1”, in case of a standalone installation on your local machine.
Topal is a multi user system, therefore you need to provide your credentials (valid user ID and password) to logon to the server. Creating new users is described in
Topal Help of your Topal installation or online via Topal Online Help.
Topal Help of your Topal installation or online via Topal Online Help.
string msg = string.Empty;
bool result = manager.Login( Maverick, ”TopUser”, “”, out msg);
if (!result) {
ShowMessage(msg);
return;
}
Dim errCode
Dim message
Dim logined
'Login to Topal server
logined = Manager.Login( ip, userName, userPass, message) 'returns true if login was successful
if (logined) then
MsgBox("Connected successfully")
else
MsgBox(message)'Show error message if not logged in
end if
In the example at hand, we connect to a server “Maverick” with user “TopUser” and empty password string.
If the connection and login is successful, the Login method returns true, otherwise you will receive an error message. The Error message
Connect to Topal Server via SSL
The following steps have to be taken, if you intend to use a secure communication via Secure Socket Layer (SSL) between 3rd party application and
Topal Financial Accounting System.
The manager object holds a property (string) Manager.CertThumbprint = "52204809F304CFA7409B3EEF33EFB490DEF06AE0". That property contains the
CertThumbprint string, which is related to your installed Certificate. The call to the Manager.LoginWindow() will not be required for 3rd Party applications.
The following steps have to be taken, if you intend to use a secure communication via Secure Socket Layer (SSL) between 3rd party application and
Topal Financial Accounting System.
The manager object holds a property (string) Manager.CertThumbprint = "52204809F304CFA7409B3EEF33EFB490DEF06AE0". That property contains the
CertThumbprint string, which is related to your installed Certificate. The call to the Manager.LoginWindow() will not be required for 3rd Party applications.
// set ssl connection for Manager
bool manager.UseSSL = true;
// set client certificate
string manager.CertThumbprint = "52204809F304CFA7409B3EEF33EFB490DEF06AE0";
// method to show dialog with certificate choosing
bool manager.ChooseSSLCertificate();
UNDER CONSTRUCTION
Topal API provides two methods to disconnect from Topal Server. The Manager.Logout() method log's the user out from Topal, while the close method also
closes the connection to the Topal Server. In case of a standalone installation you need to use the Manager.close() method.
closes the connection to the Topal Server. In case of a standalone installation you need to use the Manager.close() method.
manager.Logout();
manager.Close();
Manager.Logout()
Manager.Close()
Topal has been designed to return Error codes in case of a failure or an unsuccessful command execution. Each method will return zero (0) if command has been executed successfully,
or return an Error code <> 0. Call the static method GetErrorMessage() to receive an error message, if a command finished with Error code <> 0
Since this method is static it can be used globally to retrieve Error messages.
// Load transactions via LoadTransactions()
int errorcode = manager.LoadTransactions();
MessageBox.Show(manager.GetErrorMessage(errorcode));
UNDER CONSTRUCTION