/// <summary> /// Método que cria o relatório de estimativa /// </summary> /// <param name="project"></param> /// <param name="mensagem"></param> /// <returns></returns> public static bool CriaEstimativa(MD_Project project, string diretorio_saida, ref string mensagem) { CL_Files.WriteOnTheLog("Document.CriaEstimativa", Global.TipoLog.DETALHADO); mensagem = ""; try { if (!CriaArquivoJson(project, ref mensagem)) { return(false); } if (!CriaArquivoCSV(project.GetEstimativa(), ref mensagem)) { return(false); } if (!CriarPdf(Global.app_temp_file_csv, diretorio_saida, ref mensagem)) { return(false); } } catch (Exception e) { mensagem = e.Message; CL_Files.WriteOnTheLog("Erro: " + e.Message, Global.TipoLog.SIMPLES); return(false); } return(true); }
/// <summary> /// /// </summary> /// <param name="project"></param> /// <param name="mensagemErro"></param> /// <param name="comEstimativa"></param> /// <returns></returns> public static bool CriaRelatorioCompleto(MD_Project project, string caminhoSaida, ref string mensagemErro, bool comEstimativa) { CL_Files.WriteOnTheLog("Document.CriaRelatorioCompleto", Global.TipoLog.DETALHADO); mensagemErro = ""; try { if (!CriaArquivoJson(project, ref mensagemErro)) { return(false); } if (!CriaArquivoXMLFromProject(project, comEstimativa, ref mensagemErro)) { return(false); } if (!CriarPdf(Global.app_temp_file_xml, caminhoSaida, ref mensagemErro)) { return(false); } } catch (Exception e) { mensagemErro = e.Message; CL_Files.WriteOnTheLog("Erro: " + e.Message, Global.TipoLog.SIMPLES); return(false); } return(true); }
/// <summary> /// Método que abre a página selecionada no treeview /// </summary> /// <param name=""></param> public void AbrePagina(string code) { Util.CL_Files.WriteOnTheLog("FO_Principal.AbrePagina()", Util.Global.TipoLog.DETALHADO); int codigo = 0; string _base = code.Split(':')[0]; if (_base.Equals("tag")) { return; } else if (_base.Equals("projeto")) { codigo = int.Parse(code.Split(':')[1]); AbrirJanelaDeCadastro(codigo, int.Parse(code.Split(':')[2]), Util.Enumerator.Tarefa.VISUALIZANDO); } else if (_base.Equals("estimativa")) { codigo = int.Parse(code.Split(':')[1]); MD_Project project = new MD_Project(int.Parse(code.Split(':')[2]), int.Parse(code.Split(':')[3])); UC_CadastroEstimativa estimativa = new UC_CadastroEstimativa(this, new MD_Estimativa(codigo, project), Tarefa.VISUALIZANDO, Telas.CADASTRO_ESTIMATIVA); AbreJanela(estimativa, "Estimativa - " + project.Nome, Telas.CADASTRO_ESTIMATIVA); } else if (_base.Equals("cenario")) { codigo = int.Parse(code.Split(':')[1]); MD_Project project = new MD_Project(int.Parse(code.Split(':')[2]), int.Parse(code.Split(':')[3])); MD_Cenario cenario = new MD_Cenario(codigo, project); UC_CadastroCenarios estimativa = new UC_CadastroCenarios(this, cenario.Project, cenario, Tarefa.VISUALIZANDO, Telas.CADASTRO_ESTIMATIVA, TipoSistema.GENERICO); AbreJanela(estimativa, "Cenario " + cenario.Codigo, Telas.CADASTRO_CENARIO); } }
/// <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> /// Evento lançado na seleção do botão direito no tree view /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void item_excluir_selected_Click(object sender, EventArgs e) { Util.CL_Files.WriteOnTheLog("FO_Principal.item_excluir_selected_Click()", Util.Global.TipoLog.DETALHADO); MenuItem item = (MenuItem)sender; string codigo = item.Tag.ToString().Split(':')[0]; string numerotarefa = item.Tag.ToString().Split(':')[1]; MD_Project project = new MD_Project(int.Parse(codigo), int.Parse(numerotarefa)); if (MessageBox.Show("Deseja excluir o projeto: " + project.Nome + "?", "Excluir", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (project.Delete()) { MessageBox.Show("Excluído com sucesso!"); } else { MessageBox.Show("Erro ao excluir!"); } CarregaTreeView(); FecharTela(Telas.CADASTRO_PROJETO); FecharTela(Telas.CADASTRO_ESTIMATIVA); FecharTela(Telas.CADASTRO_CENARIO); FecharTela(Telas.CADASTRO_PROJETO_INCLUIR); } }
/// <summary> /// Construtor da classe /// </summary> public UC_CadastroProjeto(FO_Principal principal, int codigo_projeto, int numtarefa, Tarefa tarefa, Telas tela) { Util.CL_Files.WriteOnTheLog("UC_CadastroEstimativa.UC_CadastroProjeto()", Util.Global.TipoLog.DETALHADO); this.Tag = (int)tela; this.principal = principal; project = new MD_Project(codigo_projeto, numtarefa); this.tarefa = tarefa; IniciaUserControl(); }
/// <summary> /// Método que copia os arquivos de anexo /// </summary> /// <param name="mensagemErro"></param> /// <returns></returns> private static bool CopiaAnexos(MD_Project project, ref string mensagemErro) { try { if (!Directory.Exists(Global.app_files_directory)) { Directory.CreateDirectory(Global.app_files_directory); } if (!Directory.Exists(Global.app_proj_directory(project))) { Directory.CreateDirectory(Global.app_proj_directory(project)); Directory.CreateDirectory(Global.app_Prints_directory(project)); Directory.CreateDirectory(Global.app_RRM_directory(project)); } string caminho = Global.app_backup_directory + Global.app_Prints_directory(project).Replace(Global.app_main_directoty, ""); if (!Directory.Exists(caminho)) { Directory.CreateDirectory(caminho); } foreach (string file in Directory.GetFiles(caminho)) { Directory.CreateDirectory(Global.app_Prints_directory(project)); FileInfo info = new FileInfo(file); File.Copy(file, Global.app_Prints_directory(project) + info.Name); } caminho = Global.app_backup_directory + Global.app_RRM_directory(project).Replace(Global.app_main_directoty, ""); if (!Directory.Exists(caminho)) { Directory.CreateDirectory(caminho); } foreach (string dir in Directory.GetDirectories(caminho)) { string[] comp = dir.Split('\\'); foreach (string file in Directory.GetFiles(caminho)) { Directory.CreateDirectory(Global.app_RRM_directory(project) + comp[comp.Count() - 1] + "\\"); FileInfo info = new FileInfo(file); File.Copy(file, Global.app_RRM_directory(project) + comp[comp.Count() - 1] + "\\" + info.Name); } } } catch (Exception e) { mensagemErro = e.Message; Util.CL_Files.WriteOnTheLog(mensagemErro, Global.TipoLog.SIMPLES); return(false); } return(true); }
/// <summary> /// Método que adicionar os cenários de teste cadastrado para o projeto /// </summary> /// <param name="project">Projeto selecionado no node</param> /// /// <param name="node">Node a acionar os cenários</param> public void AdicionaCenarios(MD_Project project, ref TreeNode node) { Util.CL_Files.WriteOnTheLog("FO_Principal.AdicionaCenarios()", Util.Global.TipoLog.DETALHADO); MenuItem item_incluir_cenario = new MenuItem("Adicionar Cenário", item_incluir_caso_uso_selected_Click); MenuItem item_modelos_cenrios = new MenuItem("Modelos"); MenuItem item_modelos_SSI = new MenuItem("SSI", item_incluir_caso_usomodeloSSI_selected_Click); item_modelos_cenrios.MenuItems.Add(item_modelos_SSI); item_incluir_cenario.Tag = project.Codigo + ":" + project.NumeroTarefa; item_modelos_SSI.Tag = project.Codigo + ":" + project.NumeroTarefa; TreeNode nodeCenarios = new TreeNode("Cenários"); nodeCenarios.Tag = "tag:" + -1; nodeCenarios.ImageIndex = 2; nodeCenarios.SelectedImageIndex = 2; ContextMenu menuCenario = new ContextMenu(); menuCenario.MenuItems.Add(item_incluir_cenario); menuCenario.MenuItems.Add(item_modelos_cenrios); nodeCenarios.ContextMenu = menuCenario; MenuItem item_editar_cenario = new MenuItem("Editar", item_editar_cenario_selected_Click); MenuItem item_excluir_cenario = new MenuItem("Excluir", item_excluir_cenario_selected_Click); SQLiteDataReader reader = new MD_Cenario(0, project).RetornaTodosCenarios(); while (reader.Read()) { MD_Cenario cenario = new MD_Cenario(int.Parse(reader["CODIGOCEN"].ToString()), project); TreeNode node_cen = new TreeNode("Cenario " + cenario.TipoDoSistema.ToString()); node_cen.Tag = "cenario:" + cenario.Codigo + ":" + project.Codigo + ":" + project.NumeroTarefa; node_cen.ImageIndex = 3; node_cen.SelectedImageIndex = 3; item_editar_cenario.Tag = cenario; item_excluir_cenario.Tag = cenario; ContextMenu menuCen = new ContextMenu(); menuCen.MenuItems.Add(item_editar_cenario); menuCen.MenuItems.Add(item_excluir_cenario); node_cen.ContextMenu = menuCen; nodeCenarios.Nodes.Add(node_cen); } reader.Close(); node.Nodes.Add(nodeCenarios); }
/// <summary> /// Construtor principal da classe /// </summary> /// <param name="principal">Instância da tela que abriu o user control</param> /// <param name="project">Projeto referente o cenário de teste</param> /// <param name="cenario">Cenário de teste que dará o load da classe</param> /// <param name="tarefa">Tarefa a ser executada na tela</param> /// <param name="tela">Código da tela</param> public UC_CadastroCenarios(FO_Principal principal, MD_Project project, MD_Cenario cenario, Tarefa tarefa, Telas tela, TipoSistema sistema) { Util.CL_Files.WriteOnTheLog("UC_CadastroCenarios.UC_CadastroCenarios()", Util.Global.TipoLog.DETALHADO); this.principal = principal; this.project = project; this.cenario = cenario; this.tarefa = tarefa; this.Tag = (int)tela; InitializeComponent(); CarregaForm(); PopulaCampos(sistema); }
/// <summary> /// Evento lançado na seleção do botão direito no tree view /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void item_incluir_estimativa_selected_Click(object sender, EventArgs e) { Util.CL_Files.WriteOnTheLog("FO_Principal.item_incluir_estimativa_selected_Click()", Util.Global.TipoLog.DETALHADO); MenuItem item = (MenuItem)sender; string codigo = item.Tag.ToString().Split(':')[0]; string numerotarefa = item.Tag.ToString().Split(':')[1]; MD_Project project = new MD_Project(int.Parse(codigo), int.Parse(numerotarefa)); UC_CadastroEstimativa estimativa = new UC_CadastroEstimativa(this, project.GetEstimativa(), Tarefa.EDITANDO, Telas.CADASTRO_ESTIMATIVA); AbreJanela(estimativa, "Estimativa - " + project.Nome, Telas.CADASTRO_ESTIMATIVA); }
/// <summary> /// Evento lançado na seleção do botão direito no tree view /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void item_incluir_caso_usomodeloLdxMail_selected_Click(object sender, EventArgs e) { Util.CL_Files.WriteOnTheLog("FO_Principal.item_incluir_caso_uso_selected_Click()", Util.Global.TipoLog.DETALHADO); MenuItem item = (MenuItem)sender; string codigo = item.Tag.ToString().Split(':')[0]; string numerotarefa = item.Tag.ToString().Split(':')[1]; MD_Project project = new MD_Project(int.Parse(codigo), int.Parse(numerotarefa)); MD_Cenario cen = new MD_Cenario(Util.DataBase.GetIncrement("MAKCENARIOS"), project); UC_CadastroCenarios cenario = new UC_CadastroCenarios(this, project, cen, Tarefa.INCLUINDO, Telas.CADASTRO_CENARIO, TipoSistema.SSU); AbreJanela(cenario, "Cenário " + cen.Codigo, Telas.CADASTRO_CENARIO); }
/// <summary> /// Evento lançado no clique do botão cancelar /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_cancelar_Click(object sender, EventArgs e) { Util.CL_Files.WriteOnTheLog("UC_CadastroEstimativa.btn_cancelar_Click()", Util.Global.TipoLog.DETALHADO); if (tarefa == Tarefa.VISUALIZANDO) { if (project.Delete()) { MessageBox.Show("Excluído com sucesso"); } project = new MD_Project(project.Codigo, project.NumeroTarefa); FechaTela(); } else { Cancelar(); } }
/// <summary> /// Método que carrega o tree view /// </summary> public void CarregaTreeView() { Util.CL_Files.WriteOnTheLog("FO_Principal.CarregaTreeView()", Util.Global.TipoLog.DETALHADO); this.trv_projetos.ExpandAll(); this.trv_projetos.Nodes.Clear(); this.trv_projetos.Scrollable = true; SQLiteDataReader reader = new MD_Project(0, 0).RetornaTodosProjetos(); while (reader.Read()) { MD_Project project = new MD_Project(int.Parse(reader["CODIGOPROJ"].ToString()), int.Parse(reader["TAREFA"].ToString())); TreeNode node = new TreeNode(project.NumeroTarefa + " - " + project.Nome); node.Tag = "projeto:" + project.Codigo + ":" + project.NumeroTarefa; node.ImageIndex = 0; node.SelectedImageIndex = 0; MenuItem item_editar = new MenuItem("Editar", item_editar_selected_Click); item_editar.Tag = project.Codigo + ":" + project.NumeroTarefa; MenuItem item_excluir = new MenuItem("Excluir", item_excluir_selected_Click); item_excluir.Tag = project.Codigo + ":" + project.NumeroTarefa; MenuItem item_incluir_estimativa = new MenuItem("Editar Estimativa", item_incluir_estimativa_selected_Click); item_incluir_estimativa.Tag = project.Codigo + ":" + project.NumeroTarefa; MenuItem item_incluir_cenario = new MenuItem("Adicionar Cenário", item_incluir_caso_uso_selected_Click); item_incluir_cenario.Tag = project.Codigo + ":" + project.NumeroTarefa; ContextMenu menu = new ContextMenu(); menu.MenuItems.Add(item_editar); menu.MenuItems.Add(item_excluir); menu.MenuItems.Add(item_incluir_estimativa); menu.MenuItems.Add(item_incluir_cenario); node.ContextMenu = menu; AdicionarEstimativas(project, ref node); AdicionaCenarios(project, ref node); trv_projetos.Nodes.Add(node); } reader.Close(); trv_projetos.ExpandAll(); }
/// <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 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 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); }
/// <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); }