/// <summary> /// Método que cria o arquivo json de configuração /// </summary> /// <param name="project">Projeto a se criar a configuração</param> /// <param name="mensagemErro">Mensagem de erro se houver</param> /// <returns>true - Criou o arquivo com sucesso; False - erro</returns> private static bool CriaArquivoJson(MD_Project project, ref string mensagemErro) { CL_Files.WriteOnTheLog("Document.CriaEstimativa", Global.TipoLog.DETALHADO); mensagemErro = ""; try { File.Delete(Global.app_temp_file_json); MD_Estimativa estimativa = project.GetEstimativa(); StringBuilder texto = new StringBuilder(); texto.Append("{\n"); texto.Append(" 'AUTHOR':'" + project.NomeTester + "'," + Environment.NewLine); texto.Append(" 'CRIACAO':'" + project.DataCriacao.ToShortDateString() + "'," + Environment.NewLine); texto.Append(" 'CRIADOR':'" + project.NomeTester + "',"); texto.Append(" 'MODIFICACAO':'" + project.DataCriacao.ToShortDateString() + "'," + Environment.NewLine); texto.Append(" 'ASSUNTO':'" + project.Nome + "'," + Environment.NewLine); texto.Append(" 'TITULO':'" + project.NumeroTarefa + " - " + project.Nome + "'" + Environment.NewLine); texto.Append("}"); StreamWriter writer = new StreamWriter(Global.app_temp_file_json); writer.Write(texto.ToString()); writer.Close(); } catch (Exception e) { mensagemErro = e.Message; CL_Files.WriteOnTheLog("Erro: " + e.Message, Global.TipoLog.SIMPLES); return(false); } return(true); }
/// <summary> /// Construtor principal da classe /// </summary> /// <param name="principal">Tela principal que chamou o usercontrol</param> /// <param name="estimativa">Model estimativa</param> /// <param name="tarefa">Tarefa a se fazer</param> /// <param name="tela">Tag da tela</param> public UC_CadastroEstimativa(FO_Principal principal, MD_Estimativa estimativa, Tarefa tarefa, Telas tela) { Util.CL_Files.WriteOnTheLog("UC_CadastroEstimativa.UC_CadastroEstimativa()", Util.Global.TipoLog.DETALHADO); this.principal = principal; this.estimativa = estimativa; this.tarefa = tarefa; this.Tag = (int)tela; IniciaUserControl(); }
/// <summary> /// Método que retorna o texto com o relatório do tempo estimado de teste para a mudança /// </summary> /// <param name="project"></param> /// <param name="mensagem"></param> /// <returns></returns> public static string CriaTextoEstimativa(MD_Project project, ref string mensagem) { Util.CL_Files.WriteOnTheLog("Document.CriaTextoCopiarEstimativa()", Util.Global.TipoLog.DETALHADO); mensagem = ""; string retorno = ""; try { StringBuilder texto = new StringBuilder(); MD_Estimativa estimativa = project.GetEstimativa(); texto.Append("\\tabela\\tabelacorpo"); texto.Append("\\linha\\coluna\\tTarefa\\et\\ecoluna\\coluna\\tTempo\\et\\ecoluna\\elinha"); texto.Append("\\linha\\colunaLer RRM\\ecoluna\\coluna" + estimativa.TempoLeituraRRM + "\\ecoluna\\elinha"); texto.Append("\\linha\\colunaPreparação do banco\\ecoluna\\coluna" + estimativa.TempoPreparacaoBanco + "\\ecoluna\\elinha"); texto.Append("\\linha\\colunaCriar roteiro\\ecoluna\\coluna" + estimativa.TempoRoteiro + "\\ecoluna\\elinha"); texto.Append("\\linha\\colunaInstalar versão\\ecoluna\\coluna" + estimativa.TempoInstalação + "\\ecoluna\\elinha"); texto.Append("\\linha\\colunaSSI banco de dados\\ecoluna\\coluna" + estimativa.TempoBanco + "\\ecoluna\\elinha"); texto.Append("\\linha\\colunaSSI Carga\\ecoluna\\coluna" + estimativa.TempoCarga + "\\ecoluna\\elinha"); texto.Append("\\linha\\colunaImportação, Exportação\\ecoluna\\coluna" + estimativa.TempoExpImp + "\\ecoluna\\elinha"); texto.Append("\\linha\\colunaSSU - Station\\ecoluna\\coluna" + estimativa.TempoStation + "\\ecoluna\\elinha"); texto.Append("\\linha\\colunaSSI - LdxProc\\ecoluna\\coluna" + estimativa.TempoLdxproc + "\\ecoluna\\elinha"); texto.Append("\\linha\\colunaSSI - MW\\ecoluna\\coluna" + estimativa.TempoMiddleware + "\\ecoluna\\elinha"); texto.Append("\\linha\\colunaSSM - AND\\ecoluna\\coluna" + estimativa.TempoAndroid + "\\ecoluna\\elinha"); texto.Append("\\linha\\colunaSSM - WIN\\ecoluna\\coluna" + estimativa.TempoWindows + "\\ecoluna\\elinha"); texto.Append("\\linha\\colunaImpactos negativos\\ecoluna\\coluna" + estimativa.TempoImpactos + "\\ecoluna\\elinha"); texto.Append("\\linha\\colunaTotal\\ecoluna\\coluna" + CalculaTempoTotalEstimativa(estimativa) + "\\ecoluna\\elinha"); texto.Append("\\etabelacorpo\\etabela"); retorno = texto.ToString(); } catch (Exception e) { mensagem = e.Message; CL_Files.WriteOnTheLog("Erro: " + e.Message, Global.TipoLog.SIMPLES); return(""); } return(retorno); }
/// <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); }
/// <summary> /// Método que adiciona a estimativa no node do projeto /// </summary> /// <param name="project">Projeto selecionado no node</param> /// /// <param name="node">Node a acionar as estimativas</param> public void AdicionarEstimativas(MD_Project project, ref TreeNode node) { Util.CL_Files.WriteOnTheLog("FO_Principal.AdicionarEstimativas()", Util.Global.TipoLog.DETALHADO); MD_Estimativa estimativa = project.GetEstimativa(); TreeNode nodeEstimativas = new TreeNode("Estimativa: " + Util.Document.CalculaTempoTotalEstimativa(estimativa)); nodeEstimativas.Tag = "estimativa:" + estimativa.Codigo + ":" + project.Codigo + ":" + project.NumeroTarefa; nodeEstimativas.ImageIndex = 1; nodeEstimativas.SelectedImageIndex = 1; MenuItem item_editar_estimativa = new MenuItem("Editar", item_incluir_estimativa_selected_Click); item_editar_estimativa.Tag = project.Codigo + ":" + project.NumeroTarefa; ContextMenu menuEstimativa = new ContextMenu(); menuEstimativa.MenuItems.Add(item_editar_estimativa); nodeEstimativas.ContextMenu = menuEstimativa; node.Nodes.Add(nodeEstimativas); }
/// <summary> /// Método que retorna o texto com o relatório do tempo estimado de teste para a mudança /// </summary> /// <param name="project"></param> /// <param name="mensagem"></param> /// <returns></returns> public static string CriaTextoCopiarEstimativa(MD_Project project, ref string mensagem) { Util.CL_Files.WriteOnTheLog("Document.CriaTextoCopiarEstimativa()", Util.Global.TipoLog.DETALHADO); mensagem = ""; string retorno = ""; try { StringBuilder texto = new StringBuilder(); MD_Estimativa estimativa = project.GetEstimativa(); 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); retorno = texto.ToString(); } catch (Exception e) { mensagem = e.Message; CL_Files.WriteOnTheLog("Erro: " + e.Message, Global.TipoLog.SIMPLES); return(""); } return(retorno); }
/// <summary> /// Método que calcula o tempo total estimato da estimativa /// </summary> /// <param name="estimativa"></param> /// <returns>Formato das horas totais: 00:00:00</returns> public static string CalculaTempoTotalEstimativa(MD_Estimativa estimativa) { Util.CL_Files.WriteOnTheLog("Document.CalculaTempoTotalEstimativa()", Util.Global.TipoLog.DETALHADO); int horas = 0; int minutos = 0; int segundos = 0; horas += int.Parse(estimativa.TempoAndroid.Split(':')[0].ToString()); horas += int.Parse(estimativa.TempoBanco.Split(':')[0].ToString()); horas += int.Parse(estimativa.TempoCarga.Split(':')[0].ToString()); horas += int.Parse(estimativa.TempoExpImp.Split(':')[0].ToString()); horas += int.Parse(estimativa.TempoImpactos.Split(':')[0].ToString()); horas += int.Parse(estimativa.TempoInstalação.Split(':')[0].ToString()); horas += int.Parse(estimativa.TempoLdxproc.Split(':')[0].ToString()); horas += int.Parse(estimativa.TempoLeituraRRM.Split(':')[0].ToString()); horas += int.Parse(estimativa.TempoMiddleware.Split(':')[0].ToString()); horas += int.Parse(estimativa.TempoPreparacaoBanco.Split(':')[0].ToString()); horas += int.Parse(estimativa.TempoRoteiro.Split(':')[0].ToString()); horas += int.Parse(estimativa.TempoStation.Split(':')[0].ToString()); horas += int.Parse(estimativa.TempoWindows.Split(':')[0].ToString()); minutos += int.Parse(estimativa.TempoAndroid.Split(':')[1].ToString()); minutos += int.Parse(estimativa.TempoBanco.Split(':')[1].ToString()); minutos += int.Parse(estimativa.TempoCarga.Split(':')[1].ToString()); minutos += int.Parse(estimativa.TempoExpImp.Split(':')[1].ToString()); minutos += int.Parse(estimativa.TempoImpactos.Split(':')[1].ToString()); minutos += int.Parse(estimativa.TempoInstalação.Split(':')[1].ToString()); minutos += int.Parse(estimativa.TempoLdxproc.Split(':')[1].ToString()); minutos += int.Parse(estimativa.TempoLeituraRRM.Split(':')[1].ToString()); minutos += int.Parse(estimativa.TempoMiddleware.Split(':')[1].ToString()); minutos += int.Parse(estimativa.TempoPreparacaoBanco.Split(':')[1].ToString()); minutos += int.Parse(estimativa.TempoRoteiro.Split(':')[1].ToString()); minutos += int.Parse(estimativa.TempoStation.Split(':')[1].ToString()); minutos += int.Parse(estimativa.TempoWindows.Split(':')[1].ToString()); segundos += int.Parse(estimativa.TempoAndroid.Split(':')[2].ToString()); segundos += int.Parse(estimativa.TempoBanco.Split(':')[2].ToString()); segundos += int.Parse(estimativa.TempoCarga.Split(':')[2].ToString()); segundos += int.Parse(estimativa.TempoExpImp.Split(':')[2].ToString()); segundos += int.Parse(estimativa.TempoImpactos.Split(':')[2].ToString()); segundos += int.Parse(estimativa.TempoInstalação.Split(':')[2].ToString()); segundos += int.Parse(estimativa.TempoLdxproc.Split(':')[2].ToString()); segundos += int.Parse(estimativa.TempoLeituraRRM.Split(':')[2].ToString()); segundos += int.Parse(estimativa.TempoMiddleware.Split(':')[2].ToString()); segundos += int.Parse(estimativa.TempoPreparacaoBanco.Split(':')[2].ToString()); segundos += int.Parse(estimativa.TempoRoteiro.Split(':')[2].ToString()); segundos += int.Parse(estimativa.TempoStation.Split(':')[2].ToString()); segundos += int.Parse(estimativa.TempoWindows.Split(':')[2].ToString()); while (segundos >= 60) { minutos++; segundos -= 60; } while (minutos >= 60) { horas++; minutos -= 60; } string retorno = (horas >= 10 ? horas.ToString() : "0" + horas) + ":" + (minutos >= 10 ? minutos.ToString() : "0" + minutos) + ":" + (segundos >= 10 ? segundos.ToString() : "0" + segundos); return(retorno); }
/// <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); }
/// <summary> /// Método que importa backup /// </summary> /// <param name="mensagemErro"></param> /// <returns>True - importacao realizada; False - erro</returns> private static bool ImportaBancoBackup(ref string mensagemErro) { mensagemErro = ""; try { ZipFile file = new ZipFile(Global.nome_arquivo_backup); file.ExtractAll(Global.app_backup_directory); file.Dispose(); DataBase.CloseConnection(); DataBase.OpenConnection(Global.app_backup_directory + Global.app_base_file.Replace(Global.app_main_directoty, "")); List <MD_Project> project = new List <MD_Project>(); // Criar tabela ou campos que não existem MD_Project pr = new MD_Project(0, 0); List <MD_Estimativa> estimativas = new List <MD_Estimativa>(); // Criar tabela ou campos que não existem MD_Estimativa es = new MD_Estimativa(0, pr); List <MD_Status> status = new List <MD_Status>(); // Criar tabela ou campos que não existem MD_Status st = new MD_Status(0); List <MD_Cenario> cenarios = new List <MD_Cenario>(); // Criar tabela ou campos que não existem MD_Cenario ce = new MD_Cenario(0, pr); List <MD_Anexos> anexos = new List <MD_Anexos>(); // Criar tabela ou campos que não existem MD_Anexos an = new MD_Anexos(0, ce); string sentenca = "SELECT CODIGOPROJ, TAREFA FROM MAKDOCUMENTS"; SQLiteDataReader reader = DataBase.Select(sentenca); if (reader != null) { while (reader.Read()) { project.Add(new MD_Project(int.Parse(reader["CODIGOPROJ"].ToString()), int.Parse(reader["TAREFA"].ToString()))); } reader.Close(); } sentenca = "SELECT EST.CODIGOEST, DOC.CODIGOPROJ, EST.TAREFA FROM MAKESTIMATIVAS EST, MAKDOCUMENTS DOC WHERE DOC.TAREFA = EST.TAREFA "; reader = DataBase.Select(sentenca); if (reader != null) { while (reader.Read()) { estimativas.Add(new Model.MD_Estimativa(int.Parse(reader["CODIGOEST"].ToString()), new Model.MD_Project(int.Parse(reader["CODIGOPROJ"].ToString()), int.Parse(reader["TAREFA"].ToString())))); } reader.Close(); } sentenca = "SELECT CODIGOSTAT FROM MAKSTATUS "; reader = DataBase.Select(sentenca); if (reader != null) { while (reader.Read()) { status.Add(new Model.MD_Status(int.Parse(reader["CODIGOSTAT"].ToString()))); } reader.Close(); } sentenca = "SELECT CEN.CODIGOCEN, DOC.CODIGOPROJ, CEN.TAREFA FROM MAKCENARIOS CEN, MAKDOCUMENTS DOC WHERE DOC.TAREFA = CEN.TAREFA "; reader = DataBase.Select(sentenca); if (reader != null) { while (reader.Read()) { cenarios.Add(new Model.MD_Cenario(int.Parse(reader["CODIGOCEN"].ToString()), new Model.MD_Project(int.Parse(reader["CODIGOPROJ"].ToString()), int.Parse(reader["TAREFA"].ToString())))); } reader.Close(); } sentenca = "SELECT ANEX.CODIGOANEXO, CEN.CODIGOCEN, CEN.TAREFA, DOC.CODIGOPROJ FROM MAKANEXOS ANEX, MAKCENARIOS CEN, MAKDOCUMENTS DOC WHERE ANEX.TAREFA = CEN.TAREFA AND ANEX.CODIGOCEN = CEN.CODIGOCEN AND ANEX.TAREFA = DOC.TAREFA"; reader = DataBase.Select(sentenca); if (reader != null) { while (reader.Read()) { anexos.Add(new Model.MD_Anexos(int.Parse(reader["CODIGOCEN"].ToString()), new Model.MD_Cenario(int.Parse(reader["CODIGOCEN"].ToString()), new Model.MD_Project(int.Parse(reader["CODIGOPROJ"].ToString()), int.Parse(reader["TAREFA"].ToString()))))); } reader.Close(); } DataBase.CloseConnection(); DataBase.OpenConnection(); foreach (MD_Project proj in project) { proj.Load(); if (proj.Empty) { if (!proj.Insert()) { return(false); } if (!CopiaAnexos(proj, ref mensagemErro)) { return(false); } } } foreach (MD_Estimativa est in estimativas) { est.Load(); if (est.Empty) { if (!est.Insert()) { return(false); } } } foreach (MD_Status stat in status) { stat.Load(); if (stat.Empty) { if (!stat.Insert()) { return(false); } } } foreach (MD_Cenario cen in cenarios) { cen.Load(); if (cen.Empty) { if (!cen.Insert()) { return(false); } } } foreach (MD_Anexos anex in anexos) { anex.Load(); if (anex.Empty) { if (!anex.Insert()) { return(false); } } } } catch (Exception e) { mensagemErro = e.Message; Util.CL_Files.WriteOnTheLog(mensagemErro, Global.TipoLog.SIMPLES); return(false); } return(true); }