Absrtact: In practical application, the clock of each workstation in client/server architecture is often required to keep synchronized with the server clock; This paper illustrates a solution based on Sybase database and PowerBuilder development tool.
First, the preface
PowerBuilder through the Data window object, the database can be operated conveniently and directly, so it has become the first Choice development tool for developing Client/server mode application. In the development of hospital information Management system, we used PowerBuilder as the foreground development tool, Sybase as the background database.
In hospital information management system, there are many modules require workstation time and server to keep in sync, such as: outpatient fee system requires to be able to evenly to the Siyao window distribution prescriptions, hospital pharmacies to be placed according to the ward to send orders in time order. To solve this problem, we have written a corresponding program, the main idea is: the use of dynamic cursors to obtain server time, WIN32 API functions to set the local time, the specific implementation of the following methods:
Second, the realization method:
1, connect the database
PowerBuilder supports a variety of database management systems (DBMS), such as Sybase, Oracle, Informix, Microsoft SQL Server, and so on, depending on the type of database, using a private interface or ODBC connection database. Establish the interface configuration file (DB profile).
2. Create Application object, write script in Application object event
The script for the 1>, Application object Open event is as follows:
startupfile = "settime.ini"
sqlca.DBMS= ProfileString (startupfile, "database", "dbms", "")
sqlca.database=ProfileString(startupfile,"database","database","")
sqlca.userid=ProfileString(startupfile,"database","userid","")
sqlca.dbpass=ProfileString(startupfile,"database","dbpass", "")
sqlca.logid=ProfileString(startupfile, "database", "logid","")
sqlca.logpass=ProfileString (startupfile, "database","LogPassWord", "")
sqlca.servername=ProfileString(startupfile,"database",ervername","")
sqlca.dbparm= ProfileString (startupfile, "database", "dbparm", "")
connect;
f_setlocaltime() //调用自定义函数完成设置本地工作站时间
The script in the 2>, Application object Close event is as follows:
DISCONNECT Using SQLCA;
3, the definition of WIN32 API functions for external functions
In the Script Brush workspace, select Declare > Global External functions ..., which defines the WIN32 API function as an external function, defined as follows:
FUNCTION LONG SetLocalTime (ref systemtime systimeptr) LIBRARY "Kernel32.dll"
4. Define the structure of access time parameters
Click the Structure Painter button in Painterbar or Powerpanel to define a structure named: SYSTEMTIME, the variables that compose the structure and the corresponding data types are as follows:
integer wyear
integer wmonth
integer wdayofweek
integer wday
integer whour
integer wminute
integer wsecond
integer wmillisecond