Esempio n. 1
0
        public async Task <ReportInformation> ReportGeneration([ActivityTrigger] ReportGeneration filter, ILogger log)
        {
            ReportInformation reportInformation     = ReportStructure.Report(filter.FileName);
            ICollection <EventViewModelReadOnly> vm = await eventService.GetConfirmedIntervalledAsync(filter.StartDate, filter.EndDate);

            var dataStream = flatFileService.GenerateEventFlatFile(vm);
            await fileService.UploadReport(reportInformation.BlobContainerName, reportInformation.FileName, dataStream);

            return(reportInformation);
        }
Esempio n. 2
0
        public async Task ConfirmEvent([ActivityTrigger] ReportGeneration eventsData,
                                       [SendGrid(ApiKey = "SendGridConnections:ApiKey")] IAsyncCollector <SendGridMessage> messageCollector,
                                       ILogger log)
        {
            MemoryStream eventsStream = await fileService.DownloadReport(eventsData.ReportInformation.BlobContainerName, eventsData.ReportInformation.FileName);

            SendGridMessage message = new SendGridMessage();

            message.SetFrom(new EmailAddress(sendGridSettings.From));
            message.AddTos(adminSettings.GetMails().Select(x => new EmailAddress(x)).ToList());
            message.SetSubject($"Send events report from {eventsData.StartDate.ToShortDateString()} to {eventsData.EndDate.ToShortDateString()}");
            message.Contents = new List <Content>();
            message.Contents.Add(new Content("text/plain", "In this mail there is Event Report"));
            await message.AddAttachmentAsync(eventsData.FileName, eventsStream);

            await messageCollector.AddAsync(message);
        }
Esempio n. 3
0
        public async Task RunOrchestrator(
            [OrchestrationTrigger] IDurableOrchestrationContext context)
        {
            var filter = context.GetInput <ReportGeneration>();

            // Set Filter FileName
            filter.FileName = $"Report-{context.CurrentUtcDateTime.ToString("yyyy-MM-ddTHHmmssZ")}.csv";
            ReportInformation reportInformation = await context.CallActivityAsync <ReportInformation>(ReportEvents_Generate, filter);

            ReportGeneration generation = new ReportGeneration
            {
                StartDate         = filter.StartDate,
                EndDate           = filter.EndDate,
                ReportInformation = reportInformation,
                FileName          = filter.FileName
            };
            await context.CallActivityAsync(ReportEvents_SendMail, generation);
        }