Ejemplo n.º 1
0
 /// <summary>
 /// Dado un id de documento en Atenea devuelve el array de bytes que conforman el archivo
 /// </summary>
 /// <param name="idDoc"></param>
 /// <returns></returns>
 public static byte[] ObtenerDocumento(Nullable <long> idDoc)
 {
     byte[] Archivo = null;
     if (idDoc != null)
     {
         IB.Conserva.svcConserva.CSVDocument oDoc = IB.Conserva.ConservaHelper.ObtenerDocumento((long)idDoc);
         Archivo = oDoc.content;
     }
     return(Archivo);
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            byte[] oArchivo    = null;
            long?  iddocumento = null; // Identificador del documento en ATENEA
            IB.Conserva.svcConserva.CSVDocument oDoc = new IB.Conserva.svcConserva.CSVDocument();

            Hashtable ht = Utils.ParseQuerystring(Utils.unescape(Request.QueryString.ToString()));
            iddocumento = ht["d"] != null ? (long?)long.Parse(ht["d"].ToString()) : null;


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

            if (oArchivo != null)
            {
                Response.ClearContent();
                Response.ClearHeaders();
                Response.Buffer      = true;
                Response.ContentType = ContentType(oDoc.docName);
                Response.AddHeader("Content-Disposition", "attachment; filename=\"" + oDoc.docName + "\"");
                Response.BinaryWrite(oArchivo);

                Response.Flush();
                //Response.Close();
                //Response.End();
                //Javi 18.05.2015 Evitar que se produzca error con el response.end
                System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest();
            }
        }
        catch (ConservaException cex)
        {
            hdnError.Value = cex.Message;
        }
        catch (Exception ex)  //Javi 18.05.2015 Controlar excepcion general
        {
            hdnError.Value = "Error al descargar el documento.<br /><br />" + ex.Message;
        }
    }
Ejemplo n.º 3
0
 public ContentServer(Nullable <long> idDoc)
 {
     if (idDoc != null)
     {
         try
         {
             IB.Conserva.svcConserva.CSVDocument oDoc = IB.Conserva.ConservaHelper.ObtenerDocumento((long)idDoc);
             Archivo = oDoc.content;
             Error   = "";
         }
         catch (Exception ex)
         {
             Error = ex.Message;
         }
     }
     else
     {
         Error = "La clave para identificar el documento en el Content-Server es vacía";
     }
 }