Title: PowerBuilder Foundation Class
1PowerBuilder Foundation Class
- Sea Bass Software Limited
- www.seabass.co.uk
2Introduction
- David Hargreaves
- david.hargreaves_at_seabass.co.uk
- Sea Bass Software Limited
- www.seabass.co.uk
3Topics for Discussion
- Using PFC Services
- Adding Additional Services
- Debugging an Application
- PFC Security
4Using PFC Services
- Service Orientated Framework
- Service Classes
- Requestor Classes
- Creating Services
- Delegating Work to Services
5Service Orientated Framework
- Functionality is encapsulated in service classes
- Requestor classes delegate work to service
classes - Uses the Client/Server model
6Service Orientated Framework
Services
Requestor
Base
Sort
Filter
7Service Classes
- Perform work specific to the service
- Maintains a link to the requestor object
8Service Classes
n_cst_dwsrv_sort
u_dw idw_requestor ...
of_SetRequestor(u_dw adw_requestor) idw_requestor
adw_requestor ...
pfc_clicked(xpos, ypos, row, dwo) This.of_Sort()
...
of_Sort() idw_requestor.Sort() ...
9Requestor Classes
- Owns service objects
- Create service objects required
- Maintains a link to the service object
- Delegates work to the service object
- Destroys the service object
10Requestor Classes
u_dw
n_cst_dwsrv_sort inv_sort ...
of_SetSort(boolean ab_switch) inv_sort Create
n_cst_dwsrv_sort inv_sort.of_SetRequestor(This)
...
clicked(xpos, ypos, row, dwo) IF IsValid
(inv_Sort) THEN inv_Sort.Event pfc_clicked
( xpos, ypos, row, dwo ) END IF ...
11Creating Services
- Requestor object owns the service object
- Requestor object creates the service (two way
link) - Requestor contains pre-defined instance variables
to point to service - Pre-defined requestor functions allowing the
service to be created
12Creating Services
u_dw (requestor)
n_cst_dwsrv_sort inv_sort
... of_SetSort(TRUE) inv_sort Create
n_cst_dwsvr_sort inv_sort.of_SetRequestor(This)
...
n_cst_dwsvr_sort (service)
u_dw idw_requestor
... idw_requestor adw_requestor ...
13Demonstration
- Create application error service
- Create window status bar service
14Delegating Work to Services
- Work is delegated using pre-defined methods in
Requestor and Service objects - Delegation Types
- Pre-defined delegation
- User-defined delegation
15Pre-defined Delegation
- Requestor Pre-coded events
- PowerBuilder events
- PFC events called from menu
- Service Pre-coded events
- Re-directed from requestor
16Pre-defined Delegation
u_dw (requestor)
n_cst_dwsrv_sort inv_sort
IF IsValid (inv_Sort) THEN inv_Sort.Event
pfc_clicked ( xpos, ypos, row, dwo ) END IF
n_cst_dwsvr_sort (service)
u_dw idw_requestor
... idw_Requestor.Sort() ...
17User-defined Delegation
- Service pre-coded functions
- Requestor delegates work to service
- Functions used to change the state of a service
18User-defined Delegation
u_dw (requestor)
n_cst_dwsrv_sort inv_sort
This.of_SetSort(TRUE) IF IsValid(inv_Sort)
THEN inv_Sort.of_SetStyle(inv_sort.dragdrop) END
IF
n_cst_dwsvr_sort (service)
integer ii_style
... ii_style ai_style ... Return 1
19Demonstration
- Determine the error service attributes
- Database
- Log File
- Severity
- Determine the status bar attributes
- Time
- User/Database
- Progress bar
20Using PFC Services Summary
- Service Classes encapsulate functionality
- Requestor Classes call required services
- Pre-defined delegation has been coded into the
PFC - User-defined delegation changes the default style
of the service
21Adding Additional Services
- Create Additional Service Objects
- Create Service Object
- Instance variables
- Functions
- Events
- Add New Service to Requestor
- Instance variable
- Create/Destroy function
- Re-direct calls to service
22Create Additional Service Objects
pfc_w_master
pfc_n_base
w_master
n_base
pfc_w_response
pfc_n_cst_dwsrv
w_response
n_cst_dwsrv
w_column_dragdrop
n_cst_dwsrv_column
23Demonstration
- Create a DataWindow service to allow columns to
be moved during runtime - Create a column service object
- Create a column service attribute object
- Create a column drag and drop window
24Create Service Functions
- Encapsulate functionality
- Protected instance variables
- Protected functions
- Enable the requestor to customise the service
- Protected instance variables
- Public functions to change variables
25Create Service Functions
n_cst_dwsrv_column (Extension Layer)
string is_excludecolumns
Public of_setexclude (string as_excludecols) of
_getexclude (ref string as_excludecols) Protect
ed of_buildcolumnattrib ( ref
n_cst_columnattrib anv_columnattrib) ...
26Demonstration
- Create the column service functionality
- Create the required instance variables
- Create the public interface, such as get/set
functions - Create the column functionality
27Create Service Events
- Create user events for requestor redirection
- Process service functionality
- Call additional service objects
- Ensure a return code is provided
28Create Service Events
n_cst_dwsrv_column (Extension Layer)
event pfc_column()
... IF NOT IsValid(idw_requestor) THEN li_rc
-1 ELSE li_rc This.of_SetColumn() END
IF RETURN li_rc
29Demonstration
- Create the column service events
- Create a pfc_columndlg event to call the
drag-drop window
30Add New Service to Requestor
- Add instance variable for service
- Add of_Set() function to enable service
- Re-direct events to service
31Add New Service to Requestor
u_dw (Extension Layer)
n_cst_dwsrv_column inv_column ...
Public of_setcolumn(boolean ab_switch)
pfc_columndlg event IF IsValid(inv_column)
THEN inv_column.Event pfc_columndlg() END IF ...
32Demonstration
- Create the requestor service calls
- Create service instance variable
- Create function to turn service on/off
- Create a pfc_columndlg event to call the column
service
33Creating Services
- Requestor object owns the service object
- Requestor object creates the service (two way
link) - Requestor contains pre-defined instance variables
to point to service - Pre-defined requestor functions allowing the
service to be created
34Creating Services
u_dw (requestor)
n_cst_dwsrv_column inv_column
... of_SetColumn(TRUE) inv_column Create
n_cst_dwsvr_column inv_column.of_SetRequestor(Thi
s) ...
n_cst_dwsvr_column (service)
u_dw idw_requestor
... idw_requestor adw_requestor ...
35Demonstration
- Create the column service to allow columns to be
moved during runtime - Add a menu item to call the service
36Adding Additional Services Summary
- Create new service objects
- Create events for redirection and functions to
encapsulate functionality - Create requestor links to service object
- Instance variable
- Create/Destroy function
- Re-direct functionality
37Debugging an Application
- Application Debugging
- SQL Debugging
38Application Debugging
- Creating the debug service
- Display debug messages
- Debug service using the registry
39Creating the Debug Service
- Requestor creates the service (two way
link) - Requestor contains pre-defined instance variables
to point to service - Pre-defined requestor functions allowing the
service to be created - Requestor user delegation
- Delegates work to service
- Functions used to change the state of a service
40Creating the Debug Service
n_cst_appmanager (requestor)
n_cst_appmanager inv_debug
... of_SetDebug(TRUE) inv_debug Create
n_cst_error inv_debug.of_OpenLog(TRUE) inv_debug.o
f_SetAlwaysOnTop(TRUE)
41Demonstration
- Create the debug service
- Determine the debug service attributes
- Open log window
- Window state
42Display Debug Messages
- Create a standard debug message function
- Define a method for storing debug messages
- Default message a part of header script
43Standard Debug Message Function
n_cst_appmanager
of_debug(as_Object, as_Event, as_Description)
... IF IsValid(gnv_app.inv_debug) THEN IF
gnv_app.inv_debug.of_IsLogOpen() THEN
ls_Message "Object " as_Object "
ls_Message "Evt/Fun " as_Event " "
ls_Message as_Description
gnv_app.inv_debug.of_Message(ls_Message) END
IF END IF
44Default Header Script
n_cst_appmanager
pfc_open event
... gnv_app.of_Debug(This.ClassName(),
"pfc_open") ...
45Debug Service using the Registry
- Create the registry settings
- Allows service to be used in development
- Allows service to be used in live application
- Modify the creation settings
46Debug Service using the Registry
n_cst_appmanager (requestor)
n_cst_appmanager inv_debug
... RegistryGet(...\Debug', 'Application',
RegString!, ls_Debug) IF Lower(ls_Debug)
'on' THEN This.of_SetDebug(TRUE) ...
inv_debug.of_SetAlwaysOnTop(TRUE) ...
inv_debug.of_OpenLog(TRUE) END IF ...
47Demonstration
- Add service registry settings
- Turn the service on
- Make the debug window always appear on top
- Change error and status bar options
48Debugging an Application Summary
- Start the debug service
- User-defined delegation changes the default style
of the service - Start the SQL debug service
- Owned by the debug service
- User-defined delegation changes the default style
of the service
49PFC Security Utility
- Set Up the Security Application
- PFC Application Security Service
- Using the Security Application
50Set Up the Security Application
- Create the Security database tables
- SQL Scripts (pfcorax.sql, pfcsyx.sql)
- PFC Database (pfc.db)
- Create the Security scanner application
executable (pfcsecsc.exe) - All objects must be in the EXE because it changes
its library list - Create Security application executable
51Demonstration
- Create security database tables
- Create security scanner executable
52PFC Application Security Service
- Create the Application objects security service
- Start the service (of_SetSecurity)
- Initialise the service (of_InitSecurity)
- Register the relevant windows with the security
service (pfc_preopen event)
53Demonstration
- Add the security settings to the registry
- Start the security service on the application
object - Start the security service on a PFC window
54Using the Security Application
- Create Security Groups and Users
- Scan a PFC Application
- Assign permissions to PFC objects for Groups or
Application Users
55Creating Groups and Users
- Groups
- Groups of Users
- Users
- Individual user logons
56Scan a PFC Application
- Select a PFC application
- All windows and DataWindows are selected
- Highlight objects to be scanned
57Assigning Permissions
- Select application window or DataWindow
- Select Group or User
- Assign permissions to objects on window or
DataWindow - Not Set
- Invisible
- Disabled
- Enabled
58Demonstration
- Scan a PFC application
- Create ADMIN and USER groups
- Create Users and add them to the groups
- Assign permissions to application objects
59PFC Security Utility Summary
- Set Up Security application
- Create Security options in the PFC application
- Scan the PFC application
- Create groups and users
- Assign permissions to application objects
60Questions and Answers
- David Hargreaves
- david.hargreaves_at_seabass.co.uk
- Sarah Bell - Business Manager
- sarah.bell_at_seabass.co.uk
- (01491) 682585
- Web Site
- www.seabass.co.uk