HOME
User:
Anonymous
search for
in
Template Archives
Templates
Articles
Users
Login
Username:
Password:
Navigation
Registered User Functions:
Register New Account
Anonymous Functions:
Home
Users
Archives
Templates
Articles
MyGeneration Website
MyGeneration Forums
Categories
Application Type
Command Line
Graphical User Interface
Library
Sample
Web Application
Architecture Type
Client-Server
Distributed Computing
Multi-Tier
Peer-to-peer
Operating System
Linux
Win32
Programming Language
ASP
ASP.Net
C#
C++
Firebird SQL
J#
Java
Jet SQL
JScript
JSP
MySQL
Perl
PHP
PL/SQL
PostgreSQL
SQL
Transact-SQL
VB.Net
VBScript
XSLT
Template: EasyObjects 2 C# Concrete Class
Download Count:
6706
View Count:
2247
Template Properties
Unique ID:
acfece14-1cfa-45cc-99af-0c09fbc8daff
Title:
EasyObjects 2 C# Concrete Class
Namespace:
EasyObject.C#
Output Language:
C#
Mode:
Markup
Start Tag:
<%
End Tag:
%>
Template Body
Engine:
Microsoft Script
Language:
VBScript
<% '------------------------------------------------------------------------------ ' Copyright 2005 by Noonan Consulting Inc. ' All Rights Reserved ' ' Permission to use, copy, modify, and distribute this software and its ' documentation for any purpose and without fee is hereby granted, ' provided that the above copyright notice appear in all copies and that ' both that copyright notice and this permission notice appear in ' supporting documentation. ' ' NCI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS ' SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY ' AND FITNESS, IN NO EVENT SHALL NCI BE LIABLE FOR ANY ' SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ' WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, ' WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER ' TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE ' OR PERFORMANCE OF THIS SOFTWARE. '------------------------------------------------------------------------------ ' CSharp_SQL_EasyObject_ConcreteClass.vbgen ' Last Update : 12/26/2006 '------------------------------------------------------------------------------ If context.Objects.ContainsKey("DnpUtils") Then DnpUtils.SaveInputToCache(context) End if Dim objTable Dim objColumn Dim tableNames Dim namespace Dim databaseName Dim strFilename Dim strFilenameBase Dim bOtherColumns ' Save the output file for this Table strFilenameBase = input.Item("txtPath") intLen = Len(strFilenameBase) intPos = InStrRev(strFilenameBase, "\") If Not intPos = intLen Then strFilenameBase = strFilenameBase & "\" End If ' Grab the namespace namespace = input.Item("txtNamespace") databaseName = input.Item("cmbDatabase") Set database = MyMeta.Databases(databaseName) ' Set the Language for our column data types MyMeta.Language = "C#" ' Grab the choices the user made in our UI Script (see Interface Code tab) Set tableNames = input.Item("lstTables") ' Set the default command type commandType = "CommandType.StoredProcedure" If input.Item("chkQueryType") Then commandType = "CommandType.Text" ' Loop through the tables the user selected and generate the business entities For intLp = 0 To tableNames.Count - 1 Set objTable = database.Tables(tablenames.item(intLp)) bOtherColumns = (objTable.Columns.Count > objTable.PrimaryKeys.Count) %> // Generated by MyGeneration Version # (<%= input.Item("__version") %>) using System; using System.Data; using System.Data.Common; namespace <%= TrimSpaces(namespace) %> { public class <%= TrimSpaces(objTable.Alias) %> : <%= "_" & TrimSpaces(objTable.Alias) %> { public <%= TrimSpaces(objTable.Alias) %>() { this.DefaultCommandType = <%= commandType %>; <% output.tabLevel = 3 If Len(Trim(input.Item("txtDatabase"))) > 0 Then output.autoTabLn Replace("this.DatabaseInstanceName = ""{0}"";", "{0}", Trim(input.Item("txtDatabase"))) End If If Len(Trim(input.Item("txtDynamicQuery"))) > 0 Then output.autoTabLn Replace("this.DynamicQueryInstanceName = ""{0}"";", "{0}", Trim(input.Item("txtDynamicQuery"))) End If %> } // Place your custom code here. } } <% ' Save the output file for this Table strFilename = strFilenameBase & TrimSpaces(objTable.Alias) & ".cs" output.save strFilename, False strBuffer = strBuffer & output.text output.clear Next ' tableName If tableNames.Count > 1 Then output.write "// Files created in the output directory" Else output.write strBuffer End If Function GetAlias(objColumn) Dim name name = TrimSpaces(objColumn.Alias) GetAlias = UCase(Left(name, 1)) & Right(name, Len(name) -1) End Function Function GetName(objColumn) Dim name name = objColumn.Name GetName = UCase(Left(name, 1)) & Right(name, Len(name) -1) End Function Function TrimSpaces(str) Dim tname Dim name Dim char Dim l name = "" tname = str l = Len(tname) For j = 1 To l char = Mid(tname, j, 1) If Not char = " " Then name = name & char End If Next TrimSpaces = name End Function %>
Dynamic Interface:
Engine:
Microsoft Script
Language:
VBScript
Dim cmbDatabases Dim lstTables Dim chk Sub setup() If context.Objects.ContainsKey("DnpUtils") Then DnpUtils.ReadInputFromCache(context) End if ui.Title = "Generate C# EasyObject Concrete Class" ui.Width = 330 ui.Height = 560 ui.BackColor = "wheat" ' Grab default output path Dim sOutputPath sOutputPath = "" If input.Contains("defaultOutputPath") Then sOutputPath = input.Item("defaultOutputPath") End If ui.AddLabel "lblPath", "Output file path: ", "Select the output path." ui.AddTextBox "txtPath", sOutputPath, "Select the Output Path." ui.AddFilePicker "btnPath", "Select Path", "Select the Output Path.", "txtPath", true ui.AddLabel "lblNamespace", "Namespace: ", "Provide your objects namespace." ui.AddTextBox "txtNamespace", "Your.Namespace", "Provide your objects namespace." ' List Databases in a ComboBox ui.AddLabel "lblDatabases", "Select a database:", "Select a database in the dropdown below." Set cmbDatabases = ui.AddComboBox("cmbDatabase", "Select a database.") ' List Tables in a listbox ui.AddLabel "lblTables", "Select tables:", "Select tables from the listbox below." Set lstTables = ui.AddListBox ("lstTables", "Select tables:") 'lstTables.IsMultiSelect = false lstTables.Height = 120 ' Attach the onchange event to the cmbDatabases control. setupDatabaseDropdown cmbDatabases cmbDatabases.AttachEvent "onchange", "cmbDatabases_onchange" ' Database instance ui.AddLabel "lblDatabase", "Database instance: (leave blank for default)", "Select the database instance name." ui.AddTextBox "txtDatabase", "", "Override the default database instance." ' Dynamic query instance ui.AddLabel "lblDynamicQuery", "Dynamic Query instance: (leave blank for default)", "Select the dynamic query instance name." ui.AddTextBox "txtDynamicQuery", "", "Override the default dynamic query instance." ' Dynamic query default ui.AddCheckBox "chkQueryType", "Use Dynamic Queries", false, "If checked, use dynamic queries instead of stored procedures" ui.ShowGUI = true End Sub Sub setupDatabaseDropdown(cmbDatabases) cmbDatabases.BindData MyMeta.Databases If Not MyMeta.DefaultDatabase Is Nothing Then cmbDatabases.SelectedValue = MyMeta.DefaultDatabase.Name bindTables cmbDatabases.SelectedValue End If End Sub Sub bindTables(sDatabase) Set db = MyMeta.Databases(sDatabase) lstTables.BindData(db.Tables) End Sub ' Event Handler Sub cmbDatabases_onchange(control) Set cmbDatabases = ui.item("cmbDatabase") bindTables cmbDatabases.SelectedText End Sub
Copyright © 2004 MyGeneration Software. All rights reserved.
Feedback:
feedback@mygenerationsoftware.com
Support:
support@mygenerationsoftware.com