예제 #1
0
        /// <summary>
        /// Método que trata as tabelas de importação e coloca nas tabelas definitivas vinculando com o projeto
        /// </summary>
        /// <param name="projeto">Código do projeto a se vincular as tabelas</param>
        private static void TratarImportacao(int codigo, ref List <Model.Tabela> tabelas, ref List <Model.Campo> campos, ref List <Model.Relacionamento> relacionamentos)
        {
            Util.CL_Files.WriteOnTheLog("Importador.TratarImportacao()", Util.Global.TipoLog.DETALHADO);

            Model.MD_Projeto projeto = new Model.MD_Projeto(codigo);

            BarraDeCarregamento barraCarregamento = new BarraDeCarregamento(tabelas.Count(), "Importando Tabelas");

            barraCarregamento.Show();

            TratarTabelas(projeto, ref tabelas, ref barraCarregamento);

            barraCarregamento.Hide();
            barraCarregamento.Dispose();
            barraCarregamento = null;

            barraCarregamento = new BarraDeCarregamento(campos.Count(), "Importando Colunas");
            barraCarregamento.Show();

            TratarColunas(projeto, ref campos, ref barraCarregamento);

            barraCarregamento.Hide();
            barraCarregamento.Dispose();
            barraCarregamento = null;

            barraCarregamento = new BarraDeCarregamento(relacionamentos.Count(), "Importando Relacionamentos");

            barraCarregamento.Show();
            TratarRelacionamento(projeto, ref relacionamentos, ref barraCarregamento);
            projeto = null;
            barraCarregamento.Hide();
            barraCarregamento.Dispose();
            barraCarregamento = null;
        }
예제 #2
0
        /// <summary>
        /// Método que abre o arquivo DER, lê e identifica todas as tabelas e suas colunas
        /// </summary>
        /// <param name="diretorioFile"></param>
        /// <returns></returns>
        public static List <MDN_Table> MontaTabela(string diretorioFile)
        {
            Util.CL_Files.WriteOnTheLog("Backup.MontaTabela()", Util.Global.TipoLog.DETALHADO);

            List <MDN_Table> tabelas = new List <MDN_Table>();

            List <string> linhas = TextoArquivo(diretorioFile);

            BarraDeCarregamento barraDeCarregamento = new BarraDeCarregamento(linhas.Count, "Importando DER");

            barraDeCarregamento.Show();

            string nome_tabela = string.Empty;
            string tipo_coluna = string.Empty;
            string tabela      = string.Empty;
            bool   inTable     = false;

            foreach (string linha in linhas)
            {
                barraDeCarregamento.AvancaBarra(1);

                if (linha.Contains("caption1"))
                {
                    nome_tabela = linha.Replace("<div class=\"caption1\">", "").Replace("</div>", "");
                }
                else if (linha.Contains("caption2"))
                {
                    tipo_coluna = linha.Replace("<div class=\"caption2\">", "").Replace("</div>", "");
                }
                else if (linha.Contains("table class=\"tabformat\""))
                {
                    inTable = true;
                }
                else if (inTable && tipo_coluna.ToUpper().Equals("COLUMNS"))
                {
                    if (linha.Contains("</table>"))
                    {
                        tabelas.Add(MontaConfiguracaoTabela(nome_tabela, tabela, barraDeCarregamento));
                        tabela      = string.Empty;
                        inTable     = false;
                        tipo_coluna = string.Empty;
                    }
                    else if (!string.IsNullOrEmpty(linha.Trim()))
                    {
                        tabela += linha;
                    }
                }
            }

            barraDeCarregamento.Dispose();
            barraDeCarregamento = null;

            linhas.Clear();
            linhas = null;

            return(tabelas);
        }
예제 #3
0
        /// <summary>
        /// Método que preenche o corpo do html
        /// </summary>
        /// <param name="projeto">Projeto para se preencher o corpo do html</param>
        /// <param name="builder_tableB">string builder para montar o html</param>
        private static void PreencheText(Model.MD_Projeto projeto, ref StringBuilder builder_tableB, ref StringBuilder builder_tableR)
        {
            Util.CL_Files.WriteOnTheLog("Document.PreencheText", Global.TipoLog.SIMPLES);
            int quantidade = 0;

            string sentenca = "SELECT COUNT(1) AS contador FROM " + ClassesGenericas.tabelaBase.DAO.table.Table_Name + " WHERE PROJETO = " + projeto.DAO.Codigo;

            DbDataReader reader = DataBase.Connection.Select(sentenca);

            if (reader == null)
            {
                return;
            }

            while (reader.Read())
            {
                quantidade = int.Parse(reader["contador"].ToString());
            }

            sentenca = ClassesGenericas.tabelaBase.DAO.table.CreateCommandSQLTable() + " WHERE PROJETO = " + projeto.DAO.Codigo + " ORDER BY NOME";

            reader = DataBase.Connection.Select(sentenca);

            if (reader == null)
            {
                return;
            }

            BarraDeCarregamento barraCarregamento = new BarraDeCarregamento(quantidade, "Criando DER");

            barraCarregamento.Show();

            builder_tableR.Append("<div class=\"bookmark\">" + Environment.NewLine);

            while (reader.Read())
            {
                barraCarregamento.AvancaBarra(1);

                Model.MD_Tabela tabela = new MD_Tabela(int.Parse(reader["CODIGO"].ToString()), projeto.DAO.Codigo);

                builder_tableB.Append("<a name = \"Table_" + tabela.DAO.Codigo + "\"></a>" + Environment.NewLine);
                builder_tableB.Append("<div class=\"caption1\">" + tabela.DAO.Nome + "</div>" + Environment.NewLine);

                builder_tableB.Append("<div class=\"caption2\">Columns</div>" + Environment.NewLine);
                PreencheColunas(tabela, ref builder_tableB);

                builder_tableB.Append("<div class=\"caption2\">Relationships</div>" + Environment.NewLine);
                PreencheRelationships(tabela, ref builder_tableB);

                builder_tableB.Append("<div class=\"caption2\">Notes</div>" + Environment.NewLine);
                PreencheNotes(tabela, ref builder_tableB);

                builder_tableB.Append("<br><br> " + Environment.NewLine);

                builder_tableR.Append("<a href=\"TableB.html#Table_" + tabela.DAO.Codigo + "\"target=\"body\">" + tabela.DAO.Nome + "</a>" + Environment.NewLine);

                tabela = null;
            }
            builder_tableR.Append("</div>" + Environment.NewLine);

            barraCarregamento.Hide();
            barraCarregamento.Dispose();
            barraCarregamento = null;

            reader.Close();
        }
예제 #4
0
        /// <summary>
        /// Método que faz o tratamento da imagem
        /// </summary>
        public void TrataImagens()
        {
            string men = "";

            if (!ValidaPath(string.IsNullOrEmpty(tbx_folder.Text) ? tbx_file_in.Text : tbx_folder.Text, out men))
            {
                MessageBox.Show(men, "Atenção");
                return;
            }

            List <FileInfo> files = new List <FileInfo>();

            if (!string.IsNullOrEmpty(tbx_folder.Text))
            {
                DirectoryInfo directory = new DirectoryInfo(tbx_folder.Text);
                files = directory.GetFiles().ToList();
            }
            if (!string.IsNullOrEmpty(tbx_file_in.Text))
            {
                files.Add(new FileInfo(tbx_file_in.Text));
            }

            string mensagemErro = "";

            this.Hide();
            int total = 0;

            foreach (FileInfo arq in files)
            {
                if (arq.Extension == ".jpg" || arq.Extension == ".JPG" ||
                    arq.Extension == ".png" || arq.Extension == ".PNG" ||
                    arq.Extension == ".jpeg" || arq.Extension == ".JPEG" ||
                    arq.Extension == ".ico" || arq.Extension == ".ICO")
                {
                    total++;
                }
            }

            BarraDeCarregamento tela = new BarraDeCarregamento(total);

            tela.Show();

            sucesso = erro = 0;
            foreach (FileInfo arq in files)
            {
                if (arq.Extension == ".jpg" || arq.Extension == ".JPG" ||
                    arq.Extension == ".png" || arq.Extension == ".PNG" ||
                    arq.Extension == ".jpeg" || arq.Extension == ".JPEG" ||
                    arq.Extension == ".ico" || arq.Extension == ".ICO")
                {
                    tela.AvancaBarra(1);

                    if (TrataImagem(arq,
                                    int.Parse(tbx_width.Text),
                                    int.Parse(tbx_height.Text),
                                    ckb_transparent.Checked,
                                    ref mensagemErro))
                    {
                        sucesso++;
                    }
                    else
                    {
                        erro++;
                        lista_errados.Add(arq.FullName);
                        lista_errados_motivo.Add(mensagemErro);
                    }
                }
            }

            tela.Close();
            tela.Dispose();
            total = 0;
            this.Show();
            string mensagem = "Total: " + (sucesso + erro).ToString() + "\n\n";

            mensagem += "Imagens Tratadas: " + sucesso + "\n\n";

            foreach (string mens in lista_errados)
            {
                mensagem += "Imagens com erro: " + mens;
            }

            MessageBox.Show(mensagem);
        }