//------------------------------------------------------------- // 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();
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(“
评论
共有 条评论