Home Evaluation Summary for programmers Product limitations Goals of Axisbase Quick start Installation Using the launchpad and opening databases Connecting to a sample database Using building blocks Planning Define the purpose Define the requirements Borrow existing work Determine the architecture Design the data model Design the process model Deploy and maintain the product
building blocksPerforming a mailmerge Bulk e-mailing
ProgrammingSingle-threaded progress indicator in c#
Database menu itemsImport XML Save Copy As Integrity Check Change Password
Database Properties windowOpening the database properties window Record types tab Display types tab Roles and Users tabs Sidebar tab Database ID/Links tab Counters tab
Building blocksBuilding blocks window Editing grids and cells Hyperlinks and nesting Data Subset window Data Outsource window List window Window window Report window Bulk Operation window Label Printer window Choosing a data source
Special topicsExpression syntax Browse records Storing building blocks within other building blocks Programming Using custom code in building blocks Using Axisbase as an embedded database Axis1.Util namespace reference Axis1.Data namespace reference (Fishnets) Axis1.Data namespace reference (other) Axis1.Forms namespace reference
Using custom code in building blocks
There are several things you can do within building blocks with custom code. The basic idea behind custom code in Axisbase is to leverage the Axisbase functionality rather than re-writing an entire application in custom code. This page describes how to plug custom code into building blocks that are used in the Axisbase client.
Please download the sample database with external code from www.divergentlabs.org (go to Downloads area). In the rest of this page, "sample database" refers to this database, and "sample code" refers to the code that is included with that download.
All c# code is in code building blocks. From the Building blocks window, choose Create>Code. Code building blocks are referenced from several other types of building blocks that allow customization, namely data outsources, bulk operations, display types, and user-defined building blocks. Code building blocks don't do anything by themselves; they are just points of reference for custom code.
You have two options for how to include code in a database: Link to assembly, or paste in source code. You only use one of these two methods, not both, for a particular code building block.
Generally speaking, the source code method should be used for small bits of code, and saves you the trouble of the extra assembly file. If your external code is long or has multiple classes, use the external assembly.
Outsource from code
When you have a situation where you want custom code to create data or get it from a custom source, you can hook up a data outsource building block to a code building block. You can use the results of the data outsource in a list, report, bulk operation, or data subset. You can even use a data subset to combine data from a custom outsource with data from within the database.
With this functionality, Axisbase can be used to view lists, print mailing labels, or print reports from any source.
In the sample database, the list "show data from code" demonstrates this feature. Let's walk through each feature starting from the custom code:
The class AxDataSet derives from DataSet. If you follow the example in Axis1.SampleCode, you can create an AxDataSet and AxDataTable as shown in that example. If you obtain a System.Data.DataSet from some other source, such as another database, you can then create an AxDataSet and use DataSet.Merge to copy the rows from your System.Data.DataSet into the AxDataSet.
User defined bulk operation step
When you have a situation where you have a data set, and you want to do some custom processing with it that Axisbase doesn't support, you can create a user-defined process step inside a bulk operation building block, and link that step to custom code.
In the sample database, the bulk operation "bulk op with code" demonstrates this feature. Let's walk through each feature starting from the custom code:
User defined display type
When you have a situation where you want to display a custom control to edit and display a cell within a list, you can create a user defined display type for this purpose. How you might use this is up to your imagination; the main limitation to keep in mind is that the underlying data type must be one of the built in types. You are only able to change the way the value is displayed and edited.
In the sample database, the list "use custom display type" demonstrates this feature, by showing an integer value as a horizontal bar, and using a scrollbar control for editing the value. Let's walk through each feature starting from the custom code:
Note that you could define the display type at the database level, rather than within the list building block. To do this, go to the database Properties window, Display Types tab. Create the custom display type there. Then go to the Record Types tab, open the type "task", and open the property "percentcomplete". In the property definition window, select the display type you just created. Once you do this, then ever list that shows the percentcomplete property will use the custom display type by default.
User defined window
When you have a situation where you need a completely custom window to be shown within Axisbase, use a user-defined building block invoked in its own window. This is a very open-ended way to plug in functionality. Your window can contain any controls and do virtually anything.
In the sample database, the block "graph" demonstrates this feature, by showing a graph using the external code library ZedGraph, based on data in the database. Let's walk through each feature starting from the custom code:
User defined cell
When you have a situation where you need custom control over painting a single cell within a list or window, use a user-defined building block invoked as a cell. This is the most complicated of all the ways of using external code. It has some points in common with the user-defined window (above).
You can use this to embed custom interactive controls within windows, or paint arbitrary images or graphs within lists. You can also paint based on detail data, so that within a list, the image displayed for each master row is based on the child rows related to that master row.
There are three separate contexts that a user-defined cell may be used, and you can choose to implement any one of these, or all three. The three contexts are (1) a top-level interactive control, such as in a window building block; (2) a top-level painted image, with no interaction; and (3) a painted image nested in a list.
In the sample database, the block "graph" demonstrates all three contexts, by showing a graph using the external code library ZedGraph, based on data in the database. Let's walk through each feature starting from the custom code:
Now let's examine how this actually works in each of the three contexts: