From 88594961630c32cb50c6040331b2cfc72833b113 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Thu, 2 Jul 2020 14:18:09 -0700 Subject: [PATCH] ya se pueden subir y descar los certificados --- Sistemas/Empresa.aspx | 138 ++++++++++++++++++++------------------- Sistemas/Empresa.aspx.vb | 50 +++++++++----- 2 files changed, 103 insertions(+), 85 deletions(-) diff --git a/Sistemas/Empresa.aspx b/Sistemas/Empresa.aspx index d2d0a61c7..78debe01e 100644 --- a/Sistemas/Empresa.aspx +++ b/Sistemas/Empresa.aspx @@ -319,76 +319,80 @@
- - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Archivo Key: -
- Cargar Archivo Key
- - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Archivo Key: +
+ Cargar Archivo Key
+ Descargar Archivo Key <%----%> - - - - - -
Archivo CER: -
- Cargar Archivo CER
- - Descargar Archivo CER -
Archivo PFX: -
- Cargar Archivo PFX
- - Descargar Archivo PFX -
Contraseña Key: -
Contraseña CIEC: -
- Registrar en ProFact -
+ +
Archivo CER: +
+ Cargar Archivo CER
+ + Descargar Archivo CER +
Archivo PFX: +
+ Cargar Archivo PFX
+ <%----%> + Descargar Archivo PFX +
Contraseña Key: +
Contraseña CIEC: +
+ Registrar en ProFact +
+ + + + + + +
diff --git a/Sistemas/Empresa.aspx.vb b/Sistemas/Empresa.aspx.vb index 456ba4757..7b2b50f94 100644 --- a/Sistemas/Empresa.aspx.vb +++ b/Sistemas/Empresa.aspx.vb @@ -5,6 +5,7 @@ Imports System.Data Imports Extensiones Imports System.Runtime.InteropServices Imports System.IO +Imports Microsoft.Reporting.WebForms Partial Class Sistemas_Empresa Inherits ClsPaginas @@ -404,7 +405,7 @@ Partial Class Sistemas_Empresa LbBannerDescarga.OnClientClick = "javascript:AbrirVentana('/Cer/" & .ArchivoCer & "', 500, 500, 'N', 'ArchivoCer Empresa');" Session("FileUpload") = .ArchivoCer - LbArchivoPfxDescarga.OnClientClick = "javascript:AbrirVentana('/Pfx/" & .ArchivoPfx & "', 500, 500, 'N', 'ArchivoPfx Empresa');" + 'LbArchivoPfxDescarga.OnClientClick = "javascript:AbrirVentana('/Pfx/" & .ArchivoPfx & "', 500, 500, 'N', 'ArchivoPfx Empresa');" Session("FileUpload") = .ArchivoPfx End With @@ -1680,26 +1681,39 @@ Partial Class Sistemas_Empresa End Sub Protected Sub LbArchivoKeyDescarga_Download(sender As Object, e As EventArgs) Handles LbArchivoKeyDescarga.Click - Dim FilePath As String = String.Format("{0}Empresas\{1}\Certificados\{2}", ModExtensiones.DirectorioBaseEmpresas, CveEmpresa, TxtArchivoKey.Text) - 'Dim fi As New FileInfo(File) + + Dim NombreArchivo As String = TxtArchivoKey.Text + DescargarArchivo(NombreArchivo) + + End Sub + + Protected Sub LbArchivoCerDescarga_Download(sender As Object, e As EventArgs) Handles LbArchivoCerDescarga.Click + + Dim NombreArchivo As String = TxtArchivoCer.Text + DescargarArchivo(NombreArchivo) + + End Sub + + Protected Sub LbArchivoPfxDescarga_Download(sender As Object, e As EventArgs) Handles LbArchivoPfxDescarga.Click + + Dim NombreArchivo As String = TxtArchivoPfx.Text + DescargarArchivo(NombreArchivo) + + End Sub + + Private Sub DescargarArchivo(NombreArchivo As String) + + Dim FilePath As String = String.Format("{0}Empresas\{1}\Certificados\{2}", ModExtensiones.DirectorioBaseEmpresas, CveEmpresa, NombreArchivo) Dim byteArray As Byte() = File.ReadAllBytes(FilePath) - 'HttpContext.Current.Response.Clear() - 'HttpContext.Current.Response.ClearContent() - 'HttpContext.Current.Response.ContentType = "application/octet-stream" - 'HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment filename=prueba.docx") - 'HttpContext.Current.Response.AddHeader("Content-Length", byteArray.Length.ToString()) - 'HttpContext.Current.Response.OutputStream.Write(byteArray, 0, byteArray.Length) - 'HttpContext.Current.Response.End() - Response.Buffer = True - Response.Clear() - Response.ContentType = "application/octet-stream" - HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment filename=prueba.docx") - HttpContext.Current.Response.BinaryWrite(byteArray) ' create the file - HttpContext.Current.Response.Flush() ' send it to the client to download - HttpContext.Current.Response.SuppressContent = True - HttpContext.Current.ApplicationInstance.CompleteRequest() + HttpContext.Current.Response.Clear() + HttpContext.Current.Response.ClearContent() + HttpContext.Current.Response.ContentType = "application/octet-stream" + HttpContext.Current.Response.AddHeader("Content-Disposition", String.Format("attachment;filename={0}", NombreArchivo)) + HttpContext.Current.Response.AddHeader("Content-Length", byteArray.Length.ToString()) + HttpContext.Current.Response.OutputStream.Write(byteArray, 0, byteArray.Length) HttpContext.Current.Response.End() + End Sub End Class