Esempio n. 1
0
 public IImage GetThumbnail()
 {
     if (thumbnail == null)
     {
         thumbnail = renderService.CreateRenderTargetImage(ThumbnailSize);
         renderService.Render(thumbnail, new [] { Viewport.Create(IntVector2.Zero, ThumbnailSize, ThumbnailView.Create(this)) }, 0);
     }
     else if (thumbnailDirty)
     {
         renderService.Render(thumbnail, new[] { Viewport.Create(IntVector2.Zero, ThumbnailSize, ThumbnailView.Create(this)) }, 0);
     }
     thumbnailDirty = false;
     return(thumbnail);
 }
        public async Task <string> GenerateAsync(IReportServiceContext reportServiceContext, CancellationToken cancellationToken)
        {
            var fileName = _fileNameService.GetFilename(reportServiceContext, FileName, OutputTypes.Excel);

            var reportData = await _reportDataProvider.ProvideAsync(reportServiceContext, cancellationToken);

            using (var workbook = _excelFileService.NewWorkbook())
            {
                workbook.Worksheets.Clear();
                var summaries        = new List <ISummaryRow>();
                var summaryWorksheet = _excelFileService.GetWorksheetFromWorkbook(workbook, SummaryName);

                foreach (var worksheetTask in reportServiceContext.Tasks)
                {
                    var worksheet = _worksheets.GetValueOrDefault(worksheetTask);

                    summaries.Add(worksheet.Generate(workbook, reportServiceContext, reportData, cancellationToken));
                }

                var summaryModel = _summaryPageModelBuilder.Build(reportServiceContext, reportData);
                summaryModel.SummaryRows = summaries;

                _summarPageRenderService.Render(summaryModel, summaryWorksheet);

                await _excelFileService.SaveWorkbookAsync(workbook, fileName, reportServiceContext.Container, cancellationToken);
            }

            return(fileName);
        }
Esempio n. 3
0
        public async Task <IEnumerable <string> > GenerateAsync(
            IReportServiceContext reportServiceContext,
            IReportServiceDependentData reportsDependentData,
            CancellationToken cancellationToken)
        {
            var fundingSummaryReportModel = _devolvedFundingSummaryReportBuilder.Build(reportServiceContext, reportsDependentData);

            var fileName = _fileNameService.GetFilename(reportServiceContext, ReportName, OutputTypes.Excel);

            using (var workbook = _excelService.NewWorkbook())
            {
                workbook.Worksheets.Clear();

                foreach (var reportModel in fundingSummaryReportModel)
                {
                    var worksheet = _excelService.GetWorksheetFromWorkbook(workbook, reportModel.SofLookup.SofCode);

                    _devolvedFundingSummaryReportRenderService.Render(reportModel, worksheet);
                }

                await _excelService.SaveWorkbookAsync(workbook, fileName, reportServiceContext.Container, cancellationToken);
            }

            return(new[] { fileName });
        }
Esempio n. 4
0
        public async Task <IEnumerable <string> > GenerateAsync(IReportServiceContext reportServiceContext, IReportServiceDependentData reportsDependentData, CancellationToken cancellationToken)
        {
            var fileName = _fileNameService.GetFilename(reportServiceContext, ReportName, OutputTypes.Excel);

            var reportsToBeGenerated = _frmReports.Where(x => reportServiceContext.Tasks.Contains(x.TaskName, StringComparer.OrdinalIgnoreCase));

            using (var workbook = _excelService.NewWorkbook())
            {
                workbook.Worksheets.Clear();
                List <IFrmSummary> rows = new List <IFrmSummary>();
                var summaryWorksheet    = _excelService.GetWorksheetFromWorkbook(workbook, SummaryName);

                foreach (var frmReport in reportsToBeGenerated)
                {
                    rows.Add(frmReport.Generate(workbook, reportServiceContext, reportsDependentData, cancellationToken));
                }

                var frmSummaryReport = _frmSummaryReportModelBuilder.Build(reportServiceContext, reportsDependentData);
                frmSummaryReport.SummaryTable = rows;
                _frmSummaryReportRenderService.Render(frmSummaryReport, summaryWorksheet);

                await _excelService.SaveWorkbookAsync(workbook, fileName, reportServiceContext.Container, cancellationToken);
            }

            return(new[] { fileName });
        }
        public async Task <File> Convert(PrintFormModel printFormModel)
        {
            var template = await _dbRepository
                           .Get <TemplateFile>()
                           .Include(x => x.File)
                           .FirstOrDefaultAsync(x => x.Link == printFormModel.Template.Link)
                           ?? await _templateService.Create(printFormModel.Template);

            var renderedFile = await _renderService.Render(printFormModel, template);

            var targetFileName = printFormModel.Template.FullName;
            var file           = new File
            {
                Type     = FileType.Converted,
                FullName = targetFileName,
                Content  = renderedFile
            };

            if (file.Content == null)
            {
                //log
                return(null);
            }

            await _dbRepository.Add(file);

            await _dbRepository.SaveChanges();

            return(file);
        }
        public void Update(FrameTime frameTime)
        {
            if (!IsEnabled)
            {
                return;
            }
            HandleLaser();
            if (ZoomEnabled)
            {
                HandleZoom();
            }

            viewports[0].View.Update(frameTime);
            renderService.Render(rttImge, viewports, frameTime.TotalSeconds);
        }
        public virtual ISummaryRow Generate(Workbook workbook, IReportServiceContext reportServiceContext, IReportData reportData, CancellationToken cancellationToken)
        {
            var fundingReportMonitoringModels = _fundingRuleMonitoringReportModelBuilder.Build(reportServiceContext, reportData).ToList();

            if (fundingReportMonitoringModels.Any())
            {
                var worksheet = _excelService.GetWorksheetFromWorkbook(workbook, _tabName);

                _fundingRuleMonitoringRenderService.Render(fundingReportMonitoringModels, worksheet);
            }

            return(new SummaryRow
            {
                Report = _tabName,
                Title = _title,
                NumberOfQueries = fundingReportMonitoringModels.Count
            });
        }
Esempio n. 8
0
        public async Task <string> GenerateReport(IReportServiceContext reportServiceContext, CancellationToken cancellationToken)
        {
            var fileName = _fileNameService.GetFilename(reportServiceContext, ReportName, OutputTypes.Excel, true, true);

            var fundingSummaryReferenceData = await _fundingSummaryDataProvider.ProvideAsync(reportServiceContext, cancellationToken);

            var model = _fundingSummaryModelBuilder.Build(reportServiceContext, fundingSummaryReferenceData);

            using (var workbook = _excelFileService.NewWorkbook())
            {
                workbook.Worksheets.Clear();

                var worksheet = _excelFileService.GetWorksheetFromWorkbook(workbook, "FundingSummaryReport");

                _fundingSummaryRenderService.Render(model, worksheet);

                await _excelFileService.SaveWorkbookAsync(workbook, fileName, reportServiceContext.Container, cancellationToken);
            }

            var persistModels = _fundingSummaryPersistanceMapper.Map(reportServiceContext, model, cancellationToken);
            await _persistanceService.PersistAsync(reportServiceContext, persistModels, cancellationToken);

            return(fileName);
        }
        public override async Task GenerateReport(
            IReportServiceContext reportServiceContext,
            ZipArchive archive,
            CancellationToken cancellationToken)
        {
            var externalFileName = GetFilename(reportServiceContext);
            var fileName         = GetZipFilename(reportServiceContext);

            var fcsLookup = await _fcsProviderService.GetContractAllocationNumberFSPCodeLookupAsync(reportServiceContext.Ukprn, cancellationToken);

            var periodisedValuesLookup = await _periodisedValuesLookupProvider.ProvideAsync(reportServiceContext, cancellationToken);

            var model = await _modelBuilder.BuildFundingSummaryReportModel(reportServiceContext, periodisedValuesLookup, fcsLookup, cancellationToken);

            using (var workbook = _excelService.NewWorkbook())
            {
                workbook.Worksheets.Clear();

                _fundingSummaryReportRenderService.Render(model, _excelService.GetWorksheetFromWorkbook(workbook, "Funding Summary"));

                var replacedFileName = $"{externalFileName}.xlsx".Replace('_', '/');

                _excelService.ApplyLicense();

                await _excelService.SaveWorkbookAsync(workbook, replacedFileName, reportServiceContext.Container, cancellationToken);

                await WriteZipEntry(archive, $"{fileName}.xlsx", workbook, cancellationToken);
            }

            if (reportServiceContext.DataPersistFeatureEnabled)
            {
                var persistModels = model.FundingCategories.SelectMany(fc => fc.FundingSubCategories.SelectMany(fsc =>
                                                                                                                fsc.FundLineGroups.SelectMany(flg => flg.FundLines.Select(fl => new FundingSummaryPersistModel
                {
                    Ukprn              = reportServiceContext.Ukprn,
                    ContractNo         = fc.ContractAllocationNumber,
                    FundingCategory    = fc.FundingCategoryTitle,
                    FundingSubCategory = fsc.FundingSubCategoryTitle,
                    FundLine           = fl.Title,
                    Aug19              = fl.Period1,
                    Sep19              = fl.Period2,
                    Oct19              = fl.Period3,
                    Nov19              = fl.Period4,
                    Dec19              = fl.Period5,
                    Jan20              = fl.Period6,
                    Feb20              = fl.Period7,
                    Mar20              = fl.Period8,
                    Apr20              = fl.Period9,
                    May20              = fl.Period10,
                    Jun20              = fl.Period11,
                    Jul20              = fl.Period12,
                    AugMar             = fl.Period1To8,
                    AprJul             = fl.Period9To12,
                    YearToDate         = fl.YearToDate,
                    Total              = fl.Total
                })))).ToList();

                Stopwatch stopWatchLog = new Stopwatch();
                stopWatchLog.Start();
                await _persistReportData.PersistReportDataAsync(
                    persistModels,
                    reportServiceContext.Ukprn,
                    reportServiceContext.ReturnPeriod,
                    TableNameConstants.FundingSummaryReport,
                    reportServiceContext.ReportDataConnectionString,
                    cancellationToken);

                _logger.LogDebug($"Performance-FundingSummaryReport logging took - {stopWatchLog.ElapsedMilliseconds} ms ");
                stopWatchLog.Stop();
            }
            else
            {
                _logger.LogDebug(" Data Persist Feature is disabled.");
            }
        }