protected void GridView1_RowCommand1(object sender, GridViewCommandEventArgs e)
        {
            int    index;
            string diretorio;

            if (e.CommandName == "Abrir")
            {
                string nome = "";
                try
                {
                    index = Convert.ToInt32(e.CommandArgument) - (GridView1.PageSize * GridView1.PageIndex);
                    int id = Convert.ToInt32(GridView1.DataKeys[index].Value);
                    AdaptadorProtocolo adpt      = new AdaptadorProtocolo();
                    Protocolo          protocolo = new Protocolo();
                    protocolo = adpt.obterProtocoloPorId(id.ToString());
                    nome      = protocolo.arq_Arquivo;
                    //diretorio = Server.MapPath("~\\arquivos\\protocolos\\");
                    diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioProtocolo);
                    if (Directory.Exists(diretorio))
                    {
                        Response.Clear();
                        Response.ClearHeaders();
                        Response.AddHeader("Content-Type", "image/tiff");
                        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;
                }
            }
        }
示例#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 == "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();
                    //    adpt.RemoveProcesso(id);
                    //}

                    if (e.CommandName == "Abrir")
                    {
                        string nome = "";
                        string diretorio;
                        try
                        {
                            index = Convert.ToInt32(e.CommandArgument) - (GridView1.PageSize * GridView1.PageIndex);
                            int id = Convert.ToInt32(GridView1.DataKeys[index].Value);
                            AdaptadorProtocolo adpt = new AdaptadorProtocolo();
                            Protocolo protocolo = new Protocolo();
                            protocolo = adpt.obterProtocoloPorId(id.ToString());
                            nome = protocolo.arq_Arquivo;
                            //diretorio = Server.MapPath("~\\arquivos\\protocolos\\");
                            diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioProtocolo);
                            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;
                        }
                    }
                }
                else
                {
                    LabelErro.Text = "Você não tem permissão para " + e.CommandName + " esse registro.";
                }
            }
            else
            {
                LabelErro.Text = "Você não é usuário do sistema.";
            }
        }
        protected void GridView1_RowCommand1(object sender, GridViewCommandEventArgs e)
        {
            int index;
            string diretorio;

            if (e.CommandName == "Abrir")
            {
                string nome = "";
                try
                {
                    index = Convert.ToInt32(e.CommandArgument) - (GridView1.PageSize * GridView1.PageIndex);
                    int id = Convert.ToInt32(GridView1.DataKeys[index].Value);
                    AdaptadorProtocolo adpt = new AdaptadorProtocolo();
                    Protocolo protocolo = new Protocolo();
                    protocolo = adpt.obterProtocoloPorId(id.ToString());
                    nome = protocolo.arq_Arquivo;
                    //diretorio = Server.MapPath("~\\arquivos\\protocolos\\");
                    diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioProtocolo);
                    if (Directory.Exists(diretorio))
                    {
                        Response.Clear();
                        Response.ClearHeaders();
                        Response.AddHeader("Content-Type", "image/tiff");
                        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;
                }
            }
        }
示例#4
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 == "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();
                    //    adpt.RemoveProcesso(id);
                    //}

                    if (e.CommandName == "Abrir")
                    {
                        string nome = "";
                        string diretorio;
                        try
                        {
                            index = Convert.ToInt32(e.CommandArgument) - (GridView1.PageSize * GridView1.PageIndex);
                            int id = Convert.ToInt32(GridView1.DataKeys[index].Value);
                            AdaptadorProtocolo adpt      = new AdaptadorProtocolo();
                            Protocolo          protocolo = new Protocolo();
                            protocolo = adpt.obterProtocoloPorId(id.ToString());
                            nome      = protocolo.arq_Arquivo;
                            //diretorio = Server.MapPath("~\\arquivos\\protocolos\\");
                            diretorio = Server.MapPath(Settings.Default.CaminhoDoRepositorioProtocolo);
                            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;
                        }
                    }
                }
                else
                {
                    LabelErro.Text = "Você não tem permissão para " + e.CommandName + " esse registro.";
                }
            }
            else
            {
                LabelErro.Text = "Você não é usuário do sistema.";
            }
        }