コード例 #1
0
        XtraReport CreateReport(string clave)
        {
            XtraReport report = null;

            using (var conexion = new DataModelFE())
            {
                WSRecepcionPOSTProforma dato = conexion.WSRecepcionPOSTProforma.Where(x => x.clave == clave).FirstOrDefault();
                if (dato != null)
                {
                    string xml = EncodeXML.EncondeXML.base64Decode(dato.comprobanteXml);

                    //Revertimos lo de la proforma
                    xml = xml.Replace("FacturaElectronica", "ProformaElectronica");


                    RptComprobanteProformas reportES = new RptComprobanteProformas();
                    //Crear Proforma en Inglés
                    RptComprobanteProformasEN reportEN = new RptComprobanteProformasEN();

                    ProformaElectronica documento = (ProformaElectronica)EncodeXML.EncondeXML.getObjetcFromXML(xml);
                    Empresa             empresa   = conexion.Empresa.Find(documento.emisor.identificacion.numero);

                    if (empresa != null && "EN".Equals(empresa.idioma))
                    {
                        object dataSource = UtilidadesReporte.cargarObjetoImpresionProforma(documento, dato.mensaje, empresa);
                        reportEN.objectDataSource1.DataSource = dataSource;
                        string enviroment_url = ConfigurationManager.AppSettings["ENVIROMENT_URL_PROFORMA"].ToString();
                        reportEN.xrBarCode1.Text = (enviroment_url + documento.clave).ToUpper();
                        if (empresa != null && empresa.logo != null)
                        {
                            reportEN.pbLogo.Image = UtilidadesReporte.byteArrayToImage(empresa.logo);
                        }
                        reportEN.CreateDocument();
                        report = reportEN;
                    }
                    else
                    {
                        object dataSource = UtilidadesReporte.cargarObjetoImpresionProforma(documento, dato.mensaje, empresa);
                        reportES.objectDataSource1.DataSource = dataSource;
                        string enviroment_url = ConfigurationManager.AppSettings["ENVIROMENT_URL_PROFORMA"].ToString();
                        reportES.xrBarCode1.Text = (enviroment_url + documento.clave).ToUpper();
                        if (empresa != null && empresa.logo != null)
                        {
                            reportES.pbLogo.Image = UtilidadesReporte.byteArrayToImage(empresa.logo);
                        }

                        reportES.CreateDocument();
                        report = reportES;
                    }
                }
            }
            return(report);
        }
コード例 #2
0
        private XtraReport CreateReport()
        {
            XtraReport report1 = new XtraReport();
            XtraReport report2 = new XtraReport();

            List <XtraReport> oLista = new List <XtraReport>();
            XtraReport        report = null;
            var pLista = (List <String>)Session["claves"];

            foreach (var item in pLista)
            {
                XtraReport reportP = new XtraReport();

                using (var conexion = new DataModelFE())
                {
                    WSRecepcionPOSTProforma dato = conexion.WSRecepcionPOSTProforma.Where(x => x.clave == item.ToString()).FirstOrDefault();
                    string xml = EncodeXML.XMLUtils.base64Decode(dato.comprobanteXml);
                    //Cambiar sector a Factura Electrónica
                    xml = xml.Replace("FacturaElectronica", "ProformaElectronica");// esto es solo para que no se reemplace por el de abajo


                    RptComprobante   reportES = new RptComprobante();
                    RptComprobanteEN reportEN = new RptComprobanteEN();

                    ProformaElectronica documento = (ProformaElectronica)EncodeXML.XMLUtils.getObjetcFromXML(xml);
                    Empresa             empresa   = conexion.Empresa.Find(documento.emisor.identificacion.numero);

                    if (empresa != null && "EN".Equals(empresa.idioma))
                    {
                        object dataSource = UtilidadesReporte.cargarObjetoImpresionProforma(documento, dato.mensaje, empresa);
                        reportEN.objectDataSource1.DataSource = dataSource;
                        string enviroment_url = ConfigurationManager.AppSettings["ENVIROMENT_URL"].ToString();
                        reportEN.xrBarCode1.Text = (enviroment_url + documento.clave).ToUpper();
                        if (empresa != null && empresa.logo != null)
                        {
                            reportEN.pbLogo.Image = UtilidadesReporte.byteArrayToImage(empresa.logo);
                        }

                        reportEN.CreateDocument();
                        reportP = reportEN;
                    }
                    else
                    {
                        object dataSource = UtilidadesReporte.cargarObjetoImpresionProforma(documento, dato.mensaje, empresa);
                        reportES.objectDataSource1.DataSource = dataSource;
                        string enviroment_url = ConfigurationManager.AppSettings["ENVIROMENT_URL"].ToString();
                        reportES.xrBarCode1.Text = (enviroment_url + documento.clave).ToUpper();
                        if (empresa != null && empresa.logo != null)
                        {
                            reportES.pbLogo.Image = UtilidadesReporte.byteArrayToImage(empresa.logo);
                        }
                        reportES.CreateDocument();
                        reportP = reportES;
                    }
                }
                oLista.Add(reportP);
            }

            if (oLista.Count == 1)
            {
                report1 = oLista[0];
            }
            else
            {
                if (oLista.Count == 2)
                {
                    report1 = oLista[0];
                    report2 = oLista[1];
                    report1.Pages.AddRange(report2.Pages);
                    report1.PrintingSystem.ContinuousPageNumbering = true;
                }
                else
                {
                    for (int i = 0; i < oLista.Count - 1; i++)
                    {
                        if (i == 0)
                        {
                            report1 = oLista[i];
                        }
                        else
                        {
                            report1 = report1;
                        }

                        report2 = oLista[i + 1];
                        report1.Pages.AddRange(report2.Pages);
                        report1.PrintingSystem.ContinuousPageNumbering = true;
                    }
                }
            }

            report = report1;
            return(report);
        }