Example #1
0
        /// <summary>
        /// Método usado para extrair o conteúdo de um arquivo específico.
        /// </summary>
        /// <param name="arq">O arquivo a ser indexado.</param>
        public void Indexe(Arquivo arq)
        {
            try
            {
                IGoldenIndex goldenIndex =
                    GoldenIndexClient.Instance(Settings.Default.MaquinaGoldenIndex,
                                               Settings.Default.PortaGoldenIndex,
                                               Settings.Default.UriGoldenIndex,
                                               Settings.Default.ProtocoloGoldenIndex);
                User usuarioGoldenIndex = GoldenIndexClient.Authenticate(Settings.Default.UsuarioGoldenIndex,
                                                                         Settings.Default.SenhaGoldenIndex, goldenIndex);

                //string extensao = versao.Extensao.StartsWith(".") ? versao.Extensao : string.Concat(".", versao.Extensao);
                //if (!goldenIndex.IsSupported(usuarioGoldenIndex, extensao))
                //{
                //    // Se não for um arquivo suportado, não faz nada
                //    return;
                //}

                string id = obterIdCadastrado();
                //List<Arquivo> lista = new List<Arquivo>();
                //lista = obterIdArquivos(id);

                //foreach (var arq in lista)
                //{

                    FileData arquivo = new FileData();
                    //arquivo.Id = count++;
                    arquivo.Url = diretorio + arq.nome_Arquivo;

                    //TESTE

                    CollectionFieldUpdatingParameters parameters = new CollectionFieldUpdatingParameters();
                    parameters.CollectionName = "arquivos";
                    parameters.ContentField = "conteudo_Arquivo"; // é o mesmo que a coleção neste caso, porque o multivalorado não está agrupado num grupo
                    parameters.Table = "documento";
                    //parameters.ParentField = "id";
                    //parameters.ParentFieldValue = id; // aqui supomos que haja um registro na base Pessoas cujo Id seja 12. é nesse registro que será adicionado uma nova linha na coleção "Documentos"
                    parameters.IdField = "id_arquivo";
                    parameters.IdFieldValue = arq.id_Arquivo.ToString();

                    arquivo.IndexerParameters = parameters;
                    //arquivo.Id = Convert.ToUInt32(arq.id_Arquivo);

                    goldenIndex.SaveFile(usuarioGoldenIndex, arquivo);

               // }

            }
            catch (Exception exception)
            {
                string erro = exception.Message;
            }
        }
Example #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Adaptador adpt = new Adaptador();
     List<Arquivo> lista = new List<Arquivo>();
     for (int i = 0; i < 3; i++)
     {
         Arquivo arq = new Arquivo();
         arq.nome_Arquivo = "identidade" + i + ".pdf";
         lista.Add(arq);
     }
     lista = adpt.RetornaArquivos(lista);
     GridView1.DataSource = lista;
     GridView1.DataBind();
 }
Example #3
0
        public List<Documento> PorColuna(string coluna)
        {
            //Ver como faz aqui pra nao precisar ordenar por colunas na parte dos documentos. Só por nome e matricula
            List<Documento> lista = new List<Documento>();
            IDataReader reader;
            IDbConnection minhaConexao = new LightBaseConnection("user=lbw;password=lbw;UDB=defudb;server=localhost");
            try
            {
                minhaConexao.Open();
                try
                {
                    IDbCommand comando = new LightBaseCommand("select id, matricula_Colaborador, nome_Colaborador, arquivos.nome_Arquivo, "
                                                        + "arquivos.conteudo_Arquivo from documento order by " + coluna);
                    comando.Connection = minhaConexao;
                    reader = comando.ExecuteReader();

                    while (reader.Read())
                    {
                        Documento documento = new Documento();
                        Arquivo arquivo = new Arquivo();

                        documento.id = Convert.ToInt16(reader["id"]);
                        documento.matricula_Colaborador = Convert.ToString(reader["matricula_Colaborador"]);
                        documento.nome_Colaborador = Convert.ToString(reader["nome_Colaborador"]);

                        DataTable dt_Arquivos = (DataTable)reader["arquivos"];
                        string[] dados_Arquivos = { "", "", "" };
                        for (int i = 0; i < dt_Arquivos.Rows.Count; i++)
                        {
                            dados_Arquivos[i] = dt_Arquivos.Rows[i]["nome_Arquivo"].ToString();
                            dados_Arquivos[i] = dt_Arquivos.Rows[i]["conteudo_Arquivo"].ToString();
                        }
                        arquivo.nome_Arquivo = dados_Arquivos[0].ToString();
                        arquivo.conteudo_Arquivo = dados_Arquivos[0].ToString();

                        lista.Add(documento);
                    }
                }
                catch (LightBaseException e)
                {
                    string erro = e.Message;
                }
                return lista;
            }
            finally
            {
                minhaConexao.Close();
            }
        }
Example #4
0
        public List<Documento> PesquisaPorCampo(string comando)
        {
            List<Documento> lista = new List<Documento>();
            IDataReader reader;
            IDbConnection minhaConexao = new LightBaseConnection("user=lbw;password=lbw;udb=DEFUDB;server=localhost");
            try
            {
                minhaConexao.Open();
                try
                {
                    IDbCommand meuComando = new LightBaseCommand(comando);
                    meuComando.Connection = minhaConexao;

                    reader = meuComando.ExecuteReader();
                    while (reader.Read())
                    {
                        Documento documento = new Documento();
                        Arquivo arquivo = new Arquivo();

                        documento.id = Convert.ToInt16(reader["id"]);
                        documento.matricula_Colaborador = Convert.ToString(reader["matricula_Colaborador"]);
                        documento.nome_Colaborador = Convert.ToString(reader["nome_Colaborador"]);

                        DataTable dt_Arquivos = (DataTable)reader["arquivos"];
                        string[] dados_Arquivos = { "", "", "" };
                        for (int i = 0; i < dt_Arquivos.Rows.Count; i++)
                        {
                            dados_Arquivos[i] = dt_Arquivos.Rows[i]["nome_Arquivo"].ToString();
                            dados_Arquivos[i] = dt_Arquivos.Rows[i]["conteudo_Arquivo"].ToString();
                        }
                        arquivo.nome_Arquivo = dados_Arquivos[0].ToString();
                        arquivo.conteudo_Arquivo = dados_Arquivos[0].ToString();

                        lista.Add(documento);
                    }
                }
                catch (LightBaseException e)
                {
                    string texto = e.Message;
                }
                return lista;
            }
            finally
            {
                minhaConexao.Close();
            }
        }
        protected Arquivo inserirArquivosNaLista(string id, string opcao)
        {
            List<Arquivo> list_temp = new List<Arquivo>();
            list_temp = (List<Arquivo>)Session[opcao];
            Arquivo arq_temp = new Arquivo();

            if (list_temp != null)
            {
                string nomeArquivo = montarFormatoGD(id, opcao + ext);
                int count = list_temp.Count;
                if (count >= 2)
                {
                    MergeDocument document = MergeDocument.Merge(diretorio + list_temp.ElementAt(0).nome_Arquivo, diretorio + list_temp.ElementAt(1).nome_Arquivo);
                    if (count > 2)
                    {
                        for (int i = 2; i < count; i++)
                        {
                            document.Append(diretorio + list_temp.ElementAt(i).nome_Arquivo);
                        }
                    }
                    document.Draw(nomeArquivo);
                    System.IO.File.Delete(diretorio + nomeArquivo);
                    System.IO.File.Move(nomeArquivo, diretorio + nomeArquivo);
                }
                arq_temp.nome_Arquivo = nomeArquivo;
                arq_temp.tipo_Arquivo = opcao;
            }
            return arq_temp;
        }
Example #6
0
        protected void ImageButtonSalvar_Click(object sender, ImageClickEventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                //lembrar de adicionar o ID do cadastro ao nome na hora de adicionar ao banco
                String nameFile = "";
                nameFile = retornaAbaAtiva();

                string nomeArquivo1 = FileUpload1.PostedFile.FileName.Substring(FileUpload1.PostedFile.FileName.LastIndexOf('\\') + 1);
                try
                {
                    FileUpload1.SaveAs(pathDir + nomeArquivo1);
                }
                catch (Exception ex)
                {
                    LabelErro.Text = ex.Message;
                }
                //levantar flag dizendo que o arquivo foi postado
                Session.Add("postou_" + nameFile, "sim");

                Arquivo arquivo = new Arquivo();
                arquivo.nome_Arquivo = nomeArquivo1;
                arquivo.tipo_Arquivo = nameFile;

                lista = (List<Arquivo>)Session[nameFile];
                if (lista == null)
                {
                    lista = new List<Arquivo>();
                }
                lista.Add(arquivo);
                Session.Add(nameFile, lista);
                carrega_Grid(nameFile);
            }
            else
            {
                //Mostra o Erro quando não tem arquivo selecionado
                LabelErro.Text = "Selecione o arquivo";
            }
        }
        protected Arquivo inserirArquivosNaLista(string id, string opcao)
        {
            List<Arquivo> list_temp = new List<Arquivo>();
            list_temp = (List<Arquivo>)Session[opcao];
            Arquivo arq_temp = new Arquivo();

            if (list_temp != null)
            {
                string nomeArquivo = list_temp.ElementAt(0).nome_Arquivo;
                int count = list_temp.Count;

                if (count >= 2)
                {
                    MergeDocument document = MergeDocument.Merge(diretorio + list_temp.ElementAt(0).nome_Arquivo, diretorio + list_temp.ElementAt(1).nome_Arquivo);
                    if (count > 2)
                    {
                        for (int i = 2; i < count; i++)
                        {
                            document.Append(diretorio + list_temp.ElementAt(i).nome_Arquivo);
                        }
                    }
                    document.Draw(nomeArquivo);

                    //Deletando os arquivos temporarios usados no merge
                    for (int i = 0; i < count; i++)
                    {
                        if (!nomeArquivo.Equals((String)list_temp.ElementAt(i).nome_Arquivo))
                        {
                            System.IO.File.Delete(diretorio + list_temp.ElementAt(i).nome_Arquivo);
                        }
                    }
                    System.IO.File.Move(nomeArquivo, diretorio + nomeArquivo);
                }
                arq_temp.nome_Arquivo = nomeArquivo;
                arq_temp.tipo_Arquivo = opcao;
            }
            return arq_temp;
        }
 protected void atualizaSessaoDeLista(string opcao, Arquivo item)
 {
     List<Arquivo> list_temp = new List<Arquivo>();
     list_temp = (List<Arquivo>)Session[opcao];
     if (list_temp == null)
     {
         list_temp = new List<Arquivo>();
     }
     list_temp.Add(item);
     Session[opcao] = list_temp;
     Session.Add("postou_" + opcao, "sim");
 }
Example #9
0
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            string id = "";

            try
            {
                id = obterIdCadastrado();
            }
            catch (Exception ex)
            {
                LabelErro.Text         = ex.Message;
                ImageAttention.Visible = true;
            }

            Documento      documento    = new Documento();
            List <Arquivo> list_arquivo = new List <Arquivo>();

            documento.matricula_Colaborador = TextBoxMatricula.Text;
            documento.nome_Colaborador      = TextNome_Colaborador.Text;
            documento.foto            = ImageFoto.ImageUrl;
            documento.cpf_Colaborador = TextBoxCPF.Text;

            if ((TextBoxMatricula.Text.Equals("")) || (TextBoxCPF.Text.Equals("")) || (TextNome_Colaborador.Text.Equals("")))
            {
                LabelErro.Text         = "Preencha todos os campos!";
                ImageAttention.Visible = true;
            }
            else
            {
                /*
                 * Salvando arquivos postados no banco
                 */
                if (Session["postou_docsPessoais"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(id, "docsPessoais.pdf");
                    arq_temp.tipo_Arquivo = "docsPessoais";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_titulacoes"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(id, "titulacoes.pdf");
                    arq_temp.tipo_Arquivo = "titulacoes";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_portarias"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(id, "portarias.pdf");
                    arq_temp.tipo_Arquivo = "portarias";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_cis"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(id, "cis.pdf");
                    arq_temp.tipo_Arquivo = "cis";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_avisoFerias"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(id, "avisoFerias.pdf");
                    arq_temp.tipo_Arquivo = "avisoFerias";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_requerimentos"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(id, "requerimentos.pdf");
                    arq_temp.tipo_Arquivo = "requerimentos";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_outros"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(id, "outros.pdf");
                    arq_temp.tipo_Arquivo = "outros";
                    list_arquivo.Add(arq_temp);
                }

                // Verifica se existe documento pra adicionar ao banco
                if (list_arquivo.Count == 0)
                {
                    LabelErro.Text         = "Nenhum documento adicionado";
                    ImageAttention.Visible = true;
                }
                else
                {
                    //Adicionando a lista dos arquivos aos documentos pra depois adicionar no banco
                    documento.arquivos = list_arquivo;

                    Adaptador adpt = new Adaptador();
                    try
                    {
                        adpt.InserirDocumento(documento);
                        Log log = new Log();
                        log.data_log          = DateTime.Now;
                        log.tipo_acao_log     = "Inserir";
                        log.usuario_log       = (String)Session["usuario"];
                        log.mensagem_acao_log = "O usuário " + log.usuario_log + " inseriu o colaborador de matrícula " + documento.matricula_Colaborador;
                        adpt.InserirLog(log);
                    }
                    catch (Exception ex)
                    {
                        LabelErro.Text         = ex.Message;
                        ImageAttention.Visible = true;
                    }

                    /*foreach (Arquivo arq in list_arquivo)
                     * {
                     *  versiona_indexa(arq.nome_Arquivo);
                     * }*/

                    mensagem = "Colaborador inserido com sucesso";
                    Session.Add("mensagem", mensagem);
                    Server.Transfer("listar.aspx");
                }
            }
        }
Example #10
0
        /// <summary>
        /// Método usado para cadastrar o colaborador e seus respectivos documentos.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.ImageClickEventArgs"/> instance containing the event data.</param>
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            Documento documento = new Documento();
            List<Arquivo> list_arquivo = new List<Arquivo>();
            documento.matricula_Colaborador = matricula;
            documento.nome_Colaborador = TextNome_Colaborador.Text;
            documento.foto = ImageFoto.ImageUrl;
            documento.cpf_Colaborador = TextBoxCPF.Text;

            if ((TextBoxMatricula.Text.Equals("")) || (TextBoxCPF.Text.Equals("")) || (TextNome_Colaborador.Text.Equals("")))
            {
                LabelErro.Text = "Preencha todos os campos!";
                ImageAttention.Visible = true;
            }
            else
            {
                /*
                * Salvando arquivos postados no banco
                */
                if (Session["postou_docsPessoais"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(matricula, "docsPessoais.pdf");
                    arq_temp.tipo_Arquivo = "docsPessoais";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_titulacoes"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(matricula, "titulacoes.pdf");
                    arq_temp.tipo_Arquivo = "titulacoes";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_portarias"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(matricula, "portarias.pdf");
                    arq_temp.tipo_Arquivo = "portarias";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_portariasComProcesso"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(matricula, "portariasComProcesso.pdf");
                    arq_temp.tipo_Arquivo = "portariasComProcesso";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_cis"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(matricula, "cis.pdf");
                    arq_temp.tipo_Arquivo = "cis";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_avisoFerias"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(matricula, "avisoFerias.pdf");
                    arq_temp.tipo_Arquivo = "avisoFerias";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_requerimentos"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(matricula, "requerimentos.pdf");
                    arq_temp.tipo_Arquivo = "requerimentos";
                    list_arquivo.Add(arq_temp);
                }
                if (Session["postou_outros"].ToString().Equals((string)"sim"))
                {
                    Arquivo arq_temp = new Arquivo();
                    arq_temp.nome_Arquivo = montarFormatoGD(matricula, "outros.pdf");
                    arq_temp.tipo_Arquivo = "outros";
                    list_arquivo.Add(arq_temp);
                }

                // Verifica se existe documento pra adicionar ao banco
                if (list_arquivo.Count == 0)
                {
                    LabelErro.Text = "Nenhum documento adicionado";
                    ImageAttention.Visible = true;
                }
                else
                {
                    //Adicionando a lista dos arquivos aos documentos pra depois adicionar no banco
                    documento.arquivos = list_arquivo;

                    Adaptador adpt = new Adaptador();
                    try
                    {
                        adpt.InserirDocumento(documento);
                        //Após inserir o documento é inserido na base de LOG a mensagem de log do que foi feito.
                        Log log = new Log();
                        log.data_log = DateTime.Now;
                        log.tipo_acao_log = "Inserir";
                        log.usuario_log = (String)Session["usuario"];
                        log.mensagem_acao_log = "Matrícula " + documento.matricula_Colaborador + " (" + documento.nome_Colaborador + ")";
                        adpt.InserirLog(log);
                    }
                    catch (Exception ex)
                    {
                        LabelErro.Text = ex.Message;
                        ImageAttention.Visible = true;
                    }

                    //foreach (Arquivo arq in list_arquivo)
                    //{
                    //    versiona_indexa(arq.nome_Arquivo);
                    //}

                    mensagem = "Colaborador inserido com sucesso";
                    Session.Add("mensagem", mensagem);
                    Server.Transfer("listar.aspx");
                }
            }
        }
Example #11
0
        protected void ImageButtonEnviar_Click(object sender, ImageClickEventArgs e)
        {
            Documento      documento    = new Documento();
            List <Arquivo> list_arquivo = new List <Arquivo>();

            documento.matricula_Colaborador = TextBoxMatricula.Text;
            documento.nome_Colaborador      = TextNome_Colaborador.Text;
            documento.cpf_Colaborador       = TextBoxCPF.Text;
            documento.foto = ImageFoto.ImageUrl;

            /*
             * Salvando arquivos postados no banco
             * ( ver como faz pra colocar um identificador do tipo pra qnd fazer um update saber buscar esse tipo)
             */
            if (Session["postou_docsPessoais"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("docsPessoais");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_titulacoes"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("titulacoes");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_portarias"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("portarias");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_cis"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("cis");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_avisoFerias"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("avisoFerias");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_requerimentos"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("requerimentos");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_outros"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("outros");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            //Adicionando a lista dos arquivos aos documentos pra depois adicionar no banco

            //list_arquivo = (List<Arquivo>)Session["arquivos"];
            if (list_arquivo == null)
            {
                list_arquivo = new List <Arquivo>();
            }
            documento.arquivos = list_arquivo;

            Adaptador adpt = new Adaptador();

            try
            {
                adpt.AtualizarDocumento(documento, id);
                Log log = new Log();
                log.data_log          = DateTime.Now;
                log.tipo_acao_log     = "Editar";
                log.usuario_log       = (String)Session["usuario"];
                log.mensagem_acao_log = "O usuário " + log.usuario_log + " atualizou o colaborador de matrícula " + documento.matricula_Colaborador;
                adpt.InserirLog(log);
            }
            catch (Exception ex)
            {
                LabelErro.Text         = ex.Message;
                ImageAttention.Visible = true;
            }

            /*foreach (Arquivo arq in list_arquivo)
             * {
             *  versiona_indexa(arq.nome_Arquivo);
             * }*/

            mensagem = "Registro modificado com sucesso";
            Session.Add("mensagem", mensagem);
            Server.Transfer("listar.aspx");
        }
Example #12
0
        /// <summary>
        /// Método usado para salvar o arquivo no disco e quando necessário fazer um merge no arquivo.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.ImageClickEventArgs"/> instance containing the event data.</param>
        protected void ImageButtonSalvar_Click(object sender, ImageClickEventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                string id = "";
                string nameFile = "", abaAtiva;
                abaAtiva = retornaAbaAtiva();
                try
                {
                    id = obterMatricula();
                }
                catch (Exception ex)
                {
                    LabelErro.Text         = ex.Message;
                    ImageAttention.Visible = true;
                }

                //verificar se nao é uma titulaçao
                if (!abaAtiva.Equals("titulacoes"))
                {
                    nomeArquivo = montarFormatoGD(id, abaAtiva + ext);
                }
                else
                {
                    if (id.Length == 0)
                    {
                        ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "window.alert('Digite a matrícula!');", true);
                    }
                    else
                    {
                        nomeArquivo = adpt.montaFormatoTitulacao(FileUpload1.FileName.ToString(), id, DropDownListTipoProcesso.SelectedValue.ToString());
                    }
                }


                if (id.Length == 0)
                {
                    ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "window.alert('Digite a matrícula!');", true);
                }
                else
                {
                    if (Session["postou_" + abaAtiva].ToString().Equals((string)"sim") && !(abaAtiva.Equals("titulacoes")))
                    {
                        // Create a merge document and set it's properties
                        MergeDocument document = MergeDocument.Merge(pathDir + nomeArquivo, FileUpload1.PostedFile.FileName);
                        // Outputs the merged document
                        document.Draw(nomeArquivo);
                        System.IO.File.Delete(pathDir + nomeArquivo);
                        System.IO.File.Move(nomeArquivo, pathDir + nomeArquivo);
                    }
                    //se ainda nao postou o documento nao precisa fazer um merge. Ou é uma titulaçao que nao precisa de merge
                    else
                    {
                        try
                        {
                            FileUpload1.SaveAs(pathDir + nomeArquivo);
                            Session.Add("fileName", nomeArquivo);
                        }
                        catch (Exception ex)
                        {
                            LabelErro.Text         = ex.Message;
                            ImageAttention.Visible = true;
                        }
                    }
                    TableArquivo.Visible = true;
                    GridView1.Visible    = true;
                    LabelArquivo.Text    = nomeArquivo;
                    //ImageButtonVer.Visible = true;
                    ImageButtonDelete.Visible = true;
                    //levantar flag dizendo que o arquivo foi postado
                    Session.Add("postou_" + abaAtiva, "sim");

                    Arquivo arq = new Arquivo();
                    arq.nome_Arquivo = nomeArquivo;
                    arq.tipo_Arquivo = abaAtiva;

                    List <Arquivo> lista = new List <Arquivo>();
                    lista = (List <Arquivo>)Session["arquivos"];
                    if (lista == null)
                    {
                        lista = new List <Arquivo>();
                    }
                    lista.Add(arq);
                    Session["arquivos"] = lista;

                    carrega_Grid("arquivos");
                }
            }
            else
            {
                //Mostra o Erro quando não tem arquivo selecionado
                LabelErro.Text         = "Selecione o arquivo";
                ImageAttention.Visible = true;
            }
        }
Example #13
0
        protected void ImageButtonSalvar_Click(object sender, ImageClickEventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                string id = "";
                string nameFile = "";
                try
                {
                    id = obterIdCadastrado();
                }
                catch (Exception ex)
                {
                    LabelErro.Text = ex.Message;
                    ImageAttention.Visible = true;
                }
                if (Session["abaAtiva"].ToString().Equals((string)"TabPanelPessoais"))
                {
                    nameFile = "docsPessoais";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelTitulacao"))
                {
                    nameFile = "titulacoes";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelPortaria"))
                {
                    nameFile = "portarias";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelCI"))
                {
                    nameFile = "cis";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelAviso"))
                {
                    nameFile = "avisoFerias";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelRequerimento"))
                {
                    nameFile = "requerimentos";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelOutros"))
                {
                    nameFile = "outros";
                }
                string nomeArquivo = montarFormatoGD(id, nameFile + ext);
                if (Session["postou_" + nameFile].ToString().Equals((string)"sim"))
                {
                    // Create a merge document and set it's properties
                    MergeDocument document = MergeDocument.Merge(pathDir + nomeArquivo, FileUpload1.PostedFile.FileName);
                    // Outputs the merged document
                    document.Draw(nomeArquivo);
                    System.IO.File.Delete(pathDir + nomeArquivo);
                    System.IO.File.Move(nomeArquivo, pathDir + nomeArquivo);
                }
                //se ainda nao postou o documento nao precisa fazer um merge
                else
                {
                    try
                    {
                        FileUpload1.SaveAs(pathDir + nomeArquivo);
                        Session.Add("fileName", nomeArquivo);
                    }
                    catch (Exception ex)
                    {
                        LabelErro.Text = ex.Message;
                        ImageAttention.Visible = true;
                    }
                }
                TableArquivo.Visible = true;
                LabelArquivo.Text = nomeArquivo;
                ImageButtonVer.Visible = true;
                ImageButtonDelete.Visible = true;
                //levantar flag dizendo que o arquivo foi postado
                Session.Add("postou_" + nameFile, "sim");

                Arquivo arq = new Arquivo();
                arq.nome_Arquivo = nomeArquivo;
                arq.tipo_Arquivo = nameFile;

                List<Arquivo> lista = new List<Arquivo>();
                lista = (List<Arquivo>)Session["arquivos"];
                if (lista == null)
                {
                    lista = new List<Arquivo>();
                }
                lista.Add(arq);
                Session["arquivos"] = lista;
            }
            else
            {
                //Mostra o Erro quando não tem arquivo selecionado
                LabelErro.Text = "Selecione o arquivo";
                ImageAttention.Visible = true;
            }
        }
Example #14
0
        /// <summary>
        /// Método usado para salvar o arquivo no disco e quando necessário fazer um merge no arquivo.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.ImageClickEventArgs"/> instance containing the event data.</param>
        protected void ImageButtonSalvar_Click(object sender, ImageClickEventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                string id = "";
                string nameFile = "", abaAtiva;
                abaAtiva = retornaAbaAtiva();
                try
                {
                    id = obterMatricula();
                }
                catch (Exception ex)
                {
                    LabelErro.Text = ex.Message;
                    ImageAttention.Visible = true;
                }

                //verificar se nao é uma titulaçao
                if (!abaAtiva.Equals("titulacoes"))
                {
                    nomeArquivo = montarFormatoGD(id, abaAtiva + ext);
                }
                else
                {
                    if (id.Length == 0)
                    {
                        ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "window.alert('Digite a matrícula!');", true);
                    }
                    else
                    {
                        nomeArquivo = adpt.montaFormatoTitulacao(FileUpload1.FileName.ToString(), id, DropDownListTipoProcesso.SelectedValue.ToString());
                    }

                }

                if (id.Length == 0)
                {
                    ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "window.alert('Digite a matrícula!');", true);
                }
                else
                {
                    if (Session["postou_" + abaAtiva].ToString().Equals((string)"sim") && !(abaAtiva.Equals("titulacoes")))
                    {
                        // Create a merge document and set it's properties
                        MergeDocument document = MergeDocument.Merge(pathDir + nomeArquivo, FileUpload1.PostedFile.FileName);
                        // Outputs the merged document
                        document.Draw(nomeArquivo);
                        System.IO.File.Delete(pathDir + nomeArquivo);
                        System.IO.File.Move(nomeArquivo, pathDir + nomeArquivo);
                    }
                    //se ainda nao postou o documento nao precisa fazer um merge. Ou é uma titulaçao que nao precisa de merge
                    else
                    {
                        try
                        {
                            FileUpload1.SaveAs(pathDir + nomeArquivo);
                            Session.Add("fileName", nomeArquivo);
                        }
                        catch (Exception ex)
                        {
                            LabelErro.Text = ex.Message;
                            ImageAttention.Visible = true;
                        }
                    }
                    TableArquivo.Visible = true;
                    GridView1.Visible = true;
                    LabelArquivo.Text = nomeArquivo;
                    //ImageButtonVer.Visible = true;
                    ImageButtonDelete.Visible = true;
                    //levantar flag dizendo que o arquivo foi postado
                    Session.Add("postou_" + abaAtiva, "sim");

                    Arquivo arq = new Arquivo();
                    arq.nome_Arquivo = nomeArquivo;
                    arq.tipo_Arquivo = abaAtiva;

                    List<Arquivo> lista = new List<Arquivo>();
                    lista = (List<Arquivo>)Session["arquivos"];
                    if (lista == null)
                    {
                        lista = new List<Arquivo>();
                    }
                    lista.Add(arq);
                    Session["arquivos"] = lista;

                    carrega_Grid("arquivos");
                }

            }
            else
            {
                //Mostra o Erro quando não tem arquivo selecionado
                LabelErro.Text = "Selecione o arquivo";
                ImageAttention.Visible = true;
            }
        }
Example #15
0
        public List<Documento> Todos()
        {
            List<Documento> lista = new List<Documento>();
            IDataReader reader;
            IDbConnection minhaConexao = new LightBaseConnection("user=lbw;password=lbw;UDB=defudb;server=localhost");
            try
            {
                minhaConexao.Open();

                IDbCommand comando = new LightBaseCommand("select id, matricula_Colaborador, nome_Colaborador, arquivos.nome_Arquivo, "
                                                        + "arquivos.conteudo_Arquivo from documento");
                comando.Connection = minhaConexao;
                reader = comando.ExecuteReader();

                while (reader.Read())
                {
                    Documento documento = new Documento();
                    Arquivo arquivo = new Arquivo();

                    documento.id = Convert.ToInt16(reader["id"]);
                    documento.matricula_Colaborador = Convert.ToString(reader["matricula_Colaborador"]);
                    documento.nome_Colaborador = Convert.ToString(reader["nome_Colaborador"]);

                    DataTable dt_Arquivos = (DataTable)reader["arquivos"];
                    string[] dados_Arquivos = { "", "", "" };
                    for (int i = 0; i < dt_Arquivos.Rows.Count; i++)
                    {
                        dados_Arquivos[i] = dt_Arquivos.Rows[i]["nome_Arquivo"].ToString();
                        dados_Arquivos[i] = dt_Arquivos.Rows[i]["conteudo_Arquivo"].ToString();
                    }
                    arquivo.nome_Arquivo = dados_Arquivos[0].ToString();
                    arquivo.conteudo_Arquivo = dados_Arquivos[0].ToString();

                    lista.Add(documento);
                }
                return lista;
            }
            finally
            {
                minhaConexao.Close();
            }
        }
Example #16
0
        protected void ImageButtonSalvar_Click(object sender, ImageClickEventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                string id       = "";
                string nameFile = "";
                try
                {
                    id = obterIdCadastrado();
                }
                catch (Exception ex)
                {
                    LabelErro.Text         = ex.Message;
                    ImageAttention.Visible = true;
                }
                if (Session["abaAtiva"].ToString().Equals((string)"TabPanelPessoais"))
                {
                    nameFile = "docsPessoais";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelTitulacao"))
                {
                    nameFile = "titulacoes";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelPortaria"))
                {
                    nameFile = "portarias";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelCI"))
                {
                    nameFile = "cis";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelAviso"))
                {
                    nameFile = "avisoFerias";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelRequerimento"))
                {
                    nameFile = "requerimentos";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelOutros"))
                {
                    nameFile = "outros";
                }
                string nomeArquivo = montarFormatoGD(id, nameFile + ext);
                if (Session["postou_" + nameFile].ToString().Equals((string)"sim"))
                {
                    // Create a merge document and set it's properties
                    MergeDocument document = MergeDocument.Merge(pathDir + nomeArquivo, FileUpload1.PostedFile.FileName);
                    // Outputs the merged document
                    document.Draw(nomeArquivo);
                    System.IO.File.Delete(pathDir + nomeArquivo);
                    System.IO.File.Move(nomeArquivo, pathDir + nomeArquivo);
                }
                //se ainda nao postou o documento nao precisa fazer um merge
                else
                {
                    try
                    {
                        FileUpload1.SaveAs(pathDir + nomeArquivo);
                        Session.Add("fileName", nomeArquivo);
                    }
                    catch (Exception ex)
                    {
                        LabelErro.Text         = ex.Message;
                        ImageAttention.Visible = true;
                    }
                }
                TableArquivo.Visible      = true;
                LabelArquivo.Text         = nomeArquivo;
                ImageButtonVer.Visible    = true;
                ImageButtonDelete.Visible = true;
                //levantar flag dizendo que o arquivo foi postado
                Session.Add("postou_" + nameFile, "sim");

                Arquivo arq = new Arquivo();
                arq.nome_Arquivo = nomeArquivo;
                arq.tipo_Arquivo = nameFile;

                List <Arquivo> lista = new List <Arquivo>();
                lista = (List <Arquivo>)Session["arquivos"];
                if (lista == null)
                {
                    lista = new List <Arquivo>();
                }
                lista.Add(arq);
                Session["arquivos"] = lista;
            }
            else
            {
                //Mostra o Erro quando não tem arquivo selecionado
                LabelErro.Text         = "Selecione o arquivo";
                ImageAttention.Visible = true;
            }
        }
Example #17
0
        public void MontaTela(string id)
        {
            IDataReader   reader;
            IDbConnection minhaConexao = new LightBaseConnection("user=lbw;password=lbw;udb=defudb;server=localhost");

            try
            {
                minhaConexao.Open();

                IDbCommand meuComando = new LightBaseCommand("select id , matricula_Colaborador , foto, nome_Colaborador, arquivos from documento where id =" + id);
                meuComando.Connection = minhaConexao;
                reader = meuComando.ExecuteReader();

                while (reader.Read())
                {
                    TextBoxMatricula.Text     = Convert.ToString(reader["matricula_Colaborador"]);
                    TextNome_Colaborador.Text = Convert.ToString(reader["nome_Colaborador"]);
                    DataTable      dt_Arquivos = (DataTable)reader["arquivos"];
                    List <Arquivo> list_arq    = new List <Arquivo>();
                    for (int i = 0; i < dt_Arquivos.Rows.Count; i++)
                    {
                        Arquivo arquivo = new Arquivo();
                        arquivo.nome_Arquivo     = dt_Arquivos.Rows[i]["nome_Arquivo"].ToString();
                        arquivo.conteudo_Arquivo = dt_Arquivos.Rows[i]["conteudo_Arquivo"].ToString();
                        arquivo.tipo_Arquivo     = dt_Arquivos.Rows[i]["tipo_Arquivo"].ToString();
                        list_arq.Add(arquivo);
                    }

                    if (list_arq != null)
                    {
                        foreach (Arquivo item in list_arq)
                        {
                            if (item.tipo_Arquivo == "docsPessoais")
                            {
                                atualizaSessaoDeLista("docsPessoais", item);
                            }
                            else if (item.tipo_Arquivo == "titulacoes")
                            {
                                atualizaSessaoDeLista("titulacoes", item);
                            }
                            else if (item.tipo_Arquivo == "portarias")
                            {
                                atualizaSessaoDeLista("portarias", item);
                            }
                            else if (item.tipo_Arquivo == "cis")
                            {
                                atualizaSessaoDeLista("cis", item);
                            }
                            else if (item.tipo_Arquivo == "avisoFerias")
                            {
                                atualizaSessaoDeLista("avisoFerias", item);
                            }
                            else if (item.tipo_Arquivo == "requerimentos")
                            {
                                atualizaSessaoDeLista("requerimentos", item);
                            }
                            else if (item.tipo_Arquivo == "outros")
                            {
                                atualizaSessaoDeLista("outros", item);
                            }
                        }
                    }
                }
            }
            finally
            {
                minhaConexao.Close();
            }
        }
Example #18
0
        /// <summary>
        /// Método usado para listar a base ordenada por coluna.
        /// </summary>
        /// <param name="select">O comando select.</param>
        /// <param name="coluna">A coluna a ser ordenada.</param>
        /// <param name="orderBy">A ordem, se ascendente ou descendente.</param>
        /// <returns></returns>
        public List<Documento> PorColuna(string select, string coluna, string orderBy)
        {
            if (select == null)
            {
                select = "select id, matricula_Colaborador, nome_Colaborador, cpf_Colaborador, arquivos.nome_Arquivo, "
                                                        + "arquivos.conteudo_Arquivo, arquivos.tipo_Arquivo from documento";
            }
            List<Documento> lista = new List<Documento>();
            IDataReader reader;
            IDbConnection minhaConexao = new LightBaseConnection("user=lbw;password=lbw;UDB=defudb;server=localhost");
            try
            {
                minhaConexao.Open();
                try
                {
                    IDbCommand comando = new LightBaseCommand(select + " order by " + coluna + " " + orderBy);
                    comando.Connection = minhaConexao;
                    reader = comando.ExecuteReader();

                    while (reader.Read())
                    {
                        Documento documento = new Documento();

                        documento.id = Convert.ToInt16(reader["id"]);
                        documento.matricula_Colaborador = Convert.ToString(reader["matricula_Colaborador"]);
                        documento.nome_Colaborador = Convert.ToString(reader["nome_Colaborador"]);
                        documento.cpf_Colaborador = Convert.ToString(reader["cpf_Colaborador"]);

                        DataTable dt_Arquivos = (DataTable)reader["arquivos"];
                        List<Arquivo> list_arq = new List<Arquivo>();
                        for (int i = 0; i < dt_Arquivos.Rows.Count; i++)
                        {
                            Arquivo arquivo = new Arquivo();
                            arquivo.nome_Arquivo = dt_Arquivos.Rows[i]["nome_Arquivo"].ToString();
                            arquivo.conteudo_Arquivo = dt_Arquivos.Rows[i]["conteudo_Arquivo"].ToString();
                            arquivo.tipo_Arquivo = dt_Arquivos.Rows[i]["tipo_Arquivo"].ToString();
                            list_arq.Add(arquivo);
                        }
                        documento.arquivos = list_arq;
                        lista.Add(documento);
                    }
                }
                catch (LightBaseException e)
                {
                    string erro = e.Message;
                }
                return lista;
            }
            finally
            {
                minhaConexao.Close();
            }
        }
Example #19
0
        /// <summary>
        /// Método usado para obter os arquivos pelo id do documento.
        /// </summary>
        /// <param name="id">O id.</param>
        /// <returns></returns>
        public List<Arquivo> obterIdArquivos(string id)
        {
            IDataReader reader;
            IDbConnection con = new LightBaseConnection("user=lbw;password=lbw;udb=defudb;server=localhost");
            Documento documento = new Documento();
            try
            {
                con.Open();
                string comando = "select arquivos from documento where id = ";
                IDbCommand comm = new LightBaseCommand(comando + id);
                comm.Connection = con;
                reader = comm.ExecuteReader();
                reader.Read();

                DataTable dt_Arquivos = (DataTable)reader["arquivos"];
                //string[] dados_Arquivos = new string[dt_Arquivos.Rows.Count];
                List<Arquivo> list_arq = new List<Arquivo>();
                for (int i = 0; i < dt_Arquivos.Rows.Count; i++)
                {
                    Arquivo arquivo = new Arquivo();
                    arquivo.nome_Arquivo = dt_Arquivos.Rows[i]["nome_Arquivo"].ToString();
                    arquivo.id_Arquivo = Convert.ToInt32(dt_Arquivos.Rows[i]["id_arquivo"].ToString());
                    list_arq.Add(arquivo);
                }

                return list_arq;
            }
            finally
            {
                con.Close();
            }
        }
Example #20
0
        protected void ImageButtonSalvar_Click(object sender, ImageClickEventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                //lembrar de adicionar o ID do cadastro ao nome na hora de adicionar ao banco
                String nameFile = "";
                if (Session["abaAtiva"].ToString().Equals((string)"TabPanelPessoais"))
                {
                    nameFile = "docsPessoais";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelTitulacao"))
                {
                    nameFile = "titulacoes";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelPortaria"))
                {
                    nameFile = "portarias";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelCI"))
                {
                    nameFile = "cis";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelAviso"))
                {
                    nameFile = "avisoFerias";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelRequerimento"))
                {
                    nameFile = "requerimentos";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelOutros"))
                {
                    nameFile = "outros";
                }

                if (Session["postou_" + nameFile].ToString().Equals((string)"sim"))
                {
                    string nomeArquivo = nameFile + ext;
                    // Create a merge document and set it's properties
                    MergeDocument document = MergeDocument.Merge(pathDir + nomeArquivo, FileUpload1.PostedFile.FileName);
                    //string nomeArquivo1 = FileUpload1.PostedFile.FileName.Substring(FileUpload1.PostedFile.FileName.LastIndexOf('\\') + 1);
                    // Outputs the merged document
                    document.Draw(nomeArquivo);
                    System.IO.File.Delete(pathDir + nomeArquivo);
                    System.IO.File.Move(nomeArquivo, pathDir + nomeArquivo);

                }
                //se ainda nao postou o documento nao precisa fazer um merge
                else
                {
                    try
                    {
                        FileUpload1.SaveAs(pathDir + nameFile + ext);
                        //FileUpload1.SaveAs("C:\\Temp\\" + nameFile + ext);
                        Session.Add("fileName", nameFile + ext);

                    }
                    catch (Exception ex)
                    {
                        LabelErro.Text = ex.Message;
                    }
                }
                LabelArquivo.Text = nameFile + ext;
                ImageButtonVer.Visible = true;
                ImageButtonDelete.Visible = true;
                //levantar flag dizendo que o arquivo foi postado
                Session.Add("postou_" + nameFile, "sim");

                //List<Arquivo> lista = new List<Arquivo>();
                Arquivo arquivo = new Arquivo();
                arquivo.nome_Arquivo = nameFile + ext;
                arquivo.tipo_Arquivo = nameFile;

                lista = (List<Arquivo>)Session[nameFile];
                if (lista == null)
                {
                    lista = new List<Arquivo>();
                }
                lista.Add(arquivo);
                Session.Add(nameFile, lista);
                carrega_Grid(nameFile);
            }
            else
            {
                //Mostra o Erro quando não tem arquivo selecionado
                LabelErro.Text = "Selecione o arquivo";
            }
        }
Example #21
0
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            string id = "";

            try
            {
                id = obterIdCadastrado();
            }
            catch (Exception ex)
            {
                LabelErro.Text = ex.Message;
            }

            Documento documento = new Documento();
            List<Arquivo> list_arquivo = new List<Arquivo>();

            documento.matricula_Colaborador = TextBoxMatricula.Text;
            documento.nome_Colaborador = TextNome_Colaborador.Text;
            /*
             * Salvando arquivos postados no banco
             * ( ver como faz pra colocar um identificador do tipo pra qnd fazer um update saber buscar esse tipo)
             */
            if (Session["postou_docsPessoais"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "docsPessoais");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_titulacoes"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "titulacoes");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_portarias"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "portarias");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_cis"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "cis");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_avisoFerias"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "avisoFerias");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_requerimentos"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "requerimentos");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_outros"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "outros");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            //Adicionando a lista dos arquivos aos documentos pra depois adicionar no banco
            documento.arquivos = list_arquivo;

            Adaptador adpt = new Adaptador();
            try
            {
                adpt.AtualizarDocumento(documento);
            }
            catch (Exception ex)
            {
                LabelErro.Text = ex.Message;
            }

            /*foreach (Arquivo arq in list_arquivo)
            {
                versiona_indexa(arq.nome_Arquivo);
            }*/

            mensagem = "Registro modificado com sucesso";
            Session.Add("mensagem", mensagem);
            Server.Transfer("listar.aspx");
        }
Example #22
0
        protected void ImageButtonEnviar_Click(object sender, ImageClickEventArgs e)
        {
            Documento documento = new Documento();
            List<Arquivo> list_arquivo = new List<Arquivo>();

            documento.matricula_Colaborador = TextBoxMatricula.Text;
            documento.nome_Colaborador = TextNome_Colaborador.Text;
            documento.cpf_Colaborador = TextBoxCPF.Text;
            documento.foto = ImageFoto.ImageUrl;
            /*
             * Salvando arquivos postados no banco
             * ( ver como faz pra colocar um identificador do tipo pra qnd fazer um update saber buscar esse tipo)
             */
            if (Session["postou_docsPessoais"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("docsPessoais");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_titulacoes"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("titulacoes");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_portarias"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("portarias");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_cis"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("cis");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_avisoFerias"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("avisoFerias");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_requerimentos"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("requerimentos");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_outros"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = retornaArquivos("outros");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            //Adicionando a lista dos arquivos aos documentos pra depois adicionar no banco

            //list_arquivo = (List<Arquivo>)Session["arquivos"];
            if (list_arquivo == null)
            {
                list_arquivo = new List<Arquivo>();
            }
            documento.arquivos = list_arquivo;

            Adaptador adpt = new Adaptador();
            try
            {
                adpt.AtualizarDocumento(documento, id);
                Log log = new Log();
                log.data_log = DateTime.Now;
                log.tipo_acao_log = "Editar";
                log.usuario_log = (String)Session["usuario"];
                log.mensagem_acao_log = "O usuário " + log.usuario_log + " atualizou o colaborador de matrícula " + documento.matricula_Colaborador;
                adpt.InserirLog(log);
            }
            catch (Exception ex)
            {
                LabelErro.Text = ex.Message;
                ImageAttention.Visible = true;
            }

            /*foreach (Arquivo arq in list_arquivo)
            {
                versiona_indexa(arq.nome_Arquivo);
            }*/

            mensagem = "Registro modificado com sucesso";
            Session.Add("mensagem", mensagem);
            Server.Transfer("listar.aspx");
        }
Example #23
0
        public void MontaTela(string id)
        {
            IDataReader reader;
            IDbConnection minhaConexao = new LightBaseConnection("user=lbw;password=lbw;udb=defudb;server=localhost");
            try
            {
                minhaConexao.Open();

                IDbCommand meuComando = new LightBaseCommand("select id , matricula_Colaborador , foto, nome_Colaborador, arquivos from documento where id =" + id);
                meuComando.Connection = minhaConexao;
                reader = meuComando.ExecuteReader();

                while (reader.Read())
                {
                    TextBoxMatricula.Text = Convert.ToString(reader["matricula_Colaborador"]);
                    TextNome_Colaborador.Text = Convert.ToString(reader["nome_Colaborador"]);
                    DataTable dt_Arquivos = (DataTable)reader["arquivos"];
                    List<Arquivo> list_arq = new List<Arquivo>();
                    for (int i = 0; i < dt_Arquivos.Rows.Count; i++)
                    {
                        Arquivo arquivo = new Arquivo();
                        arquivo.nome_Arquivo = dt_Arquivos.Rows[i]["nome_Arquivo"].ToString();
                        arquivo.conteudo_Arquivo = dt_Arquivos.Rows[i]["conteudo_Arquivo"].ToString();
                        arquivo.tipo_Arquivo = dt_Arquivos.Rows[i]["tipo_Arquivo"].ToString();
                        list_arq.Add(arquivo);
                    }

                    if (list_arq != null)
                    {
                        foreach (Arquivo item in list_arq)
                        {
                            if (item.tipo_Arquivo == "docsPessoais")
                            {
                                atualizaSessaoDeLista("docsPessoais", item);
                            }
                            else if (item.tipo_Arquivo == "titulacoes")
                            {
                                atualizaSessaoDeLista("titulacoes", item);
                            }
                            else if (item.tipo_Arquivo == "portarias")
                            {
                                atualizaSessaoDeLista("portarias", item);
                            }
                            else if (item.tipo_Arquivo == "cis")
                            {
                                atualizaSessaoDeLista("cis", item);
                            }
                            else if (item.tipo_Arquivo == "avisoFerias")
                            {
                                atualizaSessaoDeLista("avisoFerias", item);
                            }
                            else if (item.tipo_Arquivo == "requerimentos")
                            {
                                atualizaSessaoDeLista("requerimentos", item);
                            }
                            else if (item.tipo_Arquivo == "outros")
                            {
                                atualizaSessaoDeLista("outros", item);
                            }
                        }
                    }
                }
            }
            finally
            {
                minhaConexao.Close();
            }
        }
Example #24
0
 public Documento obterDocumentoPorId(string valor)
 {
     IDataReader reader;
     IDbConnection minhaConexao = new LightBaseConnection("user=lbw;password=lbw;udb=defudb;server=localhost");
     try
     {
         minhaConexao.Open();
         Documento documento = new Documento();
         try
         {
             IDbCommand meuComando = new LightBaseCommand("select id, arquivos from documento where id = " + valor);
             meuComando.Connection = minhaConexao;
             reader = meuComando.ExecuteReader();
             while (reader.Read())
             {
                 documento.id = Convert.ToInt32(reader["id"]);
                 //ver como fazer conversao pra adicionar cada nome de arquivos a uma lista de arquivos
                 //eu faço um data table pra jogar os arquivos...ver medoto TODOS
                 DataTable dt_Arquivos = (DataTable)reader["arquivos"];
                 //string[] dados_Arquivos = new string[dt_Arquivos.Rows.Count];
                 List<Arquivo> list_arq = new List<Arquivo>();
                 for (int i = 0; i < dt_Arquivos.Rows.Count; i++)
                 {
                     Arquivo arquivo = new Arquivo();
                     arquivo.nome_Arquivo = dt_Arquivos.Rows[i]["nome_Arquivo"].ToString();
                     arquivo.conteudo_Arquivo = dt_Arquivos.Rows[i]["conteudo_Arquivo"].ToString();
                     arquivo.tipo_Arquivo = dt_Arquivos.Rows[i]["tipo_Arquivo"].ToString();
                     list_arq.Add(arquivo);
                 }
                 documento.arquivos = list_arq;
             }
         }
         catch (LightBaseException e)
         {
             string erro = e.Message;
         }
         return documento;
     }
     finally
     {
         minhaConexao.Close();
     }
 }
Example #25
0
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            string id = "";

            try
            {
                id = obterIdCadastrado();
            }
            catch (Exception ex)
            {
                LabelErro.Text = ex.Message;
            }

            Documento      documento    = new Documento();
            List <Arquivo> list_arquivo = new List <Arquivo>();

            documento.matricula_Colaborador = TextBoxMatricula.Text;
            documento.nome_Colaborador      = TextNome_Colaborador.Text;

            /*
             * Salvando arquivos postados no banco
             * ( ver como faz pra colocar um identificador do tipo pra qnd fazer um update saber buscar esse tipo)
             */
            if (Session["postou_docsPessoais"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "docsPessoais");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_titulacoes"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "titulacoes");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_portarias"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "portarias");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_cis"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "cis");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_avisoFerias"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "avisoFerias");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_requerimentos"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "requerimentos");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            if (Session["postou_outros"].ToString().Equals((string)"sim"))
            {
                Arquivo arq_temp = new Arquivo();
                arq_temp = inserirArquivosNaLista(id, "outros");
                if (arq_temp != null)
                {
                    list_arquivo.Add(arq_temp);
                }
            }
            //Adicionando a lista dos arquivos aos documentos pra depois adicionar no banco
            documento.arquivos = list_arquivo;

            Adaptador adpt = new Adaptador();

            try
            {
                adpt.InserirDocumento(documento);
            }
            catch (Exception ex)
            {
                LabelErro.Text = ex.Message;
            }

            /*foreach (Arquivo arq in list_arquivo)
             * {
             *  versiona_indexa(arq.nome_Arquivo);
             * }*/

            mensagem = "Colaborador inserido com sucesso";
            Session.Add("mensagem", mensagem);
            Server.Transfer("listar.aspx");
        }
Example #26
0
        protected void ImageButtonSalvar_Click(object sender, ImageClickEventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                //lembrar de adicionar o ID do cadastro ao nome na hora de adicionar ao banco
                String nameFile = "";
                if (Session["abaAtiva"].ToString().Equals((string)"TabPanelPessoais"))
                {
                    nameFile = "docsPessoais";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelTitulacao"))
                {
                    nameFile = "titulacoes";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelPortaria"))
                {
                    nameFile = "portarias";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelCI"))
                {
                    nameFile = "cis";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelAviso"))
                {
                    nameFile = "avisoFerias";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelRequerimento"))
                {
                    nameFile = "requerimentos";
                }
                else if (Session["abaAtiva"].ToString().Equals((string)"TabPanelOutros"))
                {
                    nameFile = "outros";
                }

                if (Session["postou_" + nameFile].ToString().Equals((string)"sim"))
                {
                    string nomeArquivo = nameFile + ext;
                    // Create a merge document and set it's properties
                    MergeDocument document = MergeDocument.Merge(pathDir + nomeArquivo, FileUpload1.PostedFile.FileName);
                    //string nomeArquivo1 = FileUpload1.PostedFile.FileName.Substring(FileUpload1.PostedFile.FileName.LastIndexOf('\\') + 1);
                    // Outputs the merged document
                    document.Draw(nomeArquivo);
                    System.IO.File.Delete(pathDir + nomeArquivo);
                    System.IO.File.Move(nomeArquivo, pathDir + nomeArquivo);
                }
                //se ainda nao postou o documento nao precisa fazer um merge
                else
                {
                    try
                    {
                        FileUpload1.SaveAs(pathDir + nameFile + ext);
                        //FileUpload1.SaveAs("C:\\Temp\\" + nameFile + ext);
                        Session.Add("fileName", nameFile + ext);
                    }
                    catch (Exception ex)
                    {
                        LabelErro.Text = ex.Message;
                    }
                }
                LabelArquivo.Text         = nameFile + ext;
                ImageButtonVer.Visible    = true;
                ImageButtonDelete.Visible = true;
                //levantar flag dizendo que o arquivo foi postado
                Session.Add("postou_" + nameFile, "sim");

                //List<Arquivo> lista = new List<Arquivo>();
                Arquivo arquivo = new Arquivo();
                arquivo.nome_Arquivo = nameFile + ext;
                arquivo.tipo_Arquivo = nameFile;

                lista = (List <Arquivo>)Session[nameFile];
                if (lista == null)
                {
                    lista = new List <Arquivo>();
                }
                lista.Add(arquivo);
                Session.Add(nameFile, lista);
                carrega_Grid(nameFile);
            }
            else
            {
                //Mostra o Erro quando não tem arquivo selecionado
                LabelErro.Text = "Selecione o arquivo";
            }
        }