예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //FileDocumento.UploadedComplete += new EventHandler<AsyncFileUploadEventArgs>(FileDocumento_UploadedComplete);
        //FileDocumento.UploadedFileError += new EventHandler<AsyncFileUploadEventArgs>(FileDocumento_UploadedFileError);
        FileDocumento.Style.Add("visibility", "hidden");

        if (!Page.IsCallback)
        {
            try
            {
                if (Request.QueryString["ID"] != null)
                {
                    hdnID.Text = Utilidades.decodpar(Request.QueryString["ID"].ToString());
                }
                if (Request.QueryString["sAccion"] != null)
                {
                    hdnAccion.Text = Utilidades.decodpar(Request.QueryString["sAccion"].ToString());
                }
                if (hdnAccion.Text == "U")
                {
                    DOCUIDFICEPI oDocu = DOCUIDFICEPI.Select(null, int.Parse(hdnID.Text));
                    txtDescrip.Text             = oDocu.t184_descripcion;
                    this.hdnContentServer.Value = oDocu.t2_iddocumento.ToString();
                    this.hdnNomArchivo.Value    = oDocu.t184_nombrearchivo.ToString();
                }
            }
            catch (Exception ex)
            {
                sErrores += Errores.mostrarError("Error al obtener los datos", ex);
            }
        }
        //1º Se indican (por este orden) la función a la que se va a devolver el resultado
        //   y la función que va a acceder al servidor
        string cbRespuesta = Page.ClientScript.GetCallbackEventReference(this, "arg", "RespuestaCallBack", "context", false);
        string cbLlamada   = "function RealizarCallBack(arg, context)" + "{" + cbRespuesta + ";" + "}";

        //2º Se "registra" la función que va a acceder al servidor.
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "RealizarCallBack", cbLlamada, true);
    }
예제 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["IDRED"] == null)
        {
            try
            {
                Response.Redirect("~/SesionCaducadaModal.aspx", true);
            }
            catch (System.Threading.ThreadAbortException) { return; }
        }

        byte[] ArchivoBinario = null;
        long?  t2_iddocumento = null;

        try
        {
            int nIDDOC = int.Parse(Request.QueryString["nIDDOC"].ToString());

            Response.ClearContent();
            Response.ClearHeaders();
            Response.Buffer      = true;
            Response.ContentType = "application/octet-stream";

            DOCUIDFICEPI oDoc = DOCUIDFICEPI.Select(null, nIDDOC);

            t2_iddocumento = oDoc.t2_iddocumento;
            if (t2_iddocumento != null)
            {
                ArchivoBinario = IB.Conserva.ConservaHelper.ObtenerDocumento((long)t2_iddocumento).content;
            }

            Response.AddHeader("Content-Disposition", "attachment; filename=\"" + oDoc.t184_nombrearchivo + "\"");
            Response.BinaryWrite(ArchivoBinario);

            if (Response.IsClientConnected)
            {
                Response.Flush();
            }
        }
        catch (ConservaException cex)
        {
            this.hdnError.Value = Utilidades.MsgErrorConserva("R", cex);
        }
        //catch (System.Web.HttpException hexc)
        //{
        //}
        catch (Exception ex)
        {
            this.hdnError.Value = "No se ha podido obtener el archivo.<br /><br />Error: " + ex.Message;
            if (ex.InnerException != null)
            {
                this.hdnError.Value += "<br />Detalle error: " + ex.InnerException.Message;
            }
        }
        //Response.Flush();
        finally
        {
            if (this.hdnError.Value == "")
            {
                Response.Close();
                //Response.End();
            }
        }
    }