Skip to content

Email report background service#33

Merged
grzechuzz merged 1 commit into
masterfrom
background-service
Jun 12, 2025
Merged

Email report background service#33
grzechuzz merged 1 commit into
masterfrom
background-service

Conversation

@NN0X

@NN0X NN0X commented Jun 12, 2025

Copy link
Copy Markdown
Owner

No description provided.

@NN0X NN0X requested review from Copilot and grzechuzz June 12, 2025 19:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a new background service that generates a daily PDF report of open service orders and emails it to administrators, introducing configuration, interfaces, implementations, and DI registrations.

  • Define ReportSettings in configuration for report scheduling and email addresses.
  • Add IEmailWithAttachmentSender interface with SMTP and SendGrid implementations.
  • Implement OpenOrdersReportBackgroundService to generate PDF via QuestPDF and send emails.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
CarWorkshopManager/appsettings.json Add ReportSettings block for interval, admin and sender emails
CarWorkshopManager/Services/Interfaces/IServiceOrderService.cs Add GetOpenServiceOrdersAsync to fetch open orders
CarWorkshopManager/Services/Interfaces/IEmailWithAttachmentSender.cs Introduce interface for sending emails with attachments
CarWorkshopManager/Services/Implementations/SmtpEmailWithAttachmentSender.cs Implement SMTP-based email sender; reads ReportSettings:Smtp
CarWorkshopManager/Services/Implementations/SendGridEmailWithAttachmentSender.cs Implement SendGrid-based email sender
CarWorkshopManager/Services/Implementations/ServiceOrderService.cs Provide implementation for fetching open orders
CarWorkshopManager/Services/Implementations/OpenOrdersReportBackgroundService.cs Add background service to generate and email PDF reports
CarWorkshopManager/Program.cs Register email sender and background service with DI container
CarWorkshopManager/Documents/DailyReportDocument.cs Define QuestPDF document classes for open orders report (filename mismatches class name)
Comments suppressed due to low confidence (6)

CarWorkshopManager/Services/Interfaces/IEmailWithAttachmentSender.cs:13

  • [nitpick] The parameter name attachmentType is ambiguous. Consider renaming to contentType or mimeType to clearly indicate it refers to the attachment's MIME type.
string attachmentType);

CarWorkshopManager/appsettings.json:19

  • Sensitive SendGrid API key is checked into source control in appsettings.json. Use user secrets or environment variables to protect credentials.
"ApiKey": "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",

CarWorkshopManager/Services/Implementations/ServiceOrderService.cs:227

  • New method GetOpenServiceOrdersAsync is not covered by existing tests. Consider adding unit tests to validate its behavior, especially the filtering logic.
public async Task<List<ServiceOrderListItemViewModel>> GetOpenServiceOrdersAsync()

CarWorkshopManager/Services/Implementations/SmtpEmailWithAttachmentSender.cs:28

  • Configuration section "ReportSettings:Smtp" does not exist in appsettings.json. You should add Host, Port, Username, Password, and EnableSsl under a "ReportSettings:Smtp" section or adjust the code to match existing settings.
var smtp = _config.GetSection("ReportSettings:Smtp");

CarWorkshopManager/Services/Implementations/SendGridEmailWithAttachmentSender.cs:21

  • The code expects a "SendGrid:SenderName" setting, but appsettings.json does not define it. Add SenderName under the SendGrid section or fallback to ReportSettings:SenderName.
var senderName = configuration["SendGrid:SenderName"]

@grzechuzz grzechuzz merged commit 555e892 into master Jun 12, 2025
1 check passed
@NN0X NN0X deleted the background-service branch June 13, 2025 08:09
NN0X pushed a commit that referenced this pull request Jun 13, 2025
Email report background service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants