1.24k likes | 1.41k Views
eB SDK Training. 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
E N D
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
Structure of the API • Core API • Lets you build your own eB-aware applications • Web API • Lets you access eB objects fromyour own web pages • Web plug-in API • Lets you add functionality to eB Web • Web Services API • Lets you integrate with foreign systems
DLLs and Namespaces • 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
Proxy class • 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
eB.Data namespace • Classes for every object • Many helper classes • Used for read operations • Object-oriented layer on Proxy class
Named constants in eB.Common.Enum • 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
Connecting to eB • 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
Initializing eBProxy • Create the Proxy object myProxy = new Proxy(); • Connect to the Application server int rtn = myProxy.connect(0, serverName); • Logon int rtn = myProxy.logon(0, dataSource, user, pswd);
Read vs Write access • intrtn = myProxy.connect ( 0, serverName ); Read vs Write access 0 = Proxy.services.both = read/write 1 = Proxy.services.olap = read 2 = Proxy.services.oltp = write Use enumerated values for clarity
Data Source discovery • Get Data Sources from proxy String dataSources = myProxy.get_data_sources(0, ref rtnCode); dataSources string:
eB Sessions • Represents context for a logged-on user • Required for most methods in eB.Data • Contains active and default scopes
Initializing a Session • Create the sessioneB.Data.Session mySession = new eB.Data.Session() • Connect to the servermySession.Connect(SessionTypes.Both, serverName) • Log on to the application servermySession.Logon(SessionTypes.Both, community, username, password)
Converting from eBProxy to Session eBProxy Session ProtoProxy
Code for eBProxy to Session • 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);
Cleanup • 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.
Sample Proxy calls • Creating objects int rtnCode = myProxy.add_keyword(keywordName) • Creating object links int rtnCode = myProxy.add_document_location( docId, locationId) • Retrieving object information string fileInfo = myProxy.get_doc_files_list (docId, levels, criteria, ref rtnCode) • Changing objects int rtnCode = myProxy.chg_location( locationId, newDesc, newLocationTypeId )
Error Handling in Proxy calls int rtnCode = myProxy.someMethod (param1, param2) Updating, deleting, linking an objectsuccess = 1 error < 0 Creating an objectsuccess = object ID error < 0
Error Handling in Proxy calls (cont) Retrieving object informationsuccess = 1 error < 0 string info = myProxy.someMethod (param1, param2, ref rtnCode) Return string contains xml data
Getting the error string • myProxy.get_error(rtnCode)
Silent Mode for errors 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.
Error Handling in eB.Data classes • Use Exception handling to deal with errors
Two approaches to retrieval • 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
Getting object data with eB Proxy • Proxy.get_report() • Gets all objects meeting specified criteria • Proxy.get_object() • Gets all specified data for a single object
Using get_report string xmlStr = proxy.get_report ( string report_name, string criteria, string options, ref int result) Object type to search for Use rules in next slide to build up a query Use a blank string or “IDS_ONLY” Returns 1 for success Returns XML string with info
Rules for criteria in get_report columnName operator value AND/OR columnName operator value ... • These booleans are allowed: • AND • OR • AND NOT • OR NOT You supply the value • Operators are: • like • = (equals) • <> (not equals) • <= (less than or equal to) • >= (greater than or equal to) Column namesdocumented at get_report_syntax Get allowed column names for eachobject from get_report_syntax
Syntax for custom attribute values (char_str_value.<AttrName> = 'finalized') Value to search for Name of the attribute inangle brackets - Required Column name for a string attribute value Use parentheses to avoid ambiguity
Using get_object • Gets only one object per call string xmlStr proxy.get_object ( int pl_object_id, int pl_object_type, long pl_options, ref int pl_result) Internal ID of the object you want Use eB.Common.Enum.ObjectType Bitwise union of options fromeB.Common.Enum.GetObject Returns all requested data for just one object
Sample options for get_object • Use bitwise OR operator to set options long options = (long) GetObject.DocumentOptions.Projects | GetObject.DocumentOptions.Characteristics| GetObject.DocumentOptions.Locations | GetObject.DocumentOptions.Security; long options = (long) GetObject.DocumentOptions.Detail; long options = GetObject.GetAllObjectOptions (objType, true, true);
Checking for relationships: hasFlags • Details option includes ahas_flags element • Convert content to long and test the relationship of interest (bitwise AND) • If 0, no relationship if (hasFlags & GetObject.DocumentOptions.Projects == 0) No Project links
Getting object data with eB.Data • 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 Data Data
Creating a search for objects • Create the search string (as eQL) • Create the search object • Run the search 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>();
Basics of eQL PrimaryObject Columnsto return Filter Criteria Sorting
eQL syntax Keywords inupper case Commas between columns No comma at end of SELECT Single quotesfor text Dot notationfor related properties Extra spaces& line breaks OK
Getting System Data • 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
Using Retreive for object data • Create the object, using the object ID • Populate the object properties using Retrieve 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
Available retrieval options • Objects know their own retrieval options
Document, Copy, File API calls • 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 (cont) • 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
Updating documents • 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" proxy.chg_document (docID, newPrefix, newMiddle, newRevision, newClassID, newTitle); proxy.chg_document (docID, “%", “%", "ver2.0", -1, “%");
Updating document attributes • In the API: Attributes == Characteristics • First get the ID of the object str = proxy.get_report ("documents", “title = ‘mydoc’, “IDS_ONLY”, ref result); • Then get the IDs of its characteristics flag = (long) GetObject.DocumentOptions.Characteristics; str = proxy.get_object (docID, flag, ref result); • Then update result = proxy.chg_char_data (docID, charID, value);
About Templates • Templates aid new object creation • Provide default settings forcommon properties • Ensure object security gets applied • Set up links to Projects, Organizations