0% found this document useful (0 votes)
716 views

Filebound 7 Api Manual: Application Programming Interface

This document provides an overview of the FileBound 7 API and examples of common tasks like searching for files, creating documents, running workflows, and accessing the FileBound viewer. It explains the main objects in the FileBound object model and how to establish a data connection, log in, retrieve collections, search, create/edit documents, and manipulate workflows. It also covers topics like groups, users, reports, e-forms, printing, scanning, annotations and various FileBound web services.

Uploaded by

Fahad Mahmood
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
716 views

Filebound 7 Api Manual: Application Programming Interface

This document provides an overview of the FileBound 7 API and examples of common tasks like searching for files, creating documents, running workflows, and accessing the FileBound viewer. It explains the main objects in the FileBound object model and how to establish a data connection, log in, retrieve collections, search, create/edit documents, and manipulate workflows. It also covers topics like groups, users, reports, e-forms, printing, scanning, annotations and various FileBound web services.

Uploaded by

Fahad Mahmood
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 82

FileBound 7 API Manual

Application Programming Interface


FileBound Technical Publications
1/1/2015

This Document is designed to be example driven and does not contain an all-inclusive list of the methods and
functions used in the entire Object Model. The intellisense capabilities of Visual Studio are utilized to show and
explain the usage of the methods available, and it is encouraged to use these in-line descriptions.
FileBound 7 API Manual
Contents
FileBound Object Model Part 1 Overview ............................................................................................4
Main Objects of Interest ...................................................................................................................4
Establishing a Data Connection ...........................................................................................................6
Creating a Business Object..................................................................................................................6
Logging In to FileBound .....................................................................................................................7
Logged In User Account .....................................................................................................................7
Retrieving Projects Collection .............................................................................................................8
Searching for Files............................................................................................................................ 10
Searching for Files Examples ............................................................................................................ 10
Searching for Files – Dynamic Field Number ..................................................................................... 10
Searching for Files – Dynamic Field Number – Shortcut version ......................................................... 11
Creating New Files ........................................................................................................................... 12
Retrieving Documents....................................................................................................................... 13
Creating New Documents.................................................................................................................. 13
Initiate Workflow - Ad-Hoc .............................................................................................................. 15
Initiate Workflow - Defined .............................................................................................................. 16
Manipulating Workflow .................................................................................................................... 17
Adding Projects ................................................................................................................................ 18
Editing Projects ................................................................................................................................ 18
Deleting Projects .............................................................................................................................. 19
Separators and Dividers .................................................................................................................... 19
Adding Groups ................................................................................................................................. 20
Adding Users ................................................................................................................................... 20
Setting Existing Users’ Passwords ..................................................................................................... 21
Adding a User and Setting Group Rights ............................................................................................ 21
Providing Group Rights for a Project ................................................................................................. 22
Revoking Group Rights from a Project............................................................................................... 23
Wiring Collections and Objects ......................................................................................................... 24
Directly Accessing Collections and Objects........................................................................................ 26
Serializing Collections and Objects.................................................................................................... 27
Cloning Objects................................................................................................................................ 28
Tag Properties .................................................................................................................................. 28
Parent Properties .............................................................................................................................. 28

1
FileBound 7 API Manual
Syncing a Collection vs. Saving the Object......................................................................................... 29
Running Reports............................................................................................................................... 31
Managing Reports ............................................................................................................................ 32
E-Forms ........................................................................................................................................... 34
Email ............................................................................................................................................... 36
Printing without a Viewer ................................................................................................................. 37
Getting Image with Annotations ........................................................................................................ 38
TWAIN Scanning ............................................................................................................................. 39
Working with Archives ..................................................................................................................... 40
Annotations...................................................................................................................................... 42
Search.aspx ...................................................................................................................................... 43
Entry.aspx ........................................................................................................................................ 43
FileDetail.aspx ................................................................................................................................. 44
Default.aspx ..................................................................................................................................... 44
Index.aspx........................................................................................................................................ 44
Examples ......................................................................................................................................... 44
Search for Files (Search.aspx): .......................................................................................................... 46
Open Viewer by FileID (viewer.ashx): ............................................................................................... 46
Open Viewer by DocumentID (viewer.ashx): ..................................................................................... 46
Web Viewer (Starting with FileBound 6): ............................................................................................. 47
Entry (entry.aspx): ............................................................................................................................ 47
Renditions (renditions.ashx – Starting with FileBound 6): ....................................................................... 47
Thumbnails (thumbnails.ashx): .......................................................................................................... 47
Barcode (barcode.ashx):.................................................................................................................... 47
Thumbnails.ashx .............................................................................................................................. 48
Viewer.ashx ..................................................................................................................................... 49
Barcode.ashx.................................................................................................................................... 50
Viewer Overview ............................................................................................................................. 51
Combination Viewers – Web connection............................................................................................ 53
Combination Viewers – SQL connection............................................................................................ 54
Document Viewers - Web connection ................................................................................................ 54
Document Viewers – SQL connection................................................................................................ 55
Document Viewers – Document Object.............................................................................................. 55
Command Viewers – Web connection................................................................................................ 56

2
FileBound 7 API Manual
Command Viewers – SQL connection................................................................................................ 56
Command Viewers – FileBound Web connection ............................................................................... 57
Command Viewers – Calling from Web Page..................................................................................... 57
Embedding Viewers in Web pages..................................................................................................... 59
Special Document-Only Viewer - DocView ....................................................................................... 60
Custom Events with the FullViewer................................................................................................... 61
Custom Assemblies with the CommandViewer................................................................................... 62
Custom Viewers for Document Types................................................................................................ 64
Settings Screens for Plug-Ins ............................................................................................................. 68
Web Service Basics Overview ........................................................................................................... 71
Setting Up a Web Reference to DataExchange2.................................................................................. 71
Creating a Web Service Instance of DataExchange2 ........................................................................... 71
Error Handling ................................................................................................................................. 72
Project Examples .............................................................................................................................. 73
File Examples................................................................................................................................... 73
Document Examples ......................................................................................................................... 74
Workflow Examples ......................................................................................................................... 76
Miscellaneous Examples ................................................................................................................... 77

3
FileBound 7 API Manual

FileBound Object Model Part 1:


FileBound Object Model Part 1 Overview
The FBOM is developed with an n-tier architecture and can be configured to use 2 or more tiers. The
configuration of the FileBound system is out of scope for the blog posts, but a general understanding of
the overall configuration options of FileBound is beneficial when developing against the FBOM.

The following diagram shows how the Interface layer of FileBound (ASP.NET) uses the Object Model to
communicate via the Business Process Layer, through the Data Access Layer and to the data source (SQL
and document storage).

Developers need to understand this relationship in order to understand the instantiation methodology of
the FBOM. The first thing a developer does is define which data source to use. The second thing is to
define the business object and pass it the data source reference. Once that relationship is established the
object model is primed and ready to use.

Main Objects of Interest


As demonstrated in the above section, the Data and Business objects are instrumental in the FBOM.
Without them, it would be impossible to communicate to a data source – Web or SQL. The primary
programming objects of interest in the system are Project, File, Document, Group and User objects.

4
FileBound 7 API Manual

All objects and collections share common methodologies for retrieving, editing and deleting elements.
This makes the learning curve for developing with the Object Model much shorter.

We strongly encourage all new FileBound developers to study the FileBound Object Model diagram to
familiarize themselves with the object relationships. The above diagram is only a small piece of the entire
puzzle.

5
FileBound 7 API Manual

FileBound Object Model Part 2:


Establishing a Data Connection
The first step in interacting with FileBound through the FBOM is to establish a Data connection. This is
done using the FileBound.Data namespace to create a FileBound.Data object.

SQL, Web (Web services connection to FileBound server) and DataArchive come standard with the
FBOM. This enables the developer to communicate with FileBound via a direct SQL connection for faster
speed on a local server, through the FileBound Web server for a remote connection or to a FileBound
Archive. Developers may find it easiest to use the AutoData

method provided in the FileBound.FBFunctions namespace. This will evaluate the incoming connection
string and create the appropriate Data object. For example, if the incoming connection is an HTTP or
HTTPS URL, it will create a Web Data object. If the connection is a SQL ODBC connection string, it
will create a SQL Data object. If the connection is a directory path then it will create a DataArchive
connector.

Custom data objects can be created by inheriting one of the standard objects (if overriding a few methods
is required) or by inheriting the FileBound.Data.Base object and starting from scratch (if creating a
completely new data source). In order to take advantage of custom Data objects the
FileBound.FBFunctions.AutoData() method must be used.

Example – FileBound.Web
Dim FBData As New FileBound.Data.Web("http://serverurl")

Example – FileBound.SQL
Dim FBData As New FileBound.Data.SQL( _
"Persist Security Info=True;User ID=fbuser;password=fbpass" & _
";Initial Catalog=filebound;Data Source=(local)\sqlexpress;")

Example – FileBound.DataArchive
Dim FBData As New FileBound.Data.DataArchive( _
"\\Server\Share\Path\Archive")

Example – FileBound.FBFunctions.AutoData()
Dim FBData As FileBound.Data.BaseData = FileBound.FBFunctions.AutoData("http://serverurl")

Creating a Business Object


Once the Data object is available, a Business object is created and provided a reference to the Data object.
This creates the link between logic (Business) and storage (Data) that is required to complete basic
operations. The Business object is the main element that developers will deal with. It handles all
communication to and from the data source, and provides logic that

handles security, workflow, e-forms and more.

Example
6
FileBound 7 API Manual

Dim FBBusiness As New FileBound.Business.Standard(FBData)

Logging In to FileBound
In order to send and receive data to and from a FileBound system, the application must authenticate using
a defined FileBound user account. The Login() method on the Business object performs this
authentication. Once authenticated, the rights and abilities provided through the FBOM are limited to the
rights and abilities given to the authenticated user’s account. This means a programmer cannot use a non-
administrator account to perform administrative functions. Any attempt to send/receive data without
being authenticated will result in program errors.

Example – Standard Login


FBBusiness.Login("admin", "admin")
If FBBusiness.LoggedIn() Then
MessageBox.Show("Congratulations!", "Login Succeeded")
Else
MessageBox.Show("Unable to log in", "Login Failed")
End If

Active Directory is supported with the FBOM if the system is setup to do so. If the FileBound system is
configured properly to use Active Directory then developers can utilize the LoginAD method to log users
in. Based on their user credentials and the FileBound configuration, the user will be brought in without
having to specify a username and password. The user who is logged in to FileBound is the user who is
logged into the computer running the code so keep this in mind.

Example – Active Directory Login


FBBusiness.LoginAD()
If FBBusiness.LoggedIn() Then
MessageBox.Show("Congratulations!", "Login Succeeded")
Else
MessageBox.Show("Unable to log in", "Login Failed")
End If

Logged In User Account


Once the user is logged in successfully, the Business object will have a property called LoggedInUser - a
User object that holds the information about the user who is currently logged in. This object provides user
information as well as access to collections of information corresponding to this user’s account such as
Workflow, Group rights, etc. 'Setup data connection and business object.

Dim FBData As New FileBound.Data.Web("http://localhost")


Dim FBBusiness As New FileBound.Business.Standard(FBData)
'Log in
FBBusiness.Login("admin", "admin")
If Not FBBusiness.LoggedIn() Then
MessageBox.Show("Unable to log in", "Login Failed")
Else
MessageBox.Show("User is " & FBBusiness.LoggedInUser.Name)
End If

7
FileBound 7 API Manual

FileBound Object Model Part 3:


Retrieving Projects Collection
Once the authentication has been completed, a logical next step for most user interfaces and back-end
systems would be to get a project list. It is not required that a project list is retrieved to manipulate other
data in the system but logically this is what would come next in most cases.
Like all collections in the FBOM, object collections are retrieved using the Collection.Fill() method.

Example – Simple Fill


FBBusiness.Projects.Fill()

In most cases the objects that fill the collection are filtered by some criteria. For instance, when filling a
Files collection, one would normally filter the resulting collection to only those that matched some search
criteria. For projects, it might be desirable to only return a Project by ID rather than return all projects.

All FBOM collections have Filter objects associated with them. In order to filter the Fill() method by
some criteria, simply set Filter properties accordingly. This is an efficient method of retrieval if only
specific items are required.

Example – Fill based on Filter


'Search for a Project with an ID of 2
With FBBusiness.Projects
.Filter.ProjectID = 2
.Fill()
End With

Some fairly advanced searching is available using the Filter/Fill() method. All Filters have a MultiIDs
array in them. This provides a way for developers to search for multiple, distinct items in one search by
their corresponding unique IDs. For example, it is quite often useful to search for all projects a user has
access to that are in a list.

Example – Multi-ID Filter


'Search for Projects with an ID of 1, 8 or 9
With FBBusiness.Projects
.Filter.MultiIDs.Add(1)
.Filter.MultiIDs.Add(8)
.Filter.MultiIDs.Add(9)
.Fill()
End With

8
FileBound 7 API Manual

Another important aspect of collections is being able to tell whether have already been filled. It might be
easy enough to look at the Count property but if it has a Count of 0 does that mean it was not filled or that
it was filled but had no matches? To address this all collections have a Filled property. If the collection
has been filled it will be set to True.

Example – ‘Filled’ Check


With FBBusiness.Projects
If Not .Filled Then
.Filter.MultiIDs.Add(8)
.Filter.MultiIDs.Add(9)
.Fill()
End If
End With

Filling large collections, such as searching for files in a very large project, can be slow to perform. The
FBOM can be instructed to fill only a portion of the search results into the collection. This is done by
setting the RangeBegin and RangeLength properties of the filters. The TotalCount property would then
show how many total files matched the criteria regardless of how many came back into the collection due
to the ranges.

Example – Range Searching


With FBBusiness.Projects
.Filter.RangeBegin = 10
.Filter.RangeLength = 5
.Fill()
MessageBox.Show("Total Found=" & .TotalCount & ", Returned = " & .Count)
End With

Sorting of collections can also be a slower operation on large collections. Databases are typically more
efficient at sorting so collections also have the ability to be sorted as they are being filled to speed up the
process.

Example – Fill Sorting


With FBBusiness.Projects
.Filter.Sort = "Name"
.Fill()
End With

Once a collection is filled it is nice to be able to utilize binding to display the results. Using custom
collections can be tricky at times so a read-only DataSet property has been added to all collections. When
called, a DataSet is returned containing all the data in the collection.

Example – DataSet Binding


FBBusiness.Projects.Fill()
ListBox1.DataSource = _
FBBusiness.Projects.Dataset.Tables(0)

One notable difference to the Files collection is its ability to be extracted into a DataSet as raw data or as
masked data. Fields 1 thru 20 can be altered by the use of field masks so to get the masked values of the
data first set the Files.MaskedDataSet property to True. Then when the DataSet is used it will be
populated with the masked version of the field data.

9
FileBound 7 API Manual

FileBound Object Model Part 4: Files


Searching for Files
Searching for Files is one of the most common operations, and like most data retrieval via the FBOM, it is
performed by filling a Files collection with File objects. As shown in previous sections, retrieving a
collection of items is done by performing a Fill() method on the specified collection. As always, utilizing
the Filter object of the Files collection is preferred to keep the data transmission requirements to a
minimum.

Searching for Files Examples


The following example shows how to connect to a FileBound Web server, select a project and search for
specific files in that project where “Invoice” (Field 1) is set to “1213”

'Log in
FBBusiness.Login("admin", "admin")
If Not FBBusiness.LoggedIn() Then
MessageBox.Show("Unable to log in", "Login Failed")
Else
'Find project
Dim FBProject As FileBound.Project
FBBusiness.Projects.Filter.ProjectID = 2
FBBusiness.Projects.Fill()
'This assumes one project was returned
FBProject = FBBusiness.Projects(0)

'Find files
FBProject.Files.Filter.Field(1) = "1213"
FBProject.Files.Fill()
End If

Searching for Files – Dynamic Field Number


The following example extends the previous example by dynamically finding the field number where the
“Invoice” is stored. The previous example assumed Field 1.

'Log in
FBBusiness.Login("admin", "admin")
If Not FBBusiness.LoggedIn() Then
MessageBox.Show("Unable to log in", "Login Failed")
Else
'Find project
Dim FBProject As FileBound.Project
FBBusiness.Projects.Filter.ProjectID = 2
FBBusiness.Projects.Fill()
'This assumes one project was returned
FBProject = FBBusiness.Projects(0)

10
FileBound 7 API Manual

'Find Invoice Number field in the Fields collection


Dim FieldNum As Integer = 1
FBProject.Fields.Fill()
Try
'Use the Collection.Find() method to
'find the field with the proper name
Dim Fld As FileBound.Field = _
FBProject.Fields.FindField("Invoice")
'Set the field number variable to
'the found field's .Number property
FieldNum = Fld.Number

Catch ex As Exception
'Failed - assume FieldNum = 1
End Try

'Find files
FBProject.Files.Filter.Field(FieldNum) = "1213"
FBProject.Files.Fill()
End If

Searching for Files – Dynamic Field Number – Shortcut version


The following example demonstrates how to search in the Files collection by field name rather than field
number. This is a very handy shortcut for developers to use.

'Log in
FBBusiness.Login("admin", "admin")
If Not FBBusiness.LoggedIn() Then
MessageBox.Show("Unable to log in", "Login Failed")
Else
'Find project
Dim FBProject As FileBound.Project
FBBusiness.Projects.Filter.ProjectID = 2
FBBusiness.Projects.Fill()
FBProject = FBBusiness.Projects(0)

'Find files
FBProject.Files.Filter.Field("Invoice") = "1213"
FBProject.Files.Fill()
End If

One important note about using the field name is that it might trigger one more data fill call to gather the
fields to figure out which field has the given name. For efficiency sake it would be a good idea to avoid
using the Field name if at all possible.

11
FileBound 7 API Manual

Creating New Files


Creating new files is very straight forward with the FBOM. Simply create a file object, set its properties,
attach it to a collection and call the .Save() method.

'Log in
FBBusiness.Login("admin", "admin")
If Not FBBusiness.LoggedIn() Then
MessageBox.Show("Unable to log in", "Login Failed")
Else
'Find project
Dim FBProject As FileBound.Project
FBBusiness.Projects.Filter.ProjectID = 2
FBBusiness.Projects.Fill()
FBProject = FBBusiness.Projects(0)

'Create a new file object and set its properties


Dim FBFile As New FileBound.File
FBFile.Field(1) = "1234" 'Invoice Number
FBFile.Field(2) = "Smith, John" 'Name
FBFile.Field(3) = "1000 Main St" 'streed Address
FBFile.Field(4) = "Anywhere" 'City
FBFile.Field(5) = "NE" 'State
FBFile.Field(6) = "00000" 'Zip

'Add to the Project.Files collection


FBProject.Files.Add(FBFile)

'Save to data source


FBFile.Save()
End If

NOTE: Although the Add methods on the collections accept items of type Object you still must place the
proper objects in the collection. Any attempt at adding an object of the incorrect type to a collection will
result in an exception.

12
FileBound 7 API Manual

FileBound Object Model Part 5:


Documents
Retrieving Documents
Once a file has been found, documents attached to that file can be easily retrieved. The Documents
collection would be used to retrieve the document list using the Fill() method. One distinction that
Documents have over most other items is the binary data that makes up the document itself. For
efficiency, when filling a Document collection it is only filling the metadata associated with the document
– not the binary data itself. One more call is required per document to retrieve its binary data –
PopulateDocument().

'Setup data connection and business object


Dim FBData As New FileBound.Data.Web("http://localhost")
Dim FBBusiness As New FileBound.Business.Standard(FBData)

'Log in
FBBusiness.Login("admin", "admin")
If Not FBBusiness.LoggedIn() Then
MessageBox.Show("Unable to log in", "Login Failed")
Else
'Find project
Dim FBProject As FileBound.Project
FBBusiness.Projects.Filter.ProjectID = 2
FBBusiness.Projects.Fill()
FBProject = FBBusiness.Projects(0)

'Find files
FBProject.Files.Filter.Field("Invoice") = "1213"
FBProject.Files.Fill()

'Set a file object


Dim FBFile As FileBound.File = FBProject.Files(0)

'Find documents
FBFile.Documents.Fill()

'Retrieve the binary data of the first document


FBFile.Documents(0).PopulateDocument()

'Save document to disk


FBFile.Documents(0).SaveToDisk("c:\Invoice-Out.tif")

End If

Creating New Documents


Creating new documents is another common task. Like in the file example, the basic concept is to create
a document object, set the properties, attach it to the proper collection and then save it. The only real

13
FileBound 7 API Manual

difference is that in order to attach an actual document (TIF file, Word document, etc) the BinaryData
property must be set. This can be done by either the LoadFromDisk() method (to load from a disk file),
SetBITMAP() method (to load an existing bitmap) or by setting the BinaryData property manually with a
byte array. The Save() method saves both the document properties as well as the binary data.

This example extends the File Save example by adding in document uploading.

'Setup data connection and business object


Dim FBData As New FileBound.Data.Web("http://localhost")
Dim FBBusiness As New FileBound.Business.Standard(FBData)

'Log in
FBBusiness.Login("admin", "admin")
If Not FBBusiness.LoggedIn() Then
MessageBox.Show("Unable to log in", "Login Failed")
Else
'Find project
Dim FBProject As FileBound.Project
FBBusiness.Projects.Filter.ProjectID = 2
FBBusiness.Projects.Fill()
FBProject = FBBusiness.Projects(0)

'Create a new file object and set its properties


Dim FBFile As New FileBound.File
FBFile.Field(1) = "1234" 'Invoice Number
FBFile.Field(2) = "Smith, John" 'Name
FBFile.Field(3) = "1000 Main St" 'streed Address
FBFile.Field(4) = "Anywhere" 'City
FBFile.Field(5) = "NE" 'State
FBFile.Field(6) = "00000" 'Zip

'Add to the Project.Files collection


FBProject.Files.Add(FBFile)

'Save to data source


FBFile.Save()

'Create a new document object


Dim FBDoc As New FileBound.Document
FBDoc.Divider = "Invoice"

'Load binary data from disk


FBDoc.LoadFromDisk("c:\invoice.tif")

'Add new Document to File's "Documents" collection


FBFile.Documents.Add(FBDoc)

'Save to data source


FBDoc.Save()

End If

14
FileBound 7 API Manual

FileBound Object Model Part 6:


Workflow
Workflow is defined as the routing of documents to a user (ad-hoc) or to a route (defined). In the Object
Model, initiation of workflow is handled through the Business object and the manipulation of existing
workflow is handled using the RoutedItems collection.

Initiate Workflow - Ad-Hoc


Sending a document from one user to another (ad-hoc routing) is done by using the Document’s
RouteToUser() method.

'Find project
Dim FBProject As FileBound.Project
FBBusiness.Projects.Filter.ProjectID = 2
FBBusiness.Projects.Fill()
FBProject = FBBusiness.Projects(0)

'Find files
FBProject.Files.Filter.Field(1) = "1213"
FBProject.Files.Fill()

'Set a file object


Dim FBFile As FileBound.File = FBProject.Files(0)

'Find documents
FBFile.Documents.Fill()

'Set a document object


Dim FBDoc As FileBound.Document = FBFile.Documents(0)

'Route to a single user (ad-hoc)


FBDoc.RouteToUser(FBBusiness.LoggedInUser, False, _
CDate("1/1/1990"))

15
FileBound 7 API Manual

Initiate Workflow - Defined


Sending a document down a pre-defined workflow route is done by using the Document’s Route()
method.

'Setup data connection and business object


Dim FBData As New FileBound.Data.Web("http://localhost")
Dim FBBusiness As New FileBound.Business.Standard(FBData)

'Find project
Dim FBProject As FileBound.Project
FBBusiness.Projects.Filter.ProjectID = 2
FBBusiness.Projects.Fill()
FBProject = FBBusiness.Projects(0)

'Find files
FBProject.Files.Filter.Field(1) = "1213"
FBProject.Files.Fill()

'Set a file object


Dim FBFile As FileBound.File = FBProject.Files(0)

'Find documents
FBFile.Documents.Fill()

'Set a document object


Dim FBDoc As FileBound.Document = FBFile.Documents(0)

'Route to a defined route with an ID of 1


'Could also use the Route object
FBDoc.Route(1)

16
FileBound 7 API Manual

Manipulating Workflow
Once a document has been routed, it is then possible to manage that document’s progress. When the
document is at a given step it is assigned to one or more users. Referencing the user object’s RoutedItems
collection will show the documents which are currently assigned to that user. Performing Complete() or
Reject() methods on the RoutedItems will move the given items forward or backward in the route in
which the item has been placed while also following the rules that have been configured in the route.

'Find project
Dim FBProject As FileBound.Project
FBBusiness.Projects.Filter.ProjectID = 2
FBBusiness.Projects.Fill()

'If any projects are found...


If FBBusiness.Projects.Count > 0 Then

FBProject = FBBusiness.Projects(0)
With FBBusiness.LoggedInUser

'Find items currently assigned to logged-in user


.RoutedItems.Filter.ProjectID = FBProject.ProjectID
.RoutedItems.Fill()

'If any routed items are found


If .RoutedItems.Count > 0 Then

'Complete first item to the next step


.RoutedItems(0).Complete("comment here")

'Reject second item to previous step


.RoutedItems(1).Reject("Place comment here")

End If

End With
End If

NOTE: Using the ‘ToStep’ parameter of the Complete method will bypass the workflow logic and send the
RoutedItem to that specific step.

17
FileBound 7 API Manual

FileBound Object Model Part 7:


Project Maintenance
Adding Projects
The Projects collection is a child collection of the Business object. To add a Project to FileBound simply
make a Project object, set its properties, add it to the collection and save it.

'Setup data connection and business object


Dim FBData As New FileBound.Data.Web("http://localhost")
Dim FBBusiness As New FileBound.Business.Standard(FBData)

'Log in
FBBusiness.Login("admin", "admin")
If Not FBBusiness.LoggedIn() Then
MessageBox.Show("Unable to log in", "Login Failed")
Else
'Create Project
Dim FBProject As New FileBound.Project("Project ")
FBProject.EnableFullText = True
'etc - add other property settings here
FBBusiness.Projects.Add(FBProject)
FBProject.Save()
End If

Editing Projects
Editing a project is handled the same as editing any object. Reference the Project in question, set
properties and call its Save() method.

'Setup data connection and business object


Dim FBData As New FileBound.Data.Web("http://localhost")
Dim FBBusiness As New FileBound.Business.Standard(FBData)

'Log in
FBBusiness.Login("admin", "admin")
If Not FBBusiness.LoggedIn() Then
MessageBox.Show("Unable to log in", "Login Failed")
Else
'Find Project
FBBusiness.Projects.Filter.ProjectID = 2
FBBusiness.Projects.Fill()
If FBBusiness.Projects.Count > 0 Then
'If there is a project, turn off "Full Text"
FBBusiness.Projects(0).EnableFullText = False
FBBusiness.Projects(0).Save()
End If
End If

18
FileBound 7 API Manual

Deleting Projects
Deleting a project is handled similar to deleting any object. Reference the Project in question and call its
Delete() method. CAUTION: This action will permanently delete the Project and all dependent
information.

'Setup data connection and business object


Dim FBData As New FileBound.Data.Web("http://localhost")
Dim FBBusiness As New FileBound.Business.Standard(FBData)

'Log in
FBBusiness.Login("admin", "admin")
If Not FBBusiness.LoggedIn() Then
MessageBox.Show("Unable to log in", "Login Failed")
Else
'Find Project
FBBusiness.Projects.Filter.ProjectID = 2
FBBusiness.Projects.Fill()
If FBBusiness.Projects.Count > 0 Then
'If there is a project then delete it
FBBusiness.Projects(0).Delete()
End If
End If

Separators and Dividers


Separators and Dividers are defined within a project. Manage the Separators and Dividers collections of
the project to define the available items for the users.

'Setup data connection and business object


Dim FBData As New FileBound.Data.Web("http://localhost")
Dim FBBusiness As New FileBound.Business.Standard(FBData)

'Log in
FBBusiness.Login("admin", "admin")
If Not FBBusiness.LoggedIn() Then
MessageBox.Show("Unable to log in", "Login Failed")
Else
'Find project
Dim FBProject As FileBound.Project
FBBusiness.Projects.Filter.ProjectID = 2
FBBusiness.Projects.Fill()
FBProject = FBBusiness.Projects(0)

'Add a new Separator


Dim Sep As New FileBound.Separator("Separator Name")
FBProject.Separators.Add(Sep)
Sep.Save()

'Add a new Divider


Dim Div As New FileBound.Divider("Divider Name")
FBProject.Dividers.Add(Div)
Div.Save()
End If

19
FileBound 7 API Manual

FileBound Object Model Part 8:


Groups/Users
Adding Groups
The Groups collection is a child collection of the Business object. To add a Group to FileBound, simply
make a Group object, set its properties, add it to the collection and save it.

'Setup data connection and business object


Dim FBData As New FileBound.Data.Web("http://localhost")
Dim FBBusiness As New FileBound.Business.Standard(FBData)

'Log in
FBBusiness.Login("admin", "admin")
If Not FBBusiness.LoggedIn() Then
MessageBox.Show("Unable to log in", "Login Failed")
Else
'Create Group
Dim FBGroup As New FileBound.Group("New Group Name")
FBGroup.FileSearch = True
FBBusiness.Groups.Add(FBGroup)
FBGroup.Save()

End If

Adding Users
Like other objects and collections, adding users is really a matter of adding new objects and saving them.
The following example adds a new user “John Doe” to the system.

'Setup data connection and business object


Dim FBData As New FileBound.Data.Web("http://localhost")
Dim FBBusiness As New FileBound.Business.Standard(FBData)

'Log in
FBBusiness.Login("admin", "admin")
If Not FBBusiness.LoggedIn() Then
MessageBox.Show("Unable to log in", "Login Failed")
Else

'Add a user
Dim FBuser As New FileBound.User("jdoe")
FBuser.DisplayName = "John Doe"
FBBusiness.Users.Add(FBuser)

'Save to data source


FBuser.Save()

End If

20
FileBound 7 API Manual

Setting Existing Users’ Passwords


You may have noticed by now that the Password property cannot be changed from the User object itself.
However, there is a Business-level method for accomplishing this. This method is only available to
Administrators and for users to change their own passwords.

'Changing password via User ID


FBBusiness.SetPassword(21, "newpass")

'Changing password via User Object


FBBusiness.SetPassword(UserObj, "newpass")

Adding a User and Setting Group Rights


This example extends the previous example by also adding the user to a specific group. One important
note is the Sync() method that is used on the User.Groups collection. When managing the relationship
between objects and not the object itself the Sync() method must be called on the collection rather than
the Save() method on the object.

'Setup data connection and business object


Dim FBData As New FileBound.Data.Web("http://localhost")
Dim FBBusiness As New FileBound.Business.Standard(FBData)

'Log in
FBBusiness.Login("admin", "admin")
If Not FBBusiness.LoggedIn() Then
MessageBox.Show("Unable to log in", "Login Failed")
Else

'Add a user
Dim FBuser As New FileBound.User("jdoe")
FBuser.DisplayName = "John Doe"
FBBusiness.Users.Add(FBuser)

'Save to data source


FBuser.Save()

'Set the User’s Password


FBBusiness.SetPassword(FBuser, "newpass")

'Place user in correct group(s)


FBBusiness.Groups.Fill()
Try
'Find the group in which to place the user
Dim FBGroup As FileBound.Group = _
FBBusiness.Groups.FindGroup("ThisGroup")
'Add group to the users' Groups collection
FBuser.Groups.Add(FBGroup)
'Sync the group
FBuser.Groups.Sync()

Catch
'Did not find the group

21
FileBound 7 API Manual

End Try

End If

Providing Group Rights for a Project


This example shows how to assign Project access to a given Group. Like the above example, the Sync()
method is instrumental in managing the relationship between the Projects and Groups.

'Setup data connection and business object


Dim FBData As New FileBound.Data.Web("http://localhost")
Dim FBBusiness As New FileBound.Business.Standard(FBData)

'Log in
FBBusiness.Login("admin", "admin")
If Not FBBusiness.LoggedIn() Then
MessageBox.Show("Unable to log in", "Login Failed")
Else
'Get project collection
FBBusiness.Projects.Fill()

'Find Project
Dim FBProject As FileBound.Project = _
FBBusiness.Projects.FindProject("ABC")

'Get Groups
FBBusiness.Groups.Fill()

'Find Group
Dim FBGroup As FileBound.Group = _
FBBusiness.Groups.FindGroup("GRPNAME")

'Give the group access to the selected project


FBGroup.Projects.Add(FBProject)
FBGroup.Projects.Sync()
End If

22
FileBound 7 API Manual

Revoking Group Rights from a Project


This example shows how to revoke access to a Project from a given Group.

'Setup data connection and business object


Dim FBData As New FileBound.Data.Web("http://localhost")
Dim FBBusiness As New FileBound.Business.Standard(FBData)

'Log in
FBBusiness.Login("admin", "admin")
If Not FBBusiness.LoggedIn() Then
MessageBox.Show("Unable to log in", "Login Failed")
Else
'Get Groups
FBBusiness.Groups.Fill()

'Find Group
Dim FBGroup As FileBound.Group = _
FBBusiness.Groups.FindGroup("ThisGroup")

'Get list of projects this group has rights to


FBGroup.Projects.Fill()
'Revoke the group's access to the project
FBGroup.Projects(0).RemoveGroup(FBGroup)
'Sync changes
FBGroup.Projects.Sync()
End If

23
FileBound 7 API Manual

FileBound Object Model Part 9:


Collection/Objects
Wiring Collections and Objects
FileBound Collections and Objects are the heart a soul of the FBOM. Their relationships to one another
define the storage and retrieval of all information contained in FileBound. In order for the collections and
objects to be able to interact with the data source (SQL, Web or Archive) there needs to be some inner
logic that ties the collection chain together and links it to the data source. For instance, why must an
object be placed into a collection before it can be saved? The answer is simple as well as complex.

In order for an object to be saved it must be placed into context. An object created in memory is not
attached to anything of value data-wise. Once that object is placed into a collection it is then associated
with that collection which in turn must be associated with another object/collection and so on up to the
top level objects that are attached to the Business object which is attached to the Data object. By the way
the items are instantiated and connected a bridge is built from every object to the data source. This is
called “wiring” up the object or collection.

Wiring consists of using event delegates in the objects to cause an object’s Save, Delete, etc methods to
be sent up the chain of objects until the Business object can operate on it and send it to the Data source.
The very act of placing an object into a collection causes an internal wiring event to happen so it is all
transparent when done that way. However, it is possible to save a document without placing it into a
File’s Documents collection. The Business object has a WireObject method that can wire the object into
the event chain directly and the object can then be saved or deleted.

The practical use of this is sometimes hard to see but if a solution is being developed where the ID of the
File that a document belongs to is already known then having to get a project object, fill the files
collection with one file and then add a document to its Documents collection can all be avoided.

Here is an example of the above scenario done 2 ways. First is the standard ‘collection’ way:

'Setup data connection and business object


Dim FBData As New FileBound.Data.Web("http://localhost")
Dim FBBusiness As New FileBound.Business.Standard(FBData)

'Log in (assuming things work fine)


FBBusiness.Login("admin", "admin")

'Retrieve project
FBBusiness.Projects.Filter.ProjectID = 2
FBBusiness.Projects.Fill()
Dim FBP As FileBound.Project = FBBusiness.Projects(0)

'Retrieve file with ID = 120


FBP.Files.Filter.FileID = 120
FBP.Files.Fill()
Dim FBF As FileBound.File = FBP.Files(0)

24
FileBound 7 API Manual

Dim D As New FileBound.Document


D.LoadFromDisk("c:\test.tif")
FBF.Documents.Add(D)
D.Save()

Now here is the same example done the direct wiring way:

'Setup data connection and business object


Dim FBData As New FileBound.Data.Web("http://localhost")
Dim FBBusiness As New FileBound.Business.Standard(FBData)

'Log in (assuming things work fine)


FBBusiness.Login("admin", "admin")

Dim D As New FileBound.Document


D.LoadFromDisk("c:\test.tif")
D.FileID = 120
FBBusiness.WireObject(D)
D.Save()

The direct wiring example is much simpler and is also much more efficient as it avoids 2 extra collection
fills (Projects and Files). However, the IDs of the items in question must already be known to use this
method with any level of success.

25
FileBound 7 API Manual

Directly Accessing Collections and Objects


A concept that very closely follows the wiring concept is something called Direct Object Access. Direct
Object Access allows developers to retrieve objects directly from the Business object without having to
navigate collections. When an object or collection is retrieved in this way it is wired directly to the
Business object automatically. Directly accessing Collections and Objects is done by calling the Business
object’s GetCollection and GetObjectItem methods respectively.

In the example in the previous section a Document was saved into a known File. To retrieve that
document in the standard way all collections from Projects down to Documents would need to be filled.
However, if the ID for the Document was retained, that document could be retrieved directly. Here is the
code to do this (assuming an ID of 500 for the Document):

'Setup data connection and business object


Dim FBData As New FileBound.Data.Web("http://localhost")
Dim FBBusiness As New FileBound.Business.Standard(FBData)

'Log in (assuming things work fine)


FBBusiness.Login("admin", "admin")

Dim D As FileBound.Document
D = FBBusiness.GetObjectItem
(FBEnumerations.ObjectType.Document, 500)
Collections operate slightly differently in that the collection’s filter properties must be set then send it in
to be filled by the Business object. The following example shows how to get the Document collection
from a File with an ID of 120:

'Setup data connection and business object


Dim FBData As New FileBound.Data.Web("http://localhost")
Dim FBBusiness As New FileBound.Business.Standard(FBData)

'Log in (assuming things work fine)


FBBusiness.Login("admin", "admin")

Dim Docs As New FileBound.DocumentCollection


Docs.Filter.FileID = 120
FBBusiness.GetCollection(Docs)

26
FileBound 7 API Manual

FileBound Object Model Part 10:


Collections/Objects
Serializing Collections and Objects
Serialization is a very useful tool that is readily available in .NET. In short, Serialization is concerned
with converting objects and collections into a formatted data stream that can be read from and written to
streams such as files, databases, memory, etc. It is a perfect way to save temporary data out and transport
it for use elsewhere.

The FBOM supports serialization and de-serialization of its objects and collections inherently. All
collections and objects have a Serialize method that can either write the contents to a file or return a byte
array of the serialized data. To de-serialize the data back into an object or a collection, use the Business
object’s Deserialize method. The following example demonstrates this.

'Setup data connection and business object


Dim FBData As New FileBound.Data.Web("http://localhost")
Dim FBBusiness As New FileBound.Business.Standard(FBData)

'Log in (assuming things work fine)


FBBusiness.Login("admin", "admin")

With FBBusiness.Projects
'Get project list
.Fill()
'Save to temp file
.Serialize("c:\test.xml")
'Clear out project list in memory
.Clear()
'Bring back the serialized collection
FBBusiness.Projects = _
FBFunctions.Deserialize("c:\test.xml", .GetType)
'Prove the collection was restored
Debug.Print(.Count)
End With

Serialization is a very important part of the FBOM and is what allows the FileBound data to be
transported easily across the Internet and through multiple tiers.

27
FileBound 7 API Manual

Cloning Objects
Most FBOM objects support a Clone() method. This allows developers to make exact copies of objects in
memory. This is important since just making a new object variable and assigning it to an existing object
merely makes a new reference to the same object in memory. Cloning the object actually make a new
object in memory – not just a pointer. This is useful if the need is to actually duplicate a document in a
file for example. Without cloning the developer would need to manually create a new document to do it
properly.

Here is an example of cloning a Document:

Dim D As New FileBound.Document


'Get the document however possible
D = FBBusiness.GetObjectItem(FBEnumerations.ObjectType.Document, 500)
Dim D2 As Document = D.Clone
'After the new document is created it will
'need to be wired to do anything

Tag Properties
All Collections and Objects in the FBOM have a Tag property. This is of type Object and can be used for
temporary storage of any type of information a developer chooses. It is meant to allow other data to flow
along with the objects during normal processing. The data in the Tag property is never directly saved by
FileBound so it cannot be used as long term storage unless the developer also makes considerations for
that as well.

On important note about the Tag property is that any data stored in it MUST be serializable if it is
intended to be sent through a Data connector since the Data connectors serialize the objects to work with
them. Placing non-serializable objects in the Tag property will cause data operations to fail.

Parent Properties
All Collections and Objects in the FBOM have a Parent property. This property allows the developer to
manually navigate to the next higher level in the object and collection chains. Since some collections can
be contained inside of more than one object type (for instance, Documents are in both the File.Documents
collection and the Archive.Documents collection) the Parent property is handy to determine in what
object the object or collection is contained. The following example demonstrates this:

If TypeOf Documents.Parent Is FileBound.File Then


'Documents collection was contained in a File
ElseIf TypeOf Documents.Parent Is FileBound.Archive Then
'Documents collection was contained in an Archive
End If

28
FileBound 7 API Manual

FileBound Object Model Part 11:


Collection/Objects
Syncing a Collection vs. Saving the Object
We made reference earlier in this document to the Sync method on collections. This is by far the most
confusing concept in the FBOM but it is not as bad as it seems. Just remember that the Sync method is
only required for collections that have a many-to-many relationship with the data contained within. This
would include Groups to Users, Projects to Groups, etc. For normal collections the Sync method is not
required. A Document object can only be contained in a single File so when the Document is placed in
that File’s Documents collection the Document only needs to be saved to make this change permanent.
Users, however, can be in multiple groups so adding a User to a Group’s Users collection and calling
Save will not suffice.

To add the User to the Group the developer would add the User object to the Group’s Users collection
and then call the Group.Users.Sync method. This Sync process updates the many-to-many relationship
pointers without actually altering the objects themselves.

Calling Sync on a standard collection (one with a one-to-many relationship) will trigger the collection to
iterate through its items and call each item’s Save method directly so this can be used as a shortcut to
mass update saves.

Another component of Syncing is the concept of the Object.SyncFlag property. The SyncFlag property is
set automatically on each object as it is added to or removed from a collection. In the example of the
Group.Users collection above each time a User is added to the Users collection its SyncFlag is set to
Added. The Sync method then simply iterates through the objects and any object where the SyncFlag is
not set to NoChange requires a status update in the database. An example might help clarify some of the
finer points.

It would be quite easy to add a new user and place them in the group as follows:

'Add user
Dim User As New FileBound.User
User.Name = "Test User"
FBBusiness.Users.Add(User)
User.Save()

'Find Test groups (Group IDs = 100 and 101)


Dim Group1 As FileBound.Group
Group1 = FBBusiness.GetObjectItem(FBEnumerations.ObjectType.Group, 100)
Dim Group2 As FileBound.Group
Group2 = FBBusiness.GetObjectItem(FBEnumerations.ObjectType.Group, 101)

'Add user to the group


User.Groups.Add(Group1)
User.Groups.Add(Group2)
User.Groups.Sync()

29
FileBound 7 API Manual

The example above works fine and the user is now in 2 groups. However, to remove this user from one
of these groups is much trickier. Consider the following example:

'Get this user's gruops


User.Groups.Fill()
'Remove the user from the first group in the list
User.Groups.Remove(0)
'Now what??

If the item is simply removed from the collection then how does the data source know to remove the item
that is no longer there? When the data source receives the collection only one item will be visible. The
first thought is to have the collection be all-inclusive so that when Sync is called then only that which is
left in the collection is then reflected in the database and any missing items will be removed. This,
however, becomes very inefficient since the FBOM would need to serialize and send over the wire every
object in every collection just to remove from or add to the collection a single item.

To overcome this shortcoming and keep efficiency at the forefront, the Sync method looks at the
SyncFlag properties of the objects. This way the FBOM can operate only on those items that need
attention. To remove an item from this type of collection simply set that item’s SyncFlag property to
Delete then call the Sync() method. The example above should be done like this:

'Get this user's groups


User.Groups.Fill()
'Set first group in list to be removed from this user
User.Groups(0).SyncFlag = FBEnumerations.ObjectSyncFlag.Delete
'Sync the changes to the data source
User.Groups.Sync()

30
FileBound 7 API Manual

FileBound Object Model Part 12:


Reports
Running Reports
Reports in FileBound are accessible now through the API. The return from a RunReport call is a DataSet.
This means it is bindable data for display in data grids, list boxes or any control that can data bind.

There are 2 object types to learn about when dealing with reports –Reports and ReportParms. The Report
object represents the report entity itself. Retrieving a list of reports from the Business object will show
what reports are available to the logged in user. The report object can then have its ReportParms
collection filled to see what parameters of what type are available for querying this report. Here is an
example of querying, finding and running a report:

'Retrieve the Reports list


FBBusiness.Reports.Fill()

'Find the User Login report


Dim R As Report = FBBusiness.Reports.FindReport("User Login Report")

If R IsNot Nothing Then

'Retrieve the report parameters


R.ReportParms.Fill()

'Look for logins for User ID 1 from 6/1/07 on


Dim RP As ReportParm

'Find and set the UserID parameter


RP = R.ReportParms.Item("UserID")
If RP IsNot Nothing Then
RP.Value = 1
End If

'Find and set the StartDate parameter


RP = R.ReportParms.Item("StartDate")
If RP IsNot Nothing Then
RP.Value = CDate("6/1/07")
End If

'Run the report


R.Run()

'Bind the DataSet to the Grid


DataGridView1.DataSource = R.DataSet.Tables(0)

End If

31
FileBound 7 API Manual

The ReportParms collection is perfect for dynamically creating a report search form. Here is a small
excerpt of code for adding fields to a FlowLayoutPanel.
** Notice setting the Tag property of the MaskedTextBox to the name of the ReportParam so that name and the box’s value can be
used in the Report run sequence later.

R = CType(listbox1.SelectedItem, FileBound.Report)
R.ReportParms.Fill()

For Each RP As FileBound.ReportParm In R.ReportParms


Dim L As New Windows.Forms.Label
L.Height = 12
L.Text = RP.Description
L.Visible = True
L.Parent = FlowLayoutPanel1

Dim M As New MaskedTextBox


M.Text = RP.Value
M.Visible = True
M.Parent = FlowLayoutPanel1
M.Tag = RP.Name

Next

Managing Reports
Not only can reports be run programmatically, they can also be added and removed programmatically as
well. Of course the SQL logic will need to be created for the report based on its particular needs. Once
that is done the rest is easy.

' -- Adding in report called 'Custom Report' --


'Find report by name and if not there then add it
FBBusiness.Reports.Fill()
Dim FBR As FileBound.Report = _
FBBusiness.Reports.FindReport("Custom Report")
If FBR Is Nothing Then

'Add report - needs to have the name of the SP as the 2nd parameter!
FBR = New FileBound.Report("Custom Report", _
"FBReport_Custom", _
CommandType.StoredProcedure, _
FBEnumerations.ReportLevel.LevelGlobal)
FBBusiness.Reports.Add(FBR)
FBR.Save()

Dim FBRP As FileBound.ReportParm = Nothing

'Add report search parameters


FBRP = New FileBound.ReportParm("UserName", _
"User Name", _
FBEnumerations.ReportParmType.Text, 50, "")
FBR.ReportParms.Add(FBRP)

32
FileBound 7 API Manual

FBRP.Save()

FBRP = New FileBound.ReportParm("StartDate", _


"Start Date", _
FBEnumerations.ReportParmType.DateField, 0, "")
FBR.ReportParms.Add(FBRP)
FBRP.Save()

FBRP = New FileBound.ReportParm("EndDate", _


"End Date", _
FBEnumerations.ReportParmType.DateField, 0, "")
FBR.ReportParms.Add(FBRP)
FBRP.Save()

End If

Deleting a report is handled in the same way as deleting any object in the FileBound Object Model. Call
that object’s Delete() method.

'' -- Deleting in report called 'Custom Report' --


'find report by name and if there then delete it
FBBusiness.Reports.Fill()
Dim FBR As FileBound.Report = _
FBBusiness.Reports.FindReport("Custom Report")
If FBR IsNot Nothing Then
'First delete the parameters
FBR.ReportParms.Fill()
For Each FBRP As FileBound.ReportParm In FBR.ReportParms
FBRP.Delete()
Next
'Then delete the report
FBR.Delete()
End If

33
FileBound 7 API Manual

FileBound Object Model Part 13:


E-Forms/Email
E-Forms
E-Forms are an optional module that can be purchased to manage electronic forms within FileBound.
The generation of these E-Forms normally happens in the viewer by the request of the end user. With the
advent of the FBOM, however, programmers can now add the merging capability into their own
applications.

'Setup data connection and business object


Dim FBData As New FileBound.Data.Web("http://localhost")
Dim FBB As New FileBound.Business.Standard(FBData)

'Log in
FBB.Login("admin", "admin")
If Not FBB.LoggedIn() Then
MessageBox.Show("Unable to log in", "Login Failed")
Return
End If

'Get project reference


FBB.Projects.Fill()
Dim FBP As FileBound.Project = FBBusiness.Projects(0)

'Find a file in which to place the merged E-Form


Dim F As FileBound.File
FBP.Files.Filter.FileID = 1 'Assume FileID of 1
FBP.Files.Fill()
F = FBP.Files(0)

'Find the E-Form


Dim Eform As FileBound.Eform
FBP.Eforms.Filter.EformID = 10 'Assume EFormID = 10
FBP.Eforms.Fill()
Eform = FBP.Eforms(0) 'Assume Eform was found

'Create new document reference since, once generated,


'E-Forms are documents
Dim D As New FileBound.Document

Try
'Attach document to file's Documents collection
F.Documents.Add(D)

'Set Document’s Extension


D.Extension = Eform.Extension

'Save document record – get DocumentID for merge


D.Save()

34
FileBound 7 API Manual

'Merge E-Form into a document


D = FBB.MergeEform(F, D, Eform)

'Save document back to server after merged


D.Save()

'EXTRA STEP if desired...


'Save to TEMP file then shell out
Dim TempFile As String = _
GetFolderPath(SpecialFolder.InternetCache) & _
"\Temp." & Eform.Extension
D.SaveToDisk(TempFile)
System.Diagnostics.Process.Start(TempFile)

Catch ex As Exception
MessageBox.Show(ex.Message)
End Try

35
FileBound 7 API Manual

Email
Email through the FBOM can be either client-side (MAPI) or server-side (SMTP). Which one to use
when is a matter of discretion but essentially any time the end user needs to see the email before it is sent
(to address it, add comments, etc) use MAPI, else use SMTP.

To use MAPI to email a document (assuming the document is m_Document below):

Dim _mail As New FileBound.Mail.MAPI


With _mail
m_Document.SaveToDisk(TempFileName, False)
If System.IO.File.Exists(TempFileName) Then
.Subject = "Document – " & _
m_Document.DocumentID.ToString & "." & _
m_Document.Extension
.Body = "Information" & vbCrLf & _
m_Document.DocumentID.ToString
.Attach(TempFileName)

.Send()
End If
End With

To use SMTP to mail the same document:

Dim _mail As New FileBound.Mail.SMTP


With _mail
m_Document.SaveToDisk(TempFileName, False)
If System.IO.File.Exists(TempFileName) Then
'The next 2 lines are SMTP-only
'IP of server – 127.0.0.1 is default
.ServerAddress = "127.0.0.1"
'Port 25 is the SMTP standard
.ServerPort = 25

.To([To])
.From = [From]
.Subject = m_Document.DocumentID.ToString & _
" - " & "Document." & m_Document.Extension
.Body = "Information" & vbCrLf & _
m_Document.DocumentID.ToString
.Attach(TempFileName)

.Send()
End If
End With

36
FileBound 7 API Manual

FileBound Object Model Part 14:


Annotations/Printing/TWAIN
Printing without a Viewer
The viewer objects make it very easy to print documents and for most scenarios this would be enough.
However, there are times when the overhead of a viewer may be a bit much or is not handy. There is
another way to print from within the Object Model by using the FileBound.UI.Viewers.UIFunctions.Print
method. The example below shows how to print a document. This example also carries the scenario
further by adding a temporary COPY watermark with the Annotation engine.

'Get document
Dim m_Document As FileBound.Document = _
FBBusiness.GetObjectItem(FBEnumerations.ObjectType.Document, 123)

'Fill the document’s annotations so they will print


m_Document.Annotations.Fill()

'Add COPY annotation as a watermark


Dim A As New FileBound.Annotation
A.Type = FBEnumerations.AnnoType.Text
A.Text = "COPY"
A.Opacity = 25
A.Position = New Rectangle(100, 100, 300, 100)
m_Document.Annotations.Add(A)

'Make temp doc collection and add doc to it


Dim FBDocs As New FileBound.DocumentCollection
FBDocs.Add(m_Document)

'Wire collection in case we need more info during call


FBBusiness.WireCollection(FBDocs)

'Call Print routine


Dim PrintJobName As String = "My Print Job"
Dim ShowDialog As Boolean = True
Dim ShowPrintStatus As Boolean = True
Dim PrintAnnotations As Boolean = True
If FileBound.UI.Viewers.UIFunctions.Print(FBDocs, _
PrintJobName, ShowDialog, ShowPrintStatus,_
PrintAnnotations) Then
'OK
Else
'Error
End If

37
FileBound 7 API Manual

Getting Image with Annotations


There are several instances where you may want to get an image object from the Document. This is fairly
easy by calling the Document’s GetBITMAP method. With the overloaded GetBITMAP method you
have the choice of returning just the BITMAP of the image itself or a BITMAP of the image with all the
annotation burned into it. The following example demonstrates this.

'Get document
Dim m_Document As Document =
FBBusiness.GetObjectItem(ObjectType.Document, 35421)

m_Document.PopulateDocument()

'Fill the document’s annotations so they will print


m_Document.Annotations.Fill()

'Write out a BMP file with annotations


m_Document.GetBITMAP(True).Save("c:\test.bmp")

38
FileBound 7 API Manual

TWAIN Scanning
As anyone in the imaging business knows, scanning is a major part of any document-oriented system.
The FBOM has its own TWAIN interface so it can actually be used to scan in TWAIN with no other 3rd
party controls or assemblies.

Private FBTwain As FileBound.Scanning.TWAIN

Private Sub Main()


FBTwain = New FileBound.Scanning.TWAIN()
FBTwain.Init(Me.Handle)
'Add event handler to make sure scanning gets handled
AddHandler FBTwain.PageScanned, AddressOf PageScanned
AddHandler FBTwain.ScanError, AddressOf ScanError

Try
FBTwain.ScanPages(1) 'Show dialog (1)
Catch ex As Exception
MessageBox.Show("Error scanning.", "Scanning", _
OK, Exclamation)
End Try
End Sub

Private Sub PageScanned(ByVal bmp As Bitmap)

'Put BMP into Document object


Dim FBDoc As New FileBound.Document
FBDoc.Extension = "TIF"
FBDoc.SetBITMAP(bmp)
FBDoc.Divider = "SCANNED PAGE"

'Add document to documents collection


FBFile.Documents.Add(FBDoc)

'Would most likely show page before saving but...


'Save document to server
FBDoc.Save()

End Sub

Private Sub ScanError(ByVal ErrorString As String)


MessageBox.Show(ErrorString)
End Sub

39
FileBound 7 API Manual

FileBound Object Model Part 15:


Archives/Annotations
Working with Archives
Archives are simply a collection of Documents that are grouped together. The Archive marker allows
administrators and developers to treat all contained Documents as a group by using the Archive object.
The main stages of Archive existence are as follows:

• Building – Building an Archive is the process of arranging Documents into the respective Archive
object’s Documents collection. Building Archives can be accomplished programmatically by making
an Archive object then adding Documents to its Documents collection and Syncing the collection.
• Managing – Managing an Archive is the process of taking the archive offline or removing it
completely from the system. Managing an Archive can be accomplished programmatically by
actually setting the Status of each of its Documents to Archived and saving (to take offline) or by
calling each Document’s Delete method (to Delete the archive).
• Creating – Creating an Archive is the process of arranging the contents of the Archive in a
searchable format. Creating the archive can be accomplished programmatically by calling the
Archive’s Create() method with a path to the folder in which to place the searchable content. There
are events named CreateStatus and CreateProgress to monitor the status text and the percent complete
of the creation process.
• Burning – Burning an Archive is the process of placing the Archive on CD or DVD media. Burning
requires CD or DVD authoring software or can be accomplished by using FileBound tools such as the
Integration Kit.

The following is an example of how to programmatically create and Archive using the Archive’s Create()
method.

Private Sub CreateArchive(ByVal Archive _


As FileBound.Archive)
Dim ArchiveFolder As String = "c:\ArchiveTest"

'Add event handlers


AddHandler Archive.CreateStatus, AddressOf ShowStatus
AddHandler Archive.CreateProgress, AddressOf ShowProgress

'Prepare directory for archive


If Not System.IO.Directory.Exists(ArchiveFolder) Then
System.IO.Directory.CreateDirectory(ArchiveFolder)
End If

'Create the archive


Archive.Create(ArchiveFolder)

'Remove event handlers


RemoveHandler Archive.CreateStatus, AddressOf ShowStatus
RemoveHandler Archive.CreateProgress, AddressOf Progress

End Sub

40
FileBound 7 API Manual

Private Sub ShowStatus(ByVal StatusText As String)


Debug.Print(StatusText)
End Sub

Private Sub Progress(ByVal Percent As Integer)


ProgressBar1.Value = Percent
End Sub

41
FileBound 7 API Manual

Annotations
Annotations are a very important and powerful component of FileBound. Starting with Version 5 the
Annotation system is data-driven and can be controlled by simply adding and manipulating objects just
like any other FBOM object.

Annotations are accessed normally through the Document object’s Annotations collection. Annotation
items can be added to and removed from the collection. For instance, adding a rectangle annotation to an
image requires only adding and saving an Annotation object of type “Rectangle” to the Annotations
collection and when the document is viewed in FileBound the annotation will show up.

'Get project
Dim Project As FileBound.Project = _
FBBusiness.Projects.FindProject(21)
Project.Files.Fill()

'Get file
Dim File As FileBound.File = _
Project.Files.FindFile(68942)
File.Documents.Fill()

'Get document
Dim Document As FileBound.Document = File.Documents(0)
Document.PopulateDocument()

'Add rectangle to image


Dim Annotation As New FileBound.Annotation
Annotation.Type = FBEnumerations.AnnoType.Rectangle
'Position RECT at upper-left and make it 100 x 100 pix
Annotation.Position = New Rectangle(0, 0, 100, 100)
'Make the rectangle Red
Annotation.Color = FBEnumerations.AnnoColor.Red

'Add to collection and save


Document.Annotations.Add(Annotation)
Annotation.Save()

It is important to note that not all Annotation types support all properties and methods of the Annotation
object. The following exceptions should be noted.

1) Only AnnotationType.Text supports the Font property.


2) Only AnnotationType.Text supports the Text property.
3) Only AnnotationType.Text supports the GetTextBITMAP and SetTextBITMAP methods.
4) Only AnnotationType.Freehand supports the GetGraphicsPath and SetGraphicsPath methods.
5) AnnotationType.Stamp does not support the Color, FillColor or LineWidth properties.
6) Only AnnotationType.Stamp supports the LoadStampFromDisk method.
7) AnnotationType.Redaction does not support the Opacity property.

42
FileBound 7 API Manual

Part 1 FileBound URL Integrations:


The Basics
Some pages in FileBound optionally take in a list of Query String parameters that determine how the page
will function.

Search.aspx
The search page will use values found in the Query String to pre-fill the search values and perform the
search.

Parameter Name Usage


Direct (or D) Must be set to true for the search page to automatically perform the search
Contents Will perform a full text search
FileNotes Will search for value in File Notes
DocNotes Will search for value in Document Notes
DateChangedFrom Sets the Date Changed From value
DateChangedTo Sets the Date Changed To value
Separator Sets the Separator value
Divider Sets the Divider value
Keys ( | ) delimited list sets the Multi-Key value
Field[#] Sets the Field search value for the Field number defined by [#]
ex) Field2=Some Value
Field[#]To Sets the Field To search value for the Field number defined by [#]
ex) Field2To=Some Value
FileID Set the filter to a specific FileID
DateCreatedFrom Sets the Date Created From value
DateCreatedTo Sets the Date Created To value
Archive Sets the Archive value
SavedSearch Will run a saved search. Set to the name of the saved search.

Entry.aspx
The Entry page will use values found in the Query String to pre-fill the index fields for the file.

Parameter Name Usage


Field[#] Prefills the field value for the Field number defined by[#] ex) Field2=Some Value

43
FileBound 7 API Manual

FileDetail.aspx
Parameter Name Usage
FileID The ID of the File to load.
ShowViewer “1” – Launches the viewer immediately after the load of the page.

Default.aspx
The FileBound login page will use values found in the Query String to set State properties, auto-log in the
user, and redirect to a return URL.

Parameter Name Usage


FBGuid The GUID generated by a successful business object login to the same site being
accessed. Stored at FBBusiness.LoggedInUser.FBGUID.same
Username FileBound will attempt to auto-log in this user
Password FileBound will attempt to auto-log in the user defined in Username using password.
Password must be passed in clear text, but is removed from the query string before
it is displayed. If possible FBGuid is the better way to auto-log in.
FileID Will set the current File id. Used if going directly to the viewer or any page that
requires a File.
ProjectID Will set the current Project id. Used if going directly to a page that requires a
Project.
DocumentID Will set the current Document id. Used if going directly to a document in the
Viewer.
ShowViewer Will automatically load the Viewer using the parameters passed in for FileID and/or
DocumentID.
ReturnURL Will set the address the page is redirected to after a successful login. Can be used
in conjunction with any of the other parameters.

Index.aspx
The Indexing Queue page or Indexing Web Viewer will use values found in the Query String to prefill
Documents.

Parameter Name Usage


DocumentIDs The ID of the Document (Optional).
ShowIndexingViewer If set to true, this will directly open indexing web viewer with
DocumentIDs parameter passed (Optional).
FBGUID The GUID generated by a successful business object login to the same
site being accessed. (Optional).

Examples
Directly load a File in the Viewer
http://mysite.filebound.com/Output/Viewer.ashx?ProjectID=25&FileID=1720&ShowViewer=1&FBG
UID=961f74e1-2a27-4add-9e12-496ff2edf5cc

44
FileBound 7 API Manual

Go directly to the File Detail page


http://mysite.filebound.com/FileDetail.aspx?ProjectID=25&FileID=1720&FBGUID=961f74e1-2a27-
4add-9e12-496ff2edf5cc

Directly perform a search on project with ID 25 where Field3 is between 60000 and 90000
http://mysite.filebound.com/Search.aspx?ProjectID=25&Direct=1&FBguid=961f74e1-2a27-4add-
9e12-496ff2edf5cc&Field3=60000&Field3To=90000

Pre-load Entry page on Project with ID 25, set Field1=Some Value, Field3=60000
http://mysite.filebound.com/Entry.aspx?ProjectID=25&Direct=1&FBguid=961f74e1-2a27-4add-9e12-
496ff2edf5cc&&Field1=Some%20Value&Field3=60000

Open indexing queue page with FBGUID=961f74e1-2a27-4add-9e12-496ff2edf5cc


http://localhost:3982/V6/Document/Index.aspx? FBGUID=961f74e1-2a27-4add-9e12-496ff2edf5cc

Open Indexing Web Viewer with DocumentID=1248, FBGUID=961f74e1-2a27-4add-9e12-496ff2edf5cc


http://localhost:3982/V6/Document/Index.aspx?DocumentIDs=1248&ShowIndexingViewer=true&FB
GUID=961f74e1-2a27-4add-9e12-496ff2edf5cc

45
FileBound 7 API Manual

Part 2 FileBound URL Integration:


Additional Query Strings
Search for Files (Search.aspx):
Search for a field value in a specific project:
http://localhost/FB7/search.aspx?ProjectID=2&Field1=205672&Direct=1

Range search for numeric or date field in a specific project:


http://localhost/FB7/search.aspx?ProjectID=2&Field1=1000&Field1To=2000&Direct=1

Search and Launch Viewer:


http://localhost/FB7/search.aspx?ProjectID=2&Field1=205672&Direct=1&ShowViewer=1

Search OCR Contents:


http://localhost/FB7/search.aspx?ProjectID=2&Contents=This%20is%20a%20test&Direct=1&ShowViewer=1

You can pass the FBGUID parameter for authentication if you already have one from your
integration
http://localhost/FB7/search.aspx?ProjectID=2&Field1=205672&Direct=1&FBguid=961f74e1-2a27-4add-9e12-
496ff2edf5cc

You can also pass credentials in the URL (only recommended if passing "view only" credentials)
http://localhost/FB7/search.aspx?
ProjectID=2&Field1=205672&Direct=1&username=viewonly&password=vie wonly1

Note: If cookies are enabled or if Active Directory is enabled for the site, authentication should happen
without passing any parameters in the URL string.

Open Viewer by FileID (viewer.ashx):


Open the full viewer for a specific FileID:
http://localhost/FB7/output/viewer.ashx?FileID=6

Open Viewer by DocumentID (viewer.ashx):


Open the document viewer for a specific DocumentID (no index information displayed)

http://localhost/FB7/output/viewer.ashx?DocumentID=5

Open the full viewer but go to a specific DocumentID (loads all pages and file index information but
goes to the specific document in the full viewer)
http://localhost/FB7/output/viewer.ashx?DocumentID=5&ShowFileViewer=1

46
FileBound 7 API Manual

Web Viewer (Starting with FileBound 6):


Open WebViewer by FileID:

http://localhost/FB7/WebViewer/WebView?

MultiID=6&DocumentID=0 Open WebViewer by DocumentID:

http://localhost/FB7/WebViewer/WebView?DocumentID=5

Entry (entry.aspx):
Load the entry page for a Project:
http://localhost/FB7/entry.aspx?ProjectID=2&Field1=123456&Field2=555&Field3=Test

Renditions (renditions.ashx – Starting with FileBound 6):


http://localhost/FB7/output/renditions.ashx?ObjectID=5&ObjectType=document ObjectID =

DocumentID

Thumbnails (thumbnails.ashx):
http://localhost/FB7/output/thumbnails.ashx?

DocumentID=5&height=225
Barcode (barcode.ashx):
http://localhost/FB7/output/barcode.ashx?text=00F00&height=30
A handler typically used in integrations to embed a barcode image. VB.NET Example:
BarCode.ImageUrl = State.RootPath + “Output/Barcode.ashx?Text=” + Server.UrlEncode(Document.Div ider)

47
FileBound 7 API Manual

Part 3 FileBound URL Integrations:


The Handlers
The Handlers are a collection of .NET .ashx handlers that are used to return some sort of data to the
calling page. They are written as handlers instead of .aspx pages to avoid the overhead that comes with
processing and returning the HTML on an aspx page.

Thumbnails.ashx
Handler: Thumbnails.ashx

Description: The Thumbnail handler is used to return a thumbnail sized version of a


Document. If the Document is not an image type, an icon representing the file
type is returned instead.

Parameter Name Usage


DocumentID The ID of the Document (required).
Scale Returned image shrunk by scale %. Should be between 0 and 1.
Height Height to resize the image.
Width Width to resize the image.

NOTE:
Scale takes preference over height and width. If Scale, Width, and Height are all undefined a Default
Height of 225px is used.

Example:
imgClicker.ImageUrl =String.Format(State.RootPath + Output/Thumbnails.ashx?DocumentID={0}",
50)

48
FileBound 7 API Manual

Viewer.ashx
Handler: Viewer.ashx

Description: The Viewer handler is used to load the FileBound viewer from a click on the
website. The handler uses the query string parameters to determine how to
preload the FileBound Command Viewer. The Command Viewer is streamed to
the browser and the FileBound Viewer is loaded.

Parameter Name Usage


ShowAdmin If true and user is admin, will load the Admin Viewer.
ShowScan If true will load the Scan Viewer.
ShowArchive If true will load the Archive Viewer.
ShowFileViewer If true will show the File Viewer.
ProjectID Project ID to pass to Viewer.
FileID File ID to pass to viewer.
FileIDs Comma separated list of File IDs to pass to viewer.
DocumentID Document ID to pass to Viewer. (if Document ID > 0 and ShowFileViewer is not
set to True Document Viewer will load).
Divider Divider to pass to Viewer (used in scan viewer).
Separator Separator to pass to Viewer (used in scan viewer).
ArchiveID Archive ID to pass to Viewer (used in Archive Viewer).
MultiQueueID MultiQueue ID to pass to Viewer.

Examples:

Javascript
window.location.href = RootPath + 'Output/Viewer.ashx?FileID=' + FileID + '&FileIDs=' + FileStr;

Document Viewer
e.Row.Attributes.Add("onclick", "javascript:document.location.href='" + State.RootPath +
Output/Viewer.ashx?DocumentID=" + dr("DocumentID").ToString() + "'")

File Viewer
FileViewer.NavigateUrl = State.RootPath + "Output/Viewer.ashx?FileID=" + Archive ID to pass to
Viewer (used in Archive Viewer). FBFile.FileID.ToString()

Admin Viewer
Response.Redirect(State.RootPath + "Output/Viewer.ashx?ShowAdmin=true")

Scan Viewer
ScanDocuments.NavigateUrl = State.RootPath + "Output/Viewer.ashx?FileID=" +
FBFile.FileID.ToString() + &ShowScan=1&Divider=DividerName"

49
FileBound 7 API Manual

Barcode.ashx
Handler: Barcode.ashx

Description: The Barcode handler is used to return a Code 39 barcode image for the Text
value passed in.
Parameter Name Usage
Text (required) – value passed here will be returned as a Code 39 barcode image.

Example:
BarCode.ImageUrl = State.RootPath + "Output/Barcode.ashx?Text=" +
Server.UrlEncode(Document.Divider)

50
FileBound 7 API Manual

FileBound Viewers Part 1


FileBound’s viewer system is architected specifically for ease of implementation into custom solutions.
Embedding viewers into WinForm applications and Web applications is possible with the built-in
viewers. This section covers the viewer system and its usage for custom applications.

Viewer Overview
There are 3 basic viewer types available – file viewers, document viewers and combination viewers. File
viewers handle viewing and navigating the page list of the file. This would typically be the tree view
portion of the viewer. Document viewers handle viewing the actual documents. Combination viewers
wrap the file and document viewers into a single control for easier integration.

The Full Viewer (combination viewer) is shown below. This component is referenced via
FileBound.Viewers.FullViewer. It houses both the File Viewer and Document Viewer so it would
normally be the viewer of choice to give full functionality to custom applications.

The File viewer is highlighted below. This component is available by itself and is referenced via
FileBound.Viewers.FileViewer.

51
FileBound 7 API Manual

The Document viewer is highlighted below. This component is available by itself and is referenced via
FileBound.Viewers.DocumentViewer.

52
FileBound 7 API Manual

FileBound Viewers Part 2


Combination Viewers – Web connection
The standard combination viewer is called the Full Viewer. The Full Viewer can be embedded in a
WinForm and set to communicate with a FileBound server in just a few shorts lines of code. This code
demonstrates the use of the Full Viewer control with a Web connection.

'Create FullViewer reference and dock in form


Dim FV As New FileBound.Viewers.FullViewer
FV.Parent = Me
FV.Visible = True
FV.BringToFront()
FV.Dock = DockStyle.Fill

'Connect viewer to FileBound server


FV.Connection = "http://localhost"
FV.UserName = "admin"
FV.Password = "admin"
'Set properties for which information to show
FV.ProjectID = FBP.ProjectID
FV.FileID = FileID
FV.DocumentID = DocumentID
'Change to false to only show Document viewer
FV.ShowFileViewer = True
'Show data
FV.ShowData()

53
FileBound 7 API Manual

Combination Viewers – SQL connection


Using the Full Viewer (as with all viewers) can be directly connected to the server as well. Simply
change the connection property to be the SQL connection string.

'Create FullViewer reference and dock in form


Dim FV As New FileBound.Viewers.FullViewer
FV.Parent = Me
FV.Visible = True
FV.BringToFront()
FV.Dock = DockStyle.Fill

'Connect viewer to FileBound server


FV.Connection = "User ID=sa;password=???;" & _
"Initial Catalog=filebound;" & _
"Data Source=localhost\sqlexpress;"
FV.UserName = "admin"
FV.Password = "admin"
'Set properties for which information to show
FV.ProjectID = FBP.ProjectID
FV.FileID = FileID
FV.DocumentID = DocumentID
'Change to false to only show Document viewer
FV.ShowFileViewer = True
'Show data
FV.ShowData()

Document Viewers - Web connection


The next most common viewer control to use is the Document viewer. Notice that the calling convention
is pretty much identical, with the exception of not having to set a ShowFileViewer (Boolean) property.

'Create DocumentViewer reference and dock in form


Dim DV As New FileBound.Viewers.DocumentViewer
DV.Parent = Me
DV.Visible = True
DV.Dock = DockStyle.Fill

'Connect viewer to FileBound server


DV.Connection = "http://localhost"
DV.UserName = "admin"
DV.Password = "admin"
'Set properties for which information to show
DV.ProjectID = 322
DV.FileID = 5786
DV.DocumentID = 126418
'Show data
DV.ShowData()

54
FileBound 7 API Manual

Document Viewers – SQL connection


As with the Full Viewer, the Document Viewer can be connected directly to SQL.

'Create DocumentViewer reference and dock in form


Dim DV As New FileBound.Viewers.DocumentViewer
DV.Parent = Me
DV.Visible = True
DV.Dock = DockStyle.Fill

'Connect viewer to FileBound server


DV.Connection = "User ID=sa;password=???;" & _
"Initial Catalog=filebound;" & _
"Data Source=localhost\sqlexpress;"
DV.UserName = "admin"
DV.Password = "admin"
'Set properties for which information to show
DV.ProjectID = 322
DV.FileID = 5786
DV.DocumentID = 126418
'Show data
DV.ShowData()

Document Viewers – Document Object


The Document Viewer has an extra feature for greater ease of use. If a document object has already been
programmatically retrieved from the FileBound server, it can be passed directly to the Document Viewer.
This is more efficient, if the document object is already created.

'Create DocumentViewer reference and dock in form


Dim DV As New FileBound.Viewers.DocumentViewer
DV.Parent = Me
DV.Visible = True
DV.Dock = DockStyle.Fill

'Show Document object directly


DV.Document = FBDocument 'Use existing Document object
DV.ShowData()

55
FileBound 7 API Manual

FileBound Viewers Part 3


Command Viewers – Web connection
If the project calls for a popup viewer instead of an embedded viewer, then the best option is to use the
Command Viewer. The Command Viewer is a Winform that is built to popup from the current
application in a modal window, to provide the same viewing experience as our Full Viewer. In fact the
Command Viewer simply embeds the Full Viewer in a form to save developers time.

Dim CV As New FileBound.Viewers.CommandViewer

'Connect viewer to FileBound server


CV.Connection = "http://localhost"
CV.UserName = "admin"
CV.Password = "admin"
'Set properties for which information to show
CV.ProjectID = 322
CV.FileID = 5786
CV.DocumentID = 126418
CV.ViewerType = Interfaces.Viewers.ViewerType.File
CV.ShowData()

Command Viewers – SQL connection


As with the Full Viewer, the Command Viewer can be connected directly to SQL.

Dim CV As New FileBound.Viewers.CommandViewer

'Connect viewer to FileBound server


CV.Connection = "User ID=sa;password=???;" & _
"Initial Catalog=filebound;" & _
"Data Source=localhost\sqlexpress;"
CV.UserName = "admin"
CV.Password = "admin"
'Set properties for which information to show
CV.ProjectID = 322
CV.FileID = 5786
CV.DocumentID = 126418
CV.ViewerType = Interfaces.Viewers.ViewerType.File
CV.ShowData()

56
FileBound 7 API Manual

Command Viewers – FileBound Web connection


When the solution calls for embedding a viewer in a custom fashion for users who are already logged into
the system, it does not make sense to use the above calls because this initiates another login() method
which wastes time and logs unnecessary logins. To use an existing logged in FileBound Web session is
simple. This method applies to ALL viewers but rather than showing the same example three times, it is
being demonstrated once in the context of the Command Viewer. This is the same method used by the
FileBound Web site’s built in viewer.

Dim CV As New FileBound.Viewers.CommandViewer

'Connect viewer to FileBound server


CV.SiteURL = "http://localhost"
'This is the Web site’s SessionID
CV.SessionID = context.Session.SessionID
'Set properties for which information to show
CV.ProjectID = 322
CV.FileID = 5786
CV.DocumentID = 126418
CV.ViewerType = Interfaces.Viewers.ViewerType.File
CV.ShowData()

Command Viewers – Calling from Web Page


The Command Viewer is great for WinForm applications but is not accessible in its normal manner for
use within Web applications. To use the Command Viewer from a Web page it is necessary to adopt the
methodology FileBound uses.

The new viewer system that is used by FileBound is far superior to our old viewer in many ways but no
way is more evident than in the way the viewer is instantiated. In previous versions the viewer was
embedded as an ActiveX control and provided a fairly seamless interface between the Web pages and the
viewer. However, security concerns and ActiveX in general were a constant nuisance and an upgrade
nightmare. Not to mention they were only supported in Internet Explorer.

FileBound Version 5’s viewer actually uses built in file download capabilities of the browsers (IE,
FireFox and others) to download a command file that is created by a server-side version of the Command
Viewer. That command file is sent down as an FBV (FileBound Viewer) file type which is associated
with our viewer launcher app that is installed on the local client during the viewer install process (which
can be automated through AD or SMS). Once that file is downloaded it is sent to the
FBViewerLauncher.exe application where it is re-instantiated into a client-side version of the Command
Viewer and launched locally. In this way the viewer commands are controlled by the command viewer
object and the viewer can be completely disassociated from the browser itself so the viewers are no longer
limited by browser type!

To take advantage of this system from web pages simply instantiate a server-side Command Viewer
object, set the properties desired and call the CommandViewer.CreateCommands method to get the
encrypted binary data that needs to be sent back through to the browser. Before the data is sent back to
the browser, the ContentType and Disposition header must be set appropriately as shown in the following
example which was written in ASP.NET.

57
FileBound 7 API Manual

Dim CV As New FileBound.Viewers.CommandViewer

CV.SiteURL = "http://localhost"
CV.SessionID = Session.SessionID
CV.ProjectID = 322
CV.FileID = 5786
CV.ViewerType = Interfaces.Viewers.ViewerType.File

context.Response.ContentType = FileBound.FBFunctions.GetContentType("fbv")
context.Response.AddHeader("content-disposition", _
"inline; filename=Viewer.fbv")
context.Response.BinaryWrite(CV.CreateCommands())

It is important to note that the CreateCommands packet is fully encrypted so it hides connection
information. The exception is at the top of the packet will be a Server URL and a Version. This is used
by the FBViewerLauncher application to determine whether or not it has the correct FileBound.dll loaded
locally. If not then it automatically downloads the correct version and instantiates it dynamically to
ensure proper viewer versions per server.

58
FileBound 7 API Manual

FileBound Viewers Part 4


Embedding Viewers in Web pages
Embedding the FileBound viewer in Web pages is similar to WinForms, except that some JavaScript is
normally required to get the viewer to operate. The following example shows how to load the document
viewer in a Web page and have it connect through a Web connection to the FileBound server.

<head>
<script type="text/javascript">
<!--
function ViewDoc()
{
document.getElementById('DocumentViewer').SiteURL='http://localhost';
document.getElementById('DocumentViewer').SessionID='asdfaasd';
document.getElementById('DocumentViewer').ProjectID=2;
document.getElementById('DocumentViewer').FileID=2644;
document.getElementById('DocumentViewer').DocumentID=115604;
document.getElementById('DocumentViewer').ShowData();
}
// -->
</script>
</head>

<body topmargin="0" leftmargin="0">

<object id="DocumentViewer" classid="http:FileBound.dll#FileBound.Viewers.DocumentVie


wer" width="100%" height="100%"></object>

<script language="javascript" type="text/javascript">ViewDoc()</script>

</body>
</html>

** Please note that embedding the viewer in a Web page in this manner is very tricky due
to security constraints and is not a supported method. This is only documented for
completeness and for those who have requested to see how it could be done.

59
FileBound 7 API Manual

Special Document-Only Viewer - DocView


Most of the included viewers also have their own navigation and interaction elements like toolbars,
menus, etc. The DocView component is built specifically to view all FileBound content items but
without any navigation or interaction elements. If a custom viewer is required with its own toolbars,
buttons, menus, etc then the DocView control is perfect. It only supports the document-level functions
such as viewing, printing, emailing, etc. It does not support authentication or navigation – that would
have to be provided by the containing application.

'Find project
Dim FBProject As FileBound.Project
FBBusiness.Projects.Filter.ProjectID = 2
FBBusiness.Projects.Fill()
FBProject = FBBusiness.Projects(0)

'Find files
FBProject.Files.Filter.Field(("Invoice Number") = "1213"
FBProject.Files.Fill()

'Set a file object


Dim FBFile As FileBound.File = FBProject.Files(0)

'Find documents
FBFile.Documents.Fill()

'Set a document object


Dim FBDoc As FileBound.Document = FBFile.Documents(0)

'Show document in embedded DocView1 control


DocView1.Document = FBDoc
DocView1.ShowData()

'Place into a form


Dim frm As New Form
frm.Controls.Add(DocView1)
DocView1.Doc = Fill
frm.Show()

60
FileBound 7 API Manual

FileBound Viewers Part 5:


Custom Viewer Methods
Custom Events with the FullViewer
The FullViewer raises events during certain operations such as setting up the menus and toolbars. These
events can be hooked into by loading a custom assembly. To do this the custom assembly should (but is
not required to) implement the FileBound.Interfaces.Viewers.iViewerPlugin interface.

The events that can be hooked into include, but are not limited to, the following list:

• Document loading
• Menu creation
• Toolbar creation
• Document printing
• Plug-In execution
• Annotation Burn-in
• Getting archive path
• Etc (refer to the intellisense of the FullViewer object for the full list of events)

To get started, create a class that implements the iViewerPlugin interface and have a place to store the
FullViewer reference for later use. In this example we will add a page-level menu option to rotate the
page.

Public Class TestPlugin


Implements FileBound.Interfaces.Viewers.iViewerPlugin

Private m_Name As String = "Page Rotator"


Private m_FullViewer As New FileBound.Viewers.FullViewer

Public ReadOnly Property PluginName() As String Implements _


FileBound.Interfaces.Viewers.iViewerPlugin.PluginName
Get
Return m_Name
End Get
End Property

End Class

Next, make sure to implement the Init method making sure to capture the FullViewer reference. Also
notice that here is where we would add some event handlers.

Public Function Init(ByVal FullViewer As _


FileBound.Interfaces.Viewers.iFullViewer) _
As Boolean Implements _
FileBound.Interfaces.Viewers.iViewerPlugin.Init

m_FullViewer = FullViewer

61
FileBound 7 API Manual

AddHandler FullViewer.FB_SetMenus, AddressOf SetMenus

End Function

For the event handler (in this case a menu update) add in the necessary method to handle the call.
Private Sub SetMenus( _
ByVal RootMenu As Windows.Forms.ContextMenuStrip, _
ByVal FileMenu As Windows.Forms.ContextMenuStrip, _
ByVal SeparatorMenu As Windows.Forms.ContextMenuStrip, _
ByVal DividerMenu As Windows.Forms.ContextMenuStrip, _
ByVal PageMenu As Windows.Forms.ContextMenuStrip, _
ByVal MasterSheetMenu As Windows.Forms.ContextMenuStrip)

'Menus generated - sure menu item is added if necessary


If PageMenu.Items("MyMenu") Is Nothing Then
Dim x As New ToolStripMenuItem("Rotate")
x.DisplayStyle = ToolStripItemDisplayStyle.Text
x.Name = "MyMenu"
AddHandler x.Click, AddressOf TestMenuClick
PageMenu.Items.Add(x)
End If
End Sub

Next, we need to add in a method called TestMenuClick to handle the actual click of the menu.

Private Sub TestMenuClick( _


ByVal sender As System.Object,_
ByVal e As System.EventArgs)

m_FullViewer.DocumentViewer.RotateRight()

End Sub

Lastly we need to add in the loading of this class and call the Init() function. This is done directly after
calling ShowData().

Dim FV As New FileBound.Viewers.FullViewer


. . .
FV.ShowData()
Dim Test As FileBound.Interfaces.Viewers.iViewerPlugin = _
New TestPlugin
Test.Init(FV)

Now any time the custom menu item is clicked the currently-displayed page will rotate right. Notice
there are options to add menu items to any level of menu in the treeview. The FB_Set_Toolbar event is
raised that allows you to add toolbar buttons in the document viewer screen as well. A good look through
the viewer events will give a good feel of what options are available.

Custom Assemblies with the CommandViewer


For Web developers, the FullViewer object is something not accessible. To facilitate the loading of
custom assemblies from a Web interface, the CommandViewer has an array list property called

62
FileBound 7 API Manual

CustomAssemblies. This holds a list of assemblies to add into the viewer when it is instantiated. On the
server side simply add into the list the full paths of all the assemblies needing to be loaded. The path can
either be a standard driver letter path or an Internet path (URL). The command viewer simply loads the
assembly and calls its Init method. For this reason the assembly MUST implement the iViewerPlugin
interface.

NOTE: The list of assemblies is added server-side but is executed client-side so make sure the paths are
valid from the client.

Dim CV As New FileBound.Viewers.CommandViewer


CV.FormTitle = "Command Viewer with Custom Assembly"
CV.SiteURL = "http://localhost/v5"
CV.SessionID = "asdkfjhasdlfkjhdsalfkj"
CV.ProjectID = m_ProjectID
CV.FileID = m_FileID
CV.ViewerType = _
FileBound.Interfaces.Viewers.ViewerType.File
CV.CustomAssemblies.Add( _
"http://mysite.com/CustomViewerEvents.dll")

From a Web server interface, serve the CreateCommands result to the client browser.

context.Response.ContentType = _
FileBound.FBFunctions.GetContentType("fbv")
context.Response.AddHeader("content-disposition", _
"inline; filename=Viewer.fbv")
context.Response.BinaryWrite(CV.CreateCommands())

Another option for adding this functionality is to rely on the CommandViewer to do it. CommandViewer
will look in the folder of the EXE that calls it for a folder name ‘Plugins’. If it finds one it will attempt to
load all assemblies in that folder as if they were fed through the CustomAssemblies array. Since this
happens at the client level this can greatly simplify installation and can make rolling out of features much
easier. The standard place for the viewer to look for PlugIns in this fashion is the ‘Program
Files\FileBound\Viewer\Plugins’ folder of the client but may change if FBViewerLauncher.exe is moved.

One more option is to utilize the Plug-Ins system to distribute the assemblies for you. When the
CommandViewer loads during normal operation in the FileBound Web interface any Plug-ins that are set
to the “In Viewer” mode will automatically be loaded into the viewer. To do this set the following
properties in the Plug-In setup screen – Hidden, In Viewer with a File Path of the URL to the DLL
(relative or absolute URL).

63
FileBound 7 API Manual

FileBound Viewers Part 6


Custom Viewers for Document Types
One more very practical feat that can be accomplished with the viewer structure is to add special support
for document types. This is done by document extension so a Plug-In could be written for an XYZ
document type. The FileBound.Interfaces.Viewers.iDocViewPlugin interface provides support for this
functionality.

The heart of this method is creating a UserControl to allow for the viewing and possibly editing of the
document type. Then implementing the iDocViewPlugin interface provides the rest of the methods
required for this to work.

The following example demonstrates how to use this interface to create a custom viewer control to allow
editing of text (TXT) files. This requires a UserControl with a text box named TextBox1.

Public Class test


Implements FileBound.Interfaces.Viewers.iDocViewPlugin

Private m_Name As String = "Text Viewer"


Private m_Document As FileBound.Document
Private m_FileTypes As New ArrayList
Private m_TempFolder As String = ""

Public Sub New()

' This call is required by the Windows Form Designer.


InitializeComponent()

' Add initialization after InitializeComponent() call.


m_FileTypes.Add("TXT")
End Sub

Public Sub AnnoBurnIn() Implements _


Interfaces.Viewers.iDocViewPlugin.AnnoBurnIn
End Sub

Public Sub CloseDocument() Implements _


Interfaces.Viewers.iDocViewPlugin.CloseDocument
End Sub

Public Property FileTypes() As System.Collections.ArrayList _


Implements Interfaces.Viewers.iDocViewPlugin.FileTypes
Get
Return m_FileTypes
End Get
Set(ByVal value As System.Collections.ArrayList)
m_FileTypes = value
End Set
End Property

64
FileBound 7 API Manual

Public Function GetBITMAP( _


ByVal WithAnnotations As Boolean) As _ System.Drawing.Bitmap _
Implements Interfaces.Viewers.iDocViewPlugin.GetBITMAP
Return Nothing
End Function

Public Function GetDocTempPath() As String Implements _


Interfaces.Viewers.iDocViewPlugin.GetDocTempPath
Return ""
End Function

Public ReadOnly Property PluginName() As String Implements _


Interfaces.Viewers.iDocViewPlugin.PluginName
Get
Return m_Name
End Get
End Property

Public Sub Repaint() Implements _


Interfaces.Viewers.iDocViewPlugin.Repaint

End Sub

Public Sub RotateLeft() Implements _


Interfaces.Viewers.iDocViewPlugin.RotateLeft

End Sub

Public Sub RotateRight() Implements _


Interfaces.Viewers.iDocViewPlugin.RotateRight

End Sub

Public Sub ScrollDoc(ByVal Delta As Integer) _


Implements Interfaces.Viewers.iDocViewPlugin.ScrollDoc

End Sub

Public Function SecurityBypass( _


ByVal Business As Business.Standard, _
ByVal AppliedGroup As Group) As Boolean _
Implements Interfaces.Viewers.iDocViewPlugin.SecurityBypass

End Function

Public Sub SetViewMode( _


ByVal ViewMode As FBEnumerations.ViewModeEnum) _
Implements Interfaces.Viewers.iDocViewPlugin.SetViewMode

End Sub

Public Function ShowDocument(_


ByVal Document As Document) As Boolean _
Implements Interfaces.Viewers.iDocViewPlugin.ShowDocument
'Retrieve the binary data and convert to text

65
FileBound 7 API Manual

If m_Document.BinaryData Is Nothing Then


m_Document.PopulateDocument()
End If
Dim enc As New System.Text.ASCIIEncoding()
TextBox1.Text = enc.GetString(m_Document.BinaryData)
End Function

Public Property TempFolder() As String _


Implements Interfaces.Viewers.iDocViewPlugin.TempFolder
Get
Return m_TempFolder
End Get
Set(ByVal value As String)
m_TempFolder = value
End Set
End Property

Public Function UpdateDocument() As Boolean Implements _


Interfaces.Viewers.iDocViewPlugin.UpdateDocument
'Set the binary data back to the text box contents
Dim enc As New System.Text.ASCIIEncoding()
m_Document.BinaryData = enc.GetBytes(TextBox1.Text)
End Function

Public Function ZoomTo(ByVal factor As Single) As Boolean _


Implements Interfaces.Viewers.iDocViewPlugin.ZoomTo

End Function

Public Sub ZoomToHeight() Implements _


Interfaces.Viewers.iDocViewPlugin.ZoomToHeight

End Sub

Public Sub ZoomToWidth() Implements _


Interfaces.Viewers.iDocViewPlugin.ZoomToWidth

End Sub

End Class

To use the Plug-Ins from your own application you will need to respond to the viewer’s requests for
assemblies by handling the DocumentViewer.FB_LoadCustomAssembly event. Here is a small example
of how to handle this event.

Public Class frmTest

Private DocViewPlugIns As New ArrayList

Private Sub frmTest_Load(ByVal sender As System.Object, _


ByVal e As System.EventArgs) Handles MyBase.Load

'Create FullViewer reference and dock in form


Dim FV As New FileBound.Viewers.FullViewer

66
FileBound 7 API Manual

FV.Parent = Me
FV.Visible = True
FV.Dock = DockStyle.Fill
FV.Connection = ConnectionString
FV.UserName = Username
FV.Password = Password
FV.ProjectID = 1
FV.FileID = 100
FV.ShowFileViewer = True
FV.ShowData()

'Add new instance of plug-in to array list for later use


DocViewPlugIns.Add(New test)

Make event handler


AddHandler FV.DocumentViewer.FB_LoadCustomAssembly, _
AddressOf FB_LoadCustomAssembly

End Sub

Private Sub FB_LoadCustomAssembly( _


ByVal FileType As String, _
ByRef DocViewPlugin As _
FileBound.Interfaces.Viewers.iDocViewPlugin)

DocViewPlugin = Nothing
For Each TestPlugin _
As FileBound.Interfaces.Viewers.iDocViewPlugin _
In DocViewPlugIns

If TestPlugin.FileTypes.Contains(FileType.ToUpper) Then
Dim t As Type = TestPlugin.GetType
DocViewPlugin = Activator.CreateInstance(t)
Return
End If

Next

End Sub

End Class

** Important note: if you need to write documents out to a temp location for processing you can use the
TempFolder property that is defined in the interface. This will be set to the unique temp folder location
for the instance of the DocView control that loads the control. Since multiple viewers could be loaded at
once and each could have multiple DocView controls showing at the same time it is best to leave the temp
folder work to the viewer system.

67
FileBound 7 API Manual

FileBound Viewers Part 7


Settings Screens for Plug-Ins
When creating Plug-Ins for the viewer it is quite natural to have configurable properties or settings for
your new features. In order to provide the end users with a consistent location for all settings we have
create a standardized settings interface named FileBound.Interfaces.Viewers.iViewerSettings.

Coding a User Control to this interface will allow developers to display their settings within the standard
viewer settings screen. The interface is quite simple and allows for retrieving, saving and verifying
settings as well as categorizing and naming the setting screen and setting a 16x16 pixel image for display
purposes. In the screen shot below ‘Category’ is the bold heading (ie File Settings, Document Settings
and My Application). ‘Name’ is the non-bolded items under the categories.

This interface only provides you with a structure to manage your settings. Storing and retrieving the
settings needs to be done by you. It is typical to store them in the Windows Registry as in the example
below or to add them to the LoggedInUser.ExtendedProperties collection. However, you can use
whatever method you choose. Typically User Controls for settings are included in the same assembly as
the custom code that uses them and are distributed in the same way as Viewer Plug-Ins.

A simple implementation like the one above can be accomplished by creating a User Control and setting
it to implement the FileBound.Interfaces.Viewers.iViewerSettings interface.

Public Class ctlSettingsTest


Implements FileBound.Interfaces.Viewers.iViewerSettings

Once that interface is implemented you will need to fill in the structure of methods that are created for
you automatically in Visual Studio. One thing to note is that the SecurityBypass method allows for the
development of security-allowed settings screens. If the SecurityBypass method returns TRUE then this
Pllug-In will not load – therefore bypassing the Plug-In based on security checks. Here is the full code
for the above example and it assumes this code is in a User Control with 2 text boxes on it called
txtLocation and txtPassword.

68
FileBound 7 API Manual

Imports Microsoft.Win32.Registry
Public Class ctlSettingsTest
Implements FileBound.Interfaces.Viewers.iViewerSettings

Private m_Category As String = "My Application"


Private m_Name As String = "General Settings"

Public ReadOnly Property Category() As String _


Implements Interfaces.Viewers.iViewerSettings.Category
Get
Return m_Category
End Get
End Property

Public ReadOnly Property PluginName() As String _


Implements _
FileBound.Interfaces.Viewers.iViewerSettings.PluginName
Get
Return m_Name
End Get
End Property

Public ReadOnly Property Image() As System.Drawing.Bitmap _


Implements _
FileBound.Interfaces.Viewers.iViewerSettings.Image
Get
Return Nothing
End Get
End Property

Public Sub Init(ByVal DocumentViewer As _


Interfaces.Viewers.iDocumentViewer) _
Implements Interfaces.Viewers.iViewerSettings.Init

End Sub

Public Function SecurityBypass(ByVal LoggedInUser As User, _


ByVal AppliedGroup As Group) As Boolean _
Implements _
Interfaces.Viewers.iViewerSettings.SecurityBypass
'Don’t show if the user does not have DocEdit rights
If Not AppliedGroup.DocEdit Then
Return True
End If
End Function

Public Function GetSettings() As Boolean _


Implements Interfaces.Viewers.iViewerSettings.GetSettings
Try
txtLocation.Text = _
GetValue("HKEY_CURRENT_USER\Software\YourApp", _
"Location", "")
txtPassword.Text = _
GetValue("HKEY_CURRENT_USER\Software\YourApp", _
"Password", "")

69
FileBound 7 API Manual

Catch ex As Exception
Return False
End Try
Return True
End Function

Public Function SaveSettings() As Boolean _


Implements Interfaces.Viewers.iViewerSettings.SaveSettings
Try
SetValue("HKEY_CURRENT_USER\Software\YourApp", _
"Location", txtLocation.Text)
SetValue("HKEY_CURRENT_USER\Software\YourApp", _
"Password", txtPassword.Text)
Catch ex As Exception
Return False
End Try
Return True
End Function

Public Function VerifySettings( _


ByRef ErrorMessage As String) As Boolean _
Implements _
Interfaces.Viewers.iViewerSettings.VerifySettings
'Make sure it is not blank
If txtLocation.Text.Trim = "" Then
ErrorMessage = "Enter location for My Application"
Return False
End If

'Make sure it is a web URL


If Not (txtLocation.Text.ToUpper.Contains("HTTP://") _
Or txtLocation.Text.ToUpper.Contains("HTTP://")) Then

ErrorMessage = "Must enter valid URL"


Return False
End If

Return True
End Function

End Class

70
FileBound 7 API Manual

FileBound Web Service Part 1:


The Basics
Web Service Basics Overview
DataExchange2 is a Web Service based on the FileBound Object Model. Since the standard FileBound
Web Service is tied to the inner workings of the FileBound Object Model & .NET, it is impractical &
confusing to use directly. DataExchange2 was created specifically to address the need of FileBound
partners to communicate directly with the FileBound Web Service in a platform independent way. Users
can access DataExchange2 from any platform or environment that allows the use of Web Services and
XML. By receiving, modifying, and sending XML to the functions a user can perform most of the basic
functions need to integrate an application with FileBound.

Setting Up a Web Reference to DataExchange2


Before using the DataExchange2 web service, a web reference must be established for it. To add this web
reference using Microsoft Visual Studio 2008, the following steps can be taken:

1. Create a new Project by clicking “File” > “New Project”.


2. Add the web reference by clicking “Project” > “Add Web Reference”, then type the location of
the web reference into the URL field or locate the web reference using the “Browse to” options.
3. After locating the web reference, type a name for the web reference in the “Web reference
name” field. This name will be used for programmatically interfacing with the web service. In
order to better illustrate use of the web reference to create a web service instance (described
below), it will be assumed that the web reference has been named “WebReference”.

Creating a Web Service Instance of DataExchange2


To create a web service instance for a web reference to DataExchange2 named “WebReference”, the
following Visual Basic .NET code can be used:
Dim de As New WebService.DataExchange2

The general procedure for making a call using DataExchange2 is as follows:


1. Create DataExchange2 connection
2. Login to DataExchange2 with username and password
3. Make a call using DataExchange2
4. Check if an error occurred by checking the returned data for the routine (if it returns a long,
check for zero, and if it returns a string, check if the string is the standard XML error).
a. If an error occurred, handle accordingly
b. If no error occurred, continue as usual

71
FileBound 7 API Manual

Error Handling
DataExchange2 is comprised of routines that perform a variety of remote operations on a data
source/destination. Some of these routines return a data value, and the returned value can be one of a
number of types (for example, one routine might return the long integer type, but another might return a
string type). To accommodate for this inconsistency, and to keep error handling relatively simple, a
number of special error-handling routines are included with

DataExchange2.

When an error occurs in DataExchange2, it is handled in one of three ways. The handling procedures are
as follows:

a. The error is returned in XML form. This is the case for routines that return a string.
b. The error is recorded, and a flag is returned indicating that an error occurred. If the flag
indicates that an error occurred, methods are available to retrieve the recorded error. This is
the case for routines that return long integers.
c. The error is recorded, and nothing is returned. This is the case for routines that return no value.
The table shown below lists and summarizes the error-handling routines. Detailed descriptions and usage
examples follow.

Name Description
GetLastErrorXML() Returns a String representation of the XML formatted error message that
last occurred.
GetLastErrorMessage() Returns the error message String for the last error that occurred.
GetLastErrorWasException Returns a Boolean value indicating whether the last error that occurred
was an Exception.

The GetLastErrorXML routine returns a string representation of the XML formatted error message
that last occurred. The XML structure for this error is as follows:
<Error>
<Message>An error occurred.</Message>
<IsException>0</IsException>
</Error>

If a routine returns a long integer type, a special value of this type will be returned that indicates an error.
This value can be retrieved using the GetErrorCode()routine.

If a routine does not return a value, then the routine will record the error then halt execution where the
error occurred, and will not make any changes to the data source being operated on.

72
FileBound 7 API Manual

FileBound Web Service Part 2:


Project/File/Document Examples
The examples shown are written using Microsoft Visual Basic .NET. It is important to note that no error
handling is done in the following examples in order to make the examples more focused and to improve
readability.

Project Examples
Returning a Project by Project ID
In the following example, the Project associated with the specified ProjectID is returned as a serialized
Project object.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim projectID As Long = 3
Dim myProjectXML As String = de.GetProjectByID(GUID, projectID)
' Note: In general, operate on myProjectXML here

Returning a Project by Project Name


In the following example, the Project associated with the specified ProjectName is returned as a serialized
Project object.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim projectName As String = " Test Project"
Dim myProjectXML As String = de.GetProjectByName(GUID, projectName)
' Note: In general, operate on myProjectXML here

Returning All Projects for User


In the following example, all Projects are retrieved for the logged in user and returned as a serialized
ProjectCollection object.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim projectName As String = " Test Project"
Dim myProjectXML As String = de.GetProjects(GUID)
' Note: In general, operate on myProjectXML here

File Examples
Returning a File by File ID
In the following example, the File associated with the specified FileID is returned as a serialized File
object.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim fileID As Long = 5

73
FileBound 7 API Manual

Dim myFileXML As String = de.GetFileByID(GUID, fileID)


' Note: In general, operate on myFileXML here

Returning Files by Field Value(s)


In the following example, a collection of Files is retrieved and returned as a serialized FileCollection
object.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim fileID As Long = 5
Dim ProjectID As Long = 1
Dim Field1 As String = "test"
Dim myFileXML As String = de.GetFilesByProject(GUID, ProjectID, Field1,
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "")
' Note: In general, operate on myFileXML here

Saving a File
In the following example, a new File is created and its FileID is returned and stored.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim ProjectID As Long = 1
Dim newFileID As Long = de.SaveFile(GUID, ProjectID, 0, "F1 Value",
"F2", "Etc", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "")
' Note: newFileID is File’s ID, used to identify the File

Deleting a File
In the following example, a new File is created, and using the new File’s ID (returned from SaveFile(…)),
the new File is deleted.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim oldFileID As Long = 1
de.DeleteFile(GUID, oldFileID)

Document Examples
Returning a Document by Document ID
In the following example, the Document associated with the specified DocumentID is returned as a
serialized Document object.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim DocumentID As Long = 5
Dim myDocumentXML As String = de.GetDocumentByID(GUID, DocumentID)
' Note: In general, operate on myDocumentXML here

Returning Documents by File ID

74
FileBound 7 API Manual

In the following example, the Documents associated with the specified FileID are returned as a serialized
DocumentCollection object.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim DocumentID As Long = 5
Dim myDocumentXML As String = de.GetDocumentByID(GUID, DocumentID)
' Note: In general, operate on myDocumentXML here

Saving a Document
In the following example, a new Document is created and its DocumentID is returned and stored.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim FileID As Long = 1
Dim DocumentID As Long = 1
Dim newDocumentID As Long = de.SaveDocument(GUID, FileID, DocumentID,
"TIF", "", "", "Div Name", 0, 1, 0, "", "1/1/1990", 0, "", "")
' Note: newDocumentID is Document’s ID, used to identify the Document

Deleting a Document
In the following example, a new Document is created, and using the new Document’s ID (returned from
SaveDocument(…)), the new Document is deleted.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim oldDocumentID As Long = 1
de.DeleteDocument(GUID, oldDocumentID)

Retrieving Document Data


In the following example, binary data is downloaded from a Document on the FileBound server. If the
return value is not Nothing/Null then the upload succeeded. If therwise then you will want to call
GetLastErrorXML() to get more information about the failure.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim ImageData As Byte() = de.GetDocumentBinaryData(GUID, DocumentID)
If Not ImageData Is Nothing Then
System.IO.File.WriteAllBytes("c:\temp.t if", ImageData)
End If

Uploading Document Data


In the following example, binary data is sent to the FileBound server and saved into a Document’s image.
If the return value is True then the upload succeeded. If not then you will want to call
GetLastErrorXML() to get more information about the failure.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim ImageData As Byte() = System.IO.File.ReadAllBytes("c:\temp.tif")
Dim DocumentID As Long = 1
de.SetDocumentBinaryData(GUID, DocumentID, ImageData)

75
FileBound 7 API Manual

FileBound Web Service Part 3:


Workflow/Miscellaneous Examples
The examples shown are written using Microsoft Visual Basic .NET. It is important to note that no error
handling is done in the following examples in order to make the examples more focused and to improve
readability.

Workflow Examples
Routing a Document AdHoc
In the following example, the Document associated with the specified DocumentID is routed to the
specified user.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim UserID As Long = 1
Dim DocumentID As Long = 1
de.RouteDocumentAdHoc(GUID, DocumentID, UserID, False, "1/1/1990")

Cancelling a Route
In the following example, the routedItem associated with the specified RoutedItemID is cancelled which
cancels that workflow.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim RoutedItemID As Long = 1
de.RouteCancel(GUID, RoutedItemID)

Completing a Route Step


In the following example, the routedItem associated with the specified RoutedItemID is completed to the
next step of the workflow. The return value of the method is the ID of the next routedItem that was
created.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim RoutedItemID As Long = 1
Dim RIID As Long = de.RouteComplete(GUID, RoutedItemID, "Testing")

Rejecting a Route Step


In the following example, the routedItem associated with the specified RoutedItemID is rejected to the
previos step of the workflow. The return value of the method is the ID of the routedItem that was created.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim RoutedItemID As Long = 1
Dim RID As Long = de.RouteReject(GUID, RoutedItemID, "Testing")

Reassigning a Route Step

76
FileBound 7 API Manual

In the following example, the routedItem associated with the specified RoutedItemID is reassigned to the
routedItem designated by UserID. The return value of the method is the ID of the next routedItem that
was created.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim RoutedItemID As Long = 1
Dim UserID As Long = 1
Dim RID As Long = de.RouteReassign(GUID, RoutedItemID, UserID,
"Testing")

Miscellaneous Examples
Retrieving Divider List for Project
In the following example, the Dividers associated with the specified ProjectID are returned as a serialized
DividerCollection object.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim ProjectID As Long = 1
Dim myDividerXML As String = de.GetDividers(GUID, ProjectID)

Retrieving Field List for Project


In the following example, the Fields associated with the specified ProjectID are returned as a serialized
FieldCollection object.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim ProjectID As Long = 1
Dim myFieldXML As String = de.GetFields(GUID, ProjectID)

Retrieving RoutedItem List for a User for a given Project


In the following example, the RoutedItems associated with the specified UserID and ProjectID are
returned as a serialized RoutedItemCollection object.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim UserID As Long = 1
Dim ProjectID As Long = 1
Dim myRIXML As String = de.GetRoutedItems(GUID, UserID, ProjectID)

Retrieving Separator List for Project


In the following example, the Separators associated with the specified ProjectID are returned as a
serialized SeparatorCollection object.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim ProjectID As Long = 1
Dim mySeparatorXML As String = de.GetSeparators(GUID, ProjectID)

Retrieving the ID of the currently logged in User


In the following example, the UserID of the user currently logged in is returned.

77
FileBound 7 API Manual

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim UserID As Long = de.GetUserID(GUID)

Retrieving the FileBound Version


In the following example, the Version of the FileBound system is returned as a string.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim Version As String = de.GetVersion(GUID)

Retrieving the FileBound Version in XML


In the following example, the Version of the FileBound system is returned as XML data.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
Dim Version As String = de.GetVersionXML(GUID)

Logging In to and Out of FileBound


In the following example, the Login routine logs you into FileBond and returns a GUID that must be used
in subsequent calls. The Login routine logs you out and invalidates the GUID previously created on login.

Dim de As New WebService.DataExchange2


Dim GUID As String = de.Login("MyUserName", "MyPassword")
de.Logout(GUID)

78
FileBound 7 API Manual

FileBound Workflow Action Plug-in:


FileBound Workflow Action Plug-ins allows the ability to insert custom actions into the FileBound
Workflow system. After inserting a FileBound Action from NuGet into a Class Library Project, your
project should look like below.

Also, make sure to add the FileBound.dll reference to the project from NuGet. Below are a few key
elements to the Workflow Actions.

Inside the MyAction, there is the ConfigSave function, which will be used to take the UserControl and
save all the necessary properties.

public override bool ConfigSave(System.Windows.Forms.UserControl UC)


{
MyActionUC config = (MyActionUC)UC;
m_FieldNum = config.cb_Field.SelectedIndex + 1;
m_UpdateString = config.tx_UpdateStr.Text;
return true;
}

Along with this there is the ConfigScreen() function, this function is the actual function that opens the
User Control that will be used to configure the Action.

public override System.Windows.Forms.UserControl ConfigScreen()

79
FileBound 7 API Manual

{
//New custom User Control
MyActionUC config = new MyActionUC();
base.ValidateContext(ShortDescription);

//Make sure your Project's fields are filled, Context should already have
your current
Context.Project.Fields.Fill();
foreach (FileBound.Field f in Context.Project.Fields)
{
config.cb_Field.Items.Add(f.Name);
}

//Reset the combo box selection


if (m_FieldNum >= 1 & m_FieldNum <= 20)
{
config.cb_Field.SelectedIndex = m_FieldNum - 1;
}

//Reset the text box


config.tx_UpdateStr.Text = m_UpdateString;

return config;
}

The last main notable function is Execute(). This will be where the actual work is performed when
Workflow is processing.

public override FileBound.FBEnumerations.RoutingRuleResult Execute()


{
base.ValidateContext(ShortDescription);

if (Context.File == null)
{
throw new Exception("Action Error-Template Action: File is Null");
}

//Set the configured Field to the update string


Context.File.Field[m_FieldNum] = m_UpdateString;
return FileBound.FBEnumerations.RoutingRuleResult.Normal;

There are a few other items found in the Action, the first being Image16x16, which is used to return the
Bitmap Icon for the Custom Action. LongDescription will return a string that is intended to be the
summary of what the Action does while the ShortDescription will be the name of the Action displayed to
the users. Also, MyActionUC is the User Control that you will want to modify for your needs.

80
FileBound 7 API Manual

81

You might also like