© 2010 bentley systems, incorporated eb sdk training
TRANSCRIPT
© 2
01
0 B
en
tley
Syst
em
s, In
corp
ora
ted
www.bentley.com
eB SDK Training
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
2 | WWW.BENTLEY.COM
Integration Methods
• Non- API integration• External Tools for eB Director
• Database events triggering stored procedures
• API-based methods:• Stand-alone Applications
• Stand-alone Web Pages
• Plug-in Web Pages for eB Web
• Scripts running in Office Apps
• Web Services integration
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
3 | WWW.BENTLEY.COM
Register tools for eB Director
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
4 | WWW.BENTLEY.COM
External Tool operation
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
5 | WWW.BENTLEY.COM
Database events
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
6 | WWW.BENTLEY.COM
• Core API– Lets you build your own eB-aware
applications
• Web API– Lets you access eB objects from
your own web pages
• Web plug-in API– Lets you add functionality to eB Web
• Web Services API– Lets you integrate with foreign systems
Structure of the API
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
7 | WWW.BENTLEY.COM
• eB.Service.Proxy.dll– eB.Service.Client namespace – implements the Proxy class– eB.Data namespace – implements object classes
• eB.Common.dll– eB.Common.Enum namespace – enumerated types used by
other classes
• eB.Library.Web.dll– eB.Library.Web namespaces
• eB.Web.Data.dll– eB.Web.Core namespaces– eB.Web.UI namespaces– eB.Web.Data namespaces
DLLs and Namespaces
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
8 | WWW.BENTLEY.COM
Core API
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
9 | WWW.BENTLEY.COM
• Proxy – master class that governs interactions with all eB objects
• Handles connection, logon, logoff
• Creates, modifies, & deletes objects
• Gets information for an object
• Provides transactions & rollback
Proxy class
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
10 | WWW.BENTLEY.COM
• Classes for every object
• Many helper classes
• Used for read operations
• Object-oriented layer on Proxy class
eB.Data namespace
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
11 | WWW.BENTLEY.COM
• Applies meaningful names to lists of values• eB.Common.Enum.ObjectType
– Lists the names of all eB object types– 1 = Item 2 = VitualItem 3 = Document
• eB.Common.Enum.GetObject– Options for flags used when getting object info
• eB.Common.Enum.HasFlags– Tests whether an object has a given
relationship
Named constants in eB.Common.Enum
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
12 | WWW.BENTLEY.COM
Connecting to the database
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
13 | WWW.BENTLEY.COM
• Connect using eB.Service.Proxy (old way)
OR
• Connect using eB.Data.Session (new way)
• Expensive operation– Preserve the connection while user is logged on
Connecting to eB
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
14 | WWW.BENTLEY.COM
• Create the Proxy objectmyProxy = new Proxy();
• Connect to the Application serverint rtn = myProxy.connect(0, serverName);
• Logonint rtn = myProxy.logon(0, dataSource, user, pswd);
Initializing eBProxy
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
15 | WWW.BENTLEY.COM
Read vs Write access
int rtn = myProxy.connect ( 0, serverName );
Read vs Write access
0 = Proxy.services.both = read/write1 = Proxy.services.olap = read2 = Proxy.services.oltp = write
Use enumerated values for clarity
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
16 | WWW.BENTLEY.COM
• Get Data Sources from proxyString dataSources =
myProxy.get_data_sources(0, ref rtnCode);
Data Source discovery
dataSources string:
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
17 | WWW.BENTLEY.COM
• Represents context for a logged-on user
• Required for most methods in eB.Data
• Contains active and default scopes
eB Sessions
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
18 | WWW.BENTLEY.COM
• Create the session
eB.Data.Session mySession = new eB.Data.Session()
• Connect to the server
mySession.Connect(SessionTypes.Both, serverName)
• Log on to the application server
mySession.Logon(SessionTypes.Both, community,
username, password)
Initializing a Session
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
19 | WWW.BENTLEY.COM
Converting from eBProxy to Session
eBProxy Session
ProtoProxy
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
20 | WWW.BENTLEY.COM
• Log on as ProxyeBProxy.connect(0, “serverName”);
eBProxy.logon(0, dataSource, userName, pwd);
• Convert to SessioneB.Data.Session session = new eB.Data.Session();
Session.AttachProtoProxy(eBProxy.proto_proxy,
eBProxy.connect_info);
Code for eBProxy to Session
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
21 | WWW.BENTLEY.COM
• Logoff-If you don’t logoff and instead just terminate the program, then the license that was being used by the logged-on user is “quarantined” and isn’t freed up for reuse for about 20 minutes. By logging off, you free up that license immediately.
• Disconnect-If you don’t Disconnect, I’m not sure what this does. It probably just holds onto some Application server resources until timeout is reached and they are freed up.
• Dispose-. It’s the memory clean-up call. In eB, the dispose method also logs the user off and disconnects as well.
Cleanup
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
22 | WWW.BENTLEY.COM
• Creating objectsint rtnCode = myProxy.add_keyword(keywordName)
• Creating object linksint rtnCode = myProxy.add_document_location( docId, locationId)
• Retrieving object informationstring fileInfo = myProxy.get_doc_files_list (docId, levels, criteria, ref rtnCode)
• Changing objectsint rtnCode = myProxy.chg_location( locationId, newDesc, newLocationTypeId )
Sample Proxy calls
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
23 | WWW.BENTLEY.COM
Error Handling in Proxy calls
int rtnCode = myProxy.someMethod (param1, param2)
Updating, deleting, linking an object success = 1 error < 0
Creating an object success = object ID error < 0
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
24 | WWW.BENTLEY.COM
Error Handling in Proxy calls (cont)
string info = myProxy.someMethod (param1, param2, ref rtnCode)
Retrieving object information success = 1 error < 0
Return string contains xml data
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
25 | WWW.BENTLEY.COM
• myProxy.get_error(rtnCode)
Getting the error string
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
26 | WWW.BENTLEY.COM
myProxy.silent_mode = true;• Normally false. Error message pops up.
• If true, trap the message yourself.
• Must be true in web apps or the web server will hang.
Silent Mode for errors
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
27 | WWW.BENTLEY.COM
• Use Exception handling to deal with errors
Error Handling in eB.Data classes
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
28 | WWW.BENTLEY.COM
Getting object information
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
29 | WWW.BENTLEY.COM
• Old Method– proxy.get_report – returns multiple objects– proxy.get_object – returns info on one object
• New Method using eB.Data namespace – eB.Data.Search – returns multiple objects– eB.Data.class.Retrieve – returns info on one object
Two approaches to retrieval
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
33 | WWW.BENTLEY.COM
• Proxy.get_report()– Gets all objects meeting specified criteria
• Proxy.get_object()– Gets all specified data for a single object
Getting object data with eB Proxy
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
34 | WWW.BENTLEY.COM
string xmlStr = proxy.get_report (
string report_name,
string criteria,
string options,
ref int result)
Using get_report
Object type to search for
Returns 1 for success
Use rules in next slide to build up a query
Use a blank string or “IDS_ONLY”
Returns XML string with info
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
35 | WWW.BENTLEY.COM
columnName operator value AND/OR columnName operator value ...
Rules for criteria in get_report
Get allowed column names for eachobject from get_report_syntax
Operators are:- like- = (equals)- <> (not equals)- <= (less than or equal to)- >= (greater than or equal to)
You supply the value
These booleans are allowed:- AND- OR- AND NOT- OR NOT
Column namesdocumented at get_report_syntax
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
36 | WWW.BENTLEY.COM
(char_str_value.<AttrName> = 'finalized')
Syntax for custom attribute values
Column name for a string attribute value
Name of the attribute inangle brackets - Required
Value to search for
Use parentheses to avoid ambiguity
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
37 | WWW.BENTLEY.COM
• Gets only one object per callUsing get_object
string xmlStr proxy.get_object (
int pl_object_id,
int pl_object_type,
long pl_options,
ref int pl_result)
Returns all requested data for just one object
Internal ID of the object you want
Use eB.Common.Enum.ObjectType
Bitwise union of options fromeB.Common.Enum.GetObject
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
38 | WWW.BENTLEY.COM
• Use bitwise OR operator to set options
Sample options for get_object
long options = (long) GetObject.DocumentOptions.Projects | GetObject.DocumentOptions.Characteristics| GetObject.DocumentOptions.Locations | GetObject.DocumentOptions.Security;
long options = GetObject.GetAllObjectOptions (objType, true, true);
long options = (long) GetObject.DocumentOptions.Detail;
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
39 | WWW.BENTLEY.COM
• Details option includes ahas_flags element
• Convert content to long and test the relationship of interest (bitwise AND)
• If 0, no relationship
Checking for relationships: hasFlags
if (hasFlags & GetObject.DocumentOptions.Projects == 0) No Project links
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
40 | WWW.BENTLEY.COM
• eB.Data.Search()– Gets all objects meeting specified criteria– One object type per search
• eB.Data.<classes>.Retrieve – Retrieve method gets specified data
for a single object– Class used corresponds to the type of object
Getting object data with eB.Data
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
41 | WWW.BENTLEY.COM
• Create the search string (as eQL)
• Create the search object
• Run the search
Creating a search for objects
String eqlStr = @“START WITH Document SELECT Id, Code, Name
WHERE Class.Code = ‘DWG’ ”;
eB.Data.Search srch = new eB.Data.Search( session, eqlStr);
System.Data.DataTable dt = srch.Retrieve<System.Data.DataTable>();
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
42 | WWW.BENTLEY.COM
Basics of eQL
PrimaryObject
Columnsto return
Filter Criteria
Sorting
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
43 | WWW.BENTLEY.COM
eQL syntax
Keywords inupper case
Single quotesfor text
Extra spaces& line breaks OK
Commas between columns
No comma at end of SELECT
Dot notationfor related properties
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
44 | WWW.BENTLEY.COM
Generate a list of searchable properties
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
45 | WWW.BENTLEY.COM
• eB.Data.SystemData class
• Used for eB configuration information– Job types– Keywords– Available Templates– Responsibility Types– Revision rules– Static Lookups– Many others
• SystemData.Retrieve(“prop1;prop2;prop3”) retrieves specified properties
Getting System Data
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
46 | WWW.BENTLEY.COM
• Create the object, using the object ID
• Populate the object properties using Retrieve
Using Retreive for object data
eB.Data.Document doc = new eB.Data.Document(session, id);
doc.Retrieve(“Header;Attributes;Files;Securities”);String docName = doc.Name;String docCode = doc.Code;
Caution: properties are NULL until retrieved
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
47 | WWW.BENTLEY.COM
• Objects know their own retrieval options
Available retrieval options
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
48 | WWW.BENTLEY.COM
Test Retrieval tool
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
49 | WWW.BENTLEY.COM
• To add a copy to a document:– add_doc_copy
• To add a file to a copy:– add_object_file
• To delete a copy object:– del_doc_copy
Document, Copy, File API calls
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
50 | WWW.BENTLEY.COM
• To get the file ids of all files in all doc copies:– get_doc_files_list
• To get the file (as a stream) knowing the file id:– get_doc_file (file_id, ref stream)
• To delete a file from the repository:– del_doc_file (file_id)
• To move a file from one doc copy to another:– del_doc_copy_file– add_doc_copy_file
Document, Copy, File API calls (cont)
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
51 | WWW.BENTLEY.COM
• When updating a document, you must supply values for all parameters in the method.
• You can supply “no op” values for parameters you don’t want to change: – Text: "%"– Numeric: -1– Date: "02-JAN-1753"
Updating documents
proxy.chg_document (docID, newPrefix, newMiddle, newRevision, newClassID, newTitle);
proxy.chg_document (docID, “%", “%", "ver2.0", -1, “%");
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
52 | WWW.BENTLEY.COM
• In the API: Attributes == Characteristics
• First get the ID of the objectstr = proxy.get_report ("documents", “title = ‘mydoc’,
“IDS_ONLY”, ref result);
• Then get the IDs of its characteristicsflag = (long) GetObject.DocumentOptions.Characteristics;str = proxy.get_object (docID, flag, ref result);
• Then updateresult = proxy.chg_char_data (docID, charID, value);
Updating document attributes
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
53 | WWW.BENTLEY.COM
• Templates aid new object creation
• Provide default settings forcommon properties
• Ensure object security gets applied
• Set up links to Projects, Organizations
About Templates
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
54 | WWW.BENTLEY.COM
• Use get_object, not get_report for template list– Use object ID = 0
• GetObject.TemplateOptions– NewFromTemplate – All templates with
“Can Use” privilege– TemplateDocuments – All document templates with
“View” privilege
Listing Templates
int objType = (int)ObjectType.Templates;long options = (long)GetObject.TemplateOptions.TemplateDocuments;string xmlRes = eBProxy.get_object( 0, objType, options, ref iRes );
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
55 | WWW.BENTLEY.COM
• Part template, part document (or other target object)
• Two IDs in XML– <obj_id> in template table– <object_id> in target object table
• Use objID to get template properties
• Use objectID to get target object properties
Templates are two-part objects
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
56 | WWW.BENTLEY.COM
• Use proxy.add_template– Takes several parameters to set template
properties– Returns the template id
Creating templates
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
57 | WWW.BENTLEY.COM
• Use proxy.create_from_template(objID)– Takes the template id as a parameter– Returns the new document id
Creating documents from templates
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
58 | WWW.BENTLEY.COM
Scripting in eB
Hello World!
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
59 | WWW.BENTLEY.COM
• Write macros with “code behind” in Excel
• Use any of the eB API calls
• Reference spreadsheet cells to get data
• Combine eB calls with spreadsheet entries– Create objects– Modify objects– Delete objects
Office Application scripting
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
60 | WWW.BENTLEY.COM
• VB is not managed code
• Register proxy as a COM dll: > cd C:\Windows\Microsoft.NET\Framework\v2.0.50727 > regasm "path\to\eB.service.Proxy.dll"
• Create the proxy: Set myProxy = CreateObject("eB.Service.Proxy")
• No overloaded methods in COM
Adjustments for VBA
set_object_statusset_object_status_2set_object_status_3
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
61 | WWW.BENTLEY.COM
Sample spreadsheet
Spreadsheet
Code Behind
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
62 | WWW.BENTLEY.COM
Event Handlers & Engines
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
63 | WWW.BENTLEY.COM
• Event is something that happens based on activity in eB– Approval of an object– Completion of a work task– File check-in
• Not database triggers
Event Handlers
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
64 | WWW.BENTLEY.COM
Working with virtual items
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
65 | WWW.BENTLEY.COM
• A non-tangible aspect of your business
• Part of a:– Process– Set of Requirements– Function, etc
• Can be grouped into hierarchies
• Hierarchy represents the completefunction or process
What is a Virtual Item?
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
66 | WWW.BENTLEY.COM
Sample Virtual Item hierarchy
Virtual Item Group
Nested Virtual Item Group
Virtual Item
Nested Virtual Item
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
67 | WWW.BENTLEY.COM
Virtual Items & VI Groups
Virtual Item GroupA
Ungrouped VI
Grouped VI
Virtual Item GroupB
• Code• Desc
ObjTyp = 123
ObjTyp = 2
• Code• Desc• Attrs 1• Links 1
Grouped VI
ObjTyp = 123• Code• Desc• Attrs 2• Links 2
add_vitemadd_vitem_grp_member add_vitem_grp_member
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
68 | WWW.BENTLEY.COM
• Virtual Itemadd_vitem (code, description)
• Virtual Item Group– It’s really a document– Acts as a container for virtual itemsadd_document (prefix, middle, revNo, classID, title)
Creating Virtual Items & VI Groups
Class must be of typeVirtual Item Structure orVirtual Item Baseline(see subsequent slides)
Can be anempty string
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
69 | WWW.BENTLEY.COM
Getting class IDs for creating VI Groups
xml = proxy.get_object (objID, objType, options, ref result);
xml = proxy.get_object (classID, objType, options, ref result);
objID = 1
GetObject.ClassGroupOptions.ChildrenObjectType.ClassGroups (=184)
ObjectType.ClassObject
GetObject.ClassObject.Children
Call get_object multiple times for nested classes
Get from xml string in previous call
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
70 | WWW.BENTLEY.COM
Document class for VI Group
Look for V or W
In the return xml string from get_object, examine <sys_type> in <child>
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
71 | WWW.BENTLEY.COM
• Add VI to group
• Attach grouped VI to VI parent
Adding Virtual Item members
gvi_id = proxy.add_vitem_grp_member (group_id, vitem_id);
ID of the VI groupID for new grouped virtual item
ID of the ungrouped virtual item
proxy.add_gvitem_structure(parent_id, child_id);
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
72 | WWW.BENTLEY.COM
• Use get_object with appropriate options
Getting VI Groups for a Virtual Item
xml = proxy.get_object (objID, objType, options, ref result);
GetObject.VitemOptions.GroupsRelated
ObjectType.VirtualItem
Examine xml for VI Group info
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
73 | WWW.BENTLEY.COM
Using workflow
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
74 | WWW.BENTLEY.COM
• A Work Order class and a template
• Work Tasks—the individual steps of the workflow
• Skills—determine which users may work on a task
Workflow components
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
75 | WWW.BENTLEY.COM
• Create WO from template
• Fill in fields & create links unique to this WO
• Calculate due dates
• Add objects to a work order or a work task– Adding to work order makes object
visible across the workflow– Adding to work task limits object to that task– Make the object subject or reference
• Approve WO to get it started
Life cycle of a work order
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
76 | WWW.BENTLEY.COM
• get_object– Gets the workflow templates
• create_from_template– Creates the work order
• add_work_order_doc– Links a document to the work order
• add_work_step_doc– Links a document to a task on the work order
• calc_wo_schedule– Calculates from a date based on task durations
WO calls
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
77 | WWW.BENTLEY.COM
• add_template – adds a template to a work order class
• get_report – gets the list of skills for assigning to tasks
• add_work_step – adds a task to a work order template
• add_ws_structure – adds arrow from one task to another
Developing the work order template
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
78 | WWW.BENTLEY.COM
• work_accept – assigns the work task
• work_choose_path – chooses the path in a branching work order
• work_delegate – delegates a task to a person or skill group
• work_cancel – cancels specified task in workflow
• work_suspend – stops the work order
• work_resume – restarts the work order
• work_complete – completes the work task
Processing work tasks
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
79 | WWW.BENTLEY.COM
Web framework
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
80 | WWW.BENTLEY.COM
• eB Web API
• eB Web Plug-in Framework
Web API Overview
Classes to let you connect existing web sites to eBusing ASP.NET
Classes to let you customize your eB web environment
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
81 | WWW.BENTLEY.COM
eB Web API
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
82 | WWW.BENTLEY.COM
• Technology for quickly creating websites
• Web pages are built on-the-fly at the server
• Simple tags specify complex UI– Server builds the complex UI
based on the simple tag
• A web page is divided into two files– Xhtml page markup– Code-behind file– Application logic separate from presentation
ASP.NET Review
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
83 | WWW.BENTLEY.COM
ASP.NET Review (cont)
default.aspx.csdefault.aspx
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
84 | WWW.BENTLEY.COM
• AssemblyInfo.cs – attributes of the assembly compiled by the ASP.NET project
• Global.asax – “page” containing application class of the web project
• Web.config – xml file containing settings and config for the web project
• default.aspx – default web page for the project
ASP.NET project files
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
85 | WWW.BENTLEY.COM
eB Web Library
Data structures
Web UI controls v15
Page classes for eB pages
Plug-in Framework
Plug-in UI controls
Web Core classes
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
86 | WWW.BENTLEY.COM
• eB.Web.eBContext– Log on and save state– Maintains Session information– Subsequent pages can use the saved state– Use in place of ProxyWrapper
(if updating v14 code)
Maintaining Logon State
eBContext eBcxt = new eBContext(appServer, dataSource, userName, password);
eBcxt.SaveInSession(HttpContext.Current);
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
87 | WWW.BENTLEY.COM
• ActivityPage– ActivityContext provides objects passed to page– ActivityContext.FocusObject is first eBObject
• AuthenticatedPage– Derived from ActivityPage– Uses state saved by eBContext
• ObjectSpecificPage– Derived from AuthenticatedPage– Meant to display data for one object per page– Get object details from ActivityContext
eB Page classes
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
89 | WWW.BENTLEY.COM
• Object Type: ActivityContext.FocusObject.Id.OfTypeActivityContext.FocusObject.Id.TypeID
• Object Id:if (!ActivityContext.FocusObject.RetrievedOptions.Contains(“Header”){ ActivityContext.FocusObject.Retrieve(“Header”);}
• The object itself:eBObjectIdentifier eBIdent = ActivityContext.FocusObject.Id.Id;eB.Data.Document doc;doc = ActivityContext.Dispenser.Dispense<eB.Data.Document>(eBIdent);
Getting object information on a page
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
90 | WWW.BENTLEY.COM
• Mechanism for referencing eB objects via URL
• Opens the object in eB Web
• Syntax to programatically generate URLs
• Send to recipients to point to specific objects
• Remember to URL encode unsafe characters
QuickLinks
http://srv1/eb/Search/QuickLink.aspx?u=ADMIN&p=admin&d=training&n=DOC01&t=3
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
91 | WWW.BENTLEY.COM
• Base URL:
• Object-specific parameters– n=<prefix>– t=<objecttype>– r=<revision>– m=v or m=l (documents only)– u=<username>&p=<password>&d=<dsn>– s=<connect_info>
QuickLink syntax
http://<server>/<webapp>/Search/QuickLink.aspx
http://srv1/eb/Search/QuickLink.aspx?u=ADMIN&p=admin&d=training&n=DOC01&t=3
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
92 | WWW.BENTLEY.COM
eB Web plug-in framework
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
93 | WWW.BENTLEY.COM
Bentley uses plug-in architecture
Plug-ins from Bentley
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
94 | WWW.BENTLEY.COM
• The Manage eB Web Applications tool lets you set up multiple web apps connecting to eB
• Each web application at a web site is a unique combination of plug-ins– Reviewers: Core, Document Manager, Viewer,
Workflow– Document Specialists: add Change Management,
SharePoint– Engineers: add Item Manager, Virtual Item Manager
• Each group accesses eB using a different URL
Managing plug-ins
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
95 | WWW.BENTLEY.COM
Manage eB Web Apps utility
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
96 | WWW.BENTLEY.COM
Custom plug-in integration points
Add Tasks
Add Custom Object PagesAdd Navigators
Change field formatAdd Basket Tasks
Add Searches
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
97 | WWW.BENTLEY.COM
• Use sample plug-in projects as templates
• Features of plug-in projects– Object-specific page– Tree control page– Action page– Authenticated web control– Layout control provider
Visual Studio setup for plug-ins
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
98 | WWW.BENTLEY.COM
• Provides minimum requirements for a plug-in
• Implement these methods in PlugIn.cs:– FormPath – determines which objects the plug-in will
handle & identifies the redirect pages– TaskList – adds tasks to Task panel for specified
objects
• The class also reads config files to add navigators, search UI, and other UI elements– AppElements.config– PlugIn.config (removed in 15.4)
ConfiguredPlugIn class
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
99 | WWW.BENTLEY.COM
• Unique ID for every plug-in
• Plug-in ID must match Installation folder
• Plug-in class and dll names should reflect function
Plug-in naming
Plug-in ID
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
100 | WWW.BENTLEY.COM
• Copy .dll to bin folder in virtual directory
• Include .pdb if debugging is required
• Add subfolder to PlugIn folder in virtual directory– Subfolder name = plugin ID– Copy PlugIn.Config, .aspx, .ascx, css, etc from
project.
• Edit web.config– Add entry in <FrameworkSettings><PlugIns>
element
Deploying eB Web plug-ins
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
101 | WWW.BENTLEY.COM
• Can’t debug in isolation
• Deploy project files to plug in folder
• Copy dll and pdb to web app bin directory
• Start browser, navigate to website
• In Visual Studio, Attach to Process – w3wp.exe for IIS
Debugging a plug-in
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
102 | WWW.BENTLEY.COM
• Add a page to your project– Use Page class derived from ObjectSpecificPage– Page uses ObjectDisplay.Master
with content placeholders
• Add controls to your page– CustomisableDisplayContainer
• Modify FormPath to redirect to your new page
• Competition for object display – Winner Takes All– [assembly: eB.Library.Web.PlugIn.Attributes.PlugInPriority(110)]
Adding object display pages
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
103 | WWW.BENTLEY.COM
Object display controls
CustomisableDisplayContainer
CustomisablePropertiesContainer
CustomisableRelationshipsContainer
These controls respect Layout Editor changes
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
104 | WWW.BENTLEY.COM
FormPath method in PlugIn.cs
Contains info about theitem to be displayed
View or Edit mode
Lets other plug-inshandle the object
Examine object data
Redirect string
Check for retrieval
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
105 | WWW.BENTLEY.COM
• Get metadata for an eB object from TargetObject– Check for eB object: TargetObject.IseBObject()– TargetObject.Activity.FocusObject.Retrieve(“Header”)
• After retrieval, create the eB.Data object– if (targetObj.eBId.OfType = ObjectType.Document)
{ eB.Data.Document doc = targetObj.Activity.FocusObject.Inner) }
TargetObject
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
106 | WWW.BENTLEY.COM
• TaskList method in PlugIn.cs adds an action to the Task Panel
• CategorizedTaskList object stores the collection of tasks for an eB object
• Use the AddTask method
Adding Tasks to Task Panel
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
107 | WWW.BENTLEY.COM
AddTask method in PlugIn.csContains info about theitem to be displayed
List of tasks
task name
category title
uri to image
uri to task page
target window
task id
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
108 | WWW.BENTLEY.COM
• Use PlugIn.Config file, <BasketAction> tag
• Creates an object of type PageTask
Adding Tasks to Basket
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
109 | WWW.BENTLEY.COM
• Framework provides controls for known data types
• Customize layout with LayoutControlProvider
• Four methods to implement:– PropertyControl – Displays properties and attributes– PropertyControlValue – Updates properties– RelationshipControl – Displays relationship table– ColumnControl – Displays a column in relationship table
Changing field format
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
110 | WWW.BENTLEY.COM
• Technique:– Use Layout Editor to create new data type for a property– In your project, derive from LayoutControlProvider class– Implement PropertyControl method (for example)
• Examine supplied property for relevant characteristics (e.g. new data type)
• Create new control • Return control
– Framework hooks up control to page and property– Register LayoutControlProvider class in PlugIn.config
Changing field format (cont)
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
111 | WWW.BENTLEY.COM
• Add entries to the list of Navigators
• Navigator types:– Tree control– Other web controls
• Register navigators in AppElements.config
Custom Navigators
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
112 | WWW.BENTLEY.COM
• TreeNavigationProvider
• WebControlNavigationProvider
Custom Navigators (cont)
Builds a tree control and displays one or more root objects, and selected children
References a web control, in which you can display any actions or links you want
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
113 | WWW.BENTLEY.COM
• Entry in AppElements.config creates a TreeControl
• References .aspx page describing the tree content
TreeNavigationProvider
Page describingtree content
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
114 | WWW.BENTLEY.COM
• Use TreeExploder.aspx page to specify contents
• Contents are combinations of these controls:– TreeExplode – get_explode on the root object– TreeSearch – get_report on the root object– TreeQuery – sql query on the root object– TreeGroup – arbitrary container for other objects– TreeLink – a leaf node that links to another page– TemplatesNode – shows templates for a class– ExplodeAddObjectTrees – expands the object and
adds subtrees for child objects
Content for TreeControl
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
115 | WWW.BENTLEY.COM
TreeControl example
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
116 | WWW.BENTLEY.COM
• AppElements.config entry adds to the list of Navigators
• Displays a web control of your choosing– Specified by the ASCX property– Often used to display a list of commands or links to other pages
WebControlNavigationProvider
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
117 | WWW.BENTLEY.COM
• Your searches appear in the Search drop-down list
• Register searches in AppElements.config
• Design the search fields in the .ascx page
Custom Search
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
118 | WWW.BENTLEY.COM
• Create .ascx page
• Use SearchParametersControl class
• Class handles submitting the searchto eB (using proxy.get_report)
• Use BuildQuery method to add criteria to queryData search structure
• Provide your own UI for this control
Designing the Search control
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
119 | WWW.BENTLEY.COM
• System Menu Task – Adds top-level icons
• Preferences – Adds user options to the preferences page
• Object Creation – References pages to create new objects
• Pickers – Specify classes of pickers for choosing objects
Additional PlugIn.config entries
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
120 | WWW.BENTLEY.COM
• Sampling of UI controls for eB pages– CustomizableDisplayContainer – Layout Editor sensitive– DateControl – Pick dates by calendar– FileUploadControl – Drag & drop target for adding files– LogInControl – Displays log-in screen– LayoutPanelManager – Lists sections from Layout Editor– LayoutSectionsList – Drop-down list of Layout Editor
sections
eB Web UI controls
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
121 | WWW.BENTLEY.COM
Web Services integration
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
122 | WWW.BENTLEY.COM
• Standard for making Remote Procedure Callsfrom client to server
• Uses HTTP POST or SOAP
• Server publishes methods in WSDL file
• Client and Server are loosely-coupled
Web Services fundamentals
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
123 | WWW.BENTLEY.COM
WebProxy.asmx
http://ServerName/eBSite/WebProxy.asmx
Listings of allWeb Servicesmethods
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
124 | WWW.BENTLEY.COM
• No Connect method, just Logon
• Logon returns session string
• Use session string in subsequent calls
• Acts like proxy.connect_info
Connecting and logging on
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
125 | WWW.BENTLEY.COM
WebProxy Test Page
© 2
010
Bent
ley
Syst
ems,
Inco
rpor
ated
126 | WWW.BENTLEY.COM
Sample WebProxy callUsing SOAP 1.2
Using HTTP POST