public Protocolo obterProtocoloPorId(string valor) { IDataReader reader; IDbConnection minhaConexao = new LightBaseConnection("user=lbw;password=lbw;udb=defudb;server=localhost"); try { minhaConexao.Open(); Protocolo protocolo = new Protocolo(); try { IDbCommand meuComando = new LightBaseCommand("select id, arq_Arquivo from folder245_indices6 where id = " + valor); meuComando.Connection = minhaConexao; reader = meuComando.ExecuteReader(); while (reader.Read()) { protocolo.id = Convert.ToInt32(reader["id"]); protocolo.arq_Arquivo = Convert.ToString(reader["arq_Arquivo"]); } } catch (LightBaseException e) { string erro = e.Message; } return protocolo; } finally { minhaConexao.Close(); } }
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; } } }
public List<Protocolo> PesquisaPorCampo(string comando) { List<Protocolo> lista = new List<Protocolo>(); 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()) { Protocolo protocolo = new Protocolo(); protocolo.id = Convert.ToInt32(reader["id"]); protocolo.arq_Arquivo = Convert.ToString(reader["arq_Arquivo"]); protocolo.documento1 = Convert.ToString(reader["documento1"]); protocolo.documento2 = Convert.ToString(reader["documento2"]); protocolo.documento3 = Convert.ToString(reader["documento3"]); protocolo.documento4 = Convert.ToString(reader["documento4"]); protocolo.documento5 = Convert.ToString(reader["documento5"]); protocolo.documento6 = Convert.ToString(reader["documento6"]); lista.Add(protocolo); } } catch (LightBaseException e) { string erro = e.Message; } return lista; } finally { minhaConexao.Close(); } }
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."; } }
public List<Protocolo> Todos() { List<Protocolo> lista = new List<Protocolo>(); IDataReader reader; IDbConnection minhaConexao = new LightBaseConnection("user=lbw;password=lbw;udb=defudb;server=localhost"); try { minhaConexao.Open(); IDbCommand meuComando = new LightBaseCommand("select id, arq_Arquivo, documento1, documento2, documento3, documento4, documento5, documento6 from folder245_indices6"); meuComando.Connection = minhaConexao; reader = meuComando.ExecuteReader(); while (reader.Read()) { Protocolo protocolo = new Protocolo(); protocolo.id = Convert.ToInt32(reader["id"]); protocolo.arq_Arquivo = Convert.ToString(reader["arq_Arquivo"]); protocolo.documento1 = Convert.ToString(reader["documento1"]); protocolo.documento2 = Convert.ToString(reader["documento2"]); protocolo.documento3 = Convert.ToString(reader["documento3"]); protocolo.documento4 = Convert.ToString(reader["documento4"]); protocolo.documento5 = Convert.ToString(reader["documento5"]); protocolo.documento6 = Convert.ToString(reader["documento6"]); lista.Add(protocolo); } return lista; } finally { minhaConexao.Close(); } }