Limpieza de codigo

This commit is contained in:
2013-10-14 20:20:23 +02:00
parent af72a4decb
commit b4eea3818f
22 changed files with 194 additions and 197 deletions

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.IO;
namespace ServerExplorer
namespace ServerExplorer.Code
{
public static class Utiles
{

View File

@@ -4,12 +4,14 @@ using System.Linq;
using System.Text;
using System.IO;
using System.Data;
using ServerExplorer.Code;
namespace ServerExplorer
{
public class CodeGen
{
private static string FixNombre(string strIn){
private static string FixNombre(string strIn)
{
return strIn.Replace(' ', '_');
}
@@ -302,10 +304,10 @@ namespace ServerExplorer
public static Boolean GenerarCodigo(Config config, DatabaseDesc database)
{
// Asegura la existencia de los directorios destinos
if (!System.IO.Directory.Exists(config.PathRaiz)) { Utiles.CrearDirectorio(config.PathRaiz); }
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); }
if (!Directory.Exists(config.PathRaiz)) { Utiles.CrearDirectorio(config.PathRaiz); }
if (!Directory.Exists(config.PathDTO)) { Utiles.CrearDirectorio(config.PathDTO); }
if (!Directory.Exists(config.PathDAL)) { Utiles.CrearDirectorio(config.PathDAL); }
if (!Directory.Exists(config.PathExtra)) { Utiles.CrearDirectorio(config.PathExtra); }
// Itera por cada tabla para crear sus DTO y DAL
foreach (TablaDesc t in database.Tablas)

View File

@@ -33,7 +33,8 @@ namespace ServerExplorer
public String pathDTO = ".";
public String PathDTO
{
get {
get
{
if (pathDTO == ".")
{
return pathRaiz;
@@ -48,7 +49,8 @@ namespace ServerExplorer
public String pathExtra = ".";
public String PathExtra
{
get {
get
{
if (pathExtra == ".")
{
return pathRaiz;
@@ -97,5 +99,4 @@ namespace ServerExplorer
Nombre = nombre;
}
}
}

View File

@@ -16,6 +16,5 @@ namespace ServerExplorer
{
Nombre = nombre;
}
}
}

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using ServerExplorer.Code;
namespace ServerExplorer
{
@@ -11,16 +12,14 @@ namespace ServerExplorer
public static void GenerarDocumentacion(Config config, DatabaseDesc database)
{
// Asegura la existencia de los directorios destinos
if (!System.IO.Directory.Exists(config.PathRaiz)) { Utiles.CrearDirectorio(config.PathRaiz); }
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); }
if (!Directory.Exists(config.PathRaiz)) { Utiles.CrearDirectorio(config.PathRaiz); }
if (!Directory.Exists(config.PathDTO)) { Utiles.CrearDirectorio(config.PathDTO); }
if (!Directory.Exists(config.PathDAL)) { Utiles.CrearDirectorio(config.PathDAL); }
if (!Directory.Exists(config.PathExtra)) { Utiles.CrearDirectorio(config.PathExtra); }
// Abrir el documento que contendra la documentacion
StreamWriter escritor = new StreamWriter(config.PathExtra + "/documentacion.html");
// Poner cabecera de la documentacion
escritor.WriteLine("<html><head><title>" + database.Nombre + "</title></head>");
escritor.WriteLine("<body>");
@@ -46,11 +45,9 @@ namespace ServerExplorer
escritor.WriteLine("</tbody></table>");
}
// Poner pie y cerrar fichero
escritor.WriteLine("</body></html>");
escritor.Close();
}
}
}

View File

@@ -15,7 +15,7 @@ namespace ServerExplorer
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmPrincipal());
Application.Run(new FrmPrincipal());
}
}
}

View File

@@ -73,72 +73,72 @@
<Compile Include="Config.cs" />
<Compile Include="DatabaseDesc.cs" />
<Compile Include="DocGen.cs" />
<Compile Include="frmBaseDatos.cs">
<Compile Include="FrmBaseDatos.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmBaseDatos.Designer.cs">
<DependentUpon>frmBaseDatos.cs</DependentUpon>
<Compile Include="FrmBaseDatos.Designer.cs">
<DependentUpon>FrmBaseDatos.cs</DependentUpon>
</Compile>
<Compile Include="frmCodeGenConfig.cs">
<Compile Include="FrmCodeGenConfig.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmCodeGenConfig.Designer.cs">
<DependentUpon>frmCodeGenConfig.cs</DependentUpon>
<Compile Include="FrmCodeGenConfig.Designer.cs">
<DependentUpon>FrmCodeGenConfig.cs</DependentUpon>
</Compile>
<Compile Include="frmDatos.cs">
<Compile Include="FrmDatos.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmDatos.Designer.cs">
<DependentUpon>frmDatos.cs</DependentUpon>
<Compile Include="FrmDatos.Designer.cs">
<DependentUpon>FrmDatos.cs</DependentUpon>
</Compile>
<Compile Include="frmExec.cs">
<Compile Include="FrmExec.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmExec.Designer.cs">
<DependentUpon>frmExec.cs</DependentUpon>
<Compile Include="FrmExec.Designer.cs">
<DependentUpon>FrmExec.cs</DependentUpon>
</Compile>
<Compile Include="frmPrincipal.cs">
<Compile Include="FrmPrincipal.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmPrincipal.Designer.cs">
<DependentUpon>frmPrincipal.cs</DependentUpon>
<Compile Include="FrmPrincipal.Designer.cs">
<DependentUpon>FrmPrincipal.cs</DependentUpon>
</Compile>
<Compile Include="frmProcedimientos.cs">
<Compile Include="FrmProcedimientos.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmProcedimientos.Designer.cs">
<DependentUpon>frmProcedimientos.cs</DependentUpon>
<Compile Include="FrmProcedimientos.Designer.cs">
<DependentUpon>FrmProcedimientos.cs</DependentUpon>
</Compile>
<Compile Include="frmServidores.cs">
<Compile Include="FrmServidores.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmServidores.Designer.cs">
<DependentUpon>frmServidores.cs</DependentUpon>
<Compile Include="FrmServidores.Designer.cs">
<DependentUpon>FrmServidores.cs</DependentUpon>
</Compile>
<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>
<Compile Include="Code\Utiles.cs" />
<EmbeddedResource Include="FrmBaseDatos.resx">
<DependentUpon>FrmBaseDatos.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmCodeGenConfig.resx">
<DependentUpon>frmCodeGenConfig.cs</DependentUpon>
<EmbeddedResource Include="FrmCodeGenConfig.resx">
<DependentUpon>FrmCodeGenConfig.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmDatos.resx">
<DependentUpon>frmDatos.cs</DependentUpon>
<EmbeddedResource Include="FrmDatos.resx">
<DependentUpon>FrmDatos.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmExec.resx">
<DependentUpon>frmExec.cs</DependentUpon>
<EmbeddedResource Include="FrmExec.resx">
<DependentUpon>FrmExec.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmPrincipal.resx">
<DependentUpon>frmPrincipal.cs</DependentUpon>
<EmbeddedResource Include="FrmPrincipal.resx">
<DependentUpon>FrmPrincipal.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmProcedimientos.resx">
<DependentUpon>frmProcedimientos.cs</DependentUpon>
<EmbeddedResource Include="FrmProcedimientos.resx">
<DependentUpon>FrmProcedimientos.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmServidores.resx">
<DependentUpon>frmServidores.cs</DependentUpon>
<EmbeddedResource Include="FrmServidores.resx">
<DependentUpon>FrmServidores.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
@@ -177,6 +177,7 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -10,8 +10,8 @@ namespace ServerExplorer
{
public class TablaDesc
{
public String Esquema="";
public String Nombre="";
public String Esquema = String.Empty;
public String Nombre = String.Empty;
public List<ColumnaDesc> Columnas = new List<ColumnaDesc>();
public TablaDesc() { }
@@ -115,8 +115,8 @@ namespace ServerExplorer
public class ColumnaDesc
{
public string Nombre = "";
public string Tipo = "";
public string Nombre = String.Empty;
public string Tipo = String.Empty;
public int Tamanho = -1;
public bool Primaria = false;

View File

@@ -1,6 +1,6 @@
namespace ServerExplorer
{
partial class frmBaseDatos
partial class FrmBaseDatos
{
/// <summary>
/// Required designer variable.

View File

@@ -13,9 +13,9 @@ using System.Threading;
namespace ServerExplorer
{
public partial class frmBaseDatos : Form
public partial class FrmBaseDatos : Form
{
private frmBaseDatos instancia;
private FrmBaseDatos instancia;
private SqlConnection cnx;
private Config config;
private String table_schema = null;
@@ -86,7 +86,8 @@ namespace ServerExplorer
String tablename =
item.SubItems[1].Text + // Esquema
item.SubItems[0].Text; // Nombre tabla
do{
do
{
if (config.Tablas[i].Esquema.
CompareTo(item.SubItems[1].Text) == 0 &&
config.Tablas[i].Nombre.
@@ -114,7 +115,7 @@ namespace ServerExplorer
return (db);
}
public frmBaseDatos(String ConString)
public FrmBaseDatos(String ConString)
{
InitializeComponent();
@@ -123,7 +124,7 @@ namespace ServerExplorer
config.ConString = ConString;
}
public frmBaseDatos(Config config)
public FrmBaseDatos(Config config)
{
InitializeComponent();
@@ -215,11 +216,10 @@ namespace ServerExplorer
private void menuConfiguracion_Click(object sender, EventArgs e)
{
// Llamar a la ventana de configuracion
frmCodeGenConfig frm = new frmCodeGenConfig(config);
FrmCodeGenConfig frm = new FrmCodeGenConfig(config);
frm.ShowDialog();
}
private void btnVerDatos_Click(object sender, EventArgs e)
{
String nombreTabla;
@@ -240,7 +240,7 @@ namespace ServerExplorer
cnx.Close();
// Crear y mostrar el formulario de los datos.
frmDatos form = new frmDatos(dt, nombreTabla);
FrmDatos form = new FrmDatos(dt, nombreTabla);
form.MdiParent = this.MdiParent;
form.Show();
@@ -267,7 +267,7 @@ namespace ServerExplorer
form.Show();*/
// Crear y mostrar el formulario de los procedimientos.
frmProcedimientos form = new frmProcedimientos(config.ConString);
FrmProcedimientos form = new FrmProcedimientos(config.ConString);
form.MdiParent = this.MdiParent;
form.Show();
}
@@ -275,7 +275,7 @@ namespace ServerExplorer
private void btnExec_Click(object sender, EventArgs e)
{
// Crear y mostrar el formulario de exec.
frmExec form = new frmExec(config.ConString);
FrmExec form = new FrmExec(config.ConString);
form.MdiParent = this.MdiParent;
form.Show();
}
@@ -285,6 +285,7 @@ namespace ServerExplorer
{
}
private void btnGenerar_Click(object sender, EventArgs e)
{
tablas_delistview();
@@ -317,6 +318,7 @@ namespace ServerExplorer
hilo.Start();
*/
}
public void GenerarDoc()
{
// Hacer insensible la ventana
@@ -336,6 +338,5 @@ namespace ServerExplorer
{
}
}
}

View File

@@ -1,6 +1,6 @@
namespace ServerExplorer
{
partial class frmCodeGenConfig
partial class FrmCodeGenConfig
{
/// <summary>
/// Required designer variable.
@@ -275,7 +275,7 @@
this.Controls.Add(this.lblConString);
this.Name = "frmCodeGenConfig";
this.Text = "Configuracion del Generador de Codigo";
this.Load += new System.EventHandler(this.frmCodeGenConfig_Load);
this.Load += new System.EventHandler(this.FrmCodeGenConfig_Load);
this.ResumeLayout(false);
this.PerformLayout();

View File

@@ -9,26 +9,26 @@ using System.Windows.Forms;
namespace ServerExplorer
{
public partial class frmCodeGenConfig : Form
public partial class FrmCodeGenConfig : Form
{
Config config;
Config _config;
public frmCodeGenConfig(Config config)
public FrmCodeGenConfig(Config config)
{
InitializeComponent();
this.config = config;
_config = config;
}
private void frmCodeGenConfig_Load(object sender, EventArgs e)
private void FrmCodeGenConfig_Load(object sender, EventArgs e)
{
txtConString.Text = config.ConString;
txtPathRaiz.Text = config.PathRaiz;
txtPathDAL.Text = config.PathDAL;
txtPathDTO.Text = config.PathDTO;
txtPathExtra.Text = config.PathExtra;
txtNSDAL.Text = config.NamespaceDAL;
txtNSDTO.Text = config.NamespaceDTO;
txtConString.Text = _config.ConString;
txtPathRaiz.Text = _config.PathRaiz;
txtPathDAL.Text = _config.PathDAL;
txtPathDTO.Text = _config.PathDTO;
txtPathExtra.Text = _config.PathExtra;
txtNSDAL.Text = _config.NamespaceDAL;
txtNSDTO.Text = _config.NamespaceDTO;
}
private void btnPathRaiz_Click(object sender, EventArgs e)
@@ -73,12 +73,12 @@ namespace ServerExplorer
private void btnAceptar_Click(object sender, EventArgs e)
{
config.PathRaiz = txtPathRaiz.Text;
config.PathDAL = txtPathDAL.Text;
config.PathDTO = txtPathDTO.Text;
config.PathExtra = txtPathExtra.Text;
config.NamespaceDAL = txtNSDAL.Text;
config.NamespaceDTO = txtNSDTO.Text;
_config.PathRaiz = txtPathRaiz.Text;
_config.PathDAL = txtPathDAL.Text;
_config.PathDTO = txtPathDTO.Text;
_config.PathExtra = txtPathExtra.Text;
_config.NamespaceDAL = txtNSDAL.Text;
_config.NamespaceDTO = txtNSDTO.Text;
this.Close();
}

View File

@@ -1,6 +1,6 @@
namespace ServerExplorer
{
partial class frmDatos
partial class FrmDatos
{
/// <summary>
/// Required designer variable.

View File

@@ -9,24 +9,18 @@ using System.Windows.Forms;
namespace ServerExplorer
{
public partial class frmDatos : Form
public partial class FrmDatos : Form
{
public frmDatos(DataTable dt,String titulo)
public FrmDatos(DataTable dt, String titulo)
{
InitializeComponent();
this.Text = titulo;
Text = titulo;
dgvDatos.DataSource = dt;
}
private void frmDatos_Load(object sender, EventArgs e)
{
}
private void dgvDatos_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
private void frmDatos_Load(object sender, EventArgs e) { }
}
private void dgvDatos_CellContentClick(object sender, DataGridViewCellEventArgs e) { }
}
}

View File

@@ -1,6 +1,6 @@
namespace ServerExplorer
{
partial class frmExec
partial class FrmExec
{
/// <summary>
/// Required designer variable.

View File

@@ -11,19 +11,20 @@ using System.Globalization;
namespace ServerExplorer
{
public partial class frmExec : Form
public partial class FrmExec : Form
{
private string cnxString;
public frmExec(string cnxString)
public FrmExec(string cnxString)
{
InitializeComponent();
this.cnxString = cnxString;
}
private void frmExec_Load(object sender, EventArgs e){
private void frmExec_Load(object sender, EventArgs e)
{
}
@@ -112,7 +113,8 @@ namespace ServerExplorer
{
// NULOS
strValues += "NULL";
}else
}
else
if (dc.DataType.Name.ToLower() == "string")
{
// Cadenas

View File

@@ -1,6 +1,6 @@
namespace ServerExplorer
{
partial class frmPrincipal
partial class FrmPrincipal
{
/// <summary>
/// Required designer variable.

View File

@@ -9,9 +9,9 @@ using System.Windows.Forms;
namespace ServerExplorer
{
public partial class frmPrincipal : Form
public partial class FrmPrincipal : Form
{
public frmPrincipal()
public FrmPrincipal()
{
InitializeComponent();
}
@@ -19,7 +19,7 @@ namespace ServerExplorer
private void menuConectarPRUEBAS_Click(object sender, EventArgs e)
{
// Crear ventana de la base de datos de pruebas
frmBaseDatos frm = new frmBaseDatos("Data Source=SSSRV3;Initial Catalog=PRUEBAS;User ID=sa;Password=SLsssrv3");
FrmBaseDatos frm = new FrmBaseDatos("Data Source=SSSRV3;Initial Catalog=PRUEBAS;User ID=sa;Password=SLsssrv3");
//frmBaseDatos frm = new frmBaseDatos("Data Source=DANTE;Initial Catalog=BD_AlfonsoRodriguez;Integrated Security=True");
//frmBaseDatos frm = new frmBaseDatos("Data Source=OSKURITO;Initial Catalog=BD_AlfonsoRodriguez;Integrated Security=True");
frm.MdiParent = this;
@@ -30,7 +30,7 @@ namespace ServerExplorer
private void menuBuscarServidor_Click(object sender, EventArgs e)
{
// Mostrar ventana de buscador de servidores
frmServidores frm = new frmServidores();
FrmServidores frm = new FrmServidores();
frm.MdiParent = this;
frm.Show();
}
@@ -44,7 +44,7 @@ namespace ServerExplorer
Config config = Config.Cargar(dialogo.FileName);
// Crear y mostrar ventana
frmBaseDatos frm = new frmBaseDatos(config);
FrmBaseDatos frm = new FrmBaseDatos(config);
frm.MdiParent = this;
frm.WindowState = FormWindowState.Maximized;
frm.Show();

View File

@@ -1,6 +1,6 @@
namespace ServerExplorer
{
partial class frmProcedimientos
partial class FrmProcedimientos
{
/// <summary>
/// Required designer variable.

View File

@@ -11,12 +11,12 @@ using System.Data.SqlClient;
namespace ServerExplorer
{
public partial class frmProcedimientos : Form
public partial class FrmProcedimientos : Form
{
private string cnxString;
private SqlConnection cnx;
public frmProcedimientos(string cnxString)
public FrmProcedimientos(string cnxString)
{
InitializeComponent();

View File

@@ -1,6 +1,6 @@
namespace ServerExplorer
{
partial class frmServidores
partial class FrmServidores
{
/// <summary>
/// Required designer variable.

View File

@@ -12,9 +12,9 @@ using System.Data.SqlTypes;
namespace ServerExplorer
{
public partial class frmServidores : Form
public partial class FrmServidores : Form
{
public frmServidores()
public FrmServidores()
{
InitializeComponent();
}
@@ -127,7 +127,7 @@ namespace ServerExplorer
}
// Llamar a la venta de la base de datos
frmBaseDatos frm = new frmBaseDatos(constructor.ConnectionString);
FrmBaseDatos frm = new FrmBaseDatos(constructor.ConnectionString);
frm.MdiParent = this.MdiParent;
frm.Show();
}