Esempio n. 1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        svcSUPER.IsvcSUPERClient osvcSUPER = new svcSUPER.IsvcSUPERClient();
        byte[] oDoc = null;

        Response.ClearContent();
        Response.ClearHeaders();
        Response.Buffer      = true;
        Response.ContentType = "application/octet-stream";
        //oDoc = osvcSUPER.obtenerCurriculum("Hola mundo !");

        if (osvcSUPER != null && osvcSUPER.State != System.ServiceModel.CommunicationState.Closed)
        {
            if (osvcSUPER.State != System.ServiceModel.CommunicationState.Faulted)
            {
                osvcSUPER.Close();
            }
            else if (osvcSUPER.State != System.ServiceModel.CommunicationState.Closed)
            {
                osvcSUPER.Abort();
            }
        }

        Response.BinaryWrite(oDoc);

        if (Response.IsClientConnected)
        {
            Response.Flush();
        }

        Response.Close();
    }
Esempio n. 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        svcSUPER.IsvcSUPERClient osvcSUPER = new svcSUPER.IsvcSUPERClient();
        byte[] oDoc = null;

        Response.ClearContent();
        Response.ClearHeaders();
        Response.Buffer      = true;
        Response.ContentType = "application/octet-stream";
        //oDoc = osvcSUPER.obtenerCurriculum("Hola mundo !");

        if (osvcSUPER != null && osvcSUPER.State != System.ServiceModel.CommunicationState.Closed)
        {
            if (osvcSUPER.State != System.ServiceModel.CommunicationState.Faulted)
            {
                osvcSUPER.Close();
            }
            else if (osvcSUPER.State != System.ServiceModel.CommunicationState.Closed)
            {
                osvcSUPER.Abort();
            }
        }

        string sNombreArchivo = "CV.doc";

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

        if (Response.IsClientConnected)
        {
            Response.Flush();
        }

        Response.Close();
    }
    private void getExcelValorGanado()
    {
        svcSUPER.IsvcSUPERClient osvcSUPER = null;
        try
        {
            int    t685_idlineabase       = int.Parse(Utilidades.decodpar(Request.QueryString["nLB"].ToString()));
            int    t325_anomes_referencia = int.Parse(Utilidades.decodpar(Request.QueryString["nAMR"].ToString()));
            int    t305_idproyectosubnodo = int.Parse(Utilidades.decodpar(Request.QueryString["nPSN"].ToString()));
            string t422_idmoneda          = Utilidades.decodpar(Request.QueryString["sMoneda"].ToString());
            int    nIAP           = int.Parse(Utilidades.decodpar(Request.QueryString["nIAP"].ToString()));
            int    nEXT           = int.Parse(Utilidades.decodpar(Request.QueryString["nEXT"].ToString()));
            int    nOCO           = int.Parse(Utilidades.decodpar(Request.QueryString["nOCO"].ToString()));
            int    nIAPCPI        = int.Parse(Utilidades.decodpar(Request.QueryString["nIAPCPI"].ToString()));
            int    nEXTCPI        = int.Parse(Utilidades.decodpar(Request.QueryString["nEXTCPI"].ToString()));
            int    nOCOCPI        = int.Parse(Utilidades.decodpar(Request.QueryString["nOCOCPI"].ToString()));
            string sExtension     = "xls";
            string sImportesEn    = MONEDA.getDenominacionImportes(t422_idmoneda);
            string sNombreArchivo = "DatosLineaBase." + sExtension;

            DataSet ds = LINEABASE.getDataSetParaExcel(
                t685_idlineabase,
                t325_anomes_referencia,
                t305_idproyectosubnodo,
                t422_idmoneda,
                nIAP,
                nEXT,
                nOCO,
                nIAPCPI,
                nEXTCPI,
                nOCOCPI
                );

            osvcSUPER      = new svcSUPER.IsvcSUPERClient();
            ArchivoBinario = osvcSUPER.getExcelValorGanado(ds, sExtension,
                                                           t325_anomes_referencia,
                                                           nIAP,
                                                           nEXT,
                                                           nOCO,
                                                           nIAPCPI,
                                                           nEXTCPI,
                                                           nOCOCPI,
                                                           t422_idmoneda,
                                                           sImportesEn);

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

            if (Response.IsClientConnected)
            {
                Response.Flush();
            }
        }
        catch (FaultException <svcSUPER.IBOfficeException> cex)
        {
            Response.ContentType = "text/HTML";
            this.hdnError.Value  = "Error: Código:" + cex.Detail.ErrorCode + ".\nDescripción: " + cex.Detail.Message;// +" " + cex.Detail.InnerMessage;

            if (cex.InnerException != null)
            {
                this.hdnError.Value += ".\nInnerException: descripción=" + cex.InnerException.Message;
            }

            if (cex.Detail.ErrorCode == 112)
            {
                this.hdnError.Value = "El servidor Office tiene todos sus recursos ocupados.\nPor favor, espere unos minutos e inténtelo de nuevo.\n\n" + this.hdnError.Value;
            }
        }
        catch (Exception ex)
        {
            Response.ContentType = "text/HTML";
            this.hdnError.Value  = "Error: " + ex.ToString();
        }
        finally
        {
            if (osvcSUPER != null && osvcSUPER.State != System.ServiceModel.CommunicationState.Closed)
            {
                if (osvcSUPER.State != System.ServiceModel.CommunicationState.Faulted)
                {
                    osvcSUPER.Close();
                }
                else if (osvcSUPER.State != System.ServiceModel.CommunicationState.Closed)
                {
                    osvcSUPER.Abort();
                }
            }
        }
    }