Example Code Kit Library Usage:
ApplicationInit, please add code to call the following function located in the NSA.cs class to your application Initialise event :-
| CustomerID (Int) | Set to your Nalpeiron CustomerID. |
|---|---|
| ProductID (Int) | Set to you Nalpeiron ProductID. |
public int init(int CustomerID, int ProductID)
Example:
ApplicationStart Logging, please add code to call the following functions located in the NSA.cs class to your application start event : -
| Parameters | Description |
|---|---|
| Username (string) | This is the recorded username of user starting the application, if not required or available set to empty string. |
| Applanguage (string) | Set to the ISO 2 digit language code for the applications running Language. |
| Version (String) | Set to your applications Major version number. |
| Build (String) | Set to your applications Build Number. |
| Edition (String) | Set to your applications Edition. |
| LicenseStatus (String) | Set to your applications License Status. |
public int ApplicationStart(string Username, string AppLanguage, string Version, string Build, string Edition, string LicenseStatus)
Example:
ApplicationEnd logging, please add code to call the following function located in the NSA.cs class to your application exit event.
| Function | Parameters |
|---|---|
| ApplicationExit | NONE |
public int ApplicationEnd()
Example:
Exception Logging (if required), please add code to call the following function located in the NSA.cs class to your applications Global error handler.
| Function | Parameters | Description |
|---|---|---|
| Exception | Username (String) | This is the recorded username of user running the application, if not required or available set to empty string. |
| ExceptionCode (string) | This is the errorcode of the exception thrown. | |
| Description (String) | This is the description of the error thrown. |
public int Exception(string Username, string ExceptionCode, string Description)
Example:
Feature logging, please add code to call the following functions located in the NSA.cs class to each feature in your application you would like to be recorded.
| Function | Parameters | Description |
|---|---|---|
| FeatureStart | Username (String) | This is the recorded username of user running the application, if not required or available set to empty string. |
| FeatureCode (String) | The feature code setup on the NSA server which records the required feature usage. | |
| Description (String) | This is the description of the error thrown. | |
| FeatureEnd | Username (String) | This is the recorded username of user running the application, if not required or available set to empty string. |
| FeatureCode (String) | The feature code setup on the NSA server which records the required feature usage. |
public int FeatureStart(string Username,string FeatureCode) public int FeatureEnd(string Username,string FeatureCode)
Example:
Setup your user logging, please add code to call the following functions located in the NSA.cs class in your code recording a user logon and logoff.
| Function | Parameters | Description |
|---|---|---|
| LogUserOn | Username (String) | This is the recorded username of the user logging on. |
| LogUserOff | Username (String) | This is the recorded username of the user logging off. |
public int LogUserOn(string Username) public int LogUserOff(string Username)
Example:
Setup your client side privacy, please add code to call the following functions located in the NSA.cs class in your code to check and change the local privacy settings.
| Function | Parameters | Description |
|---|---|---|
| GetPrivacy | NA | This function returns the current privacy settings for the client, possible values shown below. |
| LogUserOff | Privacy (PrivacyValues) | This function sets the current privacy settings for the client, possible values shown below. |
| Privacy Values | Setting | Description |
|---|---|---|
| 0 | (OFF) | Collect and send logging data to the server |
| 1 | (ON) | Do NOT collect and send logging data to the server |
| 2 | (NOT_SET) | No privacy setting has yet been selected |
public int GetPrivacy()
public int SetPrivacy(PrivacyValues Privacy)
public enum PrivacyValues: short
{
OFF = 0,
ON = 1,
NOT_SET = 2
}
Example:
NSA Library Usage:
The following functions are provided by the NSA library. For example usage see our example applications.
| Function | Description | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| int NSAOpen(string xmlParams) | Initializes the library. Returns 0 for success and a negative number for an error. NSAOpen's parameters (string xmlParams) are passed in as a a UTF* character string containing valid XML of the following form:
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
Where:<NSAXMLParams> <LogLevel>value</LogLevel> <LogDir>dir_path</LogDir> <LogQLen>int</LogQLen> <CacheQLen>int</CacheQLen> <SoapThreadsMin>int</SoapThreadsMax> <OfflineMode>0 or 1</OfflineMode> <ProxyIP>IP addr</ProxyIP> <ProxyPort>port number</ProxPort> <ProxyUsername>string</ProxUsername> <ProxyPassword>string</ProxyPassword> </NSAXMLParams> logdir is the location where NSA will store its log file and cache file. If this value is not specified the files will be stored in the default Nalpeiron directory (/etc/nalpeiron on Linux and Mac, it a publicly accessible directory selected by the OS on Windows) loglevel is an integer 0 to 6. If loglevel is not specified it will default to level 0 (off). You should not use log level higher than 4. The higher levels do not provide any useful end user debugging.
queue reaches this length, additional log entries will be discarded. As messages in the queue are written to the log file, the queue will shrink and logging will automatically begin again. The default is 300. CacheQLen is the maximum length of the cache queue. Once the cache queue reaches this length, additional cache entries will be discarded. As messages in the queue are written to the cache file, the queue will shrink and caching will automatically begin again. The default is 25. SoapThreadsMin/SoapThreadsMax - Network connections between the NSA library and the Nalpeiron server are handled by a lthread pool. The values specify the minimum number of threads available to the pool and the maximum number of threads available to the pool. The number of threads in the pool will grow and shrink between these two extremes as needed. The default for each is 10. ProxyIP/ProxyPort - If the NSA library is connecting to the internet via a proxy use these values to specify the IP address and port number of the proxy server. If no proxy is used, they can be left empty or completely unspecified. The default is no proxy. ProxyUsername/ProxyPassword - If you are using a network proxy to which requires a username and password, specify them here. OfflineMode - If OfflineMode is on (1), the no data is sent to the Nalpeiron server. All transactions are written immediately to cache. The library makes no attempts to collection location information or send the cache to Nalpeiron. The default is 0 (ie on-line). |
||||||||||||||||||||||||||||||||||||||
| int NSAClose() | Shuts down the library. THIS FUNCTION MUST BE CALLED IMMEDIATELY BEFORE CLOSING THE LIBRARY (ie with application exit). If this function is not called before the library is closed, information may be lost and memory corruption could occur. Returns 0 for success and a negative number for an error. | ||||||||||||||||||||||||||||||||||||||
| NSAHelloWorld() | Connects to Nalpeiron and retrieves a "Hello World". Used only for testing the library and connectivity. Returns 0 on success and a negative number for an error. | ||||||||||||||||||||||||||||||||||||||
| int NSAGetPrivacy() | Checks current privacy settings. Returns 0 for "no privacy", 1 for "privacy enabled", 2 for "unset" and a negative number for an error. If privacy is unset, the privacy setting used will be the one stamped into the library. | ||||||||||||||||||||||||||||||||||||||
| int NSASetPrivacy( short setting) | Sets a privacy value for the library. Possible values for setting are 0 "no privacy", 1 "privacy enabled" or a negative number for an error. | ||||||||||||||||||||||||||||||||||||||
| int NSAAppStart() | Records startup of your application. Returns 0 on success and a negative number for an error. | ||||||||||||||||||||||||||||||||||||||
| int NSAAppStop() | Records shutdown of your application. Returns 0 on success and a negative number for an error. | ||||||||||||||||||||||||||||||||||||||
| int NSALogin( string username) | Records login of username. Returns 0 on success and a negative number for an error. Username should be a ANSI C string or a utf8 encoded unicode string. | ||||||||||||||||||||||||||||||||||||||
| int NSALogout( string username) | Records logout of username. Returns 0 on success and a negative number for an error. Username should be a ANSI C string or a utf8 encoded unicode string. | ||||||||||||||||||||||||||||||||||||||
| int NSAFeatureStart( string username, string featureCode) | Records start of use of featureCode by username. Returns 0 on success and a negative number for an error. Username and featureCode should be a ANSI C strings or a utf8 encoded unicode strings. | ||||||||||||||||||||||||||||||||||||||
| int NSAFeatureStop( string username, string featureCode) | Records end of use of featureCode by username. Returns 0 on success and a negative number for an error. Username and featureCode should be a ANSI C strings or a utf8 encoded unicode strings. | ||||||||||||||||||||||||||||||||||||||
| int NSAException( string username, string exceptionCode, string description) | Records an error of type exceptionCode by username with details in description. Returns 0 on success and a negative number for an error. Username, featureCode, and description should be a ANSI C strings or a utf8 encoded unicode strings. | ||||||||||||||||||||||||||||||||||||||
| int NSASysInfo( string username, string applang, string version, string edition, string build, string licenseStatus) |
Send information about the system to Nalpeiron. Returns 0 on success and a negative number for an error. Username, applang, version, edition, build, and licenseStatus should be a ANSI C strings or a utf8 encoded unicode strings.
|
||||||||||||||||||||||||||||||||||||||
| int NSASendCache( string username) | Check NSA's job cache. If not empty, send it. Returns 0 on success and a negative number for an error. Username should be a ANSI C string or a utf8 encoded unicode string. This function is provided for special circumstances but should be largely unnecessary as sending of the cache is automatic. Upon a successful completion of any of the functions about, the communication thread checks to see if the cache contains information. If it doesn, it is sent to Nalpeiron. | ||||||||||||||||||||||||||||||||||||||
| int ValidateDLL( int customerID, int productID, int seed ) | Verifies that the shared library you are accessing is the library you stamped. It does this by checking the customerID and productID sent in against the stamped values. If they match, 1 is returned. If they do no match a 0 is returned. Set Seed = 0. | ||||||||||||||||||||||||||||||||||||||
| int ReturnVersion() | Returns the version of the NSA library being accessed. | ||||||||||||||||||||||||||||||||||||||
| int NSAGetStats( out IntPtr ReturnStats ) | Returns information about the NSA library's status. The following information is return in the form of a string. <?xml version="1.0" encoding="UTF-8"?>
<NSA Current Statistics> <OfflineMode>0</OfflineMode> <LocationInfo>1</LocationInfo> <Cache Thread> <Max Cache Que Len>25</Max Cache Que Len> <Current Cache Que Len>0</Current Cache Que Len> <Cache writes>1</Cache writes> <Cache fails>0</Cache fails> </Cache Thread> <Soap Pool> <Min Soap Threads>10</Min Soap Threads> <Max Soap Threads>10</Max Soap Threads> <Queued Jobs>0</Queued Jobs> <Running Jobs>0</Running Jobs> <Finished Jobs>145</Finished Jobs> </Soap Pool> </NSA Current Statistics> |






