资源简介

可以连接oracle的CodeSmith自动生成代码工具,需要安装CodeSmith及数据库客户端。可以自动生成实体类及数据库操作层代码,方便快捷。

资源截图

代码片段和文件信息

//-------------------------------------------------------------
// CodeSmith DBDocumenter Templates v3.0
// Author:  Jason Alexander (jalexander@telligent.com) Eric J. Smith
//-------------------------------------------------------------

using System;
using System.IO;
using System.Data;
using System.Data.SqlClient;
using System.ComponentModel;
using System.ComponentModel.Design;
using CodeSmith.Engine;
using SchemaExplorer;

public class DBDocumenterTemplate : CodeTemplate
{
// Number of columns that should be displayed on the summary lists.
public const int NUM_OF_COLUMNS = 3;

private string _outputDirectory = String.Empty;

public DBDocumenterTemplate() : base()
{
}
  
[Editor(typeof(System.Windows.Forms.Design.FolderNameEditor) typeof(System.Drawing.Design.UITypeEditor))] 
[Optional]
[Category(“Output“)]
[Description(“The directory to output the results to.“)]
public string OutputDirectory 
{
get
{
// default to the directory that the template is located in
if (_outputDirectory.Length == 0) return this.CodeTemplateInfo.DirectoryName + “output\\“;

return _outputDirectory;
}
set
{
if (!value.EndsWith(“\\“)) value += “\\“;
_outputDirectory = value;

}

public void OutputTemplate(CodeTemplate template)
{
this.CopyPropertiesTo(template);
template.Render(this.Response);
}

public SqlDataReader GetSystemInformation(string connectionString)
{
SqlConnection cn = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand();

cmd.Connection = cn;
cmd.CommandText = “master.dbo.xp_msver“;
cmd.CommandType = CommandType.StoredProcedure;

cn.Open();
SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);

return reader;
}

public void OutputExceptionInformation(Exception exception int indentLevel)
{
int originalIndentLevel = Response.IndentLevel;
Response.IndentLevel = indentLevel;
Response.WriteLine(““);
Response.WriteLine(““);
Response.WriteLine(“ “);
Response.WriteLine(“ “);
Response.WriteLine(“ An exception occurred while attempting to execute the template:“ );
Response.WriteLine(“ “ + exception.Message);
Response.WriteLine(“ “);
Response.WriteLine(“ “);
Response.WriteLine(““);
Response.WriteLine(““);
Response.IndentLevel = originalIndentLevel;
}

public void OutputSystemInformation(string connectionString int indentLevel)
{
SqlDataReader info = null;

try
{
info = this.GetSystemInformation(connectionString);

int originalIndentLevel = Response.IndentLevel;
Response.IndentLevel = indentLevel;
Response.WriteLine(““);

while (info.Read())
{
Response.WriteLine(““);
Response.WriteLine(“  “);
Response.WriteLine(“ “);

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      18004  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\Bll\aa

     文件      14575  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\Bll\DBMad.BLL.cst

     文件        524  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\Bll\DBMad.DAL.csp

     文件      29948  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\Bll\DBMad.DAL.cst

     文件      13830  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\Bll\DBMad.Models.cst

     文件      13128  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\CodeGenerator.cst

     文件      10624  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\ActiproSoftware.SQL.xml

     文件        455  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\Database.csp

     文件       4929  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\DBDocumenterTemplate.cs

     文件       1052  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\footer.cst

     文件       1426  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\general.cst

     文件       2586  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\header.cst

     文件       4636  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\master.cst

     文件       2212  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\output\dbdocs.css

     文件       1037  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\output\images\arrow.gif

     文件        881  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\output\images\check_icon.gif

     文件        904  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\output\images\database_icon.gif

     文件        910  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\output\images\folder_icon.gif

     文件        909  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\output\images\key_icon.gif

     文件       1530  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\output\images\server.gif

     文件        928  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\output\images\server_icon.gif

     文件        920  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\output\images\stored_proc_icon.gif

     文件        900  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\output\images\tables_icon.gif

     文件        857  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\output\images\unchecked_icon.gif

     文件        884  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\output\images\views_icon.gif

     文件       6613  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\output\index.html

     文件       1805  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\output\sprocs.html

     文件       2304  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\output\sproc_0.html

     文件       2149  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\output\sproc_1.html

     文件       1574  2012-08-14 09:27  三层构架的CodeSmith模板--oracle--修改后\DBDocumenter\output\sproc_2.html

............此处省略119个文件信息

评论

共有 条评论