//-----------------------------------------------------------------------------
// IConnectorExample.js file
//-----------------------------------------------------------------------------
// There is described the usage of the IConnector object in the example.
//-----------------------------------------------------------------------------
//@ Start Example
// Creating the database connection and data storage objects
var Connector = new ActiveXObject('TSObjectLibrary.Connector');
var UserInfo = new ActiveXObject('TSObjectLibrary.UserInfo');
var Value = new ActiveXObject('TSObjectLibrary.Value');
var Configuration = new ActiveXObject('TSObjectLibrary.Configuration');
Value.Value = new ActiveXObject('TSObjectLibrary.StringsList');
// Order number of the configuration that is opening
var CurrentConfiguration = 1;
// Message displaying function
function ShowMessage(Str) {
for (var i = 1; i < arguments.length; i++ ) {
Str = Str.replace(new RegExp('%' + i), arguments[i]);
}
WScript.Echo(Str);
}
// Function of the user's derived data formation
function GetUserInfo(UserInfo, Value) {
// A variable for the data strings formation
var TotalString = new String();
// Result value initial cleaning
Value.Value.Clear();
// Sequential adding of the user's data to the storage
TotalString = "Contact identifier: " + UserInfo.ContactID;
Value.Value.Add(TotalString);
TotalString = "Contact name: " + UserInfo.ContactName;
Value.Value.Add(TotalString);
TotalString = "User identifier: " + UserInfo.ID;
Value.Value.Add(TotalString);
TotalString = "Is the user an administrator? " + UserInfo.IsAdmin;
Value.Value.Add(TotalString);
TotalString = "User name: " + UserInfo.Name;
Value.Value.Add(TotalString);
}
// Configuration collection loading
Connector.LoadConfigurations();
Configuration = Connector.Configurations.Items(CurrentConfiguration);
// Displaying the name of the configuration that is opening
ShowMessage("Name of the configuration that is opening for the Supervisor: %1",
Configuration.Name);
// Opening the configuration for the Supervisor with blank password
Connector.OpenConfiguration(Configuration, 'Supervisor', '');
// Displaying the information of the current system user
GetUserInfo(Connector.CurrentUser, Value);
ShowMessage(Value.Value.Text);
// Displaying the date and time on the workstation and the server
ShowMessage("Time on the workstation: %1", Connector.GetLocalDateTime());
ShowMessage("Time on the DBMS server: %1", Connector.GetServerDateTime());
// The five global unique identifier generation
for (i = 0; i < 5; i++) {
ShowMessage("The unique identifier is generated: %1",
Connector.GenGUID());
}
// Attribute value setting and displaying
Connector.Attributes.Values('TestAttribute') = "Test value";
ShowMessage(Connector.Attributes.Values('TestAttribute'));
//@ End Example
|
Copyright (с) Terrasoft 2002-2007.
|