SelectDocumento_Path() 공개 메소드

Consulta la ruta física en donde se almacenó un documento
BPDocumento.SelectDocumento_Path 10-Septiembre-2014 Ruben.Cobos
public SelectDocumento_Path ( ENTDocumento oENTDocumento ) : ENTResponse
oENTDocumento SIAQ.Entity.Object.ENTDocumento Entidad de Documento con los parámetros necesarios para realizar la transacción
리턴 SIAQ.Entity.Object.ENTResponse
예제 #1
0
        // Rutinas el programador
        void DeleteDocumento(Int32 DocumentoId)
        {
            ENTDocumento oENTDocumento = new ENTDocumento();
            ENTResponse oENTResponse = new ENTResponse();

            BPDocumento oBPDocumento = new BPDocumento();

            try
            {

                // Formulario
                oENTDocumento.DocumentoId = DocumentoId;

                // Consultar información del archivo
                oENTResponse = oBPDocumento.SelectDocumento_Path(oENTDocumento);

                // Errores y Warnings
                if (oENTResponse.GeneratesException) { throw (new Exception(oENTResponse.sErrorMessage)); }
                if (oENTResponse.sMessage != "") { throw (new Exception(oENTResponse.sMessage)); }

                // Eliminar físicamente el archivo
                if (File.Exists(oENTResponse.dsResponse.Tables[1].Rows[0]["Ruta"].ToString())) { File.Delete(oENTResponse.dsResponse.Tables[1].Rows[0]["Ruta"].ToString()); }

                // Eliminar la referencia del archivo en la base de datos
                oENTResponse = oBPDocumento.DeleteDocumento(oENTDocumento);

                // Errores y Warnings
                if (oENTResponse.GeneratesException) { throw (new Exception(oENTResponse.sErrorMessage)); }
                if (oENTResponse.sMessage != "") { throw (new Exception(oENTResponse.sMessage)); }

                // Estado inicial del formulario
                this.ckeDescripcion.Text = "";

                // Refrescar el formulario
                SelectSolicitud();

                // Foco
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), Convert.ToString(Guid.NewGuid()), "function pageLoad(){ focusControl('" + this.fupArchivo.ClientID + "'); }", true);

            }catch ( IOException ioEx){

                throw (ioEx);
            }catch (Exception ex){

                throw (ex);
            }
        }
예제 #2
0
        // Eventos
        public void ProcessRequest(HttpContext httpContext)
        {
            ENTDocumento oENTDocumento = new ENTDocumento();
            ENTResponse oENTResponse = new ENTResponse();
            BPDocumento oBPDocumento = new BPDocumento();

            MemoryStream msFile;
            FileStream fsFile;
            Byte[] byteFile;

            Int32 DocumentoId;

            try
            {

                // Validaciones de llamada
                if (httpContext.Request.QueryString["key"] == null) { httpContext.Response.Redirect("~/Application/WebApp/Private/SysApp/saNotificacion.aspx", false); return; }

                // Obtener el id del documento
                DocumentoId = Int32.Parse(gcEncryption.DecryptString(httpContext.Request.QueryString["key"], true));

                // Consultar la ruta del archivo
                oENTDocumento.DocumentoId = DocumentoId;
                oENTResponse = oBPDocumento.SelectDocumento_Path(oENTDocumento);

                // Errores y Warnings
                if (oENTResponse.GeneratesException) { throw (new Exception(oENTResponse.sErrorMessage)); }
                if (oENTResponse.sMessage != "") { throw (new Exception(oENTResponse.sMessage)); }

                // Obtener el archivo
                fsFile = new System.IO.FileStream(oENTResponse.dsResponse.Tables[1].Rows[0]["Ruta"].ToString(), System.IO.FileMode.Open, System.IO.FileAccess.Read);

                byteFile = new Byte[fsFile.Length];
                fsFile.Read(byteFile, 0, (int)fsFile.Length);
                fsFile.Close();

                // Validación
                if (byteFile == null) { throw (new Exception("No se encontró el archivo")); }

                // Cambiar los contet de la página
                httpContext.Response.ContentType = "application/x-unknown/octet-stream";
                httpContext.Response.AppendHeader("Content-Disposition", "attachment; filename=\"" + oENTResponse.dsResponse.Tables[1].Rows[0]["Nombre"].ToString() + "\"");

                // Descargar el archivo
                msFile = new MemoryStream(byteFile, true);
                msFile.Write(byteFile, 0, byteFile.Length);
                httpContext.Response.BinaryWrite(byteFile);
                httpContext.Response.Flush();

            }catch (IOException ioEx){

                httpContext.Response.Write(ioEx.Message);

             }catch (Exception ex){

                httpContext.Response.Write(ex.Message);

            }finally{

                httpContext.Response.End();

            }
        }