Beispiel #1
0
        /// <summary>
        /// Método que monta o arquivo csv a partir dos anexos do cenário
        /// </summary>
        /// <param name="cenario">Cenário a se criar o relatório</param>
        /// <param name="mensagemErro">Mensagem de Erro</param>
        /// <returns>True - csv criado com sucesso; False - Não foi possível gerar o relatório</returns>
        private static bool MontaCSVCenario(MD_Cenario cenario, string caminhoSaida, ref string mensagemErro)
        {
            Util.CL_Files.WriteOnTheLog("Document.MontaCSVCenario()", Util.Global.TipoLog.DETALHADO);
            mensagemErro = "";
            try
            {
                File.Delete(Global.app_temp_file_csv);

                string[] texto = Directory.GetFiles(Global.app_Prints_directory(cenario.Project) + cenario.Codigo + "\\");
                if (texto.Count() == 0)
                {
                    return(true);
                }

                StringBuilder builder = new StringBuilder();

                bool      first     = true;
                string[]  txt       = texto[0].Split('\\');
                MD_Anexos anexo_old = MD_Anexos.RetornaAnexoFromFileName(txt[txt.Count() - 1], cenario);
                MD_Anexos anexos    = anexo_old;
                for (int i = 0; i < texto.Count(); i++)
                {
                    txt = texto[i].Split('\\');
                    FileInfo info = new FileInfo(texto[i]);
                    anexos = MD_Anexos.RetornaAnexoFromFileName(txt[txt.Count() - 1], cenario);

                    if (info.Extension.Equals(".jpg") || info.Extension.Equals(".jpeg") || info.Extension.Equals(".png"))
                    {
                        if (first)
                        {
                            builder.Append("<img src=\"" + texto[i] + "\" width=\"90%\" height=\"90%\" >");
                            anexo_old = anexos;
                            first     = false;
                        }
                        else
                        {
                            builder.Append(";<img src=\"" + texto[i] + "\" width=\"90%\" height=\"90%\" >" + Environment.NewLine);
                            builder.Append(anexo_old.Descricao + ";" + anexos.Descricao + Environment.NewLine);
                            first = true;
                        }
                    }
                }
                if (!first)
                {
                    builder.Append(";" + Environment.NewLine);
                    builder.Append(anexo_old.Descricao + ";" + Environment.NewLine);
                }

                CL_Files file = new CL_Files(caminhoSaida);
                file.WriteOnTheEnd(builder.ToString());
                file = null;
            }
            catch (Exception e)
            {
                mensagemErro = e.Message;
                CL_Files.WriteOnTheLog("Erro: " + e.Message, Global.TipoLog.SIMPLES);
                return(false);
            }
            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Method that write on the log
        /// </summary>
        /// <param name="message"></param>
        public static void WriteOnTheLog(string message, Global.TipoLog tipoLog)
        {
            if (Global.log_system != Global.TipoLog.DETALHADO && tipoLog == Global.TipoLog.DETALHADO)
            {
                return;
            }

            string directory_ach = Global.app_logs_directoty;

            if (DateTime.Now.Day < 10)
            {
                directory_ach += "0" + DateTime.Now.Day;
            }
            else
            {
                directory_ach += DateTime.Now.Day;
            }

            if (DateTime.Now.Month < 10)
            {
                directory_ach += "0" + DateTime.Now.Month;
            }
            else
            {
                directory_ach += DateTime.Now.Month;
            }


            directory_ach += DateTime.Now.Year + ".log";

            CL_Files file = new CL_Files(directory_ach);

            file.WriteOnTheEnd(DateTime.Now.ToString() + "- " + (tipoLog == Global.TipoLog.DETALHADO ? "DETALHADO -" : "SIMPLES -") + message + "\n");
            file = null;
        }
Beispiel #3
0
        /// <summary>
        /// Método que cria o arquivo xml a partir de um cenário
        /// </summary>
        /// <param name="cenario">cenário a se criar o arquivo xml</param>
        /// <param name="mensagemErro">mensagem se houver erro</param>
        /// <returns></returns>
        public static bool CriaArquivoXMLFromCenario(MD_Cenario cenario, ref string mensagemErro)
        {
            CL_Files.WriteOnTheLog("Document.CriaArquivoXML", Global.TipoLog.DETALHADO);
            mensagemErro = "";

            try
            {
                File.Delete(Global.app_temp_file_xml);

                if (!MontaCSVCenario(cenario, Global.app_temp_file_csv, ref mensagemErro))
                {
                    return(false);
                }

                StringBuilder texto = new StringBuilder();

                texto.Append("<?xml version=\"1.0\"?>" + Environment.NewLine);
                texto.Append("<document>" + Environment.NewLine);
                texto.Append("  <page>" + Environment.NewLine);
                texto.Append("      <title>" + Environment.NewLine);
                texto.Append("          " + cenario.Project.NumeroTarefa + "-" + cenario.Project.Nome + " - Relatório de Testes" + Environment.NewLine);
                texto.Append("      </title>" + Environment.NewLine);
                texto.Append("      <informacoes>" + Environment.NewLine);
                texto.Append("      </informacoes>" + Environment.NewLine);
                texto.Append("      <text>" + GetTextoCenario(cenario, true) + Environment.NewLine);
                texto.Append("      </text>" + Environment.NewLine);
                texto.Append("  </page>" + Environment.NewLine);

                if (Directory.GetFiles(Global.app_Prints_directory(cenario.Project) + cenario.Codigo + "\\").Count() > 0)
                {
                    texto.Append("  <page>" + Environment.NewLine);
                    texto.Append("      <title>" + Environment.NewLine);
                    texto.Append("          Relatório de Testes" + Environment.NewLine);
                    texto.Append("      </title>" + Environment.NewLine);
                    texto.Append("      <informacoes>" + Environment.NewLine);
                    texto.Append("      </informacoes>" + Environment.NewLine);
                    texto.Append("      <table_lines>2</table_lines>" + Environment.NewLine);
                    texto.Append("      <csv_file>" + Global.app_temp_file_csv + "</csv_file>" + Environment.NewLine);
                    texto.Append("  </page>" + Environment.NewLine);
                }

                texto.Append("</document>" + Environment.NewLine);

                CL_Files arquivo = new CL_Files(Global.app_temp_file_xml);
                arquivo.WriteOnTheEnd(texto.ToString());
                arquivo = null;
            }
            catch (Exception e)
            {
                mensagemErro = e.Message;
                CL_Files.WriteOnTheLog("Erro: " + e.Message, Global.TipoLog.SIMPLES);
                return(false);
            }
            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// Método que cria o arquivo csv para estimativa
        /// </summary>
        /// <param name="estimativa"></param>
        /// <param name="mensagemErro"></param>
        /// <returns></returns>
        private static bool CriaArquivoCSV(MD_Estimativa estimativa, ref string mensagemErro)
        {
            Util.CL_Files.WriteOnTheLog("Document.CriaArquivoCSV()", Util.Global.TipoLog.DETALHADO);
            mensagemErro = "";
            try
            {
                File.Delete(Global.app_temp_file_csv);

                StringBuilder texto = new StringBuilder();
                texto.Append("<b>Testes</b>;\n");
                texto.Append("Ler RRM;" + estimativa.TempoLeituraRRM + Environment.NewLine);
                texto.Append("Preparação do banco;" + estimativa.TempoPreparacaoBanco + Environment.NewLine);
                texto.Append("Criar roteiro;" + estimativa.TempoRoteiro + Environment.NewLine);
                texto.Append("Instalar versão;" + estimativa.TempoInstalação + Environment.NewLine);
                texto.Append("SSI banco de dados;" + estimativa.TempoBanco + Environment.NewLine);
                texto.Append("SSI Carga;" + estimativa.TempoCarga + Environment.NewLine);
                texto.Append("Importação, Exportação;" + estimativa.TempoExpImp + Environment.NewLine);
                texto.Append("SSU - Station;" + estimativa.TempoStation + Environment.NewLine);
                texto.Append("SSI - LdxProc;" + estimativa.TempoLdxproc + Environment.NewLine);
                texto.Append("SSI - MW;" + estimativa.TempoMiddleware + Environment.NewLine);
                texto.Append("SSM - AND ;" + estimativa.TempoAndroid + Environment.NewLine);
                texto.Append("SSM - WIN;" + estimativa.TempoWindows + Environment.NewLine);
                texto.Append("Impactos negativos;" + estimativa.TempoImpactos + Environment.NewLine);
                texto.Append("Total;" + CalculaTempoTotalEstimativa(estimativa) + Environment.NewLine);

                CL_Files file = new CL_Files(Global.app_temp_file_csv);

                file.WriteOnTheEnd(texto.ToString());
                file = null;
            }
            catch (Exception e)
            {
                mensagemErro = e.Message;
                CL_Files.WriteOnTheLog("Erro: " + e.Message, Global.TipoLog.SIMPLES);
                return(false);
            }
            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// Método que cria o arquivo xml a partir de um projeto
        /// </summary>
        /// <param name="project"></param>
        /// <param name="mensagemErro"></param>
        /// <returns></returns>
        public static bool CriaArquivoXMLFromProject(MD_Project project, bool geraestimativa, ref string mensagemErro)
        {
            CL_Files.WriteOnTheLog("Document.CriaArquivoXML", Global.TipoLog.DETALHADO);
            mensagemErro = "";

            try
            {
                File.Delete(Global.app_temp_file_xml);

                StringBuilder texto = new StringBuilder();

                texto.Append("<?xml version=\"1.0\"?>" + Environment.NewLine);
                texto.Append("<document>" + Environment.NewLine);
                texto.Append("  <page>" + Environment.NewLine);
                texto.Append("      <title>" + Environment.NewLine);
                texto.Append("          " + project.NumeroTarefa + "-" + project.Nome + Environment.NewLine);
                texto.Append("      </title>" + Environment.NewLine);
                texto.Append("      <informacoes>" + Environment.NewLine);
                texto.Append("      </informacoes>" + Environment.NewLine);
                texto.Append("      <text>" + project.Descricao + Environment.NewLine);
                texto.Append("      </text>" + Environment.NewLine);
                texto.Append("  </page>" + Environment.NewLine);

                if (geraestimativa)
                {
                    MD_Estimativa estimativa = project.GetEstimativa();
                    texto.Append("  <page>" + Environment.NewLine);
                    texto.Append("      <title>" + Environment.NewLine);
                    texto.Append("          " + project.NumeroTarefa + " - Estimativa de testes" + Environment.NewLine);
                    texto.Append("      </title>" + Environment.NewLine);
                    texto.Append("      <informacoes>" + Environment.NewLine);
                    texto.Append("      </informacoes>" + Environment.NewLine);
                    texto.Append("      <text>" + CriaTextoEstimativa(project, ref mensagemErro) + Environment.NewLine);
                    texto.Append("      </text>" + Environment.NewLine);
                    texto.Append("  </page>" + Environment.NewLine);
                }

                int i = 0;
                foreach (MD_Cenario cenario in project.GetCenarios())
                {
                    string caminhocsv = Global.app_temp_file_csv.Replace(".", i + ".");

                    texto.Append("  <page>" + Environment.NewLine);
                    texto.Append("      <title>" + Environment.NewLine);
                    texto.Append("          Cenário " + (i + 1).ToString());
                    texto.Append("      </title>" + Environment.NewLine);
                    texto.Append("      <informacoes>" + Environment.NewLine);
                    texto.Append("      </informacoes>" + Environment.NewLine);
                    texto.Append("      <text>" + GetTextoCenario(cenario, false) + Environment.NewLine);
                    texto.Append("      </text>" + Environment.NewLine);
                    texto.Append("  </page>" + Environment.NewLine);

                    if (!MontaCSVCenario(cenario, caminhocsv, ref mensagemErro))
                    {
                        return(false);
                    }

                    if (Directory.GetFiles(Global.app_Prints_directory(cenario.Project) + cenario.Codigo + "\\").Count() > 0)
                    {
                        texto.Append("  <page>" + Environment.NewLine);
                        texto.Append("      <title>" + Environment.NewLine);
                        texto.Append("          Relatório de Testes" + Environment.NewLine);
                        texto.Append("      </title>" + Environment.NewLine);
                        texto.Append("      <informacoes>" + Environment.NewLine);
                        texto.Append("      </informacoes>" + Environment.NewLine);
                        texto.Append("      <table_lines>2</table_lines>" + Environment.NewLine);
                        texto.Append("      <csv_file>" + caminhocsv + "</csv_file>" + Environment.NewLine);
                        texto.Append("  </page>" + Environment.NewLine);
                    }
                }

                texto.Append("</document>" + Environment.NewLine);

                CL_Files arquivo = new CL_Files(Global.app_temp_file_xml);
                arquivo.WriteOnTheEnd(texto.ToString());
                arquivo = null;
            }
            catch (Exception e)
            {
                mensagemErro = e.Message;
                CL_Files.WriteOnTheLog("Erro: " + e.Message, Global.TipoLog.SIMPLES);
                return(false);
            }
            return(true);
        }