Quick Start: Generate a .NET report application

Use the Business Application Modeler to generate a .NET report library, where the library feeds the report data from a database using SQL.

Before you begin, set the Report Writer environment. See Configure Genero Studio for C#.
This quick start takes you through the steps for creating a library, where the library code will create the data model in memory and fetch the data one record at a time, sending it to the Genero Report Engine before fetching the next record. The data is streamed as it is fetched, and only one record is held in memory at any time. In addition, a Report Launcher application is generated, allowing you to test your library from within the project. It is assumed that you will take the generated library and use it in your own bespoke applications.
  1. Create a new .NET project.
    1. Select File > New > C# > BAM C# Project (.4pw).
    2. Enter a name for your project in the Project name field.
      This name will become the name of the project workspace file.
    3. Specify the project directory in the Location field.
    4. Click OK.
      The project is created and saved in the selected project directory.

    Figure: The C# Project


    Screen shot of Projects view.

    The project is created, to include nodes for database-related files, the data source library files, and the report designs. A ReportLauncher application is created as well, allowing you to test your data source library from within the Genero Studio project.

  2. Add your database meta-schema (.4db) file under the Database node in the project tree, and save your changes.
    If you need to create the database schema (.4db) file, see Create the database meta-schema file.
    1. Right-click on the Database node and select Add Files.
    2. Select the meta-schema (.4db) file and click Open.

    Figure: Adding the database schema


    Screen shot showing updated Projects view and the officestore database diagram arranged in the work area.
  3. Configure the database meta-schema.
    In most cases, the database meta-schema will have been created with the tables set to Active and the primary keys defined.
    1. Open the .4db file.
    2. Set the table property for each table you will include to Active.
      Tip: To easily set multiple tables as active, hold down the CTRL key as you select the tables in the Database Structure view, then check the Active property.
    3. Define a primary key for each table. See Add constraints or indexes.
    4. Save the changes to your data schema.
  4. Create the data source (.4rdj) file.
    For this quick start, you will select a single table. Most reporting, however, will involve multiple tables and their relation. See Create a report with BAM for details on creating more complex data sources.
    1. Select File > New > C# > C# Report Data from Database (.4rdj), and click OK.
    2. In the Column selection page, select columns from a single table to include in the record.
      The record defines the data that will stream, one record at a time, to the report engine.
      Click Next > to continue.
    3. In the Query Creation page, one typically sets the Join, Where and Order by criteria for the data source. As only a single table was selected, this page can be skipped.
    4. Click Finish.
      A record is created and displayed in a .4rdj tab.
    5. Select File >> Save as and save the .4rdj file, adding the file to the DataSourceLib library node.
      Important: Check the directory before saving your file! It is recommended that you save the file in $(ProjectDir)/src.
      Selecting the right name in this step is important; the name of the .4rdj file becomes the name of the C# source, which ultimately becomes the name of the C# class.
    6. Save the changes to your project.

    Figure: Project with data model added


    Screen shot showing project and data model record.
  5. Generate the code and the data schema.
    1. Right-click the DataSourceLib library node and select Build.
      The DataSourceLib library node is the node containing the data source (.4rdj) file.
      The report library source and the data schema (.xsd) files are created and listed in the Intermediate Files folder. The location of these intermediate files is determined by the setting of the Target directory property.
  6. Create a report design from a template.
    For this quick start, we are going to use a template to create a simple, non-grouped list report. For more information on using report templates, see Create and manage report templates.
    1. Select File >> New, Report from Template.
    2. Select Simple List (PULSE). Click OK.
    3. In the Schema location field, select the schema created in the previous step.
      The rows field populates for you with the record name. Complete the Repetitions section, mapping the template repetitions to the schema repetitions. Click Next >.
    4. Add several fields from the Available Fields column to the Selected Fields column. Click Next >.
    5. On the Variables page, modify the title placeholder to state "My Report". Click Finish.
      The report is created.
    6. Select File >> Save untitled.4rp as... and save the file in the $ProjectDir/src directory, and in the Designs node.

    Figure: Report added to project


    Project view with report added.
  7. Right-click on the ReportLauncher node and select Rebuild.
  8. Run the Report Launcher application.
    1. Right-click the Report Launcher node and select Execute.
    2. In the Assembly field, select the DataSourceLib.dll file to use for this run of the ReportLauncher application. If your library is not listed, click the Add button to locate and add your report.
      The Assembly field lists your data source library. The Class combobox populates with possible classes to use.
    3. In the Class field, select the name of the class to use as the data model.
      If you have followed these quick start instructions, there will only be a single class to select from. It is possible, however, to have multiple classes in your library.
    4. In the Report field, select the report to run from the combobox. If your report is not listed, click the Add button to locate and add your report.
    5. Click Run.
      The report displays. We did not take the time to properly specify all the placeholders, or to verify the report row lengths, so the report may have some formatting issues, however it should display and be populated with data.