private void ShowReport()
        {
            List <string>   _filesNameToMerge  = new List <string>();
            OperationResult objOperationResult = new OperationResult();

            string ruta = Common.Utils.GetApplicationConfigValue("Interconsulta").ToString();
            var    aptitudeCertificate = new ServiceBL().GetReportInterconsulta(_serviceId, _Altitud, _Especialidad, _Labor, _Solicita, _Observaciones);

            //Verificar si el reporte existe en el repositorio
            string findReportInter = ruta + _serviceId + "-" + aptitudeCertificate[0].Paciente + ".pdf";

            string[] files    = Directory.GetFiles(ruta, "*.pdf");
            int      strIndex = 0;

            for (int i = 0; i < files.Length; i++)
            {
                strIndex = files[i].IndexOf(findReportInter);
                if (strIndex >= 0)
                {
                    File.Copy(findReportInter, ruta + _serviceId + "-" + aptitudeCertificate[0].Paciente + "_antiguo.pdf");
                    _filesNameToMerge.Add(ruta + _serviceId + "-" + aptitudeCertificate[0].Paciente + "_antiguo.pdf");
                }
            }

            //Crear el nuevo reporte Interconsulta
            var    rp = new Reports.crReporteInterconsulta();
            string RutaReportInterNew = ruta + _serviceId + "-" + aptitudeCertificate[0].Paciente + "_nuevo.pdf";

            DataSet   ds1 = new DataSet();
            DataTable dt  = Sigesoft.Node.WinClient.BLL.Utils.ConvertToDatatable(aptitudeCertificate);

            dt.TableName = "dtInterconsulta";
            ds1.Tables.Add(dt);

            DataTable dt1 = Sigesoft.Node.WinClient.BLL.Utils.ConvertToDatatable(_Lista);

            dt1.TableName = "dtDxs";
            ds1.Tables.Add(dt1);

            rp.SetDataSource(ds1);
            rp.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, RutaReportInterNew);

            //crystalReportViewer1.ReportSource = rp;
            //crystalReportViewer1.Show();

            //Agregar el nuevo reporte a la lista para unir PDFs
            _filesNameToMerge.Add(RutaReportInterNew);

            //Fusionar los reportes de la lista en un solo PDF
            var x = _filesNameToMerge.ToList();

            _mergeExPDF.FilesName       = x;
            _mergeExPDF.DestinationFile = ruta + _serviceId + "-" + aptitudeCertificate[0].Paciente + ".pdf";
            _mergeExPDF.Execute();
            _mergeExPDF.RunFile();

            //Borrar temporal creadas
            System.IO.File.Delete(ruta + _serviceId + "-" + aptitudeCertificate[0].Paciente + "_nuevo.pdf");
            System.IO.File.Delete(ruta + _serviceId + "-" + aptitudeCertificate[0].Paciente + "_antiguo.pdf");
        }
        private void btnImprimir_Click(object sender, EventArgs e)
        {
            using (new LoadingClass.PleaseWait(this.Location, "Generando..."))
            {
                DiskFileDestinationOptions objDiskOpt         = new DiskFileDestinationOptions();
                OperationResult            objOperationResult = new OperationResult();
                string ruta  = Common.Utils.GetApplicationConfigValue("rutaReportes").ToString();
                var    Lista = new AuthorizedPersonBL().GetAuthorizedPersonPagedAndFiltered(ref objOperationResult, 0, null, null, null);

                foreach (var item in Lista)
                {
                    var     Cabecera = new CalendarBL().HojaRutaCabecera(item.v_AuthorizedPersonId);
                    var     Detalle  = new CalendarBL().HojaRutaDetalle(item.v_ProtocolId);
                    var     rp       = new Reports.crRoadMapCampania();
                    DataSet ds       = new DataSet();

                    DataTable dtHeader = Sigesoft.Node.WinClient.BLL.Utils.ConvertToDatatable(Cabecera);
                    DataTable dtDetail = Sigesoft.Node.WinClient.BLL.Utils.ConvertToDatatable(Detalle);

                    dtHeader.TableName = "dtCabecera";
                    dtDetail.TableName = "dtDetalle";

                    ds.Tables.Add(dtHeader);
                    ds.Tables.Add(dtDetail);
                    rp.SetDataSource(ds);


                    rp.ExportOptions.ExportFormatType      = ExportFormatType.PortableDocFormat;
                    rp.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                    objDiskOpt = new DiskFileDestinationOptions();
                    objDiskOpt.DiskFileName = Application.StartupPath + @"\TempMerge\" + Guid.NewGuid().ToString() + ".pdf";
                    _filesNameToMerge.Add(objDiskOpt.DiskFileName);
                    rp.ExportOptions.DestinationOptions = objDiskOpt;
                    rp.Export();
                }

                var x = _filesNameToMerge.ToList();
                _mergeExPDF.FilesName = x;
                //_mergeExPDF.DestinationFile = Application.StartupPath + @"\TempMerge\" + _serviceId + ".pdf"; ;
                _mergeExPDF.DestinationFile = ruta + "xxx" + ".pdf";;
                _mergeExPDF.Execute();
                _mergeExPDF.RunFile();
            }
        }
        protected void btnSaveRefresh_Click(object sender, EventArgs e)
        {
            List <string> _filesNameToMerge = new List <string>();

            _tempSourcePath = Path.Combine(Server.MapPath("/TempMerge"));
            var w = (List <string>)Session["objLista"];


            foreach (var item in w)
            {
                ReportDocument rp = new ReportDocument();

                OperationResult objOperationResult = new OperationResult();

                var aptitudeCertificate = new ServiceBL().GetAptitudeCertificate(ref objOperationResult, item.ToString());

                DataSet   ds = new DataSet();
                DataTable dt = Sigesoft.Server.WebClientAdmin.UI.Utils.ConvertToDatatable(aptitudeCertificate);
                dt.TableName = "AptitudeCertificate";
                ds.Tables.Add(dt);
                rp.Load(Server.MapPath("crOccupationalMedicalAptitudeCertificate.rpt"));
                rp.SetDataSource(ds);

                rp.SetDataSource(ds);
                var ruta = Server.MapPath("files/CM" + item.ToString() + ".pdf");


                _filesNameToMerge.Add(ruta);

                rp.ExportToDisk(ExportFormatType.PortableDocFormat, ruta);
            }
            _mergeExPDF.FilesName       = _filesNameToMerge;
            _mergeExPDF.DestinationFile = Server.MapPath("files/yyy.pdf");

            _mergeExPDF.Execute();
            _mergeExPDF.RunFile();
            //rp.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat,
            //Response, false, "PersonDetails");
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            //if (_auxiliaryExams == null)
            //    _auxiliaryExams = new List<ServiceComponentList>();
            try
            {
                var    ruta       = Common.Utils.GetApplicationConfigValue("rutaExamenesAdicionales").ToString();
                var    rutaBasura = Common.Utils.GetApplicationConfigValue("rutaReportesBasura").ToString();
                string pathFile   = "";
                string CMP        = "";
                var    openFile   = false;
                using (new LoadingClass.PleaseWait(this.Location, "Cargando..."))
                {
                    OperationResult             objOperationResult = new OperationResult();
                    List <AdditionalExamCustom> ListAdditionalExam = new List <AdditionalExamCustom>();

                    foreach (ListViewItem item in lvExamenesSeleccionados.Items)
                    {
                        AdditionalExamCustom _additionalExam = new AdditionalExamCustom();
                        var fields = item.SubItems;
                        _additionalExam.ComponentId  = fields[1].Text;
                        _additionalExam.IsProcessed  = int.Parse(fields[2].Text);
                        _additionalExam.IsNewService = int.Parse(fields[3].Text);
                        _additionalExam.Commentary   = txtCommentary.Text;
                        _additionalExam.ServiceId    = _serviceId;
                        _additionalExam.PersonId     = _personId;
                        _additionalExam.ProtocolId   = "";
                        if (_additionalExam.IsNewService == 1)
                        {
                            _additionalExam.ProtocolId = Constants.Prot_Hospi_Adic;
                        }
                        ListAdditionalExam.Add(_additionalExam);
                    }


                    var datosGrabo = objServiceBL.DevolverDatosUsuarioFirma(Globals.ClientSession.i_SystemUserId);


                    if (datosGrabo != null)
                    {
                        if (datosGrabo.CMP != null)
                        {
                            CMP      = datosGrabo.CMP;
                            pathFile = string.Format("{0}.pdf", Path.Combine(ruta, _serviceId + "-" + "ORDEN-EX-MED-ADICI-" + datosGrabo.CMP));
                        }
                    }

                    using (var ts = new TransactionScope())
                    {
                        var success = _additionalExamBl.AddAdditionalExam(ListAdditionalExam, Globals.ClientSession.GetAsList());
                        if (!success)
                        {
                            throw new Exception("Sucedió un error, por favor vuelva a intentarlo");
                        }

                        ts.Complete();
                    }
                    List <Categoria> AdditionalExam = new List <Categoria>();
                    List <Categoria> DataSource     = new List <Categoria>();
                    List <string>    ComponentList  = new List <string>();
                    var ListadditExam = new AdditionalExamBL().GetAdditionalExamByServiceId_all(_serviceId, Globals.ClientSession.i_SystemUserId);

                    foreach (var componenyId in ListadditExam)
                    {
                        ComponentList.Add(componenyId.ComponentId);
                    }

                    foreach (var componentId in ComponentList)
                    {
                        var ListServiceComponent = new ServiceBL().GetAllComponents(ref objOperationResult, (int)TipoBusqueda.ComponentId, componentId);

                        Categoria categoria = DataSource.Find(x => x.i_CategoryId == ListServiceComponent[0].i_CategoryId);
                        if (categoria != null)
                        {
                            List <ComponentDetailList> componentDetail = new List <ComponentDetailList>();
                            componentDetail = ListServiceComponent[0].Componentes;
                            DataSource.Find(x => x.i_CategoryId == ListServiceComponent[0].i_CategoryId).Componentes.AddRange(componentDetail);
                        }
                        else
                        {
                            DataSource.AddRange(ListServiceComponent);
                        }
                    }


                    var MedicalCenter = objServiceBL.GetInfoMedicalCenter();
                    var DatosPaciente = new PacientBL().DevolverDatosPaciente(_serviceId);

                    new PrintAdditionalExam().GenerateAdditionalexam(pathFile, MedicalCenter, DatosPaciente, datosGrabo, txtCommentary.Text, DataSource, ListadditExam);
                }

                List <string> pdfList = new List <string>();
                pdfList.Add(pathFile);
                _mergeExPDF.FilesName       = pdfList;
                _mergeExPDF.DestinationFile = string.Format("{0}.pdf", Path.Combine(rutaBasura, _serviceId + "-" + "ORDEN-EX-MED-ADICI-" + CMP));
                _mergeExPDF.Execute();
                _mergeExPDF.RunFile();

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR:" + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Beispiel #5
0
        private void btnImprimir_Click(object sender, EventArgs e)
        {
            if (grdDataAdditionalExam.Rows.Count == 0)
            {
                MessageBox.Show("No hay exámenes para imprimir", "VALIDACIÓN", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                return;
            }
            var    ruta       = Common.Utils.GetApplicationConfigValue("rutaExamenesAdicionales").ToString();
            var    rutaBasura = Common.Utils.GetApplicationConfigValue("rutaReportesBasura").ToString();
            string pathFile   = "";
            string CMP        = "";
            var    openFile   = false;

            using (new LoadingClass.PleaseWait(this.Location, "Cargando..."))
            {
                OperationResult objOperationResult = new OperationResult();

                var datosGrabo = new ServiceBL().DevolverDatosUsuarioFirma(Globals.ClientSession.i_SystemUserId);
                CMP      = datosGrabo.CMP;
                pathFile = string.Format("{0}.pdf", Path.Combine(ruta, _serviceId + "-" + "ORDEN-EX-MED-ADICI-" + datosGrabo.CMP));


                List <Categoria> AdditionalExam = new List <Categoria>();
                List <Categoria> DataSource     = new List <Categoria>();
                List <string>    ComponentList  = new List <string>();
                var ListadditExam = new AdditionalExamBL().GetAdditionalExamByServiceId_all(_serviceId, Globals.ClientSession.i_SystemUserId);

                foreach (var componenyId in ListadditExam)
                {
                    ComponentList.Add(componenyId.ComponentId);
                }

                foreach (var componentId in ComponentList)
                {
                    var ListServiceComponent = new ServiceBL().GetAllComponents(ref objOperationResult, (int)TipoBusqueda.ComponentId, componentId);

                    Categoria categoria = DataSource.Find(x => x.i_CategoryId == ListServiceComponent[0].i_CategoryId);
                    if (categoria != null)
                    {
                        List <ComponentDetailList> componentDetail = new List <ComponentDetailList>();
                        componentDetail = ListServiceComponent[0].Componentes;
                        DataSource.Find(x => x.i_CategoryId == ListServiceComponent[0].i_CategoryId).Componentes.AddRange(componentDetail);
                    }
                    else
                    {
                        DataSource.AddRange(ListServiceComponent);
                    }
                }


                var MedicalCenter = new ServiceBL().GetInfoMedicalCenter();
                var DatosPaciente = new PacientBL().DevolverDatosPaciente(_serviceId);

                new PrintAdditionalExam().GenerateAdditionalexam(pathFile, MedicalCenter, DatosPaciente, datosGrabo, txtComentario.Text, DataSource, ListadditExam);
            }

            List <string> pdfList = new List <string>();

            pdfList.Add(pathFile);
            _mergeExPDF.FilesName       = pdfList;
            _mergeExPDF.DestinationFile = string.Format("{0}.pdf", Path.Combine(rutaBasura, _serviceId + "-" + "ORDEN-EX-MED-ADICI-" + CMP));
            _mergeExPDF.Execute();
            _mergeExPDF.RunFile();
        }