Distributed PowerBuilder Design

zhaozj2021-02-17  73

Distributed PowerBuilder Design Zhang Jianzi 01-6-22 03:09:10

Power-Builder 5.0, launched in June 1996, added many new features, which is more focused on Distributing PowerBuilder.

The so-called distributed calculation method and the three-level system structure are a new way of calculation in recent years, which is to add a middle stage called the application server in the traditional client / server two-level structure for execution. Complex business logic calculation. Traditional two-level structures are generally placed on the client, and a small amount is in the form of a database server in the form of a stored procedure. Independing commercial logic from other two levels will be more adaptable to increasingly complex and increasingly changing business logic, thereby bringing convenience in development, maintenance and use. Although the three-level structure has not been widely accepted in the traditional database field, in the Internet & intranet field, people have started to use this distributed computing method: in intranet, the system is at least by the browser (client), Web Server (Application Server), the three-level structure consisting of the database. PowerBuilder supports this distributed calculation method, which makes we use PowerBuilder to develop Internet applications.

The implementation of the so-called distributed PowerBuilder is to initialize a user-defined object in the client side, and call the properties and functions of this object.

New concepts in distributed PowerBuilder

Server Applications: In the previous PowerBuilder version, Power-Builder Application is submitted as client applications in the client / server architecture, which is introduced to the server application in distributed PowerBuilder. This application includes an invisible user object and is called by a client application, which is called a remote process object. This call can be cross-process or across the hardware platform. Distributed PowerBuilder There is a PowerScript object transport to monitor the needs of the client on the server side, and this server-side app can also call the same as the client or remote client application of the traditional client / server application. PowerBuilder server application.

Customer Application: PowerBuilder client application is part of the remote object. Distributed PowerBuilder Application includes a new object called Connection to connect to the PowerBuilder server application. When the server is connected to the server, the client application calls the remote object as the locally invisible user object.

Remote object: With other unreviewable user object classes. A remote object contains commercial logic written in PowerScript, placed on the server, as a special case that is not visible to user objects, remote objects can reference various unacceptable functions and database instructions, such as using DataWindow's invisible form DataStore to implement Package for database access, etc. Remote objects are called a process or function call, and support parameter delivery and return results to support all other types other than the object data type.

Transfer object: It is a special connection object that the server is used to receive the customer request. When you create a transfer instance using the CREATE TRANSPORT command, the object monitors the request for the received customer in the protocol defined in the object's properties. The properties of this object include communication-driven names, communication protocol types, timeout protocols, etc., and how to set and set these properties are the same as other objects of PowerBuilder as transaction.

Connection Object: It is an object of the client to send a request. When creating a connection object using Create Transport, the Connect to Server function of this object performs connection with the server, communication, such as communication name, protocol, or the like, by the properties of the connection object.

Object Storage Agent: A new selection of storage user objects. Storage agent saves the remote name of the object and generates internal code for remote calls. When the Connec-TION object is connected to it, the object can be used to remotely.

The new PowerBuilder object is the inheritance class of NonvisualObject and Structure, and their relationships are as follows:

NonvisualObject

ConnectObject (new)

CONNECTION (new)

TRANSPORT (new)

RemoteObject (new)

Structure

ConnectionInfo (new)

Design a distributed PowerBuilder application example 1. Server application

First you need to create a server-side application. All distributed PowerBuilder server applications should be run on a 32-bit platform (Windows NT or Windows 95). This application requires three components: 1. User-defined object class; Second, this object class is in the server side of the server; three, a transmission object, this transfer object is not called, it is just to listen to the network Call at one end of the customer.

· Create user objects

We first define a server-side object class, which steps are as follows:

1. Click the user object icon.

2. Click the New button.

3. Select the Custom type in the Class group in the NewUserObject dialog.

4. In the design of entering the user object, select the Declare | User Object Function menu item.

5. Click the New button.

6. The function named "of-my-message".

7. The return value of the function is String type, no parameters pass.

8. Write in the Script of the function: return "Hello World"

9. Close the function brush, store this user object as UO-My-Object "

· Set a proxy object

This agent object is called a class being referenced by the client, but it should first be created on the server side, the steps to create a proxy object are as follows:

1. Open the user object UO-My-Object that is just created.

2. Right click on the user area.

3. Select "Set Proxy Name" in the pop-up menu.

4. Enter "Uo-Proxy-My-Object" in the input domain of the agent name and click the OK button.

5. Store the "UO-My-Object" object.

* At this time, if you look at the current PBL library in the Library brush, you will see the newly created proxy object.

· Set transfer objects

This object works very similar to the transaction object in PowerBuilder, which is a structure that connects to the client. The setting process is as follows:

1. Declare a global Transport variable. Such as:

Transport GT-TRANSPORT

2. Write down in the Open event of Application:

GT-Transport = CREATE TRANSPORT

GT-Transport.driver = "namedpipe"

GT-transport.location = "."

GT-Transport.Application = "MY-DPBSERV"

GT-Transport.Options = ""

GT-Transport.Listen ()

Second, the application of the client

There are four components of the client's application: 1. Get the proxy object created in the Server side, put it into the client's object library; Second, the application of the server side is to create a connection object Example; 3, create a proxy object, set its connection (with setConnec-Tions () to connect to the Connect object); four, call the remote process object, test this connection.

· Place a proxy object into the client's object library

Here you have the following two ways: First, copy "Uo-Proxy-My-Object" agent object to the client's application object library; another means is to "Uo-Proxy-My-Object" this The object library where the object is located is also placed in the client's search library.

• Connect the client on the server application: 1. Declare a global connection object:

Connection GC-Connection 2. Creating a connection object in the app, define its partial properties and establish a connection with the server:

GC-Connection = CREATE Connection

GC-Connection.driver = "namedpipes"

GC-Connection.Location = "ServerName"

GC-Connection.Application = "MY-DPBSERV"

GC-Connection.Options = "" GC-Connection.connectTOSERVER ()

* Where the Location property refers to the name of the computer where the server application is running: Application Attribute is the name of the server-side application where the object is transferred.

· Create a proxy object instance, connect it to the connection object. 1. Declare a global variable of "Uo-Proxy-My-Object". (This is also the reason why this agent object is placed in the path searched by the client application)

UO-Proxy-My-Object GP-UO-Proxy-My-Object 2. Type the following code in the OPEN event of the application object:

GP-UO-proxy-my-object = create uo-proxy-my-object 3. Call the setConnect () function of the proxy object to pass the parameters of the connection object, connect the agent object instance on the connection object: (this end code can also Execute in the app of the OPEN event)

GP-UO-Proxy-My-Object.SetConnect (GC-Connection)

· Call the remote object

The Of-My-Message function of the distal object returns a string, so we can call this function in the following programs to display its return value. 1. In the window, design a button, its Clicked event is written as follows:

String Ls-Retcode

LS-RETCODE = iuo-proxy-my-object.of-my-message ()

MessageBox ("Message from Remote Object", LS-RETCODE) 2. First run the server on the server side; 3. Run the client on the customer; 4. Click the window button, we can get the result, show a standard There is a message box with "Hello World".

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

New Post(0)