(2012-04-27)
This commit is contained in:
Binary file not shown.
120
ServerExplorer/ServerExplorer/CodeGen.cs
Normal file
120
ServerExplorer/ServerExplorer/CodeGen.cs
Normal file
@@ -0,0 +1,120 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace ServerExplorer
|
||||
{
|
||||
public class CodeGen
|
||||
{
|
||||
public static Boolean GenerarCodigo(CodeGenConfig config,DatabaseDesc database)
|
||||
{
|
||||
// Asegura la existencia de los directorios destinos
|
||||
if (!System.IO.Directory.Exists(config.PathDTO)) { Utiles.CrearDirectorio(config.PathDTO); }
|
||||
if (!System.IO.Directory.Exists(config.PathDAL)) { Utiles.CrearDirectorio(config.PathDAL); }
|
||||
if (!System.IO.Directory.Exists(config.PathExtra)) { Utiles.CrearDirectorio(config.PathExtra); }
|
||||
|
||||
// Itera por cada tabla para crear sus DTOs
|
||||
foreach (TablaDesc t in database.Tablas)
|
||||
{
|
||||
string nombreObj = t.Esquema + t.Nombre;
|
||||
string nombreFichero = config.PathDTO + "/" + nombreObj + "_DTO.cs";
|
||||
EscritorCodigo escritor = new EscritorCodigo(nombreFichero);
|
||||
|
||||
// Cabecera.
|
||||
escritor.Escribe("using System;");
|
||||
escritor.Escribe("using System.Data;");
|
||||
escritor.Escribe("");
|
||||
escritor.EscribeInd("namespace namespace");
|
||||
|
||||
// El objeto de la tabla.
|
||||
escritor.EscribeInd("public partial class " + nombreObj);
|
||||
foreach(ColumnaDesc c in t.Columnas){
|
||||
// El atributo privado para cada columna.
|
||||
escritor.Escribe("private Object " + "_" + c.Nombre + ";");
|
||||
|
||||
// La propiedad publica para cada columna.
|
||||
escritor.EscribeInd("public Object " + c.Nombre );
|
||||
escritor.EscribeInd("get");
|
||||
escritor.Escribe("return _" + c.Nombre + ";");
|
||||
escritor.DeInd();
|
||||
escritor.EscribeInd("set");
|
||||
escritor.Escribe("_" + c.Nombre + " = value;");
|
||||
escritor.DeInd();
|
||||
escritor.DeInd();
|
||||
escritor.Escribe("");
|
||||
}
|
||||
escritor.DeInd();
|
||||
|
||||
// El Pie
|
||||
escritor.DeInd();
|
||||
|
||||
// Cerrar ficheros.
|
||||
escritor.Cerrar();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private class Indentado
|
||||
{
|
||||
private int indentado = 0;
|
||||
private StringBuilder sb = new StringBuilder();
|
||||
|
||||
public void Inc()
|
||||
{
|
||||
indentado++;
|
||||
}
|
||||
public void Dec()
|
||||
{
|
||||
indentado--;
|
||||
if (indentado < 0)
|
||||
{
|
||||
indentado = 0;
|
||||
}
|
||||
}
|
||||
public string Str()
|
||||
{
|
||||
sb.Remove(0, sb.Length);
|
||||
for (int i=0; i < indentado; i++)
|
||||
{
|
||||
sb.Append("\t");
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private class EscritorCodigo
|
||||
{
|
||||
StreamWriter escritor;
|
||||
Indentado indentado;
|
||||
|
||||
public EscritorCodigo(string nombreFichero)
|
||||
{
|
||||
escritor = new StreamWriter(nombreFichero);
|
||||
indentado = new Indentado();
|
||||
}
|
||||
public void Cerrar()
|
||||
{
|
||||
escritor.Close();
|
||||
}
|
||||
|
||||
public void Escribe(String str)
|
||||
{
|
||||
escritor.WriteLine(indentado.Str() + str);
|
||||
}
|
||||
public void EscribeInd(String str)
|
||||
{
|
||||
escritor.WriteLine(indentado.Str() + str);
|
||||
escritor.WriteLine(indentado.Str() + "{");
|
||||
indentado.Inc();
|
||||
}
|
||||
public void DeInd()
|
||||
{
|
||||
indentado.Dec();
|
||||
escritor.WriteLine(indentado.Str() + "}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,25 +8,24 @@ namespace ServerExplorer
|
||||
public class CodeGenConfig
|
||||
{
|
||||
public String ConString = "";
|
||||
public String PathRaiz="";
|
||||
public String PathDAL="";
|
||||
public String PathDTO="";
|
||||
public String PathExtra="";
|
||||
public String PathRaiz=".";
|
||||
public String PathDAL=".";
|
||||
public String PathDTO=".";
|
||||
public String PathExtra=".";
|
||||
public List<CodeGenTablaInfo> Tablas = new List<CodeGenTablaInfo>();
|
||||
|
||||
public CodeGenConfig() { }
|
||||
|
||||
public void Guardar(String fichero){
|
||||
Type[] tipos={typeof(CodeGenTablaInfo)};
|
||||
XmlSerializer seriador = new XmlSerializer(typeof(CodeGenConfig), tipos);
|
||||
public void Guardar(String fichero)
|
||||
{
|
||||
XmlSerializer seriador = new XmlSerializer(typeof(CodeGenConfig));
|
||||
StreamWriter escritor = new StreamWriter(fichero);
|
||||
seriador.Serialize(escritor, this);
|
||||
}
|
||||
|
||||
public static CodeGenConfig Cargar(String fichero)
|
||||
{
|
||||
Type[] tipos = { typeof(CodeGenTablaInfo) };
|
||||
XmlSerializer seriador = new XmlSerializer(typeof(CodeGenConfig), tipos);
|
||||
XmlSerializer seriador = new XmlSerializer(typeof(CodeGenConfig));
|
||||
StreamReader lector = new StreamReader(fichero);
|
||||
CodeGenConfig config = (CodeGenConfig)seriador.Deserialize(lector);
|
||||
return config;
|
||||
@@ -46,4 +45,5 @@ namespace ServerExplorer
|
||||
Nombre = nombre;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
21
ServerExplorer/ServerExplorer/DatabaseDesc.cs
Normal file
21
ServerExplorer/ServerExplorer/DatabaseDesc.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ServerExplorer
|
||||
{
|
||||
public class DatabaseDesc
|
||||
{
|
||||
public string Nombre = "";
|
||||
public List<TablaDesc> Tablas = new List<TablaDesc>();
|
||||
|
||||
public DatabaseDesc() { }
|
||||
|
||||
public DatabaseDesc(string nombre)
|
||||
{
|
||||
Nombre = nombre;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,9 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CodeGen.cs" />
|
||||
<Compile Include="CodeGenConfig.cs" />
|
||||
<Compile Include="DatabaseDesc.cs" />
|
||||
<Compile Include="frmBaseDatos.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -81,6 +83,12 @@
|
||||
<Compile Include="frmCodeGenConfig.Designer.cs">
|
||||
<DependentUpon>frmCodeGenConfig.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="frmDatos.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="frmDatos.Designer.cs">
|
||||
<DependentUpon>frmDatos.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="frmPrincipal.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -96,12 +104,16 @@
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TablaDesc.cs" />
|
||||
<Compile Include="Utiles.cs" />
|
||||
<EmbeddedResource Include="frmBaseDatos.resx">
|
||||
<DependentUpon>frmBaseDatos.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="frmCodeGenConfig.resx">
|
||||
<DependentUpon>frmCodeGenConfig.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="frmDatos.resx">
|
||||
<DependentUpon>frmDatos.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="frmPrincipal.resx">
|
||||
<DependentUpon>frmPrincipal.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
||||
30
ServerExplorer/ServerExplorer/Utiles.cs
Normal file
30
ServerExplorer/ServerExplorer/Utiles.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace ServerExplorer
|
||||
{
|
||||
public static class Utiles
|
||||
{
|
||||
public static void CrearDirectorio(this String path)
|
||||
{
|
||||
DirectoryInfo info=null;
|
||||
try
|
||||
{
|
||||
info = new DirectoryInfo(path);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
info = new DirectoryInfo(".");
|
||||
}
|
||||
CrearDirectorio(info);
|
||||
}
|
||||
public static void CrearDirectorio(this DirectoryInfo info)
|
||||
{
|
||||
if (info.Parent != null) CrearDirectorio(info.Parent);
|
||||
if (!info.Exists) info.Create();
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -46,23 +46,26 @@
|
||||
this.menuGuardar = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuConfiguracion = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.btnGenerar = new System.Windows.Forms.Button();
|
||||
this.btnVerDatos = new System.Windows.Forms.Button();
|
||||
this.lblTituloTabla = new System.Windows.Forms.Label();
|
||||
this.lblTituloDB = new System.Windows.Forms.Label();
|
||||
this.menuBaseDatos.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// txtConString
|
||||
//
|
||||
this.txtConString.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.txtConString.Location = new System.Drawing.Point(123, 33);
|
||||
this.txtConString.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.txtConString.Location = new System.Drawing.Point(120, 6);
|
||||
this.txtConString.Name = "txtConString";
|
||||
this.txtConString.ReadOnly = true;
|
||||
this.txtConString.Size = new System.Drawing.Size(507, 20);
|
||||
this.txtConString.Size = new System.Drawing.Size(510, 20);
|
||||
this.txtConString.TabIndex = 0;
|
||||
//
|
||||
// lblConString
|
||||
//
|
||||
this.lblConString.AutoSize = true;
|
||||
this.lblConString.Location = new System.Drawing.Point(12, 36);
|
||||
this.lblConString.Location = new System.Drawing.Point(9, 9);
|
||||
this.lblConString.Name = "lblConString";
|
||||
this.lblConString.Size = new System.Drawing.Size(105, 13);
|
||||
this.lblConString.TabIndex = 1;
|
||||
@@ -71,7 +74,7 @@
|
||||
// btnCopiarConString
|
||||
//
|
||||
this.btnCopiarConString.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnCopiarConString.Location = new System.Drawing.Point(636, 31);
|
||||
this.btnCopiarConString.Location = new System.Drawing.Point(636, 4);
|
||||
this.btnCopiarConString.Name = "btnCopiarConString";
|
||||
this.btnCopiarConString.Size = new System.Drawing.Size(52, 23);
|
||||
this.btnCopiarConString.TabIndex = 3;
|
||||
@@ -81,17 +84,17 @@
|
||||
//
|
||||
// lsvTablas
|
||||
//
|
||||
this.lsvTablas.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.lsvTablas.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.lsvTablas.CheckBoxes = true;
|
||||
this.lsvTablas.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.colNombreTabla,
|
||||
this.colEsquema,
|
||||
this.colTipo});
|
||||
this.lsvTablas.FullRowSelect = true;
|
||||
this.lsvTablas.Location = new System.Drawing.Point(12, 59);
|
||||
this.lsvTablas.Location = new System.Drawing.Point(12, 70);
|
||||
this.lsvTablas.Name = "lsvTablas";
|
||||
this.lsvTablas.Size = new System.Drawing.Size(326, 405);
|
||||
this.lsvTablas.Size = new System.Drawing.Size(326, 394);
|
||||
this.lsvTablas.TabIndex = 4;
|
||||
this.lsvTablas.UseCompatibleStateImageBehavior = false;
|
||||
this.lsvTablas.View = System.Windows.Forms.View.Details;
|
||||
@@ -113,18 +116,18 @@
|
||||
//
|
||||
// lsvColumnas
|
||||
//
|
||||
this.lsvColumnas.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lsvColumnas.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lsvColumnas.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.colNombreColumna,
|
||||
this.colTipoDatos,
|
||||
this.colTamanho,
|
||||
this.colClave});
|
||||
this.lsvColumnas.FullRowSelect = true;
|
||||
this.lsvColumnas.Location = new System.Drawing.Point(344, 59);
|
||||
this.lsvColumnas.Location = new System.Drawing.Point(344, 70);
|
||||
this.lsvColumnas.Name = "lsvColumnas";
|
||||
this.lsvColumnas.Size = new System.Drawing.Size(344, 376);
|
||||
this.lsvColumnas.Size = new System.Drawing.Size(344, 365);
|
||||
this.lsvColumnas.TabIndex = 6;
|
||||
this.lsvColumnas.UseCompatibleStateImageBehavior = false;
|
||||
this.lsvColumnas.View = System.Windows.Forms.View.Details;
|
||||
@@ -150,14 +153,17 @@
|
||||
//
|
||||
// menuBaseDatos
|
||||
//
|
||||
this.menuBaseDatos.Dock = System.Windows.Forms.DockStyle.None;
|
||||
this.menuBaseDatos.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.archivoToolStripMenuItem,
|
||||
this.menuConfiguracion});
|
||||
this.menuBaseDatos.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuBaseDatos.Location = new System.Drawing.Point(348, 467);
|
||||
this.menuBaseDatos.Name = "menuBaseDatos";
|
||||
this.menuBaseDatos.Size = new System.Drawing.Size(700, 24);
|
||||
this.menuBaseDatos.Size = new System.Drawing.Size(148, 24);
|
||||
this.menuBaseDatos.TabIndex = 9;
|
||||
this.menuBaseDatos.Text = "menuBaseDatos";
|
||||
this.menuBaseDatos.Visible = false;
|
||||
this.menuBaseDatos.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.menuBaseDatos_ItemClicked);
|
||||
//
|
||||
// archivoToolStripMenuItem
|
||||
//
|
||||
@@ -165,27 +171,27 @@
|
||||
this.menuCargar,
|
||||
this.menuGuardar});
|
||||
this.archivoToolStripMenuItem.Name = "archivoToolStripMenuItem";
|
||||
this.archivoToolStripMenuItem.Size = new System.Drawing.Size(60, 20);
|
||||
this.archivoToolStripMenuItem.Size = new System.Drawing.Size(55, 20);
|
||||
this.archivoToolStripMenuItem.Text = "Archivo";
|
||||
//
|
||||
// menuCargar
|
||||
//
|
||||
this.menuCargar.Name = "menuCargar";
|
||||
this.menuCargar.Size = new System.Drawing.Size(116, 22);
|
||||
this.menuCargar.Size = new System.Drawing.Size(124, 22);
|
||||
this.menuCargar.Text = "Cargar";
|
||||
this.menuCargar.Click += new System.EventHandler(this.menuCargar_Click);
|
||||
//
|
||||
// menuGuardar
|
||||
//
|
||||
this.menuGuardar.Name = "menuGuardar";
|
||||
this.menuGuardar.Size = new System.Drawing.Size(116, 22);
|
||||
this.menuGuardar.Size = new System.Drawing.Size(124, 22);
|
||||
this.menuGuardar.Text = "Guardar";
|
||||
this.menuGuardar.Click += new System.EventHandler(this.menuGuardar_Click);
|
||||
//
|
||||
// menuConfiguracion
|
||||
//
|
||||
this.menuConfiguracion.Name = "menuConfiguracion";
|
||||
this.menuConfiguracion.Size = new System.Drawing.Size(95, 20);
|
||||
this.menuConfiguracion.Size = new System.Drawing.Size(85, 20);
|
||||
this.menuConfiguracion.Text = "Configuracion";
|
||||
this.menuConfiguracion.Click += new System.EventHandler(this.menuConfiguracion_Click);
|
||||
//
|
||||
@@ -200,11 +206,51 @@
|
||||
this.btnGenerar.UseVisualStyleBackColor = true;
|
||||
this.btnGenerar.Click += new System.EventHandler(this.btnGenerar_Click);
|
||||
//
|
||||
// btnVerDatos
|
||||
//
|
||||
this.btnVerDatos.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnVerDatos.Location = new System.Drawing.Point(521, 441);
|
||||
this.btnVerDatos.Name = "btnVerDatos";
|
||||
this.btnVerDatos.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnVerDatos.TabIndex = 11;
|
||||
this.btnVerDatos.Text = "Ver Datos";
|
||||
this.btnVerDatos.UseVisualStyleBackColor = true;
|
||||
this.btnVerDatos.Click += new System.EventHandler(this.btnVerDatos_Click);
|
||||
//
|
||||
// lblTituloTabla
|
||||
//
|
||||
this.lblTituloTabla.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lblTituloTabla.BackColor = System.Drawing.SystemColors.ControlDarkDark;
|
||||
this.lblTituloTabla.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lblTituloTabla.ForeColor = System.Drawing.SystemColors.ControlLightLight;
|
||||
this.lblTituloTabla.Location = new System.Drawing.Point(344, 30);
|
||||
this.lblTituloTabla.Name = "lblTituloTabla";
|
||||
this.lblTituloTabla.Size = new System.Drawing.Size(344, 37);
|
||||
this.lblTituloTabla.TabIndex = 12;
|
||||
this.lblTituloTabla.Text = "lblTituloTabla";
|
||||
this.lblTituloTabla.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// lblTituloDB
|
||||
//
|
||||
this.lblTituloDB.BackColor = System.Drawing.SystemColors.ControlDarkDark;
|
||||
this.lblTituloDB.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lblTituloDB.ForeColor = System.Drawing.SystemColors.ControlLightLight;
|
||||
this.lblTituloDB.Location = new System.Drawing.Point(12, 30);
|
||||
this.lblTituloDB.Name = "lblTituloDB";
|
||||
this.lblTituloDB.Size = new System.Drawing.Size(326, 37);
|
||||
this.lblTituloDB.TabIndex = 13;
|
||||
this.lblTituloDB.Text = "lblTituloDB";
|
||||
this.lblTituloDB.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// frmBaseDatos
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(700, 476);
|
||||
this.Controls.Add(this.lblTituloDB);
|
||||
this.Controls.Add(this.lblTituloTabla);
|
||||
this.Controls.Add(this.btnVerDatos);
|
||||
this.Controls.Add(this.btnGenerar);
|
||||
this.Controls.Add(this.lsvColumnas);
|
||||
this.Controls.Add(this.lsvTablas);
|
||||
@@ -243,5 +289,8 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem menuConfiguracion;
|
||||
private System.Windows.Forms.ColumnHeader colClave;
|
||||
private System.Windows.Forms.Button btnGenerar;
|
||||
private System.Windows.Forms.Button btnVerDatos;
|
||||
private System.Windows.Forms.Label lblTituloTabla;
|
||||
private System.Windows.Forms.Label lblTituloDB;
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,8 @@ namespace ServerExplorer
|
||||
{
|
||||
SqlConnection cnx;
|
||||
CodeGenConfig config;
|
||||
String table_schema = null;
|
||||
String table_name = null;
|
||||
|
||||
private void inicializar()
|
||||
{
|
||||
@@ -96,7 +98,19 @@ namespace ServerExplorer
|
||||
j=i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public DatabaseDesc CrearDatabaseDesc()
|
||||
{
|
||||
DatabaseDesc db = new DatabaseDesc(cnx.Database);
|
||||
foreach (CodeGenTablaInfo t in config.Tablas)
|
||||
{
|
||||
TablaDesc td = new TablaDesc();
|
||||
td.FillDesc(t.Esquema, t.Nombre, cnx);
|
||||
db.Tablas.Add(td);
|
||||
}
|
||||
return (db);
|
||||
}
|
||||
|
||||
public frmBaseDatos(String ConString)
|
||||
{
|
||||
@@ -104,6 +118,7 @@ namespace ServerExplorer
|
||||
|
||||
config = new CodeGenConfig();
|
||||
config.ConString = ConString;
|
||||
|
||||
}
|
||||
|
||||
public frmBaseDatos(CodeGenConfig config)
|
||||
@@ -118,6 +133,10 @@ namespace ServerExplorer
|
||||
private void frmBaseDatos_Load(object sender, EventArgs e)
|
||||
{
|
||||
inicializar();
|
||||
|
||||
// Establecer titulos
|
||||
lblTituloDB.Text = cnx.Database;
|
||||
lblTituloTabla.Text = "";
|
||||
}
|
||||
|
||||
private void btnCopiarConString_Click(object sender, EventArgs e)
|
||||
@@ -133,13 +152,12 @@ namespace ServerExplorer
|
||||
// Determinar tabla seleccionada
|
||||
ListViewItem item = lsvTablas.SelectedItems[0];
|
||||
|
||||
/*
|
||||
TablaDesc td = new TablaDesc();
|
||||
td.FillDesc(item.SubItems[1].Text,item.SubItems[0].Text,cnx);
|
||||
Type[] tipos = { typeof(ColumnaDesc) };
|
||||
XmlSerializer seriador = new XmlSerializer(typeof(TablaDesc),tipos);
|
||||
seriador.Serialize(System.Console.Out, td);
|
||||
*/
|
||||
// Recordar tabla seleccionada
|
||||
table_schema=item.SubItems[1].Text.ToString();
|
||||
table_name = item.SubItems[0].Text.ToString();
|
||||
|
||||
// Establecer titulo de la lista de columnas
|
||||
lblTituloTabla.Text=table_schema+"."+table_name;
|
||||
|
||||
// Obtener descripcion de tabla
|
||||
TablaDesc td = new TablaDesc();
|
||||
@@ -168,8 +186,6 @@ namespace ServerExplorer
|
||||
subitem.SubItems.Add("");
|
||||
}
|
||||
}
|
||||
//XmlSerializer seriador = new XmlSerializer(typeof(TablaDesc));
|
||||
//seriador.Serialize(System.Console.Out, td);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,6 +217,43 @@ namespace ServerExplorer
|
||||
}
|
||||
|
||||
private void btnGenerar_Click(object sender, EventArgs e)
|
||||
{
|
||||
tablas_delistview();
|
||||
DatabaseDesc db = CrearDatabaseDesc();
|
||||
|
||||
//XmlSerializer seriador = new XmlSerializer(typeof(DatabaseDesc));
|
||||
//seriador.Serialize(System.Console.Out, db);
|
||||
|
||||
CodeGen.GenerarCodigo(config, db);
|
||||
}
|
||||
|
||||
private void btnVerDatos_Click(object sender, EventArgs e)
|
||||
{
|
||||
String nombreTabla;
|
||||
DataTable dt;
|
||||
SqlDataAdapter da;
|
||||
|
||||
if (table_schema == null || table_name == null) { return; }
|
||||
|
||||
nombreTabla=table_schema+"."+table_name;
|
||||
|
||||
// Obtener un datatable con todos los registros de la tabla.
|
||||
da = new SqlDataAdapter(
|
||||
"select * from "+nombreTabla,
|
||||
cnx);
|
||||
dt = new DataTable();
|
||||
cnx.Open();
|
||||
da.Fill(dt);
|
||||
cnx.Close();
|
||||
|
||||
// Crear y mostrar el formulario de los datos.
|
||||
frmDatos form = new frmDatos(dt, nombreTabla);
|
||||
form.MdiParent = this.MdiParent;
|
||||
form.Show();
|
||||
|
||||
}
|
||||
|
||||
private void menuBaseDatos_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
70
ServerExplorer/ServerExplorer/frmDatos.Designer.cs
generated
Normal file
70
ServerExplorer/ServerExplorer/frmDatos.Designer.cs
generated
Normal file
@@ -0,0 +1,70 @@
|
||||
namespace ServerExplorer
|
||||
{
|
||||
partial class frmDatos
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.dgvDatos = new System.Windows.Forms.DataGridView();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvDatos)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dgvDatos
|
||||
//
|
||||
this.dgvDatos.AllowUserToAddRows = false;
|
||||
this.dgvDatos.AllowUserToDeleteRows = false;
|
||||
this.dgvDatos.AllowUserToOrderColumns = true;
|
||||
this.dgvDatos.AllowUserToResizeRows = false;
|
||||
this.dgvDatos.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.dgvDatos.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dgvDatos.Location = new System.Drawing.Point(12, 12);
|
||||
this.dgvDatos.Name = "dgvDatos";
|
||||
this.dgvDatos.ReadOnly = true;
|
||||
this.dgvDatos.RowHeadersVisible = false;
|
||||
this.dgvDatos.Size = new System.Drawing.Size(326, 282);
|
||||
this.dgvDatos.TabIndex = 0;
|
||||
//
|
||||
// frmDatos
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(350, 306);
|
||||
this.Controls.Add(this.dgvDatos);
|
||||
this.Name = "frmDatos";
|
||||
this.Text = "frmDatos";
|
||||
this.Load += new System.EventHandler(this.frmDatos_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvDatos)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.DataGridView dgvDatos;
|
||||
}
|
||||
}
|
||||
27
ServerExplorer/ServerExplorer/frmDatos.cs
Normal file
27
ServerExplorer/ServerExplorer/frmDatos.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ServerExplorer
|
||||
{
|
||||
public partial class frmDatos : Form
|
||||
{
|
||||
public frmDatos(DataTable dt,String titulo)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.Text = titulo;
|
||||
dgvDatos.DataSource = dt;
|
||||
}
|
||||
|
||||
private void frmDatos_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
120
ServerExplorer/ServerExplorer/frmDatos.resx
Normal file
120
ServerExplorer/ServerExplorer/frmDatos.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -2,7 +2,6 @@ D:\VAR\ServerExplorer\ServerExplorer\bin\Debug\ServerExplorer.exe
|
||||
D:\VAR\ServerExplorer\ServerExplorer\bin\Debug\ServerExplorer.pdb
|
||||
D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ResolveAssemblyReference.cache
|
||||
D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.Properties.Resources.resources
|
||||
D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.csproj.GenerateResource.Cache
|
||||
D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.exe
|
||||
D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.pdb
|
||||
D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.frmServidores.resources
|
||||
@@ -32,3 +31,9 @@ C:\Users\var\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.frmS
|
||||
C:\Users\var\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.Properties.Resources.resources
|
||||
C:\Users\var\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ResGen.read.1.tlog
|
||||
C:\Users\var\Desktop\ServerExplorer\ServerExplorer\obj\Debug\ResGen.write.1.tlog
|
||||
D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.frmCodeGenConfig.resources
|
||||
D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\GenerateResource-ResGen.read.1.tlog
|
||||
D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ResGen.read.1.tlog
|
||||
D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\GenerateResource-ResGen.write.1.tlog
|
||||
D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ResGen.write.1.tlog
|
||||
D:\VAR\ServerExplorer\ServerExplorer\obj\Debug\ServerExplorer.frmDatos.resources
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user