示例#1
0
        public PresentacionTrans FindPresentacionTransCotizacionbyID(int cotizacionID, int usuarioID)
        {
            PresentacionTrans presentacion = new PresentacionTrans();

            presentacion.Textos = _cotizacionRepository.GetCotizacionPresentacionTrans(cotizacionID);

            if (presentacion.Textos.Count() > 0)
            {
                int diasRetro = Convert.ToInt32(_catalogoRepository.GetGlobalParam((int)globalParam.DiasRetro));
                //Validacion retroactividad
                if (_cotizacionRepository.GetActivoCotizacion(cotizacionID) && (DateTime.Now - presentacion.Textos[0].VigenciaInicio).Days > diasRetro)
                {
                    presentacion.MensajeError = (new Cotizacion()).ErrorRetroactividad(diasRetro);
                }
                else
                {
                    List <string> mensajesLimite = _cotizacionRepository.GetMensajeLimite(cotizacionID, usuarioID);
                    mensajesLimite.AddRange(_cotizacionRepository.GetMensajeLimiteReaseguro(cotizacionID));

                    if (mensajesLimite.Count() > 0)
                    {
                        mensajesLimite.ForEach(x => { presentacion.MensajeError += x + "<br>"; });
                    }
                    else
                    {
                        presentacion.Condiciones = _catalogoRepository.GetCondicionesTrans();
                    }
                }
            }

            return(presentacion);
        }
        public JsonResult FillDetailsReportTrans()
        {
            PresentacionTrans model      = _CotizacionService.FindPresentacionTransCotizacionbyID((int)Session["cotizacionID"], Helper.GetUserData().UserId);
            string            reportType = "Word";

            LocalReport localReport = new LocalReport();

            localReport.ReportPath = Server.MapPath("~/Reports/PresentacionTrans2.rdlc");
            localReport.DataSources.Clear();

            ReportDataSource rdc  = new ReportDataSource("dsTransporte", model.Textos);
            ReportDataSource rdc1 = new ReportDataSource("dsCondiciones", model.Condiciones);

            ReportParameter param = new ReportParameter("isSendSISE", "True");

            localReport.SetParameters(param);
            localReport.DataSources.Add(rdc);
            localReport.DataSources.Add(rdc1);
            localReport.Refresh();


            string mimeType;
            string encoding;
            string fileNameExtension;

            string deviceInfo =
                "<DeviceInfo>" +
                "  <OutputFormat>PDF</OutputFormat>" +
                "  <PageWidth>8.5in</PageWidth>" +
                "  <PageHeight>11in</PageHeight>" +
                "  <MarginTop>0.2in</MarginTop>" +
                "  <MarginLeft>0.2in</MarginLeft>" +
                "  <MarginRight>0.2in</MarginRight>" +
                "  <MarginBottom>0.2in</MarginBottom>" +
                "</DeviceInfo>";

            Warning[] warnings;
            string[]  streams;
            byte[]    renderedBytes;

            //Render the report
            renderedBytes = localReport.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
            //return File(renderedBytes, mimeType);

            using (var fs = new FileStream(Server.MapPath(ConfigurationManager.AppSettings["PathTransporte"] + ".doc"), FileMode.Create, FileAccess.Write))
            {
                fs.Write(renderedBytes, 0, renderedBytes.Length);
            }

            return(this.Json("1", JsonRequestBehavior.AllowGet));
        }