예제 #1
0
        protected void ImageButtonEnviar_Click(object sender, ImageClickEventArgs e)
        {
            if (FileUpload.PostedFile.ContentLength == 0)
            {
                Response.Write("<script>alert('Favor selecionar arquivo')</script>");
            }
            else
            {
                arquivo = FileUpload.PostedFile.FileName;
                nomeArquivo = System.IO.Path.GetFileName(arquivo);
                int pos = 0;
                pos = nomeArquivo.LastIndexOf('.');
                extensao = nomeArquivo.Substring(pos).ToLower();
                tamanho = nomeArquivo.Length;
                nomeArquivoLBW = id + "_" + "0001" + "_" + "arq_Arquivo" + extensao;
                Processo processo = new Processo();
                processo.id = Convert.ToInt16(id);
                processo.arq_Arquivo = nomeArquivoLBW;
                processo.numero_Processo = TextBoxNumeroProcesso.Text;
                processo.ano_Processo = TextBoxAnoProcesso.Text;
                processo.origem = TextBoxOrigem.Text;
                processo.assunto = TextBoxAssunto.Text;
                processo.descricao = TextBoxDescricao.Text;
                processo.pessoa1 = TextBoxPessoa1.Text;
                processo.pessoa2 = TextBoxPessoa2.Text;
                processo.pessoa3 = TextBoxPessoa3.Text;
                processo.pessoa4 = TextBoxPessoa4.Text;
                Adaptador adt = new Adaptador();
                try
                {
                    Processo proc = new Processo();
                    proc = adt.obterProcessoPorId(id);
                    nomeArquivoAntigo = proc.arq_Arquivo;
                    if (nomeArquivoAntigo != null)
                    {
                        string diretorioRemover = Settings.Default.CaminhoDoRepositorioJurisprudencia + nomeArquivoAntigo;
                        FileInfo arquivoAntigo = new FileInfo(diretorioRemover);
                        arquivoAntigo.Delete();
                    }
                    adt.AtualizaProcesso(processo);
                }
                catch (Exception ex)
                {
                    LabelErro.Text = ex.Message;
                }

                Versao versao = new Versao();

                FileUpload.PostedFile.SaveAs(Settings.Default.CaminhoDoRepositorioJurisprudencia + nomeArquivoLBW);

                versao.CaminhoDoArquivo = Settings.Default.CaminhoDoRepositorioJurisprudencia;
                versao.Extensao = extensao;
                versao.NomeDoArquivo = nomeArquivoLBW;

                versao.Id = processo.id;

                Indexador indexador = new Indexador();
                indexador.Indexe(versao);

                mensagem = "Registro modificado com sucesso";
                Session.Add("mensagem", mensagem);
                Server.Transfer("Listar.aspx");
            }
        }
예제 #2
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int index;

            usuarioConectado = (String)Session["usuario"];
            senhaConectado   = (String)Session["senha"];
            GoldenAccess goldenAccess = new GoldenAccess("http://localhost:3271/GoldenAccess.soap");
            User         usuario      = new User(usuarioConectado, senhaConectado);

            try
            {
                usuario = goldenAccess.Authenticate(usuarioConectado, senhaConectado);
            }
            catch (Exception ex)
            {
                LabelErro.Text = ex.Message;
            }
            if (usuario.IsAuthenticated && !usuario.Disabled)
            {
                if (usuario.HasGroup("TCESEADM"))
                {
                    if (e.CommandName == "Abrir")
                    {
                        string nome = "";
                        try
                        {
                            index = Convert.ToInt32(e.CommandArgument) - (GridView1.PageSize * GridView1.PageIndex);
                            int       id       = Convert.ToInt32(GridView1.DataKeys[index].Value);
                            Adaptador adpt     = new Adaptador();
                            Processo  processo = new Processo();
                            processo = adpt.obterProcessoPorId(id.ToString());
                            nome     = processo.arq_Arquivo;
                            //diretorio = Server.MapPath("~\\arquivos\\jurisprudencia\\");
                            diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioJurisprudencia);
                            //diretorio = "\\\\tce-s008\\GED_Arquivos\\jurisprudencia\\";
                            if (Directory.Exists(diretorio))
                            {
                                Response.Clear();
                                Response.ClearHeaders();
                                Response.AddHeader("Content-Type", "application/pdf");
                                Response.AddHeader("Content-Disposition", "attachment; filename=" + nome);

                                FileStream file  = new FileStream(diretorio + nome, System.IO.FileMode.Open, FileAccess.Read);
                                byte[]     bytes = new byte[Convert.ToInt32(file.Length)];
                                file.Read(bytes, 0, bytes.Length);
                                file.Close();

                                Response.OutputStream.Write(bytes, 0, bytes.GetUpperBound(0));

                                Response.Flush();
                                Response.Close();
                            }
                            else
                            {
                                LabelErro.Text = "Diretório " + diretorio + "  não encontrado";
                            }
                        }
                        catch (Exception ex)
                        {
                            LabelErro.Text = ex.Message;
                        }
                    }

                    if (e.CommandName == "Alterar")
                    {
                        index = Convert.ToInt32(e.CommandArgument);
                        string id = (String)GridView1.DataKeys[index].Value.ToString();
                        Session.Add("id", id);
                        Server.Transfer("Alterar.aspx");
                    }

                    if (e.CommandName == "Excluir")
                    {
                        index = Convert.ToInt32(e.CommandArgument);
                        int       id       = Convert.ToInt32(GridView1.DataKeys[index].Value);
                        Adaptador adpt     = new Adaptador();
                        Processo  processo = new Processo();
                        processo = adpt.obterProcessoPorId(id.ToString());

                        string nomeArquivoAntigo = processo.arq_Arquivo;
                        if (nomeArquivoAntigo != null)
                        {
                            string   diretorioRemover = Settings.Default.CaminhoDoRepositorioJurisprudencia + nomeArquivoAntigo;
                            FileInfo arquivoAntigo    = new FileInfo(diretorioRemover);
                            arquivoAntigo.Delete();
                        }

                        adpt.RemoveProcesso(id);
                    }

                    if (e.CommandName == "AbrirDecisao")
                    {
                        index = Convert.ToInt32(e.CommandArgument);
                        int       id       = Convert.ToInt32(GridView1.DataKeys[index].Value);
                        Adaptador adpt     = new Adaptador();
                        Processo  processo = new Processo();
                        processo  = adpt.obterProcessoPorId(id.ToString());
                        diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioDecisao);
                        string subDiretorio = processo.decisao.Substring(processo.decisao.IndexOf("\\DECISAO$") + 9);
                        nome         = processo.decisao.Substring(processo.decisao.LastIndexOf('\\') + 1);
                        subDiretorio = subDiretorio.Replace(nome, "");
                        if (processo.decisao == null)
                        {
                            //Response.Write("<script>alert('Ainda não existe decisão para esse processo')</script>");
                            LabelErro.Text = "Não existe decisão para este processo";
                        }
                        else
                        {
                            //if (Directory.Exists(diretorio))
                            //{
                            Response.Clear();
                            Response.ClearHeaders();
                            Response.AddHeader("Content-Type", "application/pdf");
                            Response.AddHeader("Content-Disposition", "attachment; filename=" + nome);
                            FileStream file  = new FileStream(diretorio + subDiretorio + nome, System.IO.FileMode.Open, FileAccess.Read);
                            byte[]     bytes = new byte[Convert.ToInt32(file.Length)];
                            file.Read(bytes, 0, bytes.Length);
                            file.Close();
                            Response.OutputStream.Write(bytes, 0, bytes.GetUpperBound(0));
                            Response.Flush();
                            Response.Close();
                            //}
                        }
                        GridView1.Rows[index].Cells[1].Enabled = true;
                    }
                }
                else if (usuario.HasGroup("TCESELIM"))
                {
                    if (e.CommandName == "Abrir")
                    {
                        string nome = "";
                        try
                        {
                            index = Convert.ToInt32(e.CommandArgument);
                            int       id       = Convert.ToInt32(GridView1.DataKeys[index].Value);
                            Adaptador adpt     = new Adaptador();
                            Processo  processo = new Processo();
                            processo  = adpt.obterProcessoPorId(id.ToString());
                            nome      = processo.arq_Arquivo;
                            diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioJurisprudencia);
                            if (Directory.Exists(diretorio))
                            {
                                Response.Clear();
                                Response.ClearHeaders();
                                Response.AddHeader("Content-Type", "application/pdf");
                                Response.AddHeader("Content-Disposition", "attachment; filename=" + nome);

                                FileStream file  = new FileStream(diretorio + nome, System.IO.FileMode.Open, FileAccess.Read);
                                byte[]     bytes = new byte[Convert.ToInt32(file.Length)];
                                file.Read(bytes, 0, bytes.Length);
                                file.Close();

                                Response.OutputStream.Write(bytes, 0, bytes.GetUpperBound(0));

                                Response.Flush();
                                Response.Close();
                            }
                            else
                            {
                                LabelErro.Text = "Diretório " + diretorio + "  não encontrado";
                            }
                        }
                        catch (Exception ex)
                        {
                            LabelErro.Text = ex.Message;
                        }
                    }

                    if (e.CommandName == "Alterar")
                    {
                        LabelErro.Text = "Você não tem permissão para " + e.CommandName + " esse registro.";
                    }

                    if (e.CommandName == "Excluir")
                    {
                        LabelErro.Text = "Você não tem permissão para " + e.CommandName + " esse registro.";
                    }
                }
                else
                {
                    LabelErro.Text = "Você não tem permissão para " + e.CommandName + " esse registro.";
                }
            }
            else
            {
                LabelErro.Text = "Você não é usuário do sistema.";
            }
        }
예제 #3
0
        protected void GridView1_RowCommand1(object sender, GridViewCommandEventArgs e)
        {
            int index;

            usuarioConectado = (String)Session["usuario"];
            senhaConectado = (String)Session["senha"];
            GoldenAccess goldenAccess = new GoldenAccess("http://localhost:3271/GoldenAccess.soap");
            User usuario = new User(usuarioConectado, senhaConectado);
            try
            {
                usuario = goldenAccess.Authenticate(usuarioConectado, senhaConectado);
            }
            catch (Exception ex)
            {
                LabelErro.Text = ex.Message;
            }
            if (usuario.IsAuthenticated && !usuario.Disabled)
            {
                if (usuario.HasGroup("TCESEADM"))
                {
                    if (e.CommandName == "Alterar")
                    {
                        index = Convert.ToInt32(e.CommandArgument);
                        string id = (String)GridView1.DataKeys[index].Value.ToString();
                        Session.Add("id", id);
                        Server.Transfer("Alterar.aspx");
                    }

                    if (e.CommandName == "Excluir")
                    {
                        index = Convert.ToInt32(e.CommandArgument);
                        int id = Convert.ToInt32(GridView1.DataKeys[index].Value);
                        Adaptador adpt = new Adaptador();

                        Processo processo = new Processo();
                        processo = adpt.obterProcessoPorId(id.ToString());

                        string nomeArquivoAntigo = processo.arq_Arquivo;
                        if (nomeArquivoAntigo != null)
                        {
                            string diretorioRemover = Settings.Default.CaminhoDoRepositorioJurisprudencia + nomeArquivoAntigo;
                            FileInfo arquivoAntigo = new FileInfo(diretorioRemover);
                            arquivoAntigo.Delete();
                        }

                        adpt.RemoveProcesso(id);
                    }

                    if (e.CommandName == "Abrir")
                    {
                        string nome = "";
                        try
                        {
                            index = Convert.ToInt32(e.CommandArgument) - (GridView1.PageSize * GridView1.PageIndex);
                            int id = Convert.ToInt32(GridView1.DataKeys[index].Value);
                            Adaptador adpt = new Adaptador();
                            Processo processo = new Processo();
                            processo = adpt.obterProcessoPorId(id.ToString());
                            nome = processo.arq_Arquivo;
                            diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioJurisprudencia);
                            if (Directory.Exists(diretorio))
                            {
                                Response.Clear();
                                Response.ClearHeaders();
                                Response.AddHeader("Content-Type", "application/pdf");
                                Response.AddHeader("Content-Disposition", "attachment; filename=" + nome);

                                FileStream file = new FileStream(diretorio + nome, System.IO.FileMode.Open, FileAccess.Read);
                                byte[] bytes = new byte[Convert.ToInt32(file.Length)];
                                file.Read(bytes, 0, bytes.Length);
                                file.Close();

                                Response.OutputStream.Write(bytes, 0, bytes.GetUpperBound(0));

                                Response.Flush();
                                Response.Close();
                            }
                            else
                            {
                                LabelErro.Text = "Diretório " + diretorio + "  não encontrado";
                            }
                        }
                        catch (Exception ex)
                        {
                            LabelErro.Text = ex.Message;
                        }
                    }

                    if (e.CommandName == "AbrirDecisao")
                    {
                        index = Convert.ToInt32(e.CommandArgument);
                        int id = Convert.ToInt32(GridView1.DataKeys[index].Value);
                        Adaptador adpt = new Adaptador();
                        Processo processo = new Processo();
                        processo = adpt.obterProcessoPorId(id.ToString());
                        diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioDecisao);
                        //string subDiretorio = processo.decisao.Substring(processo.decisao.IndexOf("\\DECISAO$") + 9);
                        nome = processo.decisao.Substring(processo.decisao.LastIndexOf('\\') + 1);
                        //subDiretorio = subDiretorio.Replace(nome, "");
                        if (processo.decisao == null || processo.decisao == "")
                        {
                            //Response.Write("<script>alert('Ainda não existe decisão para esse processo')</script>");
                            LabelErro.Text = "Não existe decisão para este processo";
                        }
                        else
                        {
                            if (Directory.Exists(diretorio))
                            {
                                Response.Clear();
                                Response.ClearHeaders();
                                Response.AddHeader("Content-Type", "application/pdf");
                                Response.AddHeader("Content-Disposition", "attachment; filename=" + nome);
                                FileStream file = new FileStream(diretorio /*+ subDiretorio*/ + nome, System.IO.FileMode.Open, FileAccess.Read);
                                byte[] bytes = new byte[Convert.ToInt32(file.Length)];
                                file.Read(bytes, 0, bytes.Length);
                                file.Close();
                                Response.OutputStream.Write(bytes, 0, bytes.GetUpperBound(0));
                                Response.Flush();
                                Response.Close();
                            }
                        }
                        GridView1.Rows[index].Cells[1].Enabled = true;
                    }
                }
                else
                {
                    LabelErro.Text = "Você não tem permissão para " + e.CommandName + " esse registro.";
                }
            }
            else
            {
                LabelErro.Text = "Você não é usuário do sistema.";
            }
        }
예제 #4
0
        protected void ImageButtonEnviar_Click(object sender, ImageClickEventArgs e)
        {
            if (FileUpload.PostedFile.ContentLength == 0)
            {
                Response.Write("<script>alert('Favor selecionar arquivo')</script>");
            }
            else
            {
                arquivo     = FileUpload.PostedFile.FileName;
                nomeArquivo = System.IO.Path.GetFileName(arquivo);
                int pos = 0;
                pos            = nomeArquivo.LastIndexOf('.');
                extensao       = nomeArquivo.Substring(pos).ToLower();
                tamanho        = nomeArquivo.Length;
                nomeArquivoLBW = id + "_" + "0001" + "_" + "arq_Arquivo" + extensao;
                Processo processo = new Processo();
                processo.id              = Convert.ToInt16(id);
                processo.arq_Arquivo     = nomeArquivoLBW;
                processo.numero_Processo = TextBoxNumeroProcesso.Text;
                processo.ano_Processo    = TextBoxAnoProcesso.Text;
                processo.origem          = TextBoxOrigem.Text;
                processo.assunto         = TextBoxAssunto.Text;
                processo.descricao       = TextBoxDescricao.Text;
                processo.pessoa1         = TextBoxPessoa1.Text;
                processo.pessoa2         = TextBoxPessoa2.Text;
                processo.pessoa3         = TextBoxPessoa3.Text;
                processo.pessoa4         = TextBoxPessoa4.Text;
                Adaptador adt = new Adaptador();
                try
                {
                    Processo proc = new Processo();
                    proc = adt.obterProcessoPorId(id);
                    nomeArquivoAntigo = proc.arq_Arquivo;
                    if (nomeArquivoAntigo != null)
                    {
                        string   diretorioRemover = Settings.Default.CaminhoDoRepositorioJurisprudencia + nomeArquivoAntigo;
                        FileInfo arquivoAntigo    = new FileInfo(diretorioRemover);
                        arquivoAntigo.Delete();
                    }
                    adt.AtualizaProcesso(processo);
                }
                catch (Exception ex)
                {
                    LabelErro.Text = ex.Message;
                }

                Versao versao = new Versao();

                FileUpload.PostedFile.SaveAs(Settings.Default.CaminhoDoRepositorioJurisprudencia + nomeArquivoLBW);

                versao.CaminhoDoArquivo = Settings.Default.CaminhoDoRepositorioJurisprudencia;
                versao.Extensao         = extensao;
                versao.NomeDoArquivo    = nomeArquivoLBW;

                versao.Id = processo.id;

                Indexador indexador = new Indexador();
                indexador.Indexe(versao);

                mensagem = "Registro modificado com sucesso";
                Session.Add("mensagem", mensagem);
                Server.Transfer("Listar.aspx");
            }
        }