- Created ComplianceNFs.Core project with domain entities and ports - Implemented BuyingRecord, EnergyInvoice, ParsedInvoice entities - Defined domain interfaces for mail listening, XML and PDF parsing, and repository access - Established ComplianceNFs.Infrastructure project with file archiving, mail listening, and data access implementations - Developed PDF and XML parsers for invoice data extraction - Set up AccessDbRepository and AttachmentRepository for data retrieval and storage - Created ComplianceNFs.Service project for background processing and service orchestration - Implemented Worker service for periodic tasks - Established ComplianceNFs.Monitor project with WPF UI for monitoring invoice statuses - Added ViewModel for UI data binding and command handling - Configured project files for .NET 9.0 and necessary package references - Created initial appsettings.json for configuration management - Added TODOs and roadmap for future development
34 lines
1.0 KiB
C#
34 lines
1.0 KiB
C#
using System.IO;
|
|
using System.Threading.Tasks;
|
|
using ComplianceNFs.Core.Entities;
|
|
using ComplianceNFs.Core.Ports;
|
|
using System;
|
|
using System.IO;
|
|
|
|
namespace ComplianceNFs.Infrastructure.Archiving
|
|
{
|
|
// Moves files to archive folders by status
|
|
public class FileArchiver : IFileArchiver
|
|
{
|
|
private readonly string _basePath;
|
|
public FileArchiver(string basePath)
|
|
{
|
|
_basePath = basePath;
|
|
}
|
|
|
|
public async Task ArchiveAsync(EnergyInvoice invoice, byte[] rawFile)
|
|
{
|
|
// Create subfolder for invoice.Status
|
|
var statusFolder = Path.Combine(_basePath, invoice.Status.ToString());
|
|
if (!Directory.Exists(statusFolder))
|
|
{
|
|
Directory.CreateDirectory(statusFolder);
|
|
}
|
|
// Build file path
|
|
var filePath = Path.Combine(statusFolder, invoice.Filename);
|
|
// Write file (overwrite if exists)
|
|
await File.WriteAllBytesAsync(filePath, rawFile);
|
|
}
|
|
}
|
|
}
|