/// <summary> /// Método que monta as relações da tabela /// </summary> /// <param name="tabela">Tabela para filtar as colunas</param> /// <param name="builder">Builder para montar o HTML</param> private static void PreencheRelationships(Model.MD_Tabela tabela, ref StringBuilder builder) { Util.CL_Files.WriteOnTheLog("Document.PreencheRelationships()", Util.Global.TipoLog.DETALHADO); builder.Append("<table class=\"tabformat\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\" width=\"100%\">" + Environment.NewLine); builder.Append("" + Environment.NewLine); builder.Append("<tr>" + Environment.NewLine); builder.Append("<td class=\"tabhead\" > Constraint (relationship) name </td>" + Environment.NewLine); builder.Append("<td class=\"tabhead\" > Relationship type </td>" + Environment.NewLine); builder.Append("<td class=\"tabhead\" > Parent table </td>" + Environment.NewLine); builder.Append("<td class=\"tabhead\" > Child table </td>" + Environment.NewLine); builder.Append("<td class=\"tabhead\" > Card. </td>" + Environment.NewLine); builder.Append("</tr>" + Environment.NewLine); string sentenca = ClassesGenericas.relacaoBase.DAO.table.CreateCommandSQLTable() + " WHERE TABELAORIGEM = " + tabela.DAO.Codigo + " OR TABELADESTINO = " + tabela.DAO.Codigo + " ORDER BY FOREINGKEY"; DbDataReader reader = DataBase.Connection.Select(sentenca); while (reader.Read()) { int codigo = int.Parse(reader["CODIGO"].ToString()); Model.MD_Tabela tabelaOrigem = new Model.MD_Tabela(int.Parse(reader["TABELAORIGEM"].ToString()), tabela.DAO.Projeto.Codigo); Model.MD_Tabela tabelaDestino = new Model.MD_Tabela(int.Parse(reader["TABELADESTINO"].ToString()), tabela.DAO.Projeto.Codigo); Model.MD_Campos campoOrigem = new MD_Campos(int.Parse(reader["CAMPOORIGEM"].ToString()), tabelaOrigem.DAO.Codigo, tabelaOrigem.DAO.Projeto.Codigo); Model.MD_Campos campoDestino = new MD_Campos(int.Parse(reader["CAMPODESTINO"].ToString()), tabelaDestino.DAO.Codigo, tabelaDestino.DAO.Projeto.Codigo); Model.MD_Relacao relacao = new MD_Relacao(codigo, tabela.DAO.Projeto, tabelaOrigem.DAO, tabelaDestino.DAO, campoOrigem.DAO, campoDestino.DAO); string relationship = relacao.DAO.TabelaOrigem.Descricao + " x " + relacao.DAO.TabelaDestino.Descricao + "(" + relacao.DAO.TabelaOrigem.Nome + " x " + relacao.DAO.TabelaDestino.Nome + ")"; string card = relacao.DAO.CardinalidadeOrigem + ":" + relacao.DAO.CardinalidadeDestino; string parentTable = relacao.DAO.TabelaOrigem.Nome; string childTable = relacao.DAO.TabelaDestino.Nome; builder.Append("<tr>" + Environment.NewLine); builder.Append(" <td class=\"tabdata\" > " + relationship + " </td>" + Environment.NewLine); builder.Append(" <td class=\"tabdata\" > Identifying </td>" + Environment.NewLine); builder.Append(" <td class=\"tabdata\" > " + parentTable + " </td>" + Environment.NewLine); builder.Append(" <td class=\"tabdata\" > " + childTable + " </td>" + Environment.NewLine); builder.Append(" <td class=\"tabdata\" > " + card + " </td>" + Environment.NewLine); builder.Append("</tr>" + Environment.NewLine); tabelaOrigem = null; tabelaDestino = null; campoOrigem = null; campoDestino = null; relacao = null; } reader.Close(); reader = null; builder.Append("" + Environment.NewLine); builder.Append("</table>" + Environment.NewLine); }
/// <summary> /// Método que preenche as colunas /// </summary> /// <param name="tabela">Tabela para filtar as colunas</param> /// <param name="builder">Builder para montar o HTML</param> private static void PreencheColunas(Model.MD_Tabela tabela, ref StringBuilder builder) { Util.CL_Files.WriteOnTheLog("Document.PreencheColunas()", Util.Global.TipoLog.DETALHADO); builder.Append("<table class=\"tabformat\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\" width=\"100%\">" + Environment.NewLine); builder.Append("" + Environment.NewLine); builder.Append("<tr>" + Environment.NewLine); builder.Append(" <td class=\"tabhead\" > Key </td>" + Environment.NewLine); builder.Append(" <td class=\"tabhead\" > Column name </td>" + Environment.NewLine); builder.Append(" <td class=\"tabhead\" > Domain </td>" + Environment.NewLine); builder.Append(" <td class=\"tabhead\" > Data type </td>" + Environment.NewLine); builder.Append(" <td class=\"tabhead\" > Not null </td>" + Environment.NewLine); builder.Append(" <td class=\"tabhead\" > Unique </td>" + Environment.NewLine); builder.Append(" <td class=\"tabhead\" > Check </td>" + Environment.NewLine); builder.Append(" <td class=\"tabhead\" > Default </td>" + Environment.NewLine); builder.Append(" <td class=\"tabhead\" colspan=\"2\"> Comments </td> " + Environment.NewLine); builder.Append("</tr>" + Environment.NewLine); string sentenca = ClassesGenericas.camposBase.DAO.table.CreateCommandSQLTable() + " WHERE CODIGOTABELA = " + tabela.DAO.Codigo + " ORDER BY CHAVE DESC, NOME "; DbDataReader reader = DataBase.Connection.Select(sentenca); while (reader.Read()) { Model.MD_Campos campo = new MD_Campos(int.Parse(reader["CODIGO"].ToString()), tabela.DAO.Codigo, tabela.DAO.Projeto.Codigo); string pfk = (campo.DAO.PrimaryKey ? (campo.DAO.ForeingKey ? "PFK" : "PK") : (campo.DAO.ForeingKey ? "FK" : string.Empty)); string nome = campo.DAO.Nome; string dominio = campo.DAO.Dominio; string tipo = campo.DAO.TipoCampo.Nome; if (campo.DAO.TipoCampo.Nome.ToUpper().Equals("VARCHAR") || campo.DAO.TipoCampo.Nome.ToUpper().Equals("CHAR")) { tipo += "(" + campo.DAO.Tamanho + ")"; } else if (campo.DAO.TipoCampo.Nome.ToUpper().Equals("DECIMAL") || campo.DAO.TipoCampo.Nome.ToUpper().Equals("FLOAT")) { tipo += "(" + campo.DAO.Precisao.ToString().Replace(".", ",") + ")"; } string notnull = campo.DAO.NotNull ? "YES" : "NO"; string unique = campo.DAO.Unique ? "YES" : "NO"; string check = campo.DAO.Check; string _default = campo.DAO.Default == null ? string.Empty : campo.DAO.Default.ToString(); string comments = campo.DAO.Comentario; campo = null; builder.Append("<tr>" + Environment.NewLine); builder.Append(" <td class=\"tabdata\" > " + pfk + " </td>" + Environment.NewLine); builder.Append(" <td class=\"tabdata\" > " + nome + " </td>" + Environment.NewLine); builder.Append(" <td class=\"tabdata\" > " + dominio + " </td>" + Environment.NewLine); builder.Append(" <td class=\"tabdata\" > " + tipo + " </td>" + Environment.NewLine); builder.Append(" <td class=\"tabdata\" > " + notnull + " </td>" + Environment.NewLine); builder.Append(" <td class=\"tabdata\" > " + unique + " </td>" + Environment.NewLine); builder.Append(" <td class=\"tabdata\" > " + check + " </td>" + Environment.NewLine); builder.Append(" <td class=\"tabdata\" > " + _default + " </td>" + Environment.NewLine); builder.Append(" <td class=\"tabdata\" colspan=\"2\"> " + comments + " </ td > " + Environment.NewLine); builder.Append("</tr>" + Environment.NewLine); } reader.Close(); reader = null; builder.Append("" + Environment.NewLine); builder.Append("</table>" + Environment.NewLine); }