iCodegenerator

iCodegenerator is a database centric template based code generator for any programming language like C, PHP, C#, Visual Basic, Java, Perl, Python... Supported databases are SQL Server, MySQL and PostgreSQL.

Download / Source Code

Download v2.1

github

git clone https://github.com/VientoDigital/codegenerator.git

 Source Code

Documentation

...

General View

Initial view of the iCodegenerator.

...

Database Connection

SQL Server, MySQL, Postgres & Oracle.

...

Custom Values

Special defined tags.

...

Snippets

Snippets of the tags available to use on a template.

Syntax

  • Database

    • {DATABASE.NAME}
      Returns the database name.
  • Table

    • {TABLE.NAME}
      Returns the table name.
    • {TABLE.SCHEMA}
      Returns the table schema.
    • {TABLE.COLUMNS}...{/TABLE.COLUMNS}
      Its a placeholder for the Column tags. Which can have the attributes of PRIMARY, NOPRIMARY or ALL (default) to filter which columns to process.
  • Columns

    • {COLUMN.TYPE}
      Returns the column type.
    • {COLUMN.DEFAULT}
      Returns the column default value.
    • {COLUMN.NAME}
      Returns the column name.
    • {COLUMN.LENGTH}
      Returns the column length
    • {MAP COLUMN.TYPE}
      Returns the mapping value to the column type defined in the config file: DataTypeMapping.xml.
  • Conditional Statements

    • {IF NOT COLUMN.NULLABLE}{/IF}
      Condition to test if column is nullable or not.
    • {IF COLUMN.TYPE EQ ‘int’}{/IF}
      Condition to test if column equals a SQL type.
    • {IF COLUMN.NAME =~ ‘Id’}{/IF}
      Condition to test if the name of the column contains a string.
    • {IF NOT LAST},{/IF}
      Condition to test if it is the last column.
  • Custom

    • {NAME_OF_YOUR_TAG}
      Custom Values are Key/Value Pairs that you can define to use on a template.

Example: Bootstrap Form

                      <!DOCTYPE html>
                      <html>
                      <head>
                      <title>iCodegenerator- {DATABASE.NAME}</title>
                      <meta name="viewport" content="width=device-width, initial-scale=1.0">
                      <!-- Bootstrap -->
                      <link href="css/bootstrap.min.css" rel="stylesheet">
                      </head>
                      <body>
                      <h1>{TABLE.NAME}</h1>

                      <form role="form">
                      {TABLE.COLUMNS}
                      <div class="form-group">
                      <label for="{COLUMN.NAME}">{COLUMN.NAME HUMAN}</label>
                      <input type="text" class="form-control" id="{COLUMN.NAME}" placeholder="{COLUMN.NAME HUMAN}">
                      </div>{/TABLE.COLUMNS}
                      <button type="submit" class="btn btn-default">Submit</button>
                      </form>
                      <script src="https://code.jquery.com/jquery.js"></script>
                      <script src="js/bootstrap.min.js"></script>
                      </body>
                      </html>
                    
                      <!DOCTYPE html>
                      <html>
                      <head>
                      <title>iCodegenerator- yrasesoras3_pruebas</title>
                      <meta name="viewport" content="width=device-width, initial-scale=1.0">
                      <!-- Bootstrap -->
                      <link href="css/bootstrap.min.css" rel="stylesheet">
                      </head>
                      <body>
                      <h1>Users</h1>

                      <form role="form">

                      <div class="form-group">
                      <label for="Id">Id</label>
                      <input type="text" class="form-control" id="Id" placeholder="Id">
                      </div>
                      <div class="form-group">
                      <label for="Fullname">Fullname</label>
                      <input type="text" class="form-control" id="Fullname" placeholder="Fullname">
                      </div>
                      <div class="form-group">
                      <label for="Email">Email</label>
                      <input type="text" class="form-control" id="Email" placeholder="Email">
                      </div>
                      <div class="form-group">
                      <label for="Username">Username</label>
                      <input type="text" class="form-control" id="Username" placeholder="Username">
                      </div>
                      <div class="form-group">
                      <label for="Password">Password</label>
                      <input type="text" class="form-control" id="Password" placeholder="Password">
                      </div>
                      <div class="form-group">
                      <label for="Active">Active</label>
                      <input type="text" class="form-control" id="Active" placeholder="Active">
                      </div>
                      <div class="form-group">
                      <label for="DateCreated">Date Created</label>
                      <input type="text" class="form-control" id="DateCreated" placeholder="Date Created">
                      </div>
                      <div class="form-group">
                      <label for="DateModified">Date Modified</label>
                      <input type="text" class="form-control" id="DateModified" placeholder="Date Modified">
                      </div>
                      <div class="form-group">
                      <label for="Impersonate">Impersonate</label>
                      <input type="text" class="form-control" id="Impersonate" placeholder="Impersonate">
                      </div>
                      <button type="submit" class="btn btn-default">Submit</button>
                      </form>
                      <script src="https://code.jquery.com/jquery.js"></script>
                      <script src="js/bootstrap.min.js"></script>
                      </body>
                      </html>
                    

Example: SQL Server Update Stored Procedure

                      CREATE PROCEDURE [{TABLE.SCHEMA}].[{CLASS}_Update]
                      (  
                      {TABLE.COLUMNS} @{COLUMN.NAME} {COLUMN.TYPE}{IF COLUMN.TYPE EQ 'varchar|nvarchar'}({COLUMN.LENGTH}){/IF}{IF COLUMN.NULLABLE} = NULL{/IF}{IF NOT LAST},{/IF}
                      {/TABLE.COLUMNS})
                      AS  

                      UPDATE [{TABLE.SCHEMA}].[{TABLE.NAME}] SET 
                      {TABLE.COLUMNS NOPRIMARY} {COLUMN.NAME} = @{COLUMN.NAME}{IF NOT LAST},{/IF}
                      {/TABLE.COLUMNS}
                      WHERE {TABLE.COLUMNS PRIMARY}{COLUMN.NAME}= @{COLUMN.NAME}{/TABLE.COLUMNS}
                      GO
                    
                      CREATE PROCEDURE [Viento].[Log_Update]
                      (  
                      @Id bigint,
                      @Clasification varchar(50),
                      @Keyname varchar(50),
                      @Description text,
                      @LogType varchar(50),
                      @DateCreated datetime,
                      @Username varchar(50))
                      AS  

                      UPDATE [Viento].[Logs] SET 
                      Clasification = @Clasification,
                      Keyname = @Keyname,
                      Description = @Description,
                      LogType = @LogType,
                      DateCreated = @DateCreated,
                      Username = @Username
                      WHERE Id= @Id
                      GO

                    
Tutorials

About iCodegenerator

Language: English
Programming Language: C#
Framework: Microsoft.NET 4.0
Operating System: Microsoft Windows
Intented Audience: Developers, Educational, Information Technology
License: GNU General Public License, version 2

Components & Libraries used

Educational

For educational purposes, the following were the design patterns used and where you can find its use.