Ejemplo n.º 1
0
        public byte[] GetPDF(string documentId, Int32 documentTypeId, BaseController claimsApiController, out String name, Boolean isEmpty)
        {
            Int32 serviceTypeId            = _context.DocumentPrintTypes.SingleOrDefault(x => x.Id == documentTypeId).ServiceTypeId.Value;
            ConsumerPrintDocument document = null;

            if (!String.IsNullOrEmpty(documentId))
            {
                document = this.GetDocument(Int32.Parse(documentId));
            }

            String partName = "New";

            name = "";

            if (document != null && !isEmpty)
            {
                partName = this.ConvertInvalidFilePathChars(this.GetContactName(document.Contact));
            }

            var reportViewer = new ReportViewer();

            reportViewer.Reset();
            reportViewer.LocalReport.EnableExternalImages = true;
            reportViewer.ProcessingMode = ProcessingMode.Local;

            IPDFreportModel reportTypeInstance = ReportTypesFactory.GetAppropriatePDFreportType((ServiceTypeIdEnum)serviceTypeId, (DocumentPrintTypeEnum)documentTypeId);

            reportViewer.LocalReport.ReportPath = claimsApiController.Server.MapPath(reportTypeInstance.ReportPath);
            name = reportTypeInstance.GetName(partName);

            var timeObjs = reportTypeInstance.CreateDataSet(document, isEmpty, this);

            reportViewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", timeObjs));
            return(RenderPDF(reportViewer));
        }
        public byte[] GetPDF(Int32 habReviewId, BaseController claimsApiController, out String name, DateTime?templateDate)
        {
            ConsumerHabReview document = _context.ConsumerHabReviews.SingleOrDefault(x => x.Id == habReviewId);

            name = "";
            if (document == null)
            {
                return(null);
            }

            var reportViewer = new ReportViewer();

            reportViewer.Reset();
            reportViewer.LocalReport.EnableExternalImages = true;
            reportViewer.ProcessingMode = ProcessingMode.Local;

            IPDFhabReviewReportModel habReviewTypeInstance = ReportTypesFactory.GetAppropriateHabReviewReportType((ServiceTypeIdEnum)document.ServiceId);

            if (habReviewTypeInstance == null)
            {
                throw new Exception("Wrong service type for printing the document");
            }
            habReviewTypeInstance.CalculateTemplatePath(templateDate, _context);
            reportViewer.LocalReport.ReportPath = claimsApiController.Server.MapPath(habReviewTypeInstance.ReportPath);
            Contact coordinatorContact = habReviewTypeInstance.GetCoordinatorContact(document);
            string  titleDocument      = habReviewTypeInstance.TitleDocument;
            bool    showReviewedBy     = habReviewTypeInstance.ShowReviewedBy;
            string  coordinatorLabel   = habReviewTypeInstance.CoordinatorLabel;

            name = habReviewTypeInstance.Name;

            var dataset = GenerateDataSetForHabReview(document, habReviewTypeInstance);

            reportViewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dataset));
            return(RenderPDF(reportViewer));
        }