bis and com in action

63
COM AIP4089: BIS and COM In Action Wed Nov 6, 1:30pm

Upload: jerry-merrill

Post on 10-Jul-2015

2.254 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: BIS and COM in Action

COM

AIP4089: BIS and COM In Action

Wed Nov 6, 1:30pm

Page 2: BIS and COM in Action

• Who is SCB?Who is SCB?

• What Is COM?What Is COM?

• BIS’s COM Client InterfaceBIS’s COM Client Interface

• Writing your own COM componentWriting your own COM component

• Working with other componentsWorking with other components

• GotchasGotchas

• Questions and AnswersQuestions and Answers

Discussion Outline

Page 3: BIS and COM in Action

19941994 19991999 2002

Software Services BusinessSoftware Services Business

Page 4: BIS and COM in Action

What do we do?What do we do?

IT Consulting

Project Management

IT Wellness testing

Information strategyplanning

IT Cost Analysis and ROI

Internet & Legacy SystemsIntegration

Systems Design andprogramming

IT Outsourcing

System development &Integration

System Maintenance, supportand reengineering

Facilities Management

Legacy System Transformation

Migration Service

Data Center Management

Remote Processing

IT Professional Staffing

Application Development

Database/IT project management

Datacenter Operations

Mainframe/Midrange Support

Training (mentoring, classroom,or customized)

Data Warehousing

PC/LAN Help Desk Support

Network design, administration,and operations

Page 5: BIS and COM in Action

Business Information Server(MAPPER)

Internet Commerce Enabler(Cool ICE)

Modernization Services

Solution Services GroupSolution Services Group

Page 6: BIS and COM in Action

What is COM?COM

Page 7: BIS and COM in Action

COM (component object model)COM (component object model) HistoryHistory

• DDE (dynamic data exchange)

• OLE 1.0 (object linking and embedding)

• VBX (VB controls, just for VB)

• OLE 2

• OCX (OLE Controls, VB, C, C++, Java)

• Renamed ActiveX

What is COM?

Page 8: BIS and COM in Action

A COM componentA COM component• Has “public” interfaces (properties, methods,

and events)• Has “private” variables, subroutines and

functions• Reports “public” interfaces (properties,

methods, and events)• Can include usage information with public

interfaces (properties, methods, and events)

What is COM?COM

COM info stored in Windows RegistryCOM info stored in Windows Registry Startup and persistence managed by Startup and persistence managed by

Windows OSWindows OS

Page 9: BIS and COM in Action

LibraryLibrary• Package of class(es). In VB: the project.

ClassClass• The COM component. Has code and data structure.• In VB an executable can have zero or more forms,

zero or more classes, and zero or modules InstanceInstance

• One working copy of the class CollectionCollection

• Like an array but each entry can be different ExecutableExecutable

• .EXE -out-of-process server -separate memory• .DLL -in-process server -shares memory

What is COM?

Page 10: BIS and COM in Action

What is COM?

Comparison with DDEComparison with DDECategory DDE COM

Age Old and orphaned Recent and evolving

Application complexity Moderate Very

Relative speed Fast Faster

BIS Availability W2K, UNIX, 2200 W2K only

BIS-W2K level 4.0 or above 8.1E1 or above (ICE 3.0 or above)

Execute location On workstation under MPC On server under MAPPER.exe

Foreground execution Yes Yes

Background execution No Yes

Scheduled execution No Yes

Data Types Text only Text, Integer, Boolean, Array, Rid

Page 11: BIS and COM in Action

BIS / COM interface best used with:BIS / COM interface best used with:• Centralized e-mail server

• Centralized fax server

• Centralized message server:• LEMS (Law Enforcement Messaging Switch)• MQSeries (messaging middleware for

heterogeneous hosts by IBM)

• Centralized data transfer server

What is COM?

Page 12: BIS and COM in Action

BIS’s COM Client InterfaceBIS’s COM Client Interface

COM

Page 13: BIS and COM in Action

BIS-NT 8.1E1 and aboveBIS-NT 8.1E1 and above

• Outbound only (@CCC)

ICE 3.0 and aboveICE 3.0 and above

• Outbound (@CCC)

• Inbound (ICE services)

Not available on 2200 or UNIXNot available on 2200 or UNIX

BIS’s COM Client InterfaceBIS’s COM Client Interface

Page 14: BIS and COM in Action

ICE 3.0 Inbound COMICE 3.0 Inbound COM CoolSession objectCoolSession object

Methods CoolSession.Open GatewayName, UserID, Dept, Pswd CoolSession.Close

• CoolServer objectCoolServer object Properties string = CoolServer.MIMETYPE variant = CoolServer.ServiceOutput Methods Open CreateDataSet ExecuteDataService Close ExecuteService RemoveDataSet RetreiveDataSet ProcessXML

BIS’s COM Client InterfaceBIS’s COM Client Interface

Page 15: BIS and COM in Action

• @CCC@CCC -create an instance -create an instance

• @CCP@CCP -put a property value -put a property value

• @CCG@CCG -get a property value -get a property value

• @CCI@CCI -invoke a method -invoke a method

• @CCR@CCR -release the instance -release the instance

• Missing is an “Advise”Missing is an “Advise”

BIS’s COM Client InterfaceBIS’s COM Client Interface

Page 16: BIS and COM in Action

@CCC -Create instance @CCC,label prog-id handle vmsg .

• prog-id -VB: project.class-Excel: Excel.Application-Word: Word.Application-e-mail: CDONTS.NewMail, et. al.-others: see OLE Viewer

• handle <handle>i2

• vmsg <errmsg>s

BIS’s COM Client InterfaceBIS’s COM Client Interface

@cci,199 MAPZIP.ZipManager <mz>i2 <msg>s256@cci,199 MAPZIP.ZipManager <mz>i2 <msg>s256

Only five instance handles available

Page 17: BIS and COM in Action

@CCP -Put property value @CCP[,label] hdl,property fmt value [vmsg] .

• hdl -instance handle from @CCC• property -components property name• fmt -BOOL <var>i1

-BSTR string-I2 small integer-I4 large integer-R4 real (floating)-VAR rid or result

• value -literal or variable or ([c,d,]-0,delim)

• vmsg <errmsg>s

BIS’s COM Client InterfaceBIS’s COM Client Interface

Page 18: BIS and COM in Action

@CCP -Put property value

@ccp,199 <mz>,Temp BSTR ‘c:\pcme’ <msg>s256@ccp,199 <mz>,Temp BSTR ‘c:\pcme’ <msg>s256

BIS’s COM Client InterfaceBIS’s COM Client Interface

@ldv <rep>i4=314 .@ldv <rep>i4=314 .@ccp,199 <mz>,Repeat I2 <rep> <msg> .@ccp,199 <mz>,Repeat I2 <rep> <msg> .

@brk .@brk .Salut mon vieux,Salut mon vieux,J’espere que tu va bien.J’espere que tu va bien.Ton amis toujours…Ton amis toujours…@brk ldv <lf>h1=chr$ 12 . line-feed delimiter@brk ldv <lf>h1=chr$ 12 . line-feed delimiter@ccp,199 <mz>,BodyText bstr (-0,<lf>) <msg> @ccp,199 <mz>,BodyText bstr (-0,<lf>) <msg>

Page 19: BIS and COM in Action

@CCG -Get property value @CCG[,label] hdl,property return [vmsg] .

• hdl -instance handle from @CCC

• property -components property name

• return -variable of proper type and size or array element or (c,d,r)

• vmsg <errmsg>s

BIS’s COM Client InterfaceBIS’s COM Client Interface

Page 20: BIS and COM in Action

@CCG -Get property value

@ccg,199 <mz>,Count <files>i3 <msg>s256 .@ccg,199 <mz>,Count <files>i3 <msg>s256 .

BIS’s COM Client InterfaceBIS’s COM Client Interface

@ccg,199 <mz>,Comment <cmt>s80 <msg>s256 .@ccg,199 <mz>,Comment <cmt>s80 <msg>s256 .

@ccg,199 <mz>,Item(2) <ele>h18 <msg>s256 .@ccg,199 <mz>,Item(2) <ele>h18 <msg>s256 .

Page 21: BIS and COM in Action

@CCI -invoke method @CCI[,label] hdl,method fmts params return [vmsg] .

• hdl -instance handle from @CCC

• property -components method name

• fmts -comma separated list of formats or ‘’

• params -matching comma separated list of parameters (literals or variables) or ‘’

• return -variable of proper type and size or ‘’

• vmsg <errmsg>s

BIS’s COM Client InterfaceBIS’s COM Client Interface

Page 22: BIS and COM in Action

@cci,199 <mz>,AddToZip ‘’ ‘’ <ok>i1 <msg> .@cci,199 <mz>,AddToZip ‘’ ‘’ <ok>i1 <msg> .

@cci <lsp>,Describe bstr,bstr,bstr,i2 \ .@cci <lsp>,Describe bstr,bstr,bstr,i2 \ . M,W,’6ft0’,220 ‘’ <msg> . M,W,’6ft0’,220 ‘’ <msg> .

BIS’s COM Client InterfaceBIS’s COM Client Interface

@CCI -invoke method

@cci,199 <prj>,Close ‘’ ‘’ ‘’ <msg>s256 .@cci,199 <prj>,Close ‘’ ‘’ ‘’ <msg>s256 .

Page 23: BIS and COM in Action

@CCR -release instance @CCR hdl1[,hdl2,hdl3,…] .

• hdlx -instance handle(s) from @CCC

BIS’s COM Client InterfaceBIS’s COM Client Interface

@ccr <az>,<bz> . @ccr <az>,<bz> .

Page 24: BIS and COM in Action

Writing your own COM component

COM

Page 25: BIS and COM in Action

Writing your own COM component

Page 26: BIS and COM in Action

Writing your own COM component

http://msdn.microsoft.com/library/default.asp

http://www.microsoft.com/com/

Page 27: BIS and COM in Action

Choose language: VB, C++, Java Choose language: VB, C++, Java

Use Microsoft Visual Studio 6.0Use Microsoft Visual Studio 6.0TMTM

Plan your own properties and methodsPlan your own properties and methods• Keep it simple

Use third party components Use third party components • Faxing: Faxman• ZIPing: SaxZIP• Messaging: MQSeries• Others: www.componentsource.com

www.programmersparadise.com

Writing your own COM component

Page 28: BIS and COM in Action

A simple project:A simple project: MapCalcMapCalc• add or multiply two numbers

Name the class:Name the class: AddMultAddMult

PropertiesProperties• op1 -integer• op2 -integer

MethodsMethods• Add -add op1 to op2 and return sum• Mult -multiply op1 by op2 and return product

Writing your own COM component

Page 29: BIS and COM in Action

ActiveX.EXE -out-of-process server ActiveX.DLL -in-process server

Writing your own COM component

Page 30: BIS and COM in Action

Option Explicit

Private mintOp1 As IntegerPrivate mintOp2 As Integer-----------------------------------------------Public Property Let Op1(ByVal vData As Integer)

mintOp1 = vDataEnd Property-----------------------------------------------Public Property Let Op2(ByVal vData As Integer)

mintOp2 = vDataEnd Property-----------------------------------------------Public Function Add() As Integer

Add = mintOp1 + mintOp2End Function---------------------------------Public Function Mult() As Integer

Mult = mintOp1 * mintOp2End Function

Writing your own COM component

Page 31: BIS and COM in Action

Option Explicit

Private mintOp1 As IntegerPrivate mintOp2 As IntegerPrivate mintSum as Integer--------------------------------------------------------------------Public Sub AddOps (ByVal vData1 As Integer, ByVal vData2 As Integer) mintSum = vData1 + vData2End Sub--------------------------------------------------------------------Public Property Get Sum() As Integer Sum = mintSumEnd Property

Writing your own COM component Adding a Method with parameters Adding a read only Property

Page 32: BIS and COM in Action

MapCalc.AddMultMapCalc.AddMult

Writing your component

D E M OD E M O

Page 33: BIS and COM in Action

Writing your own COM component

Page 34: BIS and COM in Action

Writing your own COM component New VB project, Standard EXE, Project / References

View / Object Browser…• Shows methods• Shows properties

How?• Pulled from the Registry!

Page 35: BIS and COM in Action

Writing your own COM component

.DATE 01 AUG 02 15:25:25 RID 15A 01 AUG 02 JERR

.RUN: MapCalc (COM interface to MapCalc.AddMult) *=======================================================@ ccc,99 MapCalc.AddMult <mc>i2 <msg>s256 . create @ ccp,98 <mc>,Op1 i2 96 <msg> . put @ ccp,98 <mc>,Op2 i2 104 <msg> . put @ cci,98 <mc>,Add '' '' <sum>i8 . invoke @ cci,98 <mc>,Mult '' '' <prd>i8 . invoke @ ccr <mc> . release The sum is <sum>. The product is <prd>. @ gto end . @98:ccr <mc> . error release@99:brk,0,i . <msg> @ brk dsp,-0 . Display error

The BIS Code (15a0)

Page 36: BIS and COM in Action

MapCalc.AddMultMapCalc.AddMult

Writing your component

D E M OD E M O

Page 37: BIS and COM in Action

Writing your own COM component Execute in RDB to see process in Task Manager

.DATE 01 AUG 02 15:26:02 REPORT GENERATION JERR*======================================================= The sum is 200. The product is 9984. ..... END REPORT .....

Results

Page 38: BIS and COM in Action

Writing your own COM component Creating an install for your component

The install files

Page 39: BIS and COM in Action

Working with other components

COM

Page 40: BIS and COM in Action

ComponentsComponents• E-mail

• Word

• Excel Finding Prog-IdsFinding Prog-Ids Finding Classes, Properties, Methods Finding Classes, Properties, Methods

Working with other components

Page 41: BIS and COM in Action

Working with other components ““How to” and How to” and

object modelsobject models• Outlook

• Excel

• Word

• FrontPage

• Project

• PowerPoint

• Access

Page 42: BIS and COM in Action

E-mail interfaceE-mail interface• According to

msdn.microsoft.com/library/default.asp• CDONTS

• Collaborative Data Objects for NT Servers• Requires Microsoft IIS or Exchange Server• Simple Object Model

• CDO for Windows 2000• Included with the OS• More complex Object Model

Working with other components

Page 43: BIS and COM in Action

E-mail interfaceE-mail interface• CDONTS supplied with IIS and/or Exchange

Working with other components

Page 44: BIS and COM in Action

CDONTS.NewMailCDONTS.NewMail• Objects• Collections• Methods• Properties

Working with other components

Page 45: BIS and COM in Action

CDONTS.NewMail exampleCDONTS.NewMail example

Working with other components

.DATE 01 AUG 02 15:25:25 RID 20A 01 AUG 02 JERR

.RUN: EZmail (COM interface to CDONTS.NewMail) *=======================================================@ ccc,99 CDONTS.NewMail <eml>i2 <msg>s256 . @ ccp,98 <eml>,From bstr ‘[email protected]’ <msg> . @ ccp,98 <eml>,To bstr ‘[email protected]’ <msg> @ ccp,98 <eml>,Subject bstr ‘COM in Action’ <msg> . @ brk .Salut mon vieux,J’espere que tu va bien.Ton amis toujours…@ brk ldv <lf>h1=chr$ 12 . line-feed delimiter@ ccp,98 <eml>,BodyText bstr (-0,<lf>) <msg> .@ cci,98 <eml>,Send ‘’ ‘’ ‘’ <msg> .@ ccr <eml> . ..... END REPORT .....

Page 46: BIS and COM in Action

Microsoft ExcelMicrosoft ExcelWorking with other components

Page 47: BIS and COM in Action

Excel.Application.10Excel.Application.10 *Application has Workbooks*Application has Workbooks -add-add -open-open -close-close *Workbook has Worksheets*Workbook has Worksheets -add-add -delete-delete -calculate-calculate *Worksheet has Range*Worksheet has Range -value (put)-value (put) -value (get)-value (get)

Working with other components

*Each needs a handle*Each needs a handle*Only five available*Only five available

Page 48: BIS and COM in Action

Excel.Application exampleExcel.Application example

Working with other components

.DATE 01 AUG 02 15:25:25 RID 25A 01 AUG 02 JERR

.RUN: MapExcel (COM interface to Excel.Application.10) *===========================================================================@ldv <xl>i2=0,<wbs>i2=0,<wb>i2=0,<wss>i2=0,<ws>i2=0,<rng>i2=0,<nms>i2=0 . @rer 0199 . @ccc,0199 'Excel.Application' <xl> <msg>s998 . @. @ccg,0199 <xl>,Workbooks <wbs> <msg>s998 . WorkBooks collection @ccg,0199 <wbs>,Count <bookcnt>i2 <msg>s998 . @cci,0199 <wbs>,Open BSTR 'c:\com_ado\comtest.xls' <wb> <msg>s998 . WorkBook@ccg,0199 <wbs>,Count <bookcnt>i2 <msg>s998 . @. @ccg,0199 <wb>,Worksheets <wss> <msg>s998 . WorkSheets collection @ccg,0199 <wss>,Count <sheetcnt>i2 <msg>s998 . @ccg,0199 <wss>,Item(1) <ws> <msg>s998 . handle to 1st WorkSheet @. @ccr <wbs> ldv <wbs>=0 . release WorkBooks handle @ccr <wss> ldv <wss>=0 . release WorkSheets handle@.@ccg <ws>,Range(A1,C3) <rng>i2 <msg>s998 . handle to Range

Page 49: BIS and COM in Action

Excel.Application example (continued)Excel.Application example (continued)

Working with other components

@ccg,0199 <xl>,Names <nms>i2 <msg>s998 . Names collection @cci,0199 <nms>,Add BSTR,BSTR First,'=Sheet1!$A$1:$A$1' <nam>i2 <msg> @ccr <nms> ldv <nms>=0 . release Names handle@. @ccg,0199 <nam>,RefersToRange <rng>i2 <msg>s998 . get Range handle @ccg,0199 <rng>,Value <cell>h18 <msg>s998 . @ccp,0199 <rng>,Value BSTR 'Pierre' <msg>s998 . @. @ldv <msg>='*** OK ***' gto 0199 . @. ------------------------------------------------------------------- @0199:if <rng> GT 0 ccr <rng> ; if <nam> GT 0 ccr <nam> ; . @ if <nms> GT 0 ccr <nms> ; if <ws> GT 0 ccr <ws> ; . @ if <wss> GT 0 ccr <wss> ; . @ if <wb> GT 0 cci,lin1 <wb>,Close I2 1 '' <close>s998 ; . @ if <wb> GT 0 ccr <wb> ; . @ if <wbs> GT 0 ccr <wbs> ; if <xl> GT 0 ccr <xl> ; . @ BRK,0,A LDV <COL>I3=1 . <MSG>(<COL>-80) @ INC,80 <COL> IF <MSG>(<COL>-80) NE '',(LIN-1) ; . @ BRK DSP,-0 .

Page 50: BIS and COM in Action

Excel.ApplicationExcel.Application

Working with other components

D E M OD E M O

Page 51: BIS and COM in Action

Microsoft WordMicrosoft WordWorking with other components

Page 52: BIS and COM in Action

Word.ApplicationWord.Application * Appl has Documents* Appl has Documents -add-add -open-open -close-close * Document has:* Document has: - sections, paragraphs- sections, paragraphs - sentences, words- sentences, words * Appl has * Appl has aa Selection Selection * Selection has Find* Selection has Find * Find has:* Find has: - target, replace- target, replace - execute- execute

Working with other components

* Each needs a handle* Each needs a handle* Only five available* Only five available

Page 53: BIS and COM in Action

Word.Application exampleWord.Application example

Working with other components

.DATE 01 AUG 02 15:25:25 RID 30A 01 AUG 02 JERR

.RUN: MapWord (COM interface to Word.Application) *=====================================================================@ldv <wrd>i2=0,<docs>i2=0,<doc>i2=0,<sel>i2=0,<fnd>i2=0,<tbl>i2=0 .@rer 0199 .@. @ccc,199 Word.Application <wrd>i2 <msg>s256 . @ccg,199 <wrd>,Documents <docs>i2 <msg> . Documents collection@cci,199 <docs>,Open BSTR 'c:\com_ado\comtest.doc' <doc>i2 <msg>@. @ccg,199 <wrd>,Selection <sel>i2 <msg> . get Hdl to Selection obj@ccg,199 <sel>,Find <fnd>i2 <msg> . get Hdl to Find obj@. @cci,199 <fnd>,Execute \ . (9) BSTR,,,,,,,,,BSTR,I2 '!org!',,,,,,,,,'Unite',2 <found>i1 .

Function Find.Execute([FindText], [MatchCase], [MatchWholeWord], [MatchWildcards], [MatchSoundsLike], [MatchAllWordForms], [Forward], [Wrap], [Format], [ReplaceWith], [Replace], [MatchKashida], [MatchDiacritics], [MatchAlefHamza], [MatchControl]) As Boolean

Page 54: BIS and COM in Action

Word.Application example (continued)Word.Application example (continued)

Working with other components

@cci,0199 <fnd>,Execute BSTR 'review' <found>i2 . @ccp,0199 <sel>,Text BSTR 'functional examination' <msg> . @. @ccr <docs> ldv <docs>=0 . release a handle @. @cci,199 <fnd>,Execute BSTR '!stcdtable!' <found>i1 .@if <found> ne 0,(0070) ; ldv <lf>h1=chr$ 12 . line-feed @cnt,0,b,2 p 'stcd' |,1 .@ccp,199 <sel>,Text BSTR (-0,<lf>) <msg> . @cci,199 <sel>,ConvertToTable BSTR,,,,,,,,,,,,,I2 \ . ‘|',,,,,,,,,,,,,1 <tbl>i2 <msg> . (13)Function Selection.ConvertToTable([Separator], [NumRows], [NumColumns], [InitialColumnWidth], [Format], [ApplyBorders], [ApplyShading], [ApplyFont], [ApplyColor], [ApplyHeadingRows], [ApplyLastRow], [ApplyFirstColumn], [ApplyLastColumn], [AutoFit], [AutoFitBehavior], [DefaultTableBehavior]) As Table

Page 55: BIS and COM in Action

Word.ApplicationWord.Application

Working with other components

D E M OD E M O

Page 56: BIS and COM in Action

Use DDE not COM for Excel and WordUse DDE not COM for Excel and Word

• Complex object models require more thanfive handles

• Debugging difficult because you cannotmake visible during execution

• Prone to hanging the run and requiring reboot

Working with other components

Page 57: BIS and COM in Action

GotchasCOM

Page 58: BIS and COM in Action

User-id’s and PermissionsUser-id’s and Permissions• Foreground = MPC script’s user-id

• Background = MAPPERguest

• Execute permission for C:\WINNT\SYSTEM32• several OLE*.DLL

• Execute permission for the directory withEXE’s and DLL’s

• Read, write, and modify permissions for directories accessed by component program

• For Excel or Word: execute permissions forC:\Program Files\Microsoft Office\Office10\

Gotchas

Page 59: BIS and COM in Action

Rudimentary DocumentationRudimentary Documentation• @CCG and @CCP offer a wealth of options

and formats

• How to use these options and formats is notexplained

• Examples using these options and formats are not presented

Gotchas

Page 60: BIS and COM in Action

Multiple Document ProgramsMultiple Document Programs• Like Excel and Word

• Not explained in BIS manuals

• No working samples from Unisys

• Instance handles• Need handles for many objects• Only five handles available

• Cannot make visible for debugging

Gotchas

Page 61: BIS and COM in Action

Orphaned ProcessesOrphaned Processes• Monitor processes in Task Manager• If the run errors off without releasing the instance,

the .EXE (or .DLL) may remain executing on the Task list.When this happens, you cannot modify the program or document or recompile the program.

• Sometimes Task Manager can end the process• Sometimes you can release the process by closing

the MPC session• Sometimes you have to down and up BIS• Most of the time you have to reboot the machine

Gotchas

Page 62: BIS and COM in Action

QuestionsQuestions

What is COM?What is COM? BIS’s COM Client InterfaceBIS’s COM Client Interface

• CCC, CCP, CCG, CCI, CCR Writing your own COM classWriting your own COM class

• VB and ActiveX .EXE’s Working with other classesWorking with other classes

• E-mail, Excel, Word GotchasGotchas

YOU

COM

BIS

Page 63: BIS and COM in Action

For More Information, Contact:For More Information, Contact:

2012 W. Lone Cactus DrivePhoenix, AZ 85027Phone: (623) 879-7900Fax: (623) 869-6984

Web site: http://www.scb-az.com

E-mail: [email protected]