public FileContentResult ExportHistory(string startDate, string endDate)
        {
            MemoryStream stream = new MemoryStream();

            try
            {
                DateTime startDateValue = DateTime.Today.AddDays(-ExportHistoryDefaultRange);
                DateTime endDateValue   = DateTime.Today;

                if (!string.IsNullOrEmpty(startDate))
                {
                    startDateValue = DateTime.ParseExact(startDate,
                                                         CommonConstant.UniversalDateFormat, CultureInfo.InvariantCulture);
                }

                if (!string.IsNullOrEmpty(endDate))
                {
                    endDateValue = DateTime.ParseExact(endDate,
                                                       CommonConstant.UniversalDateFormat, CultureInfo.InvariantCulture);
                }

                var reportDetailList = _reportService.GetExportHistory(new ReportService.GetExportHistoryParam()
                {
                    EndDate   = endDateValue,
                    StartDate = startDateValue
                });

                PagingSetup pagingSetup = ReportUtils.CreateDefaultPagingSetup();
                pagingSetup.PageOrientation = PageOrientation.Landscape;
                pagingSetup.PageSize        = PageSize.A4;
                PdfDocument document = ReportUtils.CreateDefaultPdfDocument(pagingSetup);

                ReportUtils.DrawReportHeader(pagingSetup, document, "Thống kê mẫu đã xuất", labID);
                ExportHistoryDrawReportSummary(pagingSetup, document, startDateValue, endDateValue);

                var gridTable = new ReportGridTable <ReportExportHistoryInfo>()
                {
                    Columns = ExportHistoryImportGridColumns(),
                    Datas   = reportDetailList
                };

                ReportUtils.DrawGrid(gridTable, pagingSetup, document);
                ReportUtils.DrawReportFooter(pagingSetup, document, labID);
                document.Save(stream);
            }
            catch (BusinessException exception)
            {
                _logger.DebugFormat("BusinessException: {0}-{1}", exception.ErrorCode, exception.Message);
            }
            catch (Exception exception)
            {
                _logger.Error(string.Format("Iternal error {0}", exception));
            }
            stream.Flush();
            return(File(stream.ToArray(), "application/pdf"));
        }
        public FileContentResult Print(string id)
        {
            MemoryStream stream = new MemoryStream();

            try
            {
                var exportInfo        = _tubeSampleService.GetExportInfo(id);
                var exportUserInfo    = _userService.GetLoginUserInfo(exportInfo.ExportUserId);
                var exportForUserInfo = _userService.GetLoginUserInfo(exportInfo.ExportForUserId);

                PagingSetup pagingSetup = ReportUtils.CreateDefaultPagingSetup();
                PdfDocument document    = ReportUtils.CreateDefaultPdfDocument(pagingSetup);
                ReportUtils.DrawReportHeader(pagingSetup, document, "PHIẾU XUẤT MẪU", labID);
                DrawReportHeaderSummary(pagingSetup, document, exportInfo);

                var gridTable = new ReportGridTable <ExportNoteDetail>()
                {
                    Columns = ExportGridColumns(),
                    Datas   = exportInfo.ExportNoteDetails
                };

                ReportUtils.DrawGrid(gridTable, pagingSetup, document);

                ReportUtils.IncreaseLineHeight(pagingSetup, document, pagingSetup.RegularLineHeight);

                DrawReportFooterSummary(pagingSetup, document, exportInfo);

                DrawReportFooter(pagingSetup, document,
                                 exportUserInfo == null ? exportInfo.ExportUserId : exportUserInfo.FullName,
                                 exportForUserInfo == null ? exportInfo.ExportForUserId : exportForUserInfo.FullName);

                ReportUtils.DrawReportFooter(pagingSetup, document, labID);
                document.Save(stream);
            }
            catch (BusinessException exception)
            {
                _logger.DebugFormat("BusinessException: {0}-{1}", exception.ErrorCode, exception.Message);
            }
            catch (Exception exception)
            {
                _logger.Error(string.Format("Iternal error {0}", exception));
            }
            stream.Flush();
            return(File(stream.ToArray(), "application/pdf"));
        }
Beispiel #3
0
        public FileContentResult Print(string id)
        {
            MemoryStream stream = new MemoryStream();

            try
            {
                var sampleSpec = _tubeSampleService.GetSampleSpec(id);
                var importNote = _tubeSampleService.GetImportInfo(id);
                //var historyData = _tubeSampleService.GetImportHistory(id);

                PagingSetup pagingSetup = ReportUtils.CreateDefaultPagingSetup();
                PdfDocument document    = ReportUtils.CreateDefaultPdfDocument(pagingSetup);
                PdfPage     page        = document.Pages[0];
                ReportUtils.DrawReportHeader(pagingSetup, document, "Thông tin phiếu nhập", labID);
                DrawReportSummary(pagingSetup, document, sampleSpec);

                var gridTable = new ReportGridTable <ImportNoteDetail>()
                {
                    Columns = ImportGridColumns(),
                    Datas   = importNote.ImportNoteDetails
                };

                ReportUtils.DrawGrid(gridTable, pagingSetup, document);
                ReportUtils.DrawReportFooter(pagingSetup, document, labID);
                document.Save(stream);
            }
            catch (BusinessException exception)
            {
                _logger.DebugFormat("BusinessException: {0}-{1}", exception.ErrorCode, exception.Message);
            }
            catch (Exception exception)
            {
                _logger.Error(string.Format("Iternal error {0}", exception));
            }
            stream.Flush();
            return(File(stream.ToArray(), "application/pdf"));
        }
        public FileContentResult SampleStatistics()
        {
            MemoryStream stream = new MemoryStream();

            try
            {
                var reportDetailList = _reportService.GetSampleStatistics();

                PagingSetup pagingSetup = ReportUtils.CreateDefaultPagingSetup();
                pagingSetup.PageOrientation = PageOrientation.Landscape;
                pagingSetup.PageSize        = PageSize.A4;
                PdfDocument document = ReportUtils.CreateDefaultPdfDocument(pagingSetup);
                PdfPage     page     = document.Pages[0];
                ReportUtils.DrawReportHeader(pagingSetup, document, "Thống kê tổng hợp", labID);
                ReportUtils.IncreaseLineHeight(pagingSetup, document, pagingSetup.RegularLineHeight);

                var gridTable = new ReportGridTable <ReportSampleStatisticInfo>()
                {
                    Columns = SampleStatisticsImportGridColumns(),
                    Datas   = reportDetailList
                };

                ReportUtils.DrawGrid(gridTable, pagingSetup, document);
                ReportUtils.DrawReportFooter(pagingSetup, document, labID);
                document.Save(stream);
            }
            catch (BusinessException exception)
            {
                _logger.DebugFormat("BusinessException: {0}-{1}", exception.ErrorCode, exception.Message);
            }
            catch (Exception exception)
            {
                _logger.Error(string.Format("Iternal error {0}", exception));
            }
            stream.Flush();
            return(File(stream.ToArray(), "application/pdf"));
        }