View
212
Download
0
Category
Preview:
Citation preview
8/18/2019 PowerBuilde3PDF
1/9
PowerBuilder: Article
Creating A Distributed Power-Builder PDF Generator
Creating A Distributed Power-Builder PDF Generator
By Gerald Giggs, Scott Heffron Article Rating:
Give it 1/
Give it !/
Give it "/Give it #/
Give it /
Rate
$e%te&ber 1, !''' 1!:'' A( )D* Reads: +,!
•
Related• Print
• )&ail
• Feedbac.
• Add *is
• Blog *is
*e %ur%ose o0 tis %roect was to create a 2eb-based custo&-0or&s generation syste&tat would allow ad&inistrators to add re%orts to teir re3uested %ac.age, and users to
select re%orts4 $everal &odulari5ed %ieces were included witin its s%ectru& and eac
one needed to be connected 0or te a%%lication to wor. e00ectively4 *ese %ieces were
tree dis%arate database syste&s4
*e user inter0ace sould be troug a browser, and te %ages can6t be boo.&ar.ed4 Data
validation and data auto0illing &ust be real ti&e4 A &essaging syste& was needed so te
wor.0low %rocess wouldn6t alt4 *is syste& ad to allow users to s%eci0y te re%ortstey wanted %ac.aged togeter4 *e re%ort %ac.age ad to be %resented to te user
troug a 2eb inter0ace, stored 0or 0uture re0erence and %rotected by a %assword4 *is
article 0ocuses on ow we used PowerBuilder to create te re%ort server and C7( obect4
*e %roect re3uire&ents were based on te 0ollowing issues:
14 Re%orts on te 2eb never %rint out te way te user wants te& to4!4 *e user wants to ca%ture in0or&ation at a %articular &o&ent4
"4 *e user wants to save te re%ort 0or viewing4#4 *e user wants to con0igure di00erent re%ort co&binations4
4 *e user wants to be selective in te re%orts e or se %re%ares and %laces in te
%ac.age4
http://geraldgiggs.sys-con.com/http://geraldgiggs.sys-con.com/http://scottheffron.sys-con.com/http://pbdj.sys-con.com/node/42241#20http://pbdj.sys-con.com/node/42241#40http://pbdj.sys-con.com/node/42241#60http://pbdj.sys-con.com/node/42241#80http://pbdj.sys-con.com/node/42241#100http://pbdj.sys-con.com/node/42241#relatedhttp://pbdj.sys-con.com/node/42241#%23http://pbdj.sys-con.com/node/42241#%23http://pbdj.sys-con.com/node/42241#feedbackhttp://www.addthis.com/bookmark.phphttp://pbdj.sys-con.com/node/42241#%23http://geraldgiggs.sys-con.com/http://scottheffron.sys-con.com/http://pbdj.sys-con.com/node/42241#20http://pbdj.sys-con.com/node/42241#40http://pbdj.sys-con.com/node/42241#60http://pbdj.sys-con.com/node/42241#80http://pbdj.sys-con.com/node/42241#100http://pbdj.sys-con.com/node/42241#relatedhttp://pbdj.sys-con.com/node/42241#%23http://pbdj.sys-con.com/node/42241#%23http://pbdj.sys-con.com/node/42241#feedbackhttp://www.addthis.com/bookmark.phphttp://pbdj.sys-con.com/node/42241#%23
8/18/2019 PowerBuilde3PDF
2/9
*e PowerBuilder Data2indow allowed us to sow e8actly wat users would get in a
%rintout4 2e created te Data2indows so tey6d 0it on a %age4 2e can cange te
retrieval argu&ents on te 0ly and re&ove certain Data2indow obects4 *o getin0or&ation 0ro& several sources and %resent te data on one %age, te a%%lication &ust
be connected to 7racle, Access and DB! data sources4
Architecture
*e %ieces o0 tis %roect range 0ro& te user inter0ace, 2eb server %rocesses anddistributed PowerBuilder service to database connections4 96ll %rovide an overview o0
tese di00erent %ieces4
2e used ColdFusion to generate te 2eb-based user inter0ace4 2e needed to dyna&ically %o%ulate *(; obects wit data stored in te database, connect to di00erent databases
and co&&unicate wit C7( obects4 2e used , C7( obects and te re%ort server4
Because we used te 2indows !''' server, te 2eb server was 99$4 *wo &aor logicaldatabases were used 0or tis a%%lication: &aster and control4 *e &aster database
contained te user data, wic was stored on an 7racle database4 *e control databasecontained di00erent re%ort and argu&ent-retrieval in0or&ation 0or eac re%ort accessed by
te re%ort server4 2e used Access 0or te control database4 2e also used a DB! database
0or &essaging te wor.0low %ortion o0 te a%%lication4
Note: *e &aster and control databases can be con0igured on te sa&e &acine and beon te sa&e database4 Figure 1 sows te a%%lication arcitecture4
Distributed PB
Distributed PowerBuilder lets you serve PowerBuilder 0unctionality 0or oter %rogra&s touse4 *o %rovide so&e level o0 0ault tolerance we ensured, troug a utility called?srvany,? tat tis could be con0igured as a service4 *is %rogra& can be created as a
service using anoter utility, ?instsrv?4 7nce it6s a service, you can &odi0y its registry
settings to run anoter %rogra&4 7ne li&itation is tat you can6t s%awn anoter window0ro& te ?service? a%%lication4 9t6s i&%ortant tat te a%%lication %ro%erties are
con0igured so te syste& is te owner o0 te a%%lication, since no one will be logged onto
te &acine in te nor&al state4 *e only oter ting to consider is tat te a%%lication&ust be %ut into a listening &ode wen launced4 7ur a%%lication starts in a &ini&i5ed
state4 *e distributed PowerBuilder a%%lication was really serving only one obect, wic
ad several 0unctions callable 0ro& anoter a%%lication =see Figure !>4
*e C7( &odule, created using PowerBuilder +, was te glue tat allowed ColdFusionto tal. wit distributed PowerBuilder4 As a distributed PowerBuilder client, te C7(
&odule needed a %ro8y version o0 te served obect in te distributed a%%lication4 7ur
obect na&e was n@e8%ose4 7ur %ro8y version was a co%y o0 our real version in tedistributed a%%lication but wit te code re&oved and a return call 0or eac 0unction so
you could co&%ile your C7( obect, called n@%b+co&4 *e C7( obect was created
using te C7( obect wi5ard in PB+4 2en creating C7( obects it6s i&%ortant tat
8/18/2019 PowerBuilde3PDF
3/9
eac o0 te 0unction6s return values, argu&ents and any e8%osed =not %rotected> instance
variables be si&%le ty%es su%%orted by te C7( s%eci0ication4 $i&%le is certainly better
in tis environ&ent4 Any 0unctions tat contain argu&ents o0 co&%le8 ty%es &ust alsoave an access declaration o0 ?%rotected?4 2it so&e e00ort tis in0or&ation can be
gleaned 0ro& te error &essage you receive wen you atte&%t to build te C7( obect4
9t6s a bit o0 a switc 0ro& nor&al PowerBuilder %rogra&&ing and you &igt 0orget to %rotect a 0ew tings4
*e C7( obect can be instantiated 0ro& any a%%lication environ&ent tat su%%orts
C7(4 9n our case it was te co&&on lin. between PowerBuilder and ColdFusion4 7nce
instantiated, you can call te 0unctions in te PB C7( obect4 *ese, in turn, call0unctions 0ro& te distributed a%%lication4 *e 0unctions we e8%osed to te C7(
inter0ace were o0@beginob, o0@addre%ort, o0@runob and o0@deleteob4
9n distributed PowerBuilder a%%lications it6s use0ul to create an ad&inistration tool to get
te status o0 %eo%le accessing te a%%lication4 Distributed PowerBuilder %rovides several
0unctions tat allow you to do tis4 7ur &anage&ent a%%lication was triggered 0ro& a button on te actual distributed PowerBuilder server container a%%lication4 9t consisted o0
a single Data2indow tat sowed one row 0or eac user accessing te server4 9t also gavete ability to ?.ill? a user on te server 0or watever ad&inistrative reason &ade sense at
te ti&e4 *is is o0ten used to get rid o0 ung %rocesses on databases and 7$s4 ung
%rocesses weren6t a big %roble&, but it was nice to &onitor te service activity4 *e &ostel%0ul distributed PowerBuilder 0unction is:
connection4getserver9n0o=connectionin0o
C97, C*7 Develo%er Resources
9t %rovides an array o0 connection in0or&ation records you can loo% troug to stu00 in aData2indow4 7ne o0 te ele&ents o0 te connection in0or&ation record is te clientid,wic disconnects using te i@connection4Re&ote$to%Connection=clientid> &etod4
Web Interface
*e client re3uire&ents 0or tis a%%lication re3uired us to use ColdFusion4 *e
a%%lication server needed to create a dyna&ic site4 *is 0unctionality allowed us tocange te
8/18/2019 PowerBuilde3PDF
4/9
Reort Generation
*e Data2indow de0initions E te %oint o0 tis distributed a%%lication E are noting
s%ecial4 *e a%%lication6s obective is to leverage PowerBuilder6s ability to generate clear,e00ective and %rintable re%orts4 (ost o0 our re%orts were igly 0or&atted single-%age
re%orts4 9t isn6t necessary to create any Data2indow argu&ents in te Data2indow since
any $; argu&ents are added dyna&ically at runti&e4 9t6s i&%ortant to .ee% te $;relatively si&%le so you can give yoursel0 &ore 0le8ibility wit te argu&ents4 9n our
a%%lication we ad eac re%ort ta.e te sa&e argu&ents owever, te re%ort engine was
written to su%%ort a varying nu&ber o0 argu&ents 0or eac re%ort4 9n our version tere%ort engine used a structured array to %ass argu&ents to an added re%ort4 *is is
obviously not C7( co&%liant tere0ore we ad to &a.e te C7( obect s%eci0ic to tis
a%%lication wit res%ect to te re%ort argu&ents4
9n &ost situations te 0inal PDF 0ile would be a &ulti%le %age docu&ent &ade u% o0 anu&ber o0 Data2indow re%orts4 2e andled tis by using Adobe Acrobat to %rint eac
Data2indow to a 0ile na&ed wit a &illisecond-level ti&e sta&%4 7nce eac 0ile ad
been %rinted, we6d &erge te PDF 0iles into a single out%ut 0ile using te ActivePDFtool.it 0ro& ActivePDF4co&4 *is as an AP9 tat can be called 0ro& PowerBuilder =see
;isting !>4 *is wor.ed &agni0icently and incurred very little overead4 2e ad to ado%t
tis &etod once we reali5ed we couldn6t o%en a %rint ob and use several Data2indow
%rint 0unctions to build te &ulti%age re%ort4 A %rint ob can6t be called 0ro& a distributeduser obect since it needs a window to be its %arent4 2e ado%ted tis window &ecanis&
initially, but 0ound it wouldn6t wor. once we &ade te distributed a%%lication an *
service4 *e ActivePDF tool.it gave us te ability to deal wit tese restrictions4
*e lin.age between te C7( obect and distributed PowerBuilder isn6t any di00erenttan calling a distributed PowerBuilder a%%lication 0ro& any non-C7( PowerBuilder
a%%lication4 Hou &ust 0irst connect to te distributed a%%lication using te connect0unction, wic results in a connection andle4 *is andle can ten be used to call te0unctions o0 te obect tat6s being served in te server a%%lication4 *e code in ;isting "
illustrates tis connection4
Storage of Reorts
$torage s%ace 0or tese re%orts is an ongoing issue4 7ne o0 te %roble&s is calculating tes%ace re3uired 0or tis ty%e o0 %roect4 ;uc.ily 0or tis one tere was %lenty o0 s%ace4 9n
&ost cases, toug, we ave to set u% a sceduling &ecanis& to run %eriodically and
re&ove any 0iles older tan a %rede0ined ti&e4 *e s%ace 0or te debugging 0iles alsoneeds to be considered4 For tis tas. we decided to delete te debug 0ile u%on success0ul
co&%letion o0 te re%ort being generated, wic allowed 0or 3uic.er debugging4 2e
e00ectively solved te %roble&s 0or te targeted re%ort and didn6t worry about te oterre%orts in te syste&4
*e re3uire&ents 0or tis %roect included aving te re%orts saved 0or te calling
a%%lication and also 0or 3uic. re0erence 0ro& a browser, wic was di00erent tan te
&ain section o0 te a%%lication tat allowed 0or no boo. &ar.ing4 2e created a se%arate
8/18/2019 PowerBuilde3PDF
5/9
virtual directory 0or te re%orts4 *is allows 0or browser boo. &ar.ing, were te actual
a%%lication does not allow 0or any boo. &ar.ing4 Figure " sows an e8a&%le re%ort4
Debugging Reorts !rrors *e s%ace 0or te debugging 0iles also needs to be considered4 For tis tas. we decided to
delete te debug 0ile u%on success0ul co&%letion o0 te re%ort being generated4 *iswould allow us to 0ind te %roble& re%orts 3uic.ly4 *is allowed us to e00ectively solve
0or te targeted re%ort and not worry about te oter re%orts in te syste&4
Su""ar#
Because o0 te arcitecture, adding new re%orts is a si&%le tas. E si&%ly 0ollow te rules
tat ave already been stated4 96& sure your clients won6t ave a %roble& designing newre%orts to &a.e your li0e interesting4 *is also allows you to use re%orts 0ro& your old
a%%lication and &a.e te& 2eb-ready in ours, instead o0 wee.s4 2e also de&onstrated
te ability to reuse code wit te C7( obect 0unctionality4 *is enables develo%ers to
ta.e e8isting business logic and &a.e it into distributed PowerBuilder obects4 Hour 2eb
a%%lication can call te C7( obect and use code 0ro& e8isting a%%lications4 *is %roectsowed us tat we can use te distributed PowerBuilder &ecanics to create a &ore
e00ective syste& and &aintain te code in one %lace4
8/18/2019 PowerBuilde3PDF
6/9
Creating a Distributed PowerBuilder PDF Generatorwritten by Scott Heffron and Gerald GiggsPBDJ 7-8 p
8/18/2019 PowerBuilde3PDF
7/9
!isting "# Calling t$e C%& ob'ect fro( ColdFusion
8/18/2019 PowerBuilde3PDF
8/9
,,%ret = APT00,k/t#O&e$O.t&.tF/,e2/)%'$a1e8/' ,,%ret te$
'%err0r23APT00,k/t Err0r363C0.,d $0t 0&e$ 0.t&.t '/,e3 /)%'$a1e8
,,%reta, = -
(0t0 DETROY%*Te$d /'
FOR ,,%c$t = TO .&&erb0.$d2/)%&a(e'/,e8,)%1er(e'/,e = /)%&a(e'/,e,,%c$t,,%ret = APT00,k/t#Mer(e'/,e2,)%1er(e'/,e6 6 8*F ,,%ret
8/18/2019 PowerBuilde3PDF
9/9
/' ,,%ret te$'%err0r23C0$$ect/0$ Err0r36 I3Err0r 3 )tr/$(2,,%ret8 3 3 ac0$$#ErrTeHt8ret.r$ -
e,)e
ac0$$#Create*$)ta$ce2/eH&8/' $0t /)a,/d2/eH&8 te$'%err0r23d/)tr/b.ted err0r363C0.,d $0t create /$)ta$ce 0' $%eH&0)e38ret.r$ -
e$d /' e$d /' ret.r$
Te d/)tr/b.ted .)er0bject '.$ct/0$) ca$ te$ be acce))ed a) '0,,0@)
,)tr%ar()#)%ar($a1e = 3&&'%'1c0er#'ac/,/t53,)tr%ar()#)%ar(a,.e = a)%'ac/,/t5
,)tr%ar()#)%ar($a1e = 3&&'%'1c0er#re'ere$ce%$br3,)tr%ar()#)%ar(a,.e = a)%re'%$0
,)tr%ar()#)%ar($a1eK = 3&&'%'1c0er#re'ere$ce%).b%$br3,)tr%ar()#)%ar(a,.eK = a)%re'%).b%$0
,,%ret = /eH'%addRe&0rt2/,%j0b6 a)%re&0rt6 ,)tr%ar()6 ,)%err0r8
/' ,,%ret te$'%err0r23Err0r36 3C0.,d $0t add te re&0rt 3 a)%re&0rt 3# 3 ,)%err0r8/)%err0r = ,)%err0r ret.r$ -
e$d /'
Recommended