- 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
82 lines
3.3 KiB
C#
82 lines
3.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.OleDb;
|
|
using ComplianceNFs.Core.Entities;
|
|
using ComplianceNFs.Core.Ports;
|
|
|
|
namespace ComplianceNFs.Infrastructure.Repositories
|
|
{
|
|
// Placeholder: fill in actual SQL and mapping logic
|
|
public class AccessDbRepository : IAccessDbRepository
|
|
{
|
|
private readonly string _connectionString;
|
|
public AccessDbRepository(string connectionString)
|
|
{
|
|
_connectionString = connectionString;
|
|
}
|
|
|
|
public IEnumerable<BuyingRecord> GetByUnidade(string codSmartUnidade)
|
|
{
|
|
var results = new List<BuyingRecord>();
|
|
using (var conn = new OleDbConnection(_connectionString))
|
|
{
|
|
conn.Open();
|
|
var cmd = conn.CreateCommand();
|
|
cmd.CommandText = "SELECT Cod_TE, Cod_Smart_unidade, Mes, Ano, CNPJ_comp, CNPJ_vend, Mont_LO, Prec_LO FROM Dados_TE WHERE Cod_Smart_unidade = ?";
|
|
cmd.Parameters.AddWithValue("@CodSmartUnidade", codSmartUnidade);
|
|
using (var reader = cmd.ExecuteReader())
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
results.Add(new BuyingRecord
|
|
{
|
|
CodTE = reader.GetInt32(0),
|
|
CodSmartUnidade = reader.GetString(1),
|
|
Mes = reader.GetInt32(2),
|
|
Ano = reader.GetInt32(3),
|
|
CnpjComp = reader.GetString(4),
|
|
CnpjVend = reader.GetString(5),
|
|
MontLO = reader.GetDecimal(6),
|
|
PrecLO = reader.GetDecimal(7)
|
|
});
|
|
}
|
|
}
|
|
}
|
|
return results;
|
|
}
|
|
|
|
public IEnumerable<BuyingRecord> GetByUnidadeAndMonth(string codSmartUnidade, int month, int year)
|
|
{
|
|
var results = new List<BuyingRecord>();
|
|
using (var conn = new OleDbConnection(_connectionString))
|
|
{
|
|
conn.Open();
|
|
var cmd = conn.CreateCommand();
|
|
cmd.CommandText = "SELECT Cod_TE, Cod_Smart_unidade, Mes, Ano, CNPJ_comp, CNPJ_vend, Mont_LO, Prec_LO FROM Dados_TE WHERE Cod_Smart_unidade = ? AND Mes = ? AND Ano = ?";
|
|
cmd.Parameters.AddWithValue("@CodSmartUnidade", codSmartUnidade);
|
|
cmd.Parameters.AddWithValue("@Mes", month);
|
|
cmd.Parameters.AddWithValue("@Ano", year);
|
|
using (var reader = cmd.ExecuteReader())
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
results.Add(new BuyingRecord
|
|
{
|
|
CodTE = reader.GetInt32(0),
|
|
CodSmartUnidade = reader.GetString(1),
|
|
Mes = reader.GetInt32(2),
|
|
Ano = reader.GetInt32(3),
|
|
CnpjComp = reader.GetString(4),
|
|
CnpjVend = reader.GetString(5),
|
|
MontLO = reader.GetDecimal(6),
|
|
PrecLO = reader.GetDecimal(7)
|
|
});
|
|
}
|
|
}
|
|
}
|
|
return results;
|
|
}
|
|
}
|
|
}
|