Implementation of JAGUAR GTS components in PB7.0

zhaozj2021-02-17  73

PB7.0 Implementation JAGUAR GTS Component Development Guangzhou Jinyuheng Technology Co., Ltd. Chen Jishan 01-6-25 05:42:09

PB7.0 is closely integrated with Jaguar CTS (Component Server), only need to write a small number of code, you can establish a component based on Jaguar CTS, while jaguar CTS itself has built-in PB virtual machine, using the components written in PB7.0 can be directly JAGUAR CTS performs efficient communication. Such PB components are established through the JAGUAR CTS and the background database to facilitate development based on three-layer architecture.

Establish a JAGUAR component

There are three ways in PB to establish JAGUAR components:

1, Start Wizard: Establish a new application, new user objects and new projects;

2, Object Wizard: Create a new user object and engineering on the basis of existing applications;

3, Project Wizard: Generate a JAGUAR component from the existing user object.

You can establish one of the above three methods as needed to establish a JAGUAR component. Establishing a JAGUAR component is usually as follows:

1. Use Start Wizard (or Object Wizard, Project Wizard) to create a new application, new user objects, and new projects;

2. Add methods, events, and instance variables for user objects;

3, test components;

4. Release the components to JAGUAR CTS.

Establish Jaguar client applications

In order to realize the communication of the client and JAGUAR components, you need to establish a JAGUAR client application as follows:

1. Use Jaguar Connection Object Wizard to establish a connection object;

2. Use Jaguar Proxy Wizard to create a project to use the project to generate a proxy object;

3, create a window, menu, and script to make a client graphical user interface;

4. Write appropriate code to create a JAGUAR component instance and access it (through proxy object);

5, test client application;

6. Publish client applications.

Example

This example establishes a JAGUAR CTS component by PB7.0, then publishes to the JAGUAR CTS server, which passes the ODBC data source (this source name is EAS DEMO DB V3) and the background database (this example uses Sybase Adaptive Anywhere Database, Database Name: EasDemodb.db), the client agent accesss through the JAGUAR CTS component, such as querying employees in the Employee table, etc., thereby implementing a typical PB three-layer architecture application. The specific practices are as follows:

1. Establish a JAGUAR CTS component

Start PB7.0, select File -> New, pop up a dialog, select the Start Wizard page, double-click Start Jaguar Componet icon, under the guidance guide, you can generate a new application, component, engineering, here Named JAG_APP, N_JAG_CMP, P_JAG_PRJ.

Open the library brush, open the library file where jag_app, double-click Open the n_jag_cmp user object, in the Declare column, the instance variables are as follows:

protected:

DataStore IDS_EMP / / Declare an invisible data storage object

In the constructor event of the n_jag_cmp user object, create a database connection, the code is as follows:

// Profile EAS DEMO DB V3

Sqlca.dbms = "ODBC"

Sqlca.database = "EAS DEMO DB V3"

SQLCA.AUTOCOMMIT = FALSE

Sqlca.dbparm = "ConnectString =

'DSN = EAS DEMO DB V3; UID = DBA; PWD = SQL' "

//

CONNECT Using SQLCA;

// Create a data storage object and make it necessary

IDS_EMP = CREATE DATASTORE

IDS_EMP.DataObject = "D_EMP"

IDS_EMP.SETTRANSOBJECT (SQLCA)

In the DEStructor event of the n_jag_cmp user object, do the following cleaning work to release resources:

Destroy IDS_EMP

Disconnect Using Sqlca;

Add a function uf_employee for the n_jag_cmp user object, the function accesses the type of public, the return value is the BLOB type, no parameters, the function body is as follows:

Blob LBLB_DATA

IDS_EMP.RETRIEVE ()

IDS_EMP.GETFULLSTATE (LBLB_DATA)

Return LBLB_DATA

Create a data window object, named: D_EMP, the data window shows the style Grid, the syntax is as follows:

SELECT "Employee". "EMP_ID",

"Employee". "EMP_FNAME",

"EMPLOYEE". "EMP_LNAME",

"Employee". "Birth_date",

"Employee". "Salary",

"Employee". "SEX"

From "employee"

Close all brushes other than Library, double-click the P_JAG_PRJ engineering object to open the project brush, click the build icon of the shortcut toolbar, compile and publish the component to the specified JAGUAR CTS server.

2. Establish a client application

Select File -> New, pop up a dialog, double-click the Application icon of the Start Wizard page, create a new PBL library and an application object, the PBL library name: jag_client.pbl, the application object name is: jag_client_app.

Select File -> New, pop up a dialog, double-click the Connection Object Wizard icon of the Object page, create a connection object, the connection object name is JAG_Connection, pay attention to the Requires Jaguar Connection item when the SPECIFY Connectivity screen selects the connection option. Specifies the machine name where the JAGUAR CTS server is located, the default port is 9000, the default login ID is jagadmin. Select the name of the corresponding package (that is, the name of the package specified when the JAGUAR CTS component is established). Follow the wizard to complete the remaining steps.

Select File -> New, pop up a dialog, double-click the JAGUAR Proxy Wizard icon in the Project page Create a proxy engineering object, named p_jag_client_prg, specify the parameters of the JAGUAR CTS server and packets as described above.

After the creation, double-click the p_jag_client_prg object, open the project brush, click the build icon of the shortcut toolbar, and wrap the p_jag_client_prg object. At this time, you will find more than one n_jag_cmp proxy object in jag_client.pbl. Select File -> New, pop up a dialog box, double-click the Window icon of the Object page, create a window object, the object name is: W_Proxy, save the object.

Add the following controls in W_Proxy: A data window control, the control name is: DW_EMPLOYEE, a button control, the control is named CB_RETRIEVE, the text is: extract data.

A connection instance and a component instance are declared in W_Proxy's Declare field, and the code is as follows:

JAG_CONNECTION MY_CONNNNN

n_jag_cmp my_comp

Connect the connection object in W_Proxy's Open event, and connect to JAGUAR CTS, the code is as follows:

MY_CONN = CREATE JAG_CONNECTION

my_conn.connecttoserver ()

On W_Proxy's Close event interrupt and clean up the connection object, the code is as follows:

my_conn.disconnectServer ()

Destroy my_conn

Add the following code to the CLICKED event of the CB_RETRIEVE button:

Blob LBLB_DATA

IF not isvalid (my_comp) then

MY_CONN.CREATEINSTANCE (MY_COMP)

// Create a component instance

END IF

LBLB_DATA = my_comp.uf_employee ()

// Method for calling components

DW_EMPLOYEE.SETFULLSTATE (LBLB_DATA)

// Display the required data in the data window

Finally compile and run the client program, you will get the following results:

This example runs in Windows NT4.0 (SP4), Adaptive Server Anywhere6.0, Jaguar CTS3.0, and PB7.0.

转载请注明原文地址:https://www.9cbs.com/read-31079.html

New Post(0)