public ReportFileDto Execute([NotNull] BuildReportQuery dataQuery) { if (dataQuery == null) { throw new ArgumentNullException(nameof(dataQuery)); } var userId = _userPrincipal.Info.Id; var result = _reportBuilder.Build( dataQuery.ReportId, userId, dataQuery.Parameters?.ToDictionary(_ => _.Key, _ => (object)_.Value), dataQuery.ReportFileType); if (result == null) { return(null); } return(new ReportFileDto { Content = result.Content, Title = result.FileName }); }
private void CreateAndSendNotification(NotificationRuleBundle bundle, Users targetUser) { var userAddress = _userDataProvider.GetDeliveryContacts(bundle.NotificationRule.DeliveryProtocol, targetUser); if (string.IsNullOrEmpty(userAddress)) { _logger.Warning(Resources.Resources.UserHasntContacts.FormatWith( targetUser.Login, bundle.NotificationRule.DeliveryProtocol)); return; } var notificationParameters = new ConcurrentDictionary <string, object>(); foreach (var attachmentParameter in bundle.NotificationNotificationParameters) { notificationParameters.AddOrUpdate(attachmentParameter.Key, attachmentParameter.Value, (s, o) => attachmentParameter.Value); } notificationParameters.AddOrUpdate(DefaultReportParameters.ContainerUseTable, true, (s, o) => true); var notificationReport = _reportBuilder.Build( bundle.NotificationRule.Expression.ReportId, targetUser.Id, notificationParameters, ReportFileType.Html); var notification = new Notification { Attachments = GetAttachments(bundle, targetUser), Message = notificationReport.RawHtml, Protocol = bundle.NotificationRule.DeliveryProtocol, Targets = new[] { userAddress }, Title = notificationReport.Title }; _notificationProvider.Publish(notification); }
public void ShouldGenerateReport() { const int reportId = 234234; var report = new Reports { Id = reportId }; _reportStorage .Setup(_ => _.Get(reportId)) .Returns(report); const int userId = 2342342; var parameters = new Dictionary <string, object> { { "Halo", "No" } }; var reportBundle = new ReportBundle(); _reportGenerationPipelineManager .Setup(_ => _.Generate(report, userId, parameters)) .Returns(reportBundle); const ReportFileType reportFileType = ReportFileType.Html; var reportFile = new ReportFile("Title", "Repo", "<div></div>", Guid.NewGuid().ToByteArray(), reportFileType); _reportTranslationManager .Setup(_ => _.Translate(reportBundle, reportFileType)) .Returns(reportFile); var result = _target.Build(reportId, userId, parameters, reportFileType); _repositoryLogger.Verify(_ => _.SaveReportFile(reportBundle, reportFile, userId), Times.Once); result.ShouldBeEquivalentTo(reportFile); }
public Task <List <Uri> > GenerateSvgs(IReportBuilder builder, CancellationToken cancellationToken = default) { return(GenerateSvgs(builder.Build(), cancellationToken)); }
public Task <Stream> GeneratePdfPreview(IReportBuilder builder, CancellationToken cancellationToken = default) { return(GeneratePdfPreview(builder.Build(), cancellationToken)); }
public Task <SuccessModel <string> > GeneratePdf(IReportBuilder builder, CancellationToken cancellationToken = default) { return(GeneratePdf(builder.Build(), cancellationToken)); }