Retrieving the 'SiteKey' of an OpenPetra installation

From OpenPetra Wiki
Jump to navigation Jump to search

Overview

Each installation of OpenPetra is installed for a particular 'Site' - that is an office of your organisation.

  • An instance of the OpenPetra Server runs for one Site, and all OpenPetra Clients that access that OpenPetra Server are tied to that Site.
  • The Site is set up in the System Manager Module when OpenPetra is installed for an office.
  • The Site is identified in OpenPetra with a SiteKey, which is the PartnerKey of the Partner (of PartnerClass 'UNIT') that represents that office.

The SiteKey is needed by OpenPetra's software engineers in various circumstances and this page describes how to access it.

Accessing the Site Key on Client Side

Int64 SiteKey = Convert.ToInt64(TSystemDefaults.GetSystemDefault(SharedConstants.SYSDEFAULT_SITEKEY));

(TSystemDefaults is found in Namespace Ict.Petra.Client.App.Core)

Accessing the Site Key on Server Side

Int64 SiteKey = DomainManager.GSiteKey;

(DomainManager is found in Namespace Ict.Petra.Server.App.Core)

Accessing the Country Code of this Site

You may need to retrieve the two-letter Country Code for this Site. Note the methods given here rely on the Site having a default ledger, which will be the case only if the Finance system is in use.

On the server, call TAddressTools.GetCountryCodeFromSiteLedger(ATransaction), or if you don't have a transaction handy, you can call TPartnerServerLookups.GetCountryCodeFromSiteLedger() which uses a new or existing transaction.

This method uses the DomainManager (see above) to find the site key, and then uses this to call

string GetCountryCodeFromLedger(TDBTransaction ATransaction, Int32 LedgerNumber)

which can be used to find the Country Code associated with any ledger.

On the client, the ServerLookups method can be called like this:

string LocalCountryCode = TRemote.MPartner.Partner.ServerLookups.WebConnectors.GetCountryCodeFromSiteLedger();