-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGenerateReportDataHandler.cs
More file actions
55 lines (50 loc) · 2.07 KB
/
GenerateReportDataHandler.cs
File metadata and controls
55 lines (50 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using Microsoft.Extensions.Logging;
using System.Threading.Tasks;
using Unity.GrantManager.Intakes.Events;
using Unity.Modules.Shared.Features;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EventBus;
using Volo.Abp.Features;
using Unity.GrantManager.Reporting.DataGenerators;
namespace Unity.GrantManager.Intakes.Handlers
{
public class GenerateReportDataHandler(IReportingDataGenerator reportingDataGenerator,
ILogger<GenerateReportDataHandler> logger,
IFeatureChecker featureChecker) : ILocalEventHandler<ApplicationProcessEvent>, ITransientDependency
{
/// <summary>
/// Generate Reporting for the submission
/// </summary>
/// <param name="eventData"></param>
/// <returns></returns>
public async Task HandleEventAsync(ApplicationProcessEvent eventData)
{
if (eventData == null)
{
logger.LogWarning("Event data is null in GenerateReportDataHandler.");
return;
}
if (eventData.OnlyLocationRetrofill)
{
logger.LogInformation("Skip report data generator handler.");
return;
}
if (await featureChecker.IsEnabledAsync(FeatureConsts.Reporting))
{
logger.LogInformation("Generating report data for application {ApplicationId}.", eventData.Application?.Id);
if (eventData.ApplicationFormSubmission == null)
{
logger.LogWarning("ApplicationFormSubmission is null in GenerateReportDataHandler.");
return;
}
if (await featureChecker.IsEnabledAsync(FeatureConsts.Reporting))
{
eventData.ApplicationFormSubmission.ReportData = reportingDataGenerator
.Generate(eventData.RawSubmission,
eventData.FormVersion?.ReportKeys,
eventData.ApplicationFormSubmission.Id) ?? "{}";
}
}
}
}
}