Flixon Site Generator
Update: I have now created a new version which uses T4 as the template engine. Click here to download. Please note this requires the T4 Toolbox extension.
The site generator tool is designed to reduce the repetitive tasks when creating your own website. It generates a website based on a set of templates against a Microsoft SQL Server database.
The templates provided creates an asp.net (c#) website which uses the 3 layer architecture within the beer house starter kit. The templates can be fully customized using the template builder tool also provided within the download.
The tool makes full use of a well designed database. It creates a list page (using the GridView control), edit and insert pages (using the FormView control) and the business logic and database access layers for each table you specify. It also allows you to group your tables together into different providers.
Download Flixon Site Generator v1.0.
Database Restrictions (for best result)
- Tables should not have prefixes
- Columns should not have prefixes
- Primary and Foreign keys should end with “ID”
- The database should have relationships wherever possible
Instructions
- Open “Site Generator.exe”.
- Enter the namespace, database information for your website and the path to the templates.
- Specify the name for all your providers (you can have up to 16, if you want less then just leave some blank). Providers allow you to group your tables together.
- Specify the provider next to each table you wish to generate the code for (leave blank to ignore this table). Click “Finish” and specify the path where the files will be generated. This will then scans through the templates from the directory you specified and generates the appropriate files.
Templates
You can use the “Template Builder.exe” tool to create and modify templates. You can input your own c# code within templates by putting <% … %>. This allows you to create your own loops/variables within the template.
The program comes with a set of templates which uses the infrastructure within The BeerHouse Starter Kit (http://www.asp.net/downloads/starterkits/TheBeerHouse.aspx?tabid=62). However you can modify the templates to generate the infrastructure which suits your needs.
Files within the root of the templates directory are only generated once, files within the “Provider” directory are repeated for each provider and files within the “Table” directory are repeated for each table.
Template Paths
The “Template Builder” tool allows you to specify the path the file will be saved. Templates with the “Provider” directory can use the following tokens (which will be replaced by the appropriate names for each provider):
- #ProviderName#
- #ProviderNameLower# - First letter lower case, ie “Articles” becomes “articles”
Templates with the “Table” directory can use the following tokens (which will be replaced by the appropriate names for each table):
- #ProviderName#
- #ProviderNameLower# - First letter lower case, ie “Articles” becomes “articles”
- #TableName#
- #TableNameLower# - First letter lower case, ie “UserRoles” becomes “userRoles”
- #TableRowName# - Singular form of the table name, ie “UserRoles” becomes “UserRole”
- #TableRowNameLower# - Singular form of the table name (first letter lower case), ie “UserRoles” becomes “userRole”
Template Variables
If you explore the templates directory you will notice that templates have access to some default variables. The following variables are available to all templates:
- siteNamespace (string)
- connectionString (string)
- scriptStart (string) = “<%”
- scriptEnd (string) = “%>”
- providers (List<Provider>)
- tables (List<Table>)
The following variables are only available to templates with the “Provider” directory:
The following variables are only available to templates with the “Table” directory:
The “Provider” type has access to the following properties:
- ProviderName (string)
- ProviderNameLower (string) - First letter lower case, ie “Articles” becomes “articles”
- Tables (List<Table>) - A list of tables for the provider
The “Table” type has access to the following properties:
- TableName (string)
- TableNameLower (string) - First letter lower case, ie “UserRoles” becomes “userRoles”
- TableNameCaseSeperate (string) - Case seperated, ie “UserRoles” becomes “User Roles”
- TableRowName (string) - Singular form of the table name, ie “UserRoles” becomes “UserRole”
- TableRowNameLower (string) - Singular form of the table name (first letter lower case), ie “UserRoles” becomes “userRole”
- TableRowNameCaseSeperate (string) - Singular form of the table name (case seperated), ie “UserRoles” becomes “User Role”
- Provider (Provider) - The tables provider
- Columns (List<Column>) - A list of columns for the table
- PrimaryKey (Column)
- ForeignKeys (List<Column>)
The “Column” type has access to the following properties:
- ColumnName (string)
- ColumnNameLower (string) - First letter lower case, ie “FirstName” becomes “firstName”
- ColumnNameCaseSeperate (string) - Case seperated, ie “FirstName” becomes “First Name”
- Length (int)
- IsNullable (bool)
- DataType (string)
- DBDataType (string)
- DotNetDataType (string)
- IsPrimaryKey (bool)
- IsForeignKey (bool)
- PrimaryKey (Column)
- ForeignKeys (List<Column>)
- Table (Table) - The columns table
Notes
The templates provided uses the ajax control toolkit for date time fields in the database. It also has some paths to some images/style sheets. The “Temp” directory contains the additional files to get this to work. Simply copy these files across to your site and all is well.