Ejemplo n.º 1
0
        void LoadReport(ReportInfo info)
        {
            logger.Debug(String.Format("Report Parameters[{0}]", info.GetParametersString()));

            MultiplePrintOperation multiplePrintOperation = null;

            if (info.PrintType == ReportInfo.PrintingType.MultiplePrinters)
            {
                IUnitOfWorkFactory unitOfWorkFactory = UnitOfWorkFactory.GetDefaultFactory;
                var commonService = ServicesConfig.CommonServices;
                var userPrintSettingsRepository = new UserPrintingRepository();
                multiplePrintOperation = new MultiplePrintOperation(unitOfWorkFactory, commonService, userPrintSettingsRepository);
            }

            if (info.Source != null)
            {
                reportviewer1.LoadReport(info.Source, info.GetParametersString(), info.ConnectionString, true, info.RestrictedOutputPresentationTypes);
            }
            else
            {
                if (multiplePrintOperation == null)
                {
                    reportviewer1.LoadReport(info.GetReportUri(), info.GetParametersString(), info.ConnectionString, true, info.RestrictedOutputPresentationTypes);
                }
                else
                {
                    reportviewer1.LoadReport(info.GetReportUri(), info.GetParametersString(), info.ConnectionString, true, info.RestrictedOutputPresentationTypes, multiplePrintOperation.Run);
                }
            }
            if (!string.IsNullOrWhiteSpace(info.Title))
            {
                reportviewer1.DefaultExportFileName = info.Title;
            }
        }
Ejemplo n.º 2
0
        public void Print(ReportInfo reportInfo)
        {
            var reportPath = reportInfo.GetPath();
            var source     = reportInfo.Source ?? File.ReadAllText(reportPath);

            var rdlParser = new RDLParser(source)
            {
                Folder = Path.GetDirectoryName(reportPath),
                OverwriteConnectionString = reportInfo.ConnectionString,
                OverwriteInSubreport      = true
            };

            var report = rdlParser.Parse();

            report.RunGetData(reportInfo.Parameters);
            var pages = report.BuildPages();

            switch (reportInfo.PrintType)
            {
            case ReportInfo.PrintingType.Default:
                var orientation = report.PageHeightPoints > report.PageWidthPoints
                                                ? PageOrientation.Portrait
                                                : PageOrientation.Landscape;
                var defaultPrintOperation = new DefaultPrintOperation();
                defaultPrintOperation.Run(pages, orientation);
                break;

            case ReportInfo.PrintingType.MultiplePrinters:
                var multiplePrintOperation = new MultiplePrintOperation(_unitOfWorkFactory, _commonServices, _userPrintingRepository);
                multiplePrintOperation.Run(pages);
                break;

            default:
                throw new NotSupportedException($"{reportInfo.PrintType} is not supported");
            }
        }