MiddleWare Technology- Lab Manual JWFILES

download MiddleWare Technology- Lab Manual JWFILES

of 171

Transcript of MiddleWare Technology- Lab Manual JWFILES

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    1/171

    Department of Information Technology

    MIDDLEWARE TECHNOLOGIES

    Lab Manual for the Academic Year 2007-2008

    III B.Tech

      Gr Nana! Engineering College  I"rahimpatnam# R R Di$trict % &'( &') *A+ ,+-

    In.charge HOD ,rincipal

    ,repare/ "y0 Appro1e/ 2  Re1ie3e/ "y0

    I$$e/ "y0 3+e+f Date0

    N. Kutumba RaoM. B. N. Reddy

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    2/171

    Guru Nanak Engineering College  Ibrahimpatnam, R R Distrit ! "#$ "#% &'. (.)

      Department of Information Technology

      *ab Manual +or the 'ademi ear -##/#0  &In aordane 1ith 2N34 syllabus)

    54B2EC3 6 M73 *'B

    54B2EC3 C8DE 6 I3 "9#:)

    5EME53ER 6 III / II

    53RE'M 6 In+ormation 3ehnology

    IN53R4C38R 6 5. 5'N3;I (RI'

    (R8GR'MMER5 6 $) N+ 45T5M6A RAO-) M+6+ NEELA4ANTESHWARA REDD7

    ;ead I3

    - 2 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    3/171

    Guru Nanak Engineering College  Ibrahimpatnam, R R Distrit ! "#$ "#% &'. (.)

    5uggestions +rom (rinipal 6

    Enhanement i+ any 6

    Comments 6

    - 3 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    4/171

    INDE8

    S+No Name of the Content ,AGE NO+

    $ *ab 8b

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    5/171

    *ab 8b

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    6/171

    INTROD5CTION A6O5T LA6

    3here are %% systems & Compa (resario )

    installed in this *ab. 3heir on+igurations are as +ollo1s 6

    (roessor 6 'MD 'thelon $.% G;

    R'M 6 -"% MB

    ;ard Disk 6 9# GB

    Mouse 6 8ptial Mouse

    Net1ork Inter+ae ard 6 (resent

    Soft3are

    1 'll systems are on+igured in D4'* B883 mode i.e,5tudents an boot +rom 7indo1s ( or *inu? as pertheir lab reuirement.

    3his is =ery use+ul +or students beause they are+amiliar 1ith di++erent 8perating 5ystems so thatthey an e?eute their programs in di++erent

    programming en=ironments.2 Eah student has a separate login +or database aess

    8rale :i lient =ersion is installed in all systems. 8nthe ser=er, aount +or eah student has been reated.

    3his is =ery use+ul beause students an sa=e their1ork & senariosA, plFsl programs, data related pro

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    7/171

    5tudents an e?eute their assembly languageprograms using M'5M. M'5M is =ery use+ulstudents beause 1hen they e?eute theirprograms they an see ontents o+ (roessor

    Registers and ho1 eah instrution is beinge?euted in the C(4.

    1 Rational Rose 5o+t1are is installed in somesystems

    4sing this so+t1are, students an depit 4M*diagrams o+ their pro

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    8/171

    LA6 CODE0

    $. 5tudents should report to the onerned labs as per time table

    shedule.

    -. 5tudents 1ho turn up late to the labs 1ill in no ase be permited to do

    the program sheduled +or the day.

    >. '+ter ompletion o+ the program , erti+iation o+ the onerned sta++ 

    in/harge in the obser=ation book is neessary.

    9. 5tudents should bring a notebook o+ about $## pages and should enter

    the readingFobser=ations into the notebook 1hile per+orming the

    e?periment.

    ". 3he reord o+ obser=ations along 1ith the detailed e?perimental

    proedure o+ the e?periment per+ormed in the immediate last session

    should be submitted and erti+ied by the sta++ ember in/harge.

    %. Not more than three students in a group are permitted to per+orm the

    e?periment on a setup.

    . 3he group/1ise di=ision made in the beginning should be adhered to

    and no mi? up student among di++erent groups 1ill be permitted later.

    0. 3he omponents reuired pertaining to the e?periment should be

    olleted +rom stores in/harge a+ter duly +illing in the reuisition +orm.

    :. 7hen the e?periment is ompleted, students should disonnet the

    setup made by them, and should return all the

    omponentsFinstruments taken +or the purpose.

    $#. 'ny damage o+ the euipment or burn/out o+ omponents 1ill

    be =ie1ed seriously either by putting penalty or by dismissing the total

    group o+ students +rom the lab +or the semesterFyear.

    $$. 5tudents should be present in the labs +or the total sheduled

    duration.$-. 5tudents are reuired to prepare thoroughly to per+orm the

    e?periment be+ore oming to *aboratory.

    $>. (roedure sheetsFdata sheets pro=ided to the studentAs groups

    should be maintained neatly and to be returned a+ter the e?periment.

    - 8 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    9/171

    La" ,rogram$

    Middle1are 3ehnologies ! *ab (rograms *ist

    5ubmission ! $

    7eek ! $$. Commnication0 Create a ser=er that aepts the reuests +rom lientand lient displays the ser=er system in+ormation

    7eek ! -

    -. 9ile tran$fer0 Create a ser=er that asks +or a pass1ord, then opens a+ile and sends the +ile o=er the net1ork onnetion. Create a lient thatonnets to this ser=er, gi=es the appropriate pass1ord, then aptures andsa=es the +ile.

    7eek ! >

     >. Calclator0 Create a remote ser=er that implements a alulator 1ith

    basi +untionalities like addition, subtration, di=ision, multipliation andlient, 1hih uses the remote alulator.9. Stoc!mar!et0 Create a remote stok ser=er that aepts the ompanyname and gi=es the share =alue. 5tok lient that retrie=es the ompanyshare =alue and displays by gi=ing the ompany name.

    7eek ! 9

     ". ,hone "oo! $er1er0 Create a remote phone book ser=er thatmaintains names and phone numbers. (hone book lient should pro=ide auser inter+ae that allo1s the user to sroll through entries, add a ne1entry, modi+y an e?isting entry and delete an e?isting entry. 3he lient andthe ser=er should pro=ide proper error handling.

    5ubmission ! -

    7eek ! " Introdution to C

    7eek ! %

    $. Wor!ing 3ith call"ac!$ an/ /elegate$ in C: 0 Demonstrates the useo+ delegates, allbaks, and synhronous and asynhronous methodin=oation, inluding ho1 Miroso+t .NE3 Hrame1ork lasses pro=ide e?pliitasynhronous support using the Begin and End namingon=entions and ho1 you an make use o+ this support in your o1n ode.

    7eek ! -. Co/e acce$$ $ecrity 3ith C: 0 Demonstrates the use o+ .NE3Hrame1ork Code 'ess 5eurity, in 1hih ode an ha=e permissionsindependent o+ the person e?euting the ode.

    5ubmission ! >

    7eek ! 0

     >. Creating a COM; component 3ith C: 0 Demonstrates ho1 to reatea C8M omponent, that takes ad=antage o+ 3ransation managementser=ie 1ithin C8M, then assign a strong name to the assembly, registerthe assembly in the Global 'ssembly Cahe, and register the omponent1ith C8M.

    - 9 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    10/171

    7eek ! :9. Creating a Win/o3$ Ser1ice 3ith C: 0 Demonstrates ho1 to reate aMiroso+t 7indo1s 5er=ie that uses a Hile 5ystem 7ather ob

    $#. Sen/ing Mail 3ith SmtpMail an/ C: 0 4ses a simple 7eb +orm todemonstrate ho1 to use the 5mtpMail lass in the .NE3 Hrame1ork.$$. ,erform String Maniplation 3ith the String 6il/er an/ StringCla$$e$ an/ C: 0

    Demonstrates some basi string manipulation using both the 5tring Builderand 5tring lasses.

    7eek ! $9

    $- . Application Configration 5$ing Configration 9ile$ an/ theRegi$try 5$ing C: 0 ' sample appliation that demonstrates methods o+storing appliation settings by making use o+ both the system registry andappliation on+iguration +iles. Implements a ustom on+iguration setionto sho1 ho1 you an tailor these +iles to the spei+i needs o+ a partiularappliation.$>. 5$ing the Sy$tem+Net+We"Client to Retrie1e or 5ploa/ Data 3ithC: 0 Demonstrate ho1 to reate a 7indo1s Horm that an use ;33( todo1nload and sa=e a resoure +rom a spei+ied 4RI, upload a resoure to a

    spei+ied 4RI, or read and 1rite data through a stream ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    11/171

    Desription about M73 Conepts6

    In the computer industry, middleware is a eneral term !or any prorammin that

    ser"es to #lue toether# or mediate $etween two separate and o!ten already e%istin

     prorams& ' common application o! middleware is to allow prorams written !or access

    to a particular data$ase to access other data$ases&

    (iddleware, or #lue#, is a layer o! so!tware $etween the networ) and the

    applications& *his so!tware pro"ides ser"ices such as identi!ication, authentication,

    authori+ation, directories, and security& In todays Internet, applications usually ha"e to

     pro"ide these ser"ices themsel"es, which leads to competin and incompati$le standards&

    y promotin standardi+ation and interopera$ility, middleware will ma)e ad"anced

    networ) applications much easier to use&

    *ypically, middleware prorams pro"ide messain ser"ices so that di!!erent

    applications can communicate& *he systematic tyin toether o! disparate applications,

    o!ten throuh the use o! middleware, is )nown as enterprise application interation

    ./'I&

    - 11 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    12/171

    'IM

    Create a ser=er that aepts the reuests +rom lient and lientdisplays the ser=er system in+ormation

    (R8GR'M

    import

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    13/171

    'IMCreate a ser=er that asks +or a pass1ord, then opens a +ile andsends the +ile o=er the net1ork onnetion. Create a lient thatonnets to this ser=er, gi=es the appropriate pass1ord, thenaptures and sa=es the +ile.

    (R8GR'M

    import

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    14/171

    'IM

    Create a remote ser=er that implements a alulator 1ith basi+untionalities like addition, subtration, di=ision, multipliation andlient, 1hih uses the remote alulator.

    (R8GR'M

    Inter+aes

     

    3he +irst step is to 1rite and ompile the 2a=a ode+or the ser=ie inter+ae. 3he Calulator inter+aede+ines all o+ the remote +eatures o++ered by the

    ser=ie6

    publi inter+ae Calulatore?tends

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    15/171

    Implementation

     Ne?t, you 1rite the implementation +or the remoteser=ie. 3his is the CalulatorImpl lass6

    publi lass CalulatorImple?tends 

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    16/171

    Ho$t Ser1er

    Remote RMI ser=ies must be hosted in a ser=erproess. 3he lass Calulator5er=er is a =ery simpleser=er that pro=ides the bare essentials +or hosting.

     import

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    17/171

      ath &Mal+ormed4R*E?eption murle) 5ystem.out.println&)L5ystem.out.println&

      QMal+ormed4R*E?eptionQ)L5ystem.out.println&murle)L

    ath &RemoteE?eption re)

    5ystem.out.println&)L5ystem.out.println&

      QRemoteE?eptionQ)L5ystem.out.println&re)L

    ath &NotBoundE?eption nbe)

    5ystem.out.println&)L5ystem.out.println&

      QNotBoundE?eptionQ)L5ystem.out.println&nbe)L

    ath &

     

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    18/171

    AIM

    Create a remote stok ser=er that aepts the ompany name andgi=es the share =alue. 5tok lient that retrie=es the ompany share

    =alue and displays by gi=ing the ompany name.

    ,ROGRAM

    import

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    19/171

    Stoc! Contine/

      F

      4pdate the stok prie &generates a random hange).  F  publi +loat update&)

      +loat hange P &&+loat)&random.ne?tGaussian&) $.#))L  i+ &symbol.euals&Q5unQ) YY urrent V M'UW'*4E / ")  hange P Math.abs&hange)L FF 1hat did you e?petZ  +loat ne1Current P urrent hangeL  FF donSt allo1 stok prie to step outside range  i+ &ne1Current V # [[ ne1Current \ M'UW'*4E)  hange P #L  urrent P hangeL 

    return hangeL     

    StockNotify 

    import

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    20/171

    StockWatch

    import

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    21/171

     

    StockNotFoundException

     F 5tokNotHoundE?eption is thro1n i+ a stok, +or 1hih noti+iations

      o+ updates are reuested, is not kno1n. Fpubli lass 5tokNotHoundE?eption e?tends E?eption

      publi 5tokNotHoundE?eption&5tring s)

      super&s)L     

    StockSerer

    import

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    22/171

     

    Stoc!Ser1er Contine/

     F  Reuest noti+iation o+ stok updates.  ]param stok the stok name  ]param ob< the remote ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    23/171

     

    - 23 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    24/171

    Stoc!Ser1er Contine/

     F  Canel reuest +or stok updates +or a partiular stok.

      ]param stok the stok name  ]param ob< the remote ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    25/171

    Stoc!Ser1er Contine/

     F

      Canel all reuests +or stok updates +or the remote ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    26/171

    Stoc!Ser1er Contine/

     F  3he run method &alled +rom the noti+ier thread) sends out stok

      updates periodially to those remote ob###)L 

    ath &InterruptedE?eption e)   Date date P ne1 Date&)L  FF update stoks in table  generate4pdates&)L 

     FF enumerate through eah 1ather...  Enumeration enum P noti+y3able.keys&)L  1hile &enum.hasMoreElements&))   5tokNoti+y ob< P &5tokNoti+y)enum.ne?tElement&)L  5tokO stok*ist P list&ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    27/171

    Stoc!Ser1er Contine/

     F  5tart up the stok ser=erL also reates a registry so that the

      5tok'pplet an lookup the ser=er.  F  publi stati =oid main&5tring argsO)   FF Create and install the seurity manager  5ystem.set5eurityManager&ne1 RMI5eurityManager&))L  try   FF 5ome hanges +rom 5un ode  (rogram(roperties +lags P

    ne1 (rogram(roperties& args )L  int port P +lags.getInt& QpQ, $#:: )L  5tring ser=er*abel P Q5tok5er=erQL  5ystem.out.println&  Q5tok5er=er.main6 reating registryQ)L  Registry loalRegistry P

    *oateRegistry.reateRegistry&port)LL  5ystem.out.println&Q5tok5er=er.main6 reating ser=erQ)L  5tok5er=er ser=er P ne1 5tok5er=er&)L 

    5ystem.out.println&Q5tok5er=er.main6 binding ser=er Q)L  loalRegistry.rebind& ser=er*abel, ser=er)L 

    5ystem.out.println&Q5tok5er=er.main6 doneQ)L 

    ath &E?eption e)   5ystem.out.println&  Q5tok5er=er.main6 an e?eption ourred6 Q   e.getMessage&))L  e.print5tak3rae&)L    FFend lass 

    - 27 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    28/171

    Stoc!>ie3er

    import

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    29/171

    Stoc!>ie3er Contine/

    publi boolean anel& 5tring stok ) 

      try    stok5er=er.anel& stok, this )L    ath &RemoteE?eption transmissionError)    return +alseL    return trueL   

    publi =oid update& Date stok4pdate3ime, 5tokO stok*ist )    5ystem.err.println& QWie1er updateQ )L  i+ & stok*ist.length VP# )  returnL 

    out.println& Q3he +ollo1ing stoks 1ere updated on6 Q stok4pdate3ime )L

      +or & int kP#L k V stok*ist.lengthL k )    out.println& stok*istkO )L 

      out.+lush&)L   

    - 29 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    30/171

    Stoc!>ie3er Contine/

    publi stati =oid main& 5tringO args ) 

      try

      5tring ser=er'ddress P get5er=er'ddress& args)L  5tok7ath ser=er P &5tok7ath)

    Naming.lookup& ser=er'ddress )L 

    5tokWie1er aWie1er P ne1 5tokWie1er& ser=er,ne1 (rint7riter& 5ystem.out ))L

      Enumeration stoks P get5tok*ist& args )L  1hile & stoks.hasMoreElements&) )  aWie1er.1ath& &5tring) stoks.ne?tElement&) )L 

    ath & E?eption error)

      error.print5tak3rae&)L      pri=ate stati Enumeration get5tok*ist& 5tring argsO )

    thro1s I8E?eption    (rogram(roperties +lags P ne1 (rogram(roperties& args )L  5tring stokNames P +lags.get5tring& QsQ )L

      *ist stok*ist P ne1 *ist&)L  stok*ist.+rom5tring& stokNames )L  return stok*ist.elements&)L 

    Stoc!>ie3er Contine/

      pri=ate stati 5tring get5er=er'ddress& 5tring argsO )thro1s I8E?eption

     

      (rogram(roperties +lags P ne1 (rogram(roperties& args )L  5tring host P +lags.get5tring& QhQ )L  5tring port P +lags.get5tring& QpQ, Q$#::Q )L 

    return Qrmi6FFQ host Q6Q port QF5tok5er=erQL   

    - 30 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    31/171

    'IM

    Create a remote phone book ser=er that maintains names andphone numbers. (hone book lient should pro=ide a user

    inter+ae that allo1s the user to sroll through entries, add ane1 entry, modi+y an e?isting entry and delete an e?istingentry. 3he lient and the ser=er should pro=ide proper errorhandling.

    (R8GR'M

    RMI supports 2a=a ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    32/171

    Hor this appliation, the ser=er ode looks like this6

     FF *ookup5er=er.

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    33/171

      try   RMI5eurityManager seurity P  ne1 RMI5eurityManager&)L  5ystem.set5eurityManager&seurity)L  5tring db P args#OL  *ookup5er=er ser=er P ne1 *ookup5er=er&db)L  Naming.rebind&Q*ookup5er=erQ, ser=er)L  5ystem.err.println&Q*ookup5er=er ready...Q)L    ath &3hro1able e)   5ystem.err.println&Qe?eption6 Q e)L  5ystem.e?it&$)L     

    3he ser=er reads in a te?t database o+ phone numbers and names andstores them internally. +indIn+o then does a aseless lookup o+ a gi=enname or number in the database.

    ' simple e?ample o+ the database is6

     5mith, 2oan -#9/::0

     2ones, Milton 0:0/:9:

     Bro1n, Gertrude ":0/$-%"

    - 33 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    34/171

    Start the Ser1er

    ou start the ser=er 1ith6

     

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    35/171

    'IM

    Demonstrates the use o+ delegates, allbaks, and synhronous andasynhronous method in=oation, inluding ho1 Miroso+t .NE3Hrame1ork lasses pro=ide e?pliit asynhronous support using the

    Begin and End naming on=entions and ho1 you an makeuse o+ this support in your o1n ode.

    (R8GR'M

    A$$em"ly Information

    using 5ystem.Re+letionLusing 5ystem.Runtime.Compiler5er=iesL

     FF FF General In+ormation about an assembly is ontrolled through the +ollo1ing FF set o+ attributes. Change these attribute =alues to modi+y the in+ormation FF assoiated 1ith an assembly. FFassembly6 'ssembly3itle&QQ)Oassembly6 'ssemblyDesription&QQ)Oassembly6 'ssemblyCon+iguration&QQ)Oassembly6 'ssemblyCompany&QQ)Oassembly6 'ssembly(rodut&QQ)Oassembly6 'ssemblyCopyright&QQ)O

    assembly6 'ssembly3rademark&QQ)Oassembly6 'ssemblyCulture&QQ)O

     FF Wersion in+ormation +or an assembly onsists o+ the +ollo1ing +our =alues6 FF FF Ma

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    36/171

     FF FF Notes6 FF &) I+ no key is spei+ied, the assembly is not signed. FF &) KeyName re+ers to a key that has been installed in the Crypto 5er=ie FF (ro=ider &C5() on your mahine. KeyHile re+ers to a +ile 1hih ontains FF a key. FF &) I+ the KeyHile and the KeyName =alues are both spei+ied, the FF +ollo1ing proessing ours6 FF &$) I+ the KeyName an be +ound in the C5(, that key is used. FF &-) I+ the KeyName does not e?ist and the KeyHile does e?ist, the key FF in the KeyHile is installed into the C5( and used. FF &) In order to reate a KeyHile, you an use the sn.e?e &5trong Name)utility.

     FF 7hen spei+ying the KeyHile, the loation o+ the KeyHile should be FF relati=e to the pro

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    37/171

    IResol=e Callbak

    using 5ystemLusing 5ystem.NetL

    namespae Callbak5ample

     FFF Vsummary\ FFF 3he IResol=eCallbak inter+ae de+ines a allbak method to use

    1hen the alled FFF ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    38/171

    Resol=e Console

    using 5ystemLusing 5ystem.NetL

    namespae Callbak5ample  FFF Vsummary\  FFF 3he Resol=eConsole lass demonstrates =arious types o+ allbaks and  FFF asynhronous alls.  FFF VFsummary\

    internal sealed lass Resol=eConsole 6 IResol=eCallbak

      pri=ate bool resultsDisplayed P +alseL

      FF 3his lass an only be reated by the Main stati method.  pri=ate Resol=eConsole&)   

      FFF Vsummary\  FFF 3his method implements the IResol=eCallbak inter+ae and allo1s  FFF a alled ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    39/171

        ase Callbak8ption.4seInter+ae6

        Console.7rite*ine&QResol=ing...Q)L

      FF By passing an inter+ae that this ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    40/171

      I'synResult ar P synhMethod.BeginIn=oke&host, null, null)L

      FF 7rite another period +or eah $##ms inter=al o+ 1ait time.  1hile &Tar.'syn7ait;andle.7ait8ne&$##, +alse))  Console.7rite&Q.Q)L  Console.7rite*ine&)L

      FF I+ any e?eptions are raised by the alled method, they 1onSt  FF be thro1n until the results are obtained.  try    FF 3he EndIn=oke method is supplied by the C ompiler...  FF 3he Intelli5ense engine does not display this at design time.  hostIn+ormation P synhMethod.EndIn=oke&ar)L  DisplayResults&hostIn+ormation)L    ath &5ystem.Net.5okets.5oketE?eption)

        Console.7rite*ine&QBad host name &5oketE?eption)Q)L  resultsDisplayed P trueL    breakL 

      ase Callbak8ption.4se'synhronousDelegate7ithCallbak6

        Console.7rite*ine&QResol=ing...Q)L

      Resol=eDelegate synhMethod P ne1Resol=eDelegate&resol=er.Resol=e)L  'synCallbak b P ne1'synCallbak&this.'synCustomCallbakMethod)L  FF Begin the methodSs e?eution...1hen +inished, the allbak 1ill be  FF alled.  I'synResult ar P synhMethod.BeginIn=oke&host, b, null)L  breakL 

      ase Callbak8ption.4seHrame1ork5upplied5ynhronousMethod6

        Console.7rite*ine&QResol=ing...Q)L

      FF 3his alls the synhronous =ersion o+ a +rame1ork/de+ined lass  FF that also e?pliitly supports asynhronous in=oation.  try 

    - 40 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    41/171

      hostIn+ormation P Dns.Resol=e&host)L  DisplayResults&hostIn+ormation)L    ath &5ystem.Net.5okets.5oketE?eption)    Console.7rite*ine&QBad host name &5oketE?eption)Q)L  resultsDisplayed P trueL    breakL 

      aseCallbak8ption.4seHrame1ork5upplied'synhronousMethod7ith7ait6

        Console.7rite&QResol=ingQ)L

      I'synResult ar P Dns.BeginResol=e&host, null, null)L

      FF 7rite another period +or eah $##ms inter=al o+ 1ait time.  1hile &Tar.'syn7ait;andle.7ait8ne&$##, +alse))  Console.7rite&Q.Q)L  Console.7rite*ine&)L

      FF I+ any e?eptions are raised by the alled method, they 1onSt  FF be thro1n until the results are obtained.  try 

      hostIn+ormation P Dns.EndResol=e&ar)L  DisplayResults&hostIn+ormation)L    ath &5ystem.Net.5okets.5oketE?eption)    Console.7rite*ine&QBad host name &5oketE?eption)Q)L  resultsDisplayed P trueL    breakL 

      ase

    Callbak8ption.4seHrame1ork5upplied'synhronousMethod7ithCallbak6

        Console.7rite*ine&QResol=ing...Q)L

      'synCallbak b P ne1'synCallbak&this.'synHrame1orkCallbakMethod)L  FF Begin the all...1hen it is +inished, the allbak method 1ill be

    - 41 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    42/171

      FF alled.  I'synResult ar P Dns.BeginResol=e&host, b, null)L  breakL 

      de+ault6  Console.7rite*ine&QNot Implemented etQ)L  breakL 

      FF I+ this method ends no1, there is no guarantee that the hostin+ormation  FF 1ill be displayed be+ore the ne?t prompt to the user +or more hosts to  FF resol=e is sho1n. In order to +ore the 1ait, put the thread to sleep  FF +or $##ms inter=als until the output has been displayed.  1hile &TresultsDisplayed) 

      FF Hor the synhronous options, this 1ill ne=er get e?euted  FF beause the results 1ill ha=e been displayed be+ore e?eution  FF reahes this point.  5ystem.3hreading.3hread.5leep&$##)L   

      pri=ate =oid 'synHrame1orkCallbakMethod&I'synResult ar)    FF I+ any e?eptions are raised by the alled method, they 1onSt  FF be thro1n until the results are obtained.

      try    I(;ostEntry hostIn+ormation P Dns.EndResol=e&ar)L  DisplayResults&hostIn+ormation)L    ath &5ystem.Net.5okets.5oketE?eption)    Console.7rite*ine&QBad host name &5oketE?eption)Q)L  resultsDisplayed P trueL   

      5ystem.Runtime.Remoting.Messaging.8ne7ay&)O  pri=ate =oid 'synCustomCallbakMethod&I'synResult ar)    FF I+ any e?eptions are raised by the alled method, they 1onSt  FF be thro1n until the results are obtained.  try    FF 4n1rap the delegate so that the EndIn=oke method an be alled.

    - 42 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    43/171

      Resol=eDelegate synhMethod P &Resol=eDelegate)&&5ystem.Runtime.Remoting.Messaging.'synResult)ar).'synDelegateL  I(;ostEntry hostIn+ormation P synhMethod.EndIn=oke&ar)L  DisplayResults&hostIn+ormation)L    ath &5ystem.Net.5okets.5oketE?eption)    Console.7rite*ine&QBad host name &5oketE?eption)Q)L  resultsDisplayed P trueL   

      FFF Vsummary\  FFF Display the host in+ormation +rom an I(;ostEntry ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    44/171

      Console.7rite*ine&Q(lease enter an I( address or host name to Q   Qresol=e, or the letter S?S to uit.Q)L  userInput P Console.Read*ine&).3o*o1er&).3rim&)L

      FF I+ the user 1ants to uit, then e?it the main loop.  i+ &userInput PP Q?Q)  breakL

      FF Walidate the user input, and reprompt the user i+ in=alid.  4ri;ostName3ype host3ype P 4ri.Chek;ostName&userInput)L  i+ &host3ype PP 4ri;ostName3ype.Dns [[ host3ype PP4ri;ostName3ype.I(=9 [[  host3ype PP 4ri;ostName3ype.I(=%)    string host P userInputL

      FF (rompt the user +or the method to use 1hen resol=ing the host.

      FF 3he methods supported are de+ined in the Callbak8ptionenumeration.  ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    45/171

      1hile &TEnum.IsDe+ined&typeo+&Callbak8ption), enumWalue))L FFend option loop

      FF (arse the input to an entry in the Callbak8ption enumeration.  Callbak8ption method3o4se P &Callbak8ption)Enum.(arse&  typeo+&Callbak8ption), userInput, true  )L

      app.DoResol=e&host, method3o4se)L  FF end =alid host entered.  else    Console.7rite*ine&Q3he I( address or host name you entered 1as Q   Q+ormatted inorretly, please try again.Q)L  FF end in=alid host entered.

      FF Continue looping until the user 1ants to uit.

      1hile &true)L FF end primary loop.

      app P nullL FF end Main method

    FF end lass FF end namespae

    Resol=e Delegates

    using 5ystemLusing 5ystem.NetL

    namespae Callbak5ample

     FFF Vsummary\ FFF 3he Resol=eDelegate is used to 1rap alls to methods ha=ing this

    signature. FFF VFsummary\

      internal delegate I(;ostEntry Resol=eDelegate&string host)L

    - 45 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    46/171

    Resol=er

    using 5ystemLusing 5ystem.NetL

    namespae Callbak5ample FFF Vsummary\ FFF 3he Resol=er lass supplies some synhronous methods to do DN5

    resolution FFF 1ith &this 1raps the Dns.Resol=e method de+ined by the

    +rame1ork, but any FFF long/running operation 1ill su++ie). 5ome o+ these methods aept

    a FFF allbak inter+ae or delegate as a parameter to in+orm the aller

    1hen FFF the operation is omplete. FFF VFsummary\internal sealed lass Resol=er

      FFF Vsummary\  FFF Resol=e an I( address or host name, and return the resultsynhronously  FFF through the inter+ae pro=ided.  FFF VFsummary\  FFF Vparam namePQhostQ\3he I( address or host name toresol=eVFparam\  FFF Vparam namePQallbakInter+aeQ\3he inter+ae de+ining the allbak

    methodVFparam\  internal =oid Resol=e&string host, IResol=eCallbak allbakInter+ae)    FF 3his per+orms a long/running operation &DN5 resolution) and  FF returns the result through the inter+ae aepted as a parameter.  allbakInter+ae.;ostResol=ed&Dns.Resol=e&host))L 

      FFF Vsummary\  FFF Resol=e an I( address or host name, and return the resultsynhronously

      FFF through the delegate passed in by the aller.  FFF VFsummary\  FFF Vparam namePQhostQ\3he I( address or host name toresol=eVFparam\  FFF Vparam namePQallbakDelegateQ\3he delegate 1rapping the allbakmethodVFparam\  internal =oid Resol=e&string host, Resol=eCallbakDelegateallbakDelegate) 

    - 46 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    47/171

      FF 3his per+orms the same task as abo=e, but instead o+ alling bak  FF through an inter+ae, a delegate is used to in+orm the aller o+ the  FF results.  allbakDelegate&Dns.Resol=e&host))L 

      FFF Vsummary\  FFF Resol=e an I( address or host name, and return the resultsynhronously.  FFF VFsummary\  FFF Vparam namePQhostQ\3he I( address or host name toresol=eVFparam\  FFF Vreturns\'n I(;ostEntry ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    48/171

    'IM

    Demonstrates the use o+ .NE3 Hrame1ork Code 'ess 5eurity, in1hih ode an ha=e permissions independent o+ the persone?euting the ode.

    (R8GR'M

    '55EMB* INH8RM'3I8N

    using 5ystem.Re+letionLusing 5ystem.Runtime.Compiler5er=iesL

     FF

     FF General In+ormation about an assembly is ontrolled through the +ollo1ing FF set o+ attributes. Change these attribute =alues to modi+y the in+ormation FF assoiated 1ith an assembly. FFassembly6 'ssembly3itle&QQ)Oassembly6 'ssemblyDesription&QQ)Oassembly6 'ssemblyCon+iguration&QQ)Oassembly6 'ssemblyCompany&QQ)Oassembly6 'ssembly(rodut&QQ)Oassembly6 'ssemblyCopyright&QQ)Oassembly6 'ssembly3rademark&QQ)Oassembly6 'ssemblyCulture&QQ)O

     FF FF Wersion in+ormation +or an assembly onsists o+ the +ollo1ing +our =alues6 FF FF Ma

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    49/171

     FF FF 4se the attributes belo1 to ontrol 1hih key is used +or signing. FF FF Notes6 FF &) I+ no key is spei+ied, the assembly is not signed. FF &) KeyName re+ers to a key that has been installed in the Crypto 5er=ie FF (ro=ider &C5() on your mahine. KeyHile re+ers to a +ile 1hih ontains FF a key. FF &) I+ the KeyHile and the KeyName =alues are both spei+ied, the FF +ollo1ing proessing ours6 FF &$) I+ the KeyName an be +ound in the C5(, that key is used. FF &-) I+ the KeyName does not e?ist and the KeyHile does e?ist, the key FF in the KeyHile is installed into the C5( and used. FF &) In order to reate a KeyHile, you an use the sn.e?e &5trong Name)utility.

     FF 7hen spei+ying the KeyHile, the loation o+ the KeyHile should be FF relati=e to the pro

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    50/171

    H8RM$

    using 5ystemLusing 5ystem.Dra1ingLusing 5ystem.ColletionsL

    using 5ystem.ComponentModelLusing 5ystem.7indo1s.HormsLusing 5ystem.DataLusing 5ystem.I8L

    namespae 7indo1s'ppliation-

     FFF Vsummary\ FFF 5ummary desription +or Horm$. FFF VFsummary\publi lass Horm$ 6 5ystem.7indo1s.Horms.Hormpri=ate 5ystem.7indo1s.Horms.Button CreateHileNoError;andlingLpri=ate 5ystem.7indo1s.Horms.Button CreateHile7ithError;andlingL

    pri=ate 5ystem.7indo1s.Horms.5tatusBar statusBar$L FFF Vsummary\ FFF Reuired designer =ariable. FFF VFsummary\

    pri=ate 5ystem.ComponentModel.Container omponents P nullL

    publi Horm$&)

     FF

     FF Reuired +or 7indo1s Horm Designer support FFInitialieComponent&)L

     FF FF 38D86 'dd any onstrutor ode a+ter InitialieComponent all

     FF

     FFF Vsummary\ FFF Clean up any resoures being used.

     FFF VFsummary\proteted o=erride =oid Dispose& bool disposing )

    i+& disposing )

    i+ &omponents TP null)

    omponents.Dispose&)L

    - 50 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    51/171

    base.Dispose& disposing )L

    region 7indo1s Horm Designer generated ode FFF Vsummary\ FFF Reuired method +or Designer support / do not modi+y FFF the ontents o+ this method 1ith the ode editor. FFF VFsummary\pri=ate =oid InitialieComponent&)

    this.CreateHileNoError;andling P ne1 5ystem.7indo1s.Horms.Button&)Lthis.CreateHile7ithError;andling P ne1

    5ystem.7indo1s.Horms.Button&)Lthis.statusBar$ P ne1 5ystem.7indo1s.Horms.5tatusBar&)L

    this.5uspend*ayout&)L FF

     FF CreateHileNoError;andling FF

    this.CreateHileNoError;andling.*oation P ne15ystem.Dra1ing.(oint&$-0, 90)Lthis.CreateHileNoError;andling.Name P QCreateHileNoError;andlingQLthis.CreateHileNoError;andling.5ie P ne1 5ystem.Dra1ing.5ie&$$-, ->)L

    this.CreateHileNoError;andling.3abInde? P #Lthis.CreateHileNoError;andling.3e?t P QNo Error ;andlingQL

    this.CreateHileNoError;andling.Clik P ne15ystem.E=ent;andler&this.CreateHileNoError;andlingUClik)L

     FF

     FF CreateHile7ithError;andling FFthis.CreateHile7ithError;andling.*oation P ne1

    5ystem.Dra1ing.(oint&>#9, 90)Lthis.CreateHile7ithError;andling.Name P QCreateHile7ithError;andlingQL

    this.CreateHile7ithError;andling.5ie P ne15ystem.Dra1ing.5ie&$$-, ->)L

    this.CreateHile7ithError;andling.3abInde? P $Lthis.CreateHile7ithError;andling.3e?t P Q7ith Error ;andlingQLthis.CreateHile7ithError;andling.Clik P ne1

    5ystem.E=ent;andler&this.CreateHile7ithError;andlingUClik)L FF

     FF statusBar$ FF

    this.statusBar$.*oation P ne1 5ystem.Dra1ing.(oint, ->-)Lthis.statusBar$.Name P QstatusBar$QL

    this.statusBar$.5ie P ne1 5ystem.Dra1ing.5ie&%#0, --)Lthis.statusBar$.3abInde? P -L

     FF FF Horm$

    - 51 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    52/171

     FFthis.'uto5aleBase5ie P ne1 5ystem.Dra1ing.5ie&", $>)Lthis.Client5ie P ne1 5ystem.Dra1ing.5ie&%#0, -"9)L

    this.Controls.'ddRange&ne1 5ystem.7indo1s.Horms.ControlO this.statusBar$,this.CreateHile7ithError;andling,this.CreateHileNoError;andling)Lthis.Name P QHorm$QL

    this.3e?t P QCode 'ess 5eurityQLthis.Resume*ayout&+alse)L

    endregion

     FFF Vsummary\ FFF 3his appliation attempts to reate a +ile in the root o+ the C6 dri=e. FFF I+ it is do1nloaded =ia ;33(, this 1ill +ail. 3he +irst button +ails

     FFF ungrae+ullyL the seond button traps the error. FFF VFsummary\53'3hreadOstati =oid Main&)

    'ppliation.Run&ne1 Horm$&))L

    pri=ate =oid CreateHileNoError;andlingUClik&ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    53/171

    statusBar$.3e?t P QHile &test-.t?t) Created 5uess+ullyQLath &E?eption e?)

     FFF Vsummary\ FFF I+ there 1as an error reating the +ile, display that message to the user. FFF 7hile the message might not be too +riendly, this does sho1 that youha=e

     FFF generated a trappable error. VFsummary\statusBar$.3e?t P Q3he +ollo1ing error ourred Q e?.Message Q reating+ile &test-.t?t)QL

    - 53 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    54/171

    'IM

    Demonstrates ho1 to reate a C8M omponent, that takesad=antage o+ 3ransation management ser=ie 1ithin C8M, thenassign a strong name to the assembly, register the assembly in the

    Global 'ssembly Cahe, and register the omponent 1ith C8M.

    (R8GR'M

    C8M(lusClient

    '55EMB* INH8RM'3I8N6

    using 5ystem.Re+letionLusing 5ystem.Runtime.Compiler5er=iesL

     FF FF General In+ormation about an assembly is ontrolled through the +ollo1ing FF set o+ attributes. Change these attribute =alues to modi+y the in+ormation FF assoiated 1ith an assembly. FFassembly6 'ssembly3itle&QQ)Oassembly6 'ssemblyDesription&QQ)Oassembly6 'ssemblyCon+iguration&QQ)Oassembly6 'ssemblyCompany&QQ)Oassembly6 'ssembly(rodut&QQ)O

    assembly6 'ssemblyCopyright&QQ)Oassembly6 'ssembly3rademark&QQ)Oassembly6 'ssemblyCulture&QQ)O

     FF FF Wersion in+ormation +or an assembly onsists o+ the +ollo1ing +our =alues6 FF FF Ma

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    55/171

     FF Miroso+t .NE3 Hrame1ork doumentation +or more in+ormation onassembly signing.

     FF FF 4se the attributes belo1 to ontrol 1hih key is used +or signing. FF FF Notes6 FF &) I+ no key is spei+ied, the assembly is not signed. FF &) KeyName re+ers to a key that has been installed in the Crypto 5er=ie FF (ro=ider &C5() on your mahine. KeyHile re+ers to a +ile 1hih ontains FF a key. FF &) I+ the KeyHile and the KeyName =alues are both spei+ied, the FF +ollo1ing proessing ours6 FF &$) I+ the KeyName an be +ound in the C5(, that key is used. FF &-) I+ the KeyName does not e?ist and the KeyHile does e?ist, the key FF in the KeyHile is installed into the C5( and used. FF &) In order to reate a KeyHile, you an use the sn.e?e &5trong Name)utility.

     FF 7hen spei+ying the KeyHile, the loation o+ the KeyHile should be FF relati=e to the pro

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    56/171

    C4538MER 8RDER56

    using 5ystemLusing 5ystem.Dra1ingL

    using 5ystem.ColletionsLusing 5ystem.ComponentModelLusing 5ystem.7indo1s.HormsLusing 5ystem.Enterprise5er=iesLusing C8M(lus5er=iesE?ampleLusing 5ystem.DataLusing 5ystem.Data.5lClientLnamespae C8M(lus

     FFF Vsummary\ FFF 5ummary desription +or Customer8rders. FFF VFsummary\publi lass Customer8rders 6 5ystem.7indo1s.Horms.Horm

    pri=ate int mU8rderIDLpri=ate string mU(rodutNameLpri=ate int mUJuantityLpri=ate int mUDetailRo1Lpri=ate 5ystem.7indo1s.Horms.ComboBo? boCustomersLpri=ate 5ystem.7indo1s.Horms.*abel label$Lpri=ate 5ystem.7indo1s.Horms.Button btnGetCustLpri=ate 5ystem.7indo1s.Horms.*abel label-L

    pri=ate 5ystem.7indo1s.Horms.Button btn4pdateLpri=ate 5ystem.7indo1s.Horms.DataGrid dg8rdersLpri=ate 5ystem.7indo1s.Horms.DataGrid dg8rderDetailsL

     FFF Vsummary\ FFF Reuired designer =ariable. FFF VFsummary\

    pri=ate 5ystem.ComponentModel.Container omponents P nullL

    publi Customer8rders&)

     FF

     FF Reuired +or 7indo1s Horm Designer support FFInitialieComponent&)L

     FF FF 38D86 'dd any onstrutor ode a+ter InitialieComponent all

     FF

    - 56 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    57/171

     FFF Vsummary\ FFF Clean up any resoures being used. FFF VFsummary\proteted o=erride =oid Dispose& bool disposing )

    i+& disposing )

    i+&omponents TP null)

    omponents.Dispose&)L

    base.Dispose& disposing )L

    region 7indo1s Horm Designer generated ode FFF Vsummary\

     FFF Reuired method +or Designer support / do not modi+y FFF the ontents o+ this method 1ith the ode editor. FFF VFsummary\pri=ate =oid InitialieComponent&)

    this.boCustomers P ne1 5ystem.7indo1s.Horms.ComboBo?&)Lthis.label$ P ne1 5ystem.7indo1s.Horms.*abel&)Lthis.btnGetCust P ne1 5ystem.7indo1s.Horms.Button&)L

    this.dg8rders P ne1 5ystem.7indo1s.Horms.DataGrid&)Lthis.label- P ne1 5ystem.7indo1s.Horms.*abel&)L

    this.dg8rderDetails P ne1 5ystem.7indo1s.Horms.DataGrid&)L

    this.btn4pdate P ne1 5ystem.7indo1s.Horms.Button&)L&&5ystem.ComponentModel.I5upportInitialie)&this.dg8rders)).BeginInit&)L&&5ystem.ComponentModel.I5upportInitialie)&this.dg8rderDetails)).BeginInit&)L

    this.5uspend*ayout&)L FF FF boCustomers FF

    this.boCustomers.*oation P ne1 5ystem.Dra1ing.(oint&$$-, 0)Lthis.boCustomers.Name P QboCustomersQL

    this.boCustomers.5ie P ne1 5ystem.Dra1ing.5ie&->-, -$)Lthis.boCustomers.3abInde? P #L

     FF FF label$ FF

    this.label$.*oation P ne1 5ystem.Dra1ing.(oint&$%, 0)Lthis.label$.Name P Qlabel$QL

    this.label$.5ie P ne1 5ystem.Dra1ing.5ie&:%, ->)Lthis.label$.3abInde? P $Lthis.label$.3e?t P Q5elet Customer6QL

    - 57 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    58/171

    this.label$.3e?t'lign P 5ystem.Dra1ing.Content'lignment.MiddleRightL FF FF btnGetCust FF

    this.btnGetCust.*oation P ne1 5ystem.Dra1ing.(oint&>%#, 0)Lthis.btnGetCust.Name P QbtnGetCustQLthis.btnGetCust.3abInde? P -Lthis.btnGetCust.3e?t P QGet 8rdersQL

    this.btnGetCust.Clik P ne1 5ystem.E=ent;andler&this.btnGetCustUClik)L FF FF dg8rders FF

    this.dg8rders.DataMember P QQLthis.dg8rders.;eaderHoreColor P 5ystem.Dra1ing.5ystemColors.Control3e?tL

    this.dg8rders.*oation P ne1 5ystem.Dra1ing.(oint&$%, -)Lthis.dg8rders.Name P Qdg8rdersQL

    this.dg8rders.5ie P ne1 5ystem.Dra1ing.5ie&9-9, $99)L

    this.dg8rders.3abInde? P >Lthis.dg8rders.Mouse4p P ne15ystem.7indo1s.Horms.MouseE=ent;andler&this.dg8rdersUMouse4p)L

     FF FF label- FF

    this.label-.*oation P ne1 5ystem.Dra1ing.(oint&$%, "%)Lthis.label-.Name P Qlabel-QL

    this.label-.5ie P ne1 5ystem.Dra1ing.5ie&$##, $%)Lthis.label-.3abInde? P 9Lthis.label-.3e?t P Q8rders6QL

     FF FF dg8rderDetails FFthis.dg8rderDetails.DataMember P QQL

    this.dg8rderDetails.;eaderHoreColor P5ystem.Dra1ing.5ystemColors.Control3e?tLthis.dg8rderDetails.*oation P ne1 5ystem.Dra1ing.(oint&$%, -90)Lthis.dg8rderDetails.Name P Qdg8rderDetailsQL

    this.dg8rderDetails.5ie P ne1 5ystem.Dra1ing.5ie&9-9, $99)Lthis.dg8rderDetails.3abInde? P "L

    this.dg8rderDetails.Mouse4p P ne15ystem.7indo1s.Horms.MouseE=ent;andler&this.dg8rderDetailsUMouse4p)L

     FF FF btn4pdate FF

    this.btn4pdate.*oation P ne1 5ystem.Dra1ing.(oint&$%, 9$%)Lthis.btn4pdate.Name P Qbtn4pdateQL

    this.btn4pdate.5ie P ne1 5ystem.Dra1ing.5ie&00, ->)Lthis.btn4pdate.3abInde? P %Lthis.btn4pdate.3e?t P Q4pdate DetailsQL

    - 58 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    59/171

    this.btn4pdate.Clik P ne15ystem.E=ent;andler&this.btn4pdateUClik)L

     FF FF Customer8rders FF

    this.'uto5aleBase5ie P ne1 5ystem.Dra1ing.5ie&", $>)Lthis.Client5ie P ne1 5ystem.Dra1ing.5ie&9"%, 9%9)L

    this.Controls.'ddRange&ne1 5ystem.7indo1s.Horms.ControlO this.btn4pdate, this.dg8rderDetails,

      this.label-,  this.dg8rders,

    this.btnGetCust, this.label$,  this.boCustomers)L

    this.Name P QCustomer8rdersQLthis.3e?t P QCustomer 8rdersQL

    this.*oad P ne1 5ystem.E=ent;andler&this.Customer8rdersU*oad)L&&5ystem.ComponentModel.I5upportInitialie)&this.dg8rders)).EndInit&)L

    &&5ystem.ComponentModel.I5upportInitialie)&this.dg8rderDetails)).EndInit&)L

    this.Resume*ayout&+alse)L

    endregion

    pri=ate =oid Customer8rdersU*oad&ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    60/171

     FFF 3he main entry point +or the appliation. FFF VFsummary\53'3hreadOstati =oid Main&)

    'ppliation.Run&ne1 Customer8rders&))L

    pri=ate =oid btnGetCustUClik&ob-&this.dg8rdershitin+o.Ro1, #O.3o5tring&))L

    mU8rderID P 8rderIDL

     FFall the helper method to retrie=e the FForder details.Hill8rderDetails&mU8rderID)L

    pri=ate =oid Hill8rderDetails&int 8rderID)

     FFreate an instane o+ the CustomersDB lassCustomersDB ustomer P ne1 CustomersDB&)L

    Data5et dataset8rders P ustomer.Get8rderDetails&8rderID)L FFbind the data set to the datagrid.dg8rderDetails.5etDataBinding&dataset8rders,dataset8rders.3ables#O.3ableName)L

    - 60 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    61/171

    pri=ate =oid dg8rderDetailsUMouse4p&ob-&this.dg8rderDetailsmUDetailRo1,-O.3o5tring&))LmUJuantity P JuantityL

     FFreate an instane o+ the Customers lass FFto initiate the update.Customers ustomer P ne1 Customers&)L

     FFall the 4pdate method. FFi+ the uantity is less than or eual to ero, then FFthe update 1ill +ail.

    bool updateIs5uess+ul P ustomer.4pdateDetailJuantity&mU8rderID,mU(rodutName, mUJuantity)L

    string MessagePQQL

    i+ &updateIs5uess+ul PP true)Message P Q8peration 5ueeded and 3ransation 1as CommittedTQL

    else i+ &updateIs5uess+ul PP +alse)

    Message P Q8peration Hailed and 3ransation 1as 'bortedTQL

     FFsho1 the on+irmation message bo?.MessageBo?.5ho1&Message)LHill8rderDetails&mU8rderID)L

    - 61 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    62/171

    C'M(*45 D83NE3

    ASSEM6L7 IN9ORMATION0

    using 5ystem.Re+letionLusing 5ystem.Runtime.Compiler5er=iesLusing 5ystem.Enterprise5er=iesL

     FF FF General In+ormation about an assembly is ontrolled through the +ollo1ing FF set o+ attributes. Change these attribute =alues to modi+y the in+ormation FF assoiated 1ith an assembly. FFassembly6 'ssembly3itle&QC8M 5er=ies E?ampleQ)Oassembly6 'ssemblyDesription&Q3his is an e?ample +or reating C8M5er=ied appliations in .NE3Q)O

    assembly6 'ssemblyCon+iguration&QQ)Oassembly6 'ssemblyCompany&QQ)Oassembly6 'ssembly(rodut&QCQ)Oassembly6 'ssemblyCopyright&QQ)Oassembly6 'ssembly3rademark&QQ)Oassembly6 'ssemblyCulture&QQ)O

     FF FF Wersion in+ormation +or an assembly onsists o+ the +ollo1ing +our =alues6 FF FF Ma

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    63/171

     FF (ro=ider &C5() on your mahine. KeyHile re+ers to a +ile 1hih ontains FF a key. FF &) I+ the KeyHile and the KeyName =alues are both spei+ied, the FF +ollo1ing proessing ours6 FF &$) I+ the KeyName an be +ound in the C5(, that key is used. FF &-) I+ the KeyName does not e?ist and the KeyHile does e?ist, the key FF in the KeyHile is installed into the C5( and used. FF &) In order to reate a KeyHile, you an use the sn.e?e &5trong Name)utility.

     FF 7hen spei+ying the KeyHile, the loation o+ the KeyHile should be FF relati=e to the proBE"C'B#Q)Oassembly6 'ppliationName&QC8M (lus 5er=ies E?ampleQ)O

    assembly6 Desription&Q'n e?ample o+ reating a C8M appliation +rom.NE3Q)O

    - 63 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    64/171

    C'M(*45 5'M(*E6

    using 5ystemLusing 5ystem.DataLusing 5ystem.Data.5lClientL

    using 5ystem.Enterprise5er=iesLnamespae C8M(lus5er=iesE?ample

     FFF Vsummary\ FFF 5ummary desription +or CustomersDB. FFF VFsummary\3ransation&3ransation8ption.5upported)Opubli lass CustomersDB 6 5er=iedComponent

     FFthis lass handles all data retrie=al.

     FFlass onstrutorpubli CustomersDB&)

     FFmethod returns a onnetion ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    65/171

    slCommand3oE?eute.Command3e?t P Q5elet +rom CustomersQL FFreate and +ill the data adapter 1ith the FFommand ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    66/171

    return datasetCustomerL

     FFgets a dataset 1ith the order details.publi Data5et Get8rderDetails&int 8rderID)

     FFgrab the onnetion ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    67/171

     FFmethod returns a onnetion ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    68/171

     FFomplete the transation.Conte?t4til.5etComplete&)Lreturn trueL

    ath &E?eption e)

     FFi+ an e?eption is thro1n FFlose the onnetion ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    69/171

    'IM

    Demonstrates ho1 to reate a Miroso+t 7indo1s 5er=ie that uses aHile 5ystem 7ather ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    70/171

     FF Miroso+t .NE3 Hrame1ork doumentation +or more in+ormation onassembly signing.

     FF FF 4se the attributes belo1 to ontrol 1hih key is used +or signing. FF FF Notes6 FF &) I+ no key is spei+ied, the assembly is not signed. FF &) KeyName re+ers to a key that has been installed in the Crypto 5er=ie FF (ro=ider &C5() on your mahine. KeyHile re+ers to a +ile 1hih ontains FF a key. FF &) I+ the KeyHile and the KeyName =alues are both spei+ied, the FF +ollo1ing proessing ours6 FF &$) I+ the KeyName an be +ound in the C5(, that key is used. FF &-) I+ the KeyName does not e?ist and the KeyHile does e?ist, the key FF in the KeyHile is installed into the C5( and used. FF &) In order to reate a KeyHile, you an use the sn.e?e &5trong Name)utility.

     FF 7hen spei+ying the KeyHile, the loation o+ the KeyHile should be FF relati=e to the pro

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    71/171

    DIREC38R M8NI38R6

    using 5ystemLusing 5ystem.ColletionsLusing 5ystem.ComponentModelL

    using 5ystem.DataLusing 5ystem.DiagnostisLusing 5ystem.5er=ie(roessLusing 5ystem.Con+igurationLusing 5ystem.I8Lusing 5ystem.3hreadingL

    namespae DiretoryMonitor5er=ie

    publi lass DiretoryMonitor 6 5ystem.5er=ie(roess.5er=ieBase

    pri=ate stati string (athLpri=ate stati string HilterLpri=ate stati bool Inlude5ubsLpri=ate 5ystem.I8.Hile5ystem7ather HileMonitorL

     FFF Vsummary\ FFF Reuired designer =ariable. FFF VFsummary\

    pri=ate 5ystem.ComponentModel.Container omponents P nullLpubli DiretoryMonitor&)

     FF 3his all is reuired by the 7indo1s.Horms Component Designer.

    InitialieComponent&)L

     FF 3he main entry point +or the proessstati =oid Main&)

    5ystem.5er=ie(roess.5er=ieBaseO 5er=ies3oRunL FF More than one user 5er=ie may run 1ithin the same proess. 3o add FF another ser=ie to this proess, hange the +ollo1ing line to FF reate a seond ser=ie ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    72/171

     FFF Reuired method +or Designer support / do not modi+y FFF the ontents o+ this method 1ith the ode editor. FFF VFsummary\pri=ate =oid InitialieComponent&)

    this.HileMonitor P ne1 5ystem.I8.Hile5ystem7ather&)L&&5ystem.ComponentModel.I5upportInitialie)

    &this.HileMonitor)).BeginInit&)L FF FF HileMonitor FFthis.HileMonitor.EnableRaisingE=ents P trueL

    this.HileMonitor.Deleted P ne15ystem.I8.Hile5ystemE=ent;andler&this.HileMonitorUChanged)L

    this.HileMonitor.Renamed P ne15ystem.I8.RenamedE=ent;andler&this.HileMonitorU8nRenamed)L

    this.HileMonitor.Changed P ne1

    5ystem.I8.Hile5ystemE=ent;andler&this.HileMonitorUChanged)Lthis.HileMonitor.Created P ne1

    5ystem.I8.Hile5ystemE=ent;andler&this.HileMonitorUChanged)L FF FF DiretoryMonitor FFthis.Can(ause'ndContinue P trueLthis.Can5hutdo1n P trueLthis.5er=ieName P QDiretoryMonitorQL

    &&5ystem.ComponentModel.I5upportInitialie)&this.HileMonitor)).EndInit&)L

     FFF Vsummary\ FFF Clean up any resoures being used. FFF VFsummary\proteted o=erride =oid Dispose& bool disposing )

    i+& disposing )

    i+ &omponents TP null)

    omponents.Dispose&)L

    base.Dispose& disposing )L

     FFF Vsummary\ FFF 5et things in motion so your ser=ie an do its 1ork.

    - 72 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    73/171

     FFF VFsummary\proteted o=erride =oid 8n5tart&stringO args)

     FFretrie=e the on+iguration properties +rom the Mahine.on+ig +ile.(ath P

    Con+iguration5ettings.'pp5ettings.Get&QDiretoryMonitor(athQ).3o5tring&)LHilter P

    Con+iguration5ettings.'pp5ettings.Get&QDiretoryMonitorHilterQ).3o5tring&)LInlude5ubs P

    &Con=ert.3oBoolean&Con+iguration5ettings.'pp5ettings.Get&QDiretoryMonitorInlude5ubsQ).3o5tring&)))L

     FF5et the path +or the Hile5ystem7ather to monitor.HileMonitor.(ath P (ath.3o5tring&)L

     FF5et the +ile type +ilter +or the Hile5ystem7ather to monitor.HileMonitor.Hilter P Hilter.3o5tring&)L

     FFDetermine i+ the Hile5ystem7ather should monitor subdiretories.HileMonitor.Inlude5ubdiretories P Inlude5ubsL

     FF5et the Noti+yHilters +or raising e=ents.HileMonitor.Noti+yHilter P Noti+yHilters.*ast'ess [

    Noti+yHilters.*ast7riteNoti+yHilters.HileName [ Noti+yHilters.DiretoryNameL

     FFBegin monitoring.HileMonitor.EnableRaisingE=ents P trueL

     FFF Vsummary\ FFF 5top this ser=ie. FFF VFsummary\proteted o=erride =oid 8n5top&)

     FF7hen the ser=ie is stopped the Hile5ystemMonitor should stopraising e=ents.

    HileMonitor.EnableRaisingE=ents P +alseL

    proteted o=erride =oid 8n(ause&)

     FF7hen the ser=ie is paused the Hile5ystemMonitor should stopraising e=ents.

    HileMonitor.EnableRaisingE=ents P +alseL

    proteted o=erride =oid 8nContinue&)

     FF7hen the ser=ie is ontinued, then retrie=e the on+iguration propertiesagain.(ath PCon+iguration5ettings.'pp5ettings.Get&QDiretoryMonitor(athQ).3o5tring&)LHilter PCon+iguration5ettings.'pp5ettings.Get&QDiretoryMonitorHilterQ).3o5tring&)L

    - 73 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    74/171

    Inlude5ubs P&Con=ert.3oBoolean&Con+iguration5ettings.'pp5ettings.Get&QDiretoryMonitorInlude5ubsQ).3o5tring&)))L

     FF5et the properties on the monitor.HileMonitor.(ath P (ath.3o5tring&)LHileMonitor.Hilter P Hilter.3o5tring&)LHileMonitor.Inlude5ubdiretories P Inlude5ubsL

    pri=ate =oid HileMonitorU8nRenamed&ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    75/171

    (R82EC3 IN53'**ER6

    using 5ystemLusing 5ystem.ColletionsLusing 5ystem.ComponentModelL

    using 5ystem.Con+iguration.InstallL

    namespae DiretoryMonitor

     FFF Vsummary\ FFF 5ummary desription +or (ro

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    76/171

     FF ser=ieInstaller$ FF

    this.ser=ieInstaller$.DisplayName P QDiretory Monitor 5er=ieQLthis.ser=ieInstaller$.5er=ieName P QDiretory MonitorQLthis.ser=ieInstaller$.5tart3ype P5ystem.5er=ie(roess.5er=ie5tartMode.'utomatiL

     FF FF (ro

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    77/171

    'IM

    Demonstrates ho1 to upload images into 5J* 5er=er by usingstandard ;3M* upload methods and then insert eah image as a bytearray into 5J* 5er=er.

    (R8GR'M

    GE33ING IM'GE

    using 5ystemLusing 5ystem.ColletionsLusing 5ystem.ComponentModelLusing 5ystem.DataLusing 5ystem.Dra1ingLusing 5ystem.7ebL

    using 5ystem.7eb.5ession5tateLusing 5ystem.7eb.4ILusing 5ystem.7eb.4I.7ebControlsLusing 5ystem.7eb.4I.;tmlControlsLusing 5ystem.Data.5lClientL

    namespae 4ploadImages$

     FFF Vsummary\ FFF GetImage is the +ile used to atually retrie=e the image +rom 5J*

    5er=er FFF and display it in a bro1ser. FFF VFsummary\publi lass GetImage 6 5ystem.7eb.4I.(age

    pri=ate =oid (ageU*oad&ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    78/171

     FFF Vsummary\ FFF 3he Image3ype is retrie=ed +rom the database and sent to the bro1ser asthe

     FFF Content3ype. 3his tells the bro1ser ho1 to display the image.VFsummary\Response.Content3ype P imageContentQImage3ypeQO.3o5tring&)L

     FFF Vsummary\ FFF 3he 8utput5tream.7rite is used to 1rite a byte array o+ the image,starting at

     FFF the +irst byte and proeeding through the entire +ile. VFsummary\

    Response.8utput5tream.7rite&&byteO)imageContentQImageHileQO, #,5ystem.Con=ert.3oInt>-&imageContentQImage5ieQO))L

     FFF Vsummary\ FFF Call the End method to indiate to the bro1ser that the entire image hasbeen sent. VFsummary\

    Response.End&)L

     FFF Vsummary\ FFF GetImages is used to atually retrie=e the reord, based on the ImageIdthat is passed in.

     FFF VFsummary\ FFF Vparam namePQImageIdQ\ImageId is the ID o+ the image hosen onWie1Images.asp?.VFparam\

     FFF Vreturns\GetImages returns a 5lDataReader, 1hih is more e++iientthan a Data5et in this ase.VFreturns\

    pri=ate 5lDataReader GetImages&int imageId)

     FFF Vsummary\ FFF 8pen a onnetion to the 5J* 5er=er VFsummary\

    5lConnetion Connetion P ne1 5lConnetion&Qser=er PloalhostLuidPsaLdatabasePImage4ploadQ)L

     FFF Vsummary\ FFF 3he 5lCommand retrie=es a single reord +rom the Images tableVFsummary\5lCommand Command P ne1 5lCommand&Q5elet Hrom Images 7hereImageIdP]ImageIdQ, Connetion)L

     FFF Vsummary\

     FFF Create a 5l(arameter that 1ill allo1 you to pass in the ImageId to theuery VFsummary\5l(arameter imageID(arameter P ne1 5l(arameter&Q]ImageIdQ,5lDb3ype.Int)L

     FFF Vsummary\ FFF 'ssign the ImageId to the parameter that 1as reated VFsummary\

    imageID(arameter.Walue P imageIdL FFF Vsummary\

    - 78 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    79/171

     FFF 'dd the (arameter to the 5lCommandSs (arameters olletionVFsummary\

    Command.(arameters.'dd&imageID(arameter)L FFF Vsummary\

     FFF 8pen the onnetion in order to retrie=e the reord VFsummary\Connetion.8pen&)L

     FFF Vsummary\ FFF Return a 5lDataReader to the alling proedure. Notie that theonnetion 1ill

     FFF be losed a+er the reord has been read VFsummary\return

    Command.E?euteReader&CommandBeha=ior.CloseConnetion)Lregion 7eb Horm Designer generated odeo=erride proteted =oid 8nInit&E=ent'rgs e)

     FF C8DEGEN6 3his all is reuired by the '5(.NE3 7eb Horm Designer.InitialieComponent&)Lbase.8nInit&e)L

     FFF Vsummary\

     FFF Reuired method +or Designer support / do not modi+y FFF the ontents o+ this method 1ith the ode editor. FFF VFsummary\pri=ate =oid InitialieComponent&)this.*oad P ne1 5ystem.E=ent;andler&this.(ageU*oad)L

    endregion

    - 79 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    80/171

    WIE7ING IM'GE

    using 5ystemLusing 5ystem.ColletionsLusing 5ystem.ComponentModelL

    using 5ystem.DataLusing 5ystem.Dra1ingLusing 5ystem.7ebLusing 5ystem.7eb.5ession5tateLusing 5ystem.7eb.4ILusing 5ystem.7eb.4I.7ebControlsLusing 5ystem.7eb.4I.;tmlControlsLusing 5ystem.Data.5lClientL

    namespae 4ploadImages$

     FFF Vsummary\ FFF Wie1Images is used to display a list o+ the images in the database.

    Eah FFF image is listed by desription and is a link that 1ill all GetImage,

    passing FFF in the ID o+ the image. FFF VFsummary\publi lass Wie1Images 6 5ystem.7eb.4I.(age

    pri=ate =oid (ageU*oad&ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    81/171

     FFF Vsummary\ FFF *oop through the reords using the Read method VFsummary\

    1hile &myDR.Read&))

     FFF Vsummary\ FFF 7rite out hyperlinks that sho1 the desriptions and inlude the

    ImageID in a uerystring VFsummary\Response.7rite&QVa hre+PSGetImage.asp?ZimageidPQ myDRQImageIDQO QS\Q myDRQDesriptionQO QVFa\Vbr\Q)L

    region 7eb Horm Designer generated odeo=erride proteted =oid 8nInit&E=ent'rgs e)

     FF FF C8DEGEN6 3his all is reuired by the '5(.NE3 7eb Horm Designer.

     FF

    InitialieComponent&)Lbase.8nInit&e)L

     FFF Vsummary\ FFF Reuired method +or Designer support / do not modi+y FFF the ontents o+ this method 1ith the ode editor. FFF VFsummary\pri=ate =oid InitialieComponent&)

    this.*oad P ne1 5ystem.E=ent;andler&this.(ageU*oad)L

    endregion

    - 81 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    82/171

    7EBH8RM

    using 5ystemLusing 5ystem.ColletionsLusing 5ystem.ComponentModelL

    using 5ystem.DataLusing 5ystem.Dra1ingLusing 5ystem.7ebLusing 5ystem.7eb.5ession5tateLusing 5ystem.7eb.4ILusing 5ystem.7eb.4I.7ebControlsLusing 5ystem.7eb.4I.;tmlControlsLusing 5ystem.Data.5lClientL

    namespae 4ploadImages$

     FFF Vsummary\ FFF 7ebHorm$ allo1s you to upload images into the Images table. It

    uses standard FFF ;3M* upload methods to get the +ile to the ser=er. FFF VFsummary\publi lass 7ebHorm$ 6 5ystem.7eb.4I.(ageproteted 5ystem.7eb.4I.7ebControls.3e?tBo? imageDesriptionL

    proteted 5ystem.7eb.4I.7ebControls.Button 4ploadImageLproteted 5ystem.7eb.4I.;tmlControls.;tmlInputHile Image3o4ploadL

    pri=ate =oid (ageU*oad&ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    83/171

    this.4ploadImage.Clik P ne15ystem.E=ent;andler&this.4ploadImageUClik)L

    this.*oad P ne1 5ystem.E=ent;andler&this.(ageU*oad)Lendregion

    pri=ate =oid 4ploadImageUClik&ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    84/171

    imageHile(arameter.Walue P ContentLCommand.(arameters.'dd&imageHile(arameter)L

     FFF Vsummary\ FFF 3he Image5ie parameter is used to add the image +ile sie to thedatabase5l(arameter image5ie(arameter P ne1 5l(arameter&Q]Image5ieQ,5lDb3ype.Int)Limage5ie(arameter.Walue P *engthL

    Command.(arameters.'dd&image5ie(arameter)L FFF Vsummary\

     FFF 3he Image3ype parameter is used to add the image +ile type to thedatabase

     5l(arameter image3ype(arameter P ne15l(arameter&Q]Image3ypeQ, 5lDb3ype.NWarChar)L

      image3ype(arameter.Walue P Content3ypeL  Command.(arameters.'dd&image3ype(arameter)L

     FFF Vsummary\

     FFF 8pen the onnetion in order to retrie=e the reord VFsummary\Connetion.8pen&)L

     FFF Vsummary\ FFF 3he 5J* statement is e?euted. E?euteNonJuery is used sine noreords

     FFF 1ill be returned. VFsummary\Command.E?euteNonJuery&)L

     FFF Vsummary\ FFF 3he onnetion is losed VFsummary\

    Connetion.Close&)L

    - 84 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    85/171

    'IM

    De=elop a sample appliation that launhes a 7indo1s Horm to allo1the user to interat and manipulate the II5 'dmin ser=ie on theloal mahine. 3he appliation should 1ork by plaing an ion in the

    5ystem 3ray.

    (R8GR'M

    '55EMB* INH8RM'3I8N6

    using 5ystem.Re+letionLusing 5ystem.Runtime.Compiler5er=iesL

     FF FF General In+ormation about an assembly is ontrolled through the +ollo1ing FF set o+ attributes. Change these attribute =alues to modi+y the in+ormation

     FF assoiated 1ith an assembly. FFassembly6 'ssembly3itle&QQ)Oassembly6 'ssemblyDesription&QQ)Oassembly6 'ssemblyCon+iguration&QQ)Oassembly6 'ssemblyCompany&QQ)Oassembly6 'ssembly(rodut&QQ)Oassembly6 'ssemblyCopyright&QQ)Oassembly6 'ssembly3rademark&QQ)Oassembly6 'ssemblyCulture&QQ)O

     FF FF Wersion in+ormation +or an assembly onsists o+ the +ollo1ing +our =alues6 FF FF Ma

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    86/171

     FF FF Notes6 FF &) I+ no key is spei+ied, the assembly is not signed. FF &) KeyName re+ers to a key that has been installed in the Crypto 5er=ie FF (ro=ider &C5() on your mahine. KeyHile re+ers to a +ile 1hih ontains FF a key. FF &) I+ the KeyHile and the KeyName =alues are both spei+ied, the FF +ollo1ing proessing ours6 FF &$) I+ the KeyName an be +ound in the C5(, that key is used. FF &-) I+ the KeyName does not e?ist and the KeyHile does e?ist, the key FF in the KeyHile is installed into the C5( and used. FF &) In order to reate a KeyHile, you an use the sn.e?e &5trong Name)utility.

     FF 7hen spei+ying the KeyHile, the loation o+ the KeyHile should be FF relati=e to the pro

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    87/171

     FFkeep the +orm hiddenthis.;ide&)LInitialieNoti+yIon&)L

     FFF Vsummary\ FFF Clean up any resoures being used. FFF VFsummary\proteted o=erride =oid Dispose& bool disposing )

    i+& disposing )

    i+ &omponents TP null)

    omponents.Dispose&)L

    base.Dispose& disposing )L

    region 7indo1s Horm Designer generated ode FFF Vsummary\ FFF Reuired method +or Designer support / do not modi+y FFF the ontents o+ this method 1ith the ode editor. FFF VFsummary\

    pri=ate =oid InitialieComponent&)this.omponents P ne1 5ystem.ComponentModel.Container&)Lthis.75Noti+yIon P ne15ystem.7indo1s.Horms.Noti+yIon&this.omponents)L

     FF FF 75Noti+yIon FFthis.75Noti+yIon.3e?t P QQLthis.75Noti+yIon.Wisible P trueL

     FF FF 5ys3ray

     FFthis.'essibleRole P 5ystem.7indo1s.Horms.'essibleRole.NoneL

    this.'uto5aleBase5ie P ne1 5ystem.Dra1ing.5ie&", $>)Lthis.Client5ie P ne1 5ystem.Dra1ing.5ie&0, )Lthis.ControlBo? P +alseLthis.Enabled P +alseL

    this.HormBorder5tyle P 5ystem.7indo1s.Horms.HormBorder5tyle.NoneLthis.Ma?imieBo? P +alseL

    - 87 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    88/171

    this.MinimieBo? P +alseLthis.Name P Q5ystem3rayQLthis.8paity P #Lthis.5ho1In3askbar P +alseLthis.5tart(osition P

    5ystem.7indo1s.Horms.Horm5tart(osition.ManualL

    endregion

     FFF Vsummary\ FFF 3he main entry point +or the appliation. FFF VFsummary\53'3hreadOstati =oid Main&)

    'ppliation.Run&ne1 5ystem3ray&))L

    publi =oid 5ho1ControlHorm&ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    89/171

    mnuItems-O P ne1 MenuItem&QE?itQ, ne1E=ent;andler&this.E?itControlHorm))L

     FFadd the menu items to the onte?t menu o+ the Noti+yIonConte?tMenu noti+yIonMenu P ne1 Conte?tMenu&mnuItems)L

    75Noti+yIon.Conte?tMenuPnoti+yIonMenuL

    - 89 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    90/171

    WSCONTROLLER9ORM0

    using 5ystemLusing 5ystem.Dra1ingLusing 5ystem.ColletionsLusing 5ystem.ComponentModelLusing 5ystem.7indo1s.HormsLusing 5ystem.5er=ie(roessLpubli lass 75ControllerHorm 6 5ystem.7indo1s.Horms.Horm

    pri=ate 5ystem.5er=ie(roess.5er=ieController 75ControllerLpri=ate 5ystem.7indo1s.Horms.*abel *abel$Lpri=ate 5ystem.7indo1s.Horms.Button Button5tartLpri=ate 5ystem.7indo1s.Horms.Button Button5topLpri=ate 5ystem.7indo1s.Horms.Button Button(auseLpri=ate 5ystem.7indo1s.Horms.*abel ontrolled5er=ieL

     FFF Vsummary\ FFF Reuired designer =ariable. FFF VFsummary\pri=ate 5ystem.ComponentModel.Container omponents P nullL

    publi 75ControllerHorm&)

     FF FF Reuired +or 7indo1s Horm Designer support FFInitialieComponent&)L

     FF FF 38D86 'dd any onstrutor ode a+ter InitialieComponent all

     FF

     FFF Vsummary\ FFF Clean up any resoures being used. FFF VFsummary\proteted o=erride =oid Dispose& bool disposing )

    i+& disposing )

    i+&omponents TP null)

    omponents.Dispose&)L

    base.Dispose& disposing )L

    - 90 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    91/171

    region 7indo1s Horm Designer generated ode FFF Vsummary\ FFF Reuired method +or Designer support / do not modi+y FFF the ontents o+ this method 1ith the ode editor. FFF VFsummary\pri=ate =oid InitialieComponent&)

    this.75Controller P ne1 5ystem.5er=ie(roess.5er=ieController&)Lthis.*abel$ P ne1 5ystem.7indo1s.Horms.*abel&)Lthis.Button5tart P ne1 5ystem.7indo1s.Horms.Button&)Lthis.Button5top P ne1 5ystem.7indo1s.Horms.Button&)Lthis.Button(ause P ne1 5ystem.7indo1s.Horms.Button&)L

    this.ontrolled5er=ie P ne1 5ystem.7indo1s.Horms.*abel&)Lthis.5uspend*ayout&)L

     FF FF *abel$

     FFthis.*abel$.Hont P ne1 5ystem.Dra1ing.Hont&QMiroso+t 5ans 5eri+Q, $-H,5ystem.Dra1ing.Hont5tyle.Bold, 5ystem.Dra1ing.Graphis4nit.(oint,&&5ystem.Byte))))L

    this.*abel$.*oation P ne1 5ystem.Dra1ing.(oint&90, 0)Lthis.*abel$.Name P Q*abel$QLthis.*abel$.5ie P ne1 5ystem.Dra1ing.5ie&->-, ->)Lthis.*abel$.3abInde? P #Lthis.*abel$.3e?t P Q7indo1s 5er=ie ControllerQL

    this.*abel$.3e?t'lign P 5ystem.Dra1ing.Content'lignment.3opCenterL FF

     FF Button5tart FFthis.Button5tart.*oation P ne1 5ystem.Dra1ing.(oint&$-#, 90)L

    this.Button5tart.Name P QButton5tartQLthis.Button5tart.3abInde? P $Lthis.Button5tart.3e?t P Q5tartQL

    this.Button5tart.Clik P ne1 5ystem.E=ent;andler&this.Button5tartUClik)L FF FF Button5top FF

    this.Button5top.*oation P ne1 5ystem.Dra1ing.(oint&$-#, $$-)Lthis.Button5top.Name P QButton5topQL

    this.Button5top.3abInde? P -Lthis.Button5top.3e?t P Q5topQL

    this.Button5top.Clik P ne1 5ystem.E=ent;andler&this.Button5topUClik)L FF FF Button(ause FF

    this.Button(ause.*oation P ne1 5ystem.Dra1ing.(oint&$-#, 0#)Lthis.Button(ause.Name P QButton(auseQL

    - 91 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    92/171

    this.Button(ause.3abInde? P >Lthis.Button(ause.3e?t P Q(auseQL

    this.Button(ause.Clik P ne15ystem.E=ent;andler&this.Button(auseUClik)L

     FF FF ontrolled5er=ie FF

    this.ontrolled5er=ie.'uto5ie P trueLthis.ontrolled5er=ie.*oation P ne1 5ystem.Dra1ing.(oint&:%, $99)L

    this.ontrolled5er=ie.Name P Qontrolled5er=ieQLthis.ontrolled5er=ie.5ie P ne1 5ystem.Dra1ing.5ie, $>)L

    this.ontrolled5er=ie.3abInde? P 9L FF FF 75ControllerHorm FFthis.'uto5aleBase5ie P ne1 5ystem.Dra1ing.5ie&", $>)Lthis.Client5ie P ne1 5ystem.Dra1ing.5ie&>>%, $9)L

    this.Controls.'ddRange&ne1 5ystem.7indo1s.Horms.ControlO this.ontrolled5er=ie,

      this.Button(ause,  this.Button5top,

      this.Button5tart,  this.*abel$)L

    this.Minimum5ie P ne1 5ystem.Dra1ing.5ie&-%9, $%#)Lthis.Name P Q75ControllerHormQLthis.3e?t P Q7indo1s 5er=ie ControllerQL

    this.*oad P ne1 5ystem.E=ent;andler&this.75ControllerHormU*oad)Lthis.Resume*ayout&+alse)L

    endregionpri=ate =oid 75ControllerHormU*oad&ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    93/171

    pri=ate =oid 5etButton5tatus&)

     FFget the status o+ the ser=ie.string str5er=er5tatus P 75Controller.5tatus.3o5tring&)L

     FFhek the status o+ the ser=ie and enable the FFommand buttons aordingly.ontrolled5er=ie.3e?t P 75Controller.5er=ieNameLi+ &str5er=er5tatus PP QRunningQ)

     FFhek to see i+ the ser=ie an be pausedi+ &75Controller.Can(ause'ndContinue PP true)

    Button(ause.Enabled P trueLelse

    Button(ause.Enabled P +alseL

    Button5top.Enabled P trueLButton5tart.Enabled P +alseL

    else i+&str5er=er5tatus PP Q(ausedQ)

    Button5tart.Enabled P trueLButton(ause.Enabled P +alseL

    Button5top.Enabled P trueLelse i+ &str5er=er5tatus PP Q5toppedQ)

    Button5tart.Enabled P trueLButton(ause.Enabled P +alseLButton5top.Enabled P +alseL

    pri=ate =oid Button5tartUClik&ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    94/171

     FFget an array o+ ser=ies this ser=ie depends upon, loop through FFthe array and prompt the user to start all reuired ser=ies.5er=ieControllerO (arent5er=ies P 75Controller.5er=iesDepended8nL

     FFi+ the length o+ the array is greater than or eual to $.i+ &(arent5er=ies.*ength \P $)

    +oreah&5er=ieController (arent5er=ie in (arent5er=ies)

     FFmake sure the parent ser=ie is running or at least paused.i+&(arent5er=ie.5tatus.3o5tring&) TP QRunningQ [[(arent5er=ie.5tatus.3o5tring&) TP Q(ausedQ)

    i+ &MessageBo?.5ho1&Q3his ser=ie is reuired. 7ould you like to also startthis ser=ieZ^nQ(arent5er=ie.DisplayName, QReuired 5er=ieQ,MessageBo?Buttons.esNo).3o5tring&) PP QesQ)

     FFi+ the user hooses to start the ser=ie(arent5er=ie.5tart&)L(arent5er=ie.7aitHor5tatus&5er=ieController5tatus.Running)L

    else

     FFother1ise

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    95/171

    +oreah&5er=ieController Dependent5er=ie in Dependent5er=ies)

     FFmake sure the dependent ser=ie is not already stopped.i+&Dependent5er=ie.5tatus.3o5tring&) TP Q5toppedQ)i+ &MessageBo?.5ho1&Q7ould you like to also stop this dependentser=ieZ^nQDependent5er=ie.DisplayName, QDependent 5er=ieQ,MessageBo?Buttons.esNo).3o5tring&) PP QesQ)

     FF not heking at this point 1hether the dependent ser=ie an be stopped. FF de=eloper may 1ant to inlude this hek to a=oid e?eption.

    Dependent5er=ie.5top&)LDependent5er=ie.7aitHor5tatus&5er=ieController5tatus.5topped)L

    else

    returnL

     FFhek the status o+ the ser=iei+&75Controller.5tatus.3o5tring&) PP QRunningQ [[75Controller.5tatus.3o5tring&) PP Q(ausedQ)

    75Controller.5top&)L

    75Controller.7aitHor5tatus&5ystem.5er=ie(roess.5er=ieController5tatus.5

    topped)L 5etButton5tatus&)L

    pri=ate =oid Button(auseUClik&ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    96/171

    'IM

    4nderstand 1hy it an be bene+iial to reate separate modules +oran appliation do1nload, and then demonstrates ho1 to do so 1ithC.

    (R8GR'M

    MATH0

    using 5ystemLnamespae myMath

      publi lass Math5tu++  

    publi =oid 5uareIt&int num3o5uare)

      5ystem.Console.7rite*ine&num3o5uare num3o5uare)L     

    M'3; C*IEN36

    using 5ystemLusing myMathL

    lass MathClient  FF 5tati method Main is the entry point method.  publi stati =oid Main&)

    Math5tu++ myMath5tu++ P ne1 Math5tu++&)L

      Console.7rite*ine&Q5aring "Q)L  myMath5tu++.5uareIt&")L 

    - 96 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    97/171

    'IM

    De=elop a sample appliation that sho1s ho1 to print a +ormattedreport +rom sample data stored in an M* +ile using the(rintDoument lass in the 5ystem.Dra1ing.(rinting namespae. 'lso

    illustrates the user seletion o+ a destination printer and multipleprint +onts.

    (R8GR'M

    ASSEM6L7 IN9ORMATION0

    using 5ystem.Re+letionLusing 5ystem.Runtime.Compiler5er=iesL

     FF

     FF General In+ormation about an assembly is ontrolled through the +ollo1ing FF set o+ attributes. Change these attribute =alues to modi+y the in+ormation FF assoiated 1ith an assembly. FFassembly6 'ssembly3itle&QQ)Oassembly6 'ssemblyDesription&QQ)Oassembly6 'ssemblyCon+iguration&QQ)Oassembly6 'ssemblyCompany&QQ)Oassembly6 'ssembly(rodut&QQ)Oassembly6 'ssemblyCopyright&QQ)Oassembly6 'ssembly3rademark&QQ)Oassembly6 'ssemblyCulture&QQ)O

     FF FF Wersion in+ormation +or an assembly onsists o+ the +ollo1ing +our =alues6 FF FF Ma

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    98/171

     FF FF 4se the attributes belo1 to ontrol 1hih key is used +or signing. FF FF Notes6 FF &) I+ no key is spei+ied, the assembly is not signed. FF &) KeyName re+ers to a key that has been installed in the Crypto 5er=ie FF (ro=ider &C5() on your mahine. KeyHile re+ers to a +ile 1hih ontains FF a key. FF &) I+ the KeyHile and the KeyName =alues are both spei+ied, the FF +ollo1ing proessing ours6 FF &$) I+ the KeyName an be +ound in the C5(, that key is used. FF &-) I+ the KeyName does not e?ist and the KeyHile does e?ist, the key FF in the KeyHile is installed into the C5( and used. FF &) In order to reate a KeyHile, you an use the sn.e?e &5trong Name)utility.

     FF 7hen spei+ying the KeyHile, the loation o+ the KeyHile should be FF relati=e to the pro

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    99/171

    9ORM0

    using 5ystemLusing 5ystem.Dra1ingLusing 5ystem.ColletionsL

    using 5ystem.ComponentModelLusing 5ystem.7indo1s.HormsLusing 5ystem.DataL

    namespae (rintDoument

     FFF Vsummary\ FFF 5ummary desription +or Horm$. FFF VFsummary\publi lass Horm$ 6 5ystem.7indo1s.Horms.Horm

    pri=ate 5ystem.7indo1s.Horms.*abel lblCompanyL

    pri=ate 5ystem.7indo1s.Horms.*abel lbl;eaderHontLpri=ate 5ystem.7indo1s.Horms.*abel lblBodyHontLpri=ate 5ystem.7indo1s.Horms.*abel lblReportDataL

     FFF Vsummary\ FFF Reuired designer =ariable. FFF VFsummary\

    pri=ate 5ystem.ComponentModel.Container omponents P nullL

     FFF Vsummary\ FFF 4sed to display a +ont seletion dialog. 3his single dialog is

     FFF used +or both the header and body te?t +ont seletions.

     FFF VFsummary\pri=ate 5ystem.7indo1s.Horms.HontDialog +ontDialog$L

     FFF Vsummary\ FFF 4sed to handle the atual +ormatting and printing o+ the report.

     FFF VFsummary\pri=ate 5ystem.Dra1ing.(rinting.(rintDoument printDoument$L

     FFF Vsummary\ FFF 4sed to selet a destination printer. FFF VFsummary\pri=ate 5ystem.7indo1s.Horms.(rintDialog printDialog$L

     FFF Vsummary\ FFF Hont to use +or printing the page header. FFF VFsummary\pri=ate 5ystem.Dra1ing.Hont headerHontL

     FFF Vsummary\ FFF Hont to use +or printing the report body te?t. FFF VFsummary\pri=ate 5ystem.Dra1ing.Hont bodyHontL

    - 99 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    100/171

    pri=ate 5ystem.7indo1s.Horms.3e?tBo? headerHontDe+initionLpri=ate 5ystem.7indo1s.Horms.3e?tBo? ompanyNameLpri=ate 5ystem.7indo1s.Horms.Button (rintButtonLpri=ate 5ystem.7indo1s.Horms.3e?tBo? reportDataLpri=ate 5ystem.7indo1s.Horms.3e?tBo? bodyHontDe+initionLpri=ate 5ystem.7indo1s.Horms.Button 5elet;eaderHontLpri=ate 5ystem.7indo1s.Horms.Button 5eletBodyHontL

     FFF Vsummary\ FFF 4sed to read report data +rom a stati M* +ile. FFF VFsummary\pri=ate 5ystem.ml.ml3e?tReader ?mlReaderL

    publi Horm$&)

     FF FF Reuired +or 7indo1s Horm Designer support

     FFInitialieComponent&)L

     FF FF 38D86 'dd any onstrutor ode a+ter InitialieComponent all

     FF

     FFF Vsummary\ FFF Clean up any resoures being used. FFF VFsummary\

    proteted o=erride =oid Dispose& bool disposing )i+& disposing )

    i+ &omponents TP null)

    omponents.Dispose&)L

    base.Dispose& disposing )L

    region 7indo1s Horm Designer generated ode FFF Vsummary\ FFF Reuired method +or Designer support / do not modi+y FFF the ontents o+ this method 1ith the ode editor. FFF VFsummary\pri=ate =oid InitialieComponent&)

    this.lblReportData P ne1 5ystem.7indo1s.Horms.*abel&)L

    - 100 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    101/171

    this.printDialog$ P ne1 5ystem.7indo1s.Horms.(rintDialog&)Lthis.printDoument$ P ne1 5ystem.Dra1ing.(rinting.(rintDoument&)Lthis.headerHontDe+inition P ne1 5ystem.7indo1s.Horms.3e?tBo?&)Lthis.ompanyName P ne1 5ystem.7indo1s.Horms.3e?tBo?&)Lthis.lblBodyHont P ne1 5ystem.7indo1s.Horms.*abel&)Lthis.5elet;eaderHont P ne1 5ystem.7indo1s.Horms.Button&)Lthis.(rintButton P ne1 5ystem.7indo1s.Horms.Button&)Lthis.reportData P ne1 5ystem.7indo1s.Horms.3e?tBo?&)Lthis.5eletBodyHont P ne1 5ystem.7indo1s.Horms.Button&)Lthis.bodyHontDe+inition P ne1 5ystem.7indo1s.Horms.3e?tBo?&)Lthis.lbl;eaderHont P ne1 5ystem.7indo1s.Horms.*abel&)Lthis.+ontDialog$ P ne1 5ystem.7indo1s.Horms.HontDialog&)Lthis.lblCompany P ne1 5ystem.7indo1s.Horms.*abel&)L

    this.5uspend*ayout&)L FF FF lblReportData

     FF

    this.lblReportData.*oation P ne1 5ystem.Dra1ing.(oint&0, $%#)Lthis.lblReportData.Name P QlblReportDataQLthis.lblReportData.3abInde? P $:Lthis.lblReportData.3e?t P QReport Data6QL

     FF FF printDialog$ FFthis.printDialog$.Doument P this.printDoument$L

     FF FF printDoument$ FF

    this.printDoument$.DoumentName P QCustomer *istQLthis.printDoument$.(rint(age P ne15ystem.Dra1ing.(rinting.(rint(ageE=ent;andler&this.printDoument$U(rint(age)L

     FF FF headerHontDe+inition FF

    this.headerHontDe+inition.*oation P ne1 5ystem.Dra1ing.(oint&$-#, 9#)Lthis.headerHontDe+inition.Multiline P trueL

    this.headerHontDe+inition.Name P QheaderHontDe+initionQLthis.headerHontDe+inition.Read8nly P trueLthis.headerHontDe+inition.5ie P ne1 5ystem.Dra1ing.5ie&9#0, 90)L

    this.headerHontDe+inition.3abInde? P $9Lthis.headerHontDe+inition.3e?t P QQL

     FF FF ompanyName FF

    this.ompanyName.*oation P ne1 5ystem.Dra1ing.(oint&$-#, 0)Lthis.ompanyName.Name P QompanyNameQL

    this.ompanyName.5ie P ne1 5ystem.Dra1ing.5ie&9#0,-#)L

    - 101 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    102/171

    this.ompanyName.3abInde? P $-Lthis.ompanyName.3e?t P Q5ample CompanyQL

     FF FF lblBodyHont

     FFthis.lblBodyHont.*oation P ne1 5ystem.Dra1ing.(oint&0, $#9)Lthis.lblBodyHont.Name P QlblBodyHontQLthis.lblBodyHont.3abInde? P $%Lthis.lblBodyHont.3e?t P QBody 3e?t Hont6QL

     FF FF 5elet;eaderHont FF

    this.5elet;eaderHont.*oation P ne1 5ystem.Dra1ing.(oint&">%, 9#)Lthis.5elet;eaderHont.Name P Q5elet;eaderHontQL

    this.5elet;eaderHont.5ie P ne1 5ystem.Dra1ing.5ie&-9, -#)Lthis.5elet;eaderHont.3abInde? P $"Lthis.5elet;eaderHont.3e?t P Q...QL

    this.5elet;eaderHont.Clik P ne1

    5ystem.E=ent;andler&this.5elet;eaderHontUClik)L FF FF (rintButton FF

    this.(rintButton.*oation P ne1 5ystem.Dra1ing.(oint&-90, >$-)Lthis.(rintButton.Name P Q(rintButtonQLthis.(rintButton.3abInde? P -$Lthis.(rintButton.3e?t P Q(rintQL

    this.(rintButton.Clik P ne15ystem.E=ent;andler&this.(rintButtonUClik)L

     FF

     FF reportData FFthis.reportData.*oation P ne1 5ystem.Dra1ing.(oint&$-#, $%#)L

    this.reportData.Multiline P trueLthis.reportData.Name P QreportDataQLthis.reportData.Read8nly P trueL

    this.reportData.5rollBars P 5ystem.7indo1s.Horms.5rollBars.BothLthis.reportData.5ie P ne1 5ystem.Dra1ing.5ie&9#0, $99)L

    this.reportData.3abInde? P -#Lthis.reportData.3e?t P QQL

     FF FF 5eletBodyHont

     FFthis.5eletBodyHont.*oation P ne1 5ystem.Dra1ing.(oint&">%, $#9)L

    this.5eletBodyHont.Name P Q5eletBodyHontQLthis.5eletBodyHont.5ie P ne1 5ystem.Dra1ing.5ie&-9, -#)L

    this.5eletBodyHont.3abInde? P $0Lthis.5eletBodyHont.3e?t P Q...QL

    this.5eletBodyHont.Clik P ne15ystem.E=ent;andler&this.5eletBodyHontUClik)L

    - 102 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    103/171

     FF FF bodyHontDe+inition FF

    this.bodyHontDe+inition.*oation P ne1 5ystem.Dra1ing.(oint&$-#, $#9)Lthis.bodyHontDe+inition.Multiline P trueL

    this.bodyHontDe+inition.Name P QbodyHontDe+initionQLthis.bodyHontDe+inition.Read8nly P trueL

    this.bodyHontDe+inition.5ie P ne1 5ystem.Dra1ing.5ie&9#0, 90)Lthis.bodyHontDe+inition.3abInde? P $Lthis.bodyHontDe+inition.3e?t P QQL

     FF FF lbl;eaderHont FF

    this.lbl;eaderHont.*oation P ne1 5ystem.Dra1ing.(oint&0, 9#)Lthis.lbl;eaderHont.Name P Qlbl;eaderHontQLthis.lbl;eaderHont.3abInde? P $>Lthis.lbl;eaderHont.3e?t P Q;eader 3e?t Hont6QL

     FF FF lblCompany FF

    this.lblCompany.*oation P ne1 5ystem.Dra1ing.(oint&0, 0)Lthis.lblCompany.Name P QlblCompanyQLthis.lblCompany.3abInde? P $$Lthis.lblCompany.3e?t P QCompany Name6QL

     FF FF Horm$ FF

    this.'uto5aleBase5ie P ne1 5ystem.Dra1ing.5ie&", $>)L

    this.Client5ie P ne1 5ystem.Dra1ing.5ie&"%0, >9#)Lthis.Controls.'ddRange&ne1 5ystem.7indo1s.Horms.ControlO   this.lblBodyHont, this.5elet;eaderHont,

      this.(rintButton, this.reportData,  this.5eletBodyHont,

    this.bodyHontDe+inition,this.lbl;eaderHont, this.lblCompany,

      this.lblReportData,  this.headerHontDe+inition,

      this.ompanyName)Lthis.Name P QHorm$QLthis.3e?t P QCustomer *ist (rinting 5ampleQL

    this.*oad P ne15ystem.E=ent;andler&this.Horm$U*oad)L

    this.Resume*ayout&+alse)L

    endregion

     FFF Vsummary\

    - 103 -

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    104/171

     FFF 3he main entry point +or the appliation. FFF VFsummary\53'3hreadOstati =oid Main&)

    'ppliation.Run&ne1 Horm$&))L

     FFF Vsummary\ FFF 8urs be+ore a +orm is displayed +or the +irst time. FFF Contains ode to update read an M* +ile and update FFF the te?t o+ some +orm ontrols. FFF VFsummary\

     FFF Vparam namePQsenderQ\3he soure o+ the e=ent.VFparam\ FFF Vparam namePQeQ\'n E=ent'rgs that ontains the e=ent data.VFparam\pri=ate =oid Horm$U*oad&ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    105/171

     FF 'n error 1as enountered opening or reading the data +ile. FF Display an appropriate message to the user.

    MessageBo?.5ho1&QError opening +ile6 ^r^nQ e?.Message)L FF Close the +orm sine a report anSt be printed 1ithout aess

     FF to the data +ile.this.Close&)L

     FFF Vsummary\ FFF 3his e=ent displays a printer seletion dialog and then starts the print

     FFF proess. FFF VFsummary\

     FFF Vparam namePQsenderQ\3he soure o+ the e=ent.VFparam\ FFF Vparam namePQeQ\'n E=ent'rgs that ontains the e=ent data.VFparam\

    pri=ate =oid (rintButtonUClik&ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    106/171

    try

     FF 8pen the M* Data +ile.?mlReader P ne15ystem.ml.ml3e?tReader&Q..^^..^^..^^Mis^^ReportData.?mlQ)L

     FF (osition the pointer to the +irst element.?mlReader.Read&)L

     FF Display a printer seletion dialog. FF 8nly print the doument i+ the user liks 8K.i+ &printDialog$.5ho1Dialog&) PP DialogResult.8K)

     FF 3his starts the atual print. 3he ode to output FF te?t to the seleted printer resides in the (rintDoument$U(rint(age FF e=ent handler.

    (rintDoument$.(rint&)L

     FF Close the data +ile.

    ?mlReader.Close&)Lath &E?eption e?)

     FF I+ any error ours, display a messagebo?.MessageBo?.5ho1&QError printing report6 ^r^nQ e?.Message)L

     FFF Vsummary\ FFF 3his e=ent ours 1hen the output to print +or the urrent page is needed,

    and FFF ontains the logi to handle the ontent and layout o+ the printed page. FFF VFsummary\

     FFF Vparam namePQsenderQ\3he soure o+ the e=ent.VFparam\ FFF Vparam namePQeQ\' (rint(ageE=ent'rgs that ontains the e=entata.VFparam\pri=ate =oid printDoument$U(rint(age&ob

  • 8/17/2019 MiddleWare Technology- Lab Manual JWFILES

    107/171

    +loat y(osition P #L FF 4sed to store the number o+ lines printed so +ar on the FF urrent page.int ount P #L

     FF 4ser to store the te?t o+ the urrent line.string line P nullL

     FF (rint the page header, as spei+ied by the user in the +orm. FF 4se the header +ont +or this line only.e.Graphis.Dra15tring&ompanyName.3e?t.3rim&), headerHont,

    rushes.Blak, e.MarginBounds.*e+t, e.MarginBounds.3op, ne15tringHormat&))L

     FF (rint eah line o+ the data +ile, but donSt e?eed the ma?imum allo1able FF number o+ lines per