コード例 #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);
        }
コード例 #2
0
 /// <summary>
 /// Construtor Principal da classe
 /// </summary>
 /// <param name="anexo">Anexo pertencente ao formulario</param>
 public FO_CadastroInfoAnexo(MD_Anexos anexo, Tarefa tarefa)
 {
     Util.CL_Files.WriteOnTheLog("FO_CadastroInfoAnexo.FO_CadastroInfoAnexo()", Util.Global.TipoLog.DETALHADO);
     this.anexo  = anexo;
     this.tarefa = tarefa;
     InicializaForm();
 }
コード例 #3
0
        /// <summary>
        /// Evento acionado no clique do botão excluir anexo
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_removerAnexo_Click(object sender, EventArgs e)
        {
            Util.CL_Files.WriteOnTheLog("UC_CadastroCenarios.btn_removerAnexo_Click()", Util.Global.TipoLog.DETALHADO);
            int count = lvw_anexos.Items.Count;

            if (lvw_anexos.SelectedIndices.Count <= 0)
            {
                MessageBox.Show("Selecione um anexo!");
                return;
            }

            if (lvw_anexos.SelectedIndices.Count > 1)
            {
                MessageBox.Show("Para visualizar anexos, deve ser selecionado apenas um.");
            }

            string caminho_arquivo = lvw_anexos.Items[lvw_anexos.SelectedIndices[0]].Tag.ToString();

            try
            {
                File.Delete(caminho_arquivo);
                if (!File.Exists(caminho_arquivo))
                {
                    MessageBox.Show("Arquivo excluído do cenário com sucesso.");

                    string[] info = caminho_arquivo.Split('\\');

                    MD_Anexos anexo = MD_Anexos.RetornaAnexoFromFileName(info[info.Count() - 1].ToString(), cenario);
                    if (anexo != null)
                    {
                        anexo.Delete();
                    }
                    PreencheListView();
                }
                else
                {
                    MessageBox.Show("Erro ao excluir");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro ao excluir o anexo!");
                Util.CL_Files.WriteOnTheLog("Erro: " + ex.Message, Util.Global.TipoLog.SIMPLES);
            }
        }
コード例 #4
0
 /// <summary>
 /// Evento lançado no clique do botão cancelar
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_cancela_Click(object sender, EventArgs e)
 {
     Util.CL_Files.WriteOnTheLog("FO_CadastroInfoAnexo.btn_cancela_Click()", Util.Global.TipoLog.DETALHADO);
     anexo = null;
     this.Dispose();
 }
コード例 #5
0
        /// <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);
        }