This commit is contained in:
qkrlnt 2024-12-07 02:35:40 +04:00
parent 26c6d5523c
commit 5b6aa053b6
15 changed files with 677 additions and 76 deletions

View File

@ -80,6 +80,6 @@ namespace FuelAccounting.Forms
private Car CreateCar(int id) =>
Car.CreateEntity(id, textBoxModel.Text,
(CarCategory)comboBoxCategory.SelectedItem!,
(int)comboBoxDriverId.SelectedItem!);
(int)comboBoxDriverId.SelectedValue!);
}
}

View File

@ -72,7 +72,7 @@ namespace FuelAccounting.Forms
}
else
{
_driverRepository.UpdateDriver(CreateDriver(0));
_driverRepository.CreateDriver(CreateDriver(0));
}
Close();

View File

@ -131,7 +131,7 @@
buttonSave.TabIndex = 10;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
buttonSave.Click += ButtonSave_Click;
//
// FormRefueling
//

View File

@ -27,7 +27,7 @@ namespace FuelAccounting.Forms
comboBoxCar.ValueMember = "Id";
}
private void buttonSave_Click(object sender, EventArgs e)
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
@ -38,7 +38,7 @@ namespace FuelAccounting.Forms
}
_refuelingRepository.CreateRefueling(Refueling.CreateOperation(0, (int)comboBoxCar.SelectedValue!,
Convert.ToDouble(numericUpDownKm), Convert.ToDouble(numericUpDownLiters), textBoxTypeOfFuel.Text));
Convert.ToDouble(numericUpDownKm.Value), Convert.ToDouble(numericUpDownLiters.Value), textBoxTypeOfFuel.Text));
Close();
}

View File

@ -9,7 +9,19 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Npgsql" Version="9.0.1" />
<PackageReference Include="Serilog" Version="4.1.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.9.0" />
<PackageReference Include="Unity" Version="5.11.10" />
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
</ItemGroup>
<ItemGroup>
@ -27,4 +39,10 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -1,7 +1,11 @@
using FuelAccounting.Repositories;
using FuelAccounting.Repositories.Implementations;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Serilog;
using Unity;
using Unity.Lifetime;
using Unity.Microsoft.Logging;
namespace FuelAccounting;
@ -23,13 +27,28 @@ internal static class Program
{
var container = new UnityContainer();
container.RegisterType<ICarsRepository, CarRepository>(new TransientLifetimeManager());
container.RegisterType<IDriversRepository, DriverRepository>(new TransientLifetimeManager());
container.RegisterType<IRouteRepository, RouteRepository>(new TransientLifetimeManager());
container.RegisterType<IShiftRepository, ShiftRepository>(new TransientLifetimeManager());
container.RegisterType<IEquipageRepository, EquipageRepository>(new TransientLifetimeManager());
container.RegisterType<IRefuelingRepository, RefuelingRepository>(new TransientLifetimeManager());
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
container.RegisterType<ICarsRepository, CarRepository>();
container.RegisterType<IDriversRepository, DriverRepository>();
container.RegisterType<IRouteRepository, RouteRepository>();
container.RegisterType<IShiftRepository, ShiftRepository>();
container.RegisterType<IEquipageRepository, EquipageRepository>();
container.RegisterType<IRefuelingRepository, RefuelingRepository>();
container.RegisterType<IConnectionString, ConnectionString>();
return container;
}
private static LoggerFactory CreateLoggerFactory()
{
var loggerFactory = new LoggerFactory();
loggerFactory.AddSerilog(new LoggerConfiguration()
.ReadFrom.Configuration(new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build())
.CreateLogger());
return loggerFactory;
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FuelAccounting.Repositories;
public interface IConnectionString
{
public string ConnectionString { get; }
}

View File

@ -1,29 +1,130 @@
using FuelAccounting.Entities;
using FuelAccounting.Entities.Enums;
using Dapper;
using FuelAccounting.Entities;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
namespace FuelAccounting.Repositories.Implementations;
internal class CarRepository : ICarsRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<CarRepository> _logger;
public CarRepository(IConnectionString connectionString, ILogger<CarRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateCar(Car car)
{
}
public void DeleteCar(int id)
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(car));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Cars (model, category, driver_id)
VALUES (@Model, @Category, @DriverID)";
connection.Execute(queryInsert, car);
}
public Car ReadCarById(int id)
catch (Exception ex)
{
return Car.CreateEntity(0, string.Empty, CarCategory.None, 0);
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
public IEnumerable<Car> ReadCars()
{
return [];
}
public void UpdateCar(Car car)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(car));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE Cars
SET
model = @model,
category = @category,
driver_id = @DriverID
WHERE id = @id";
connection.Execute(queryUpdate, car);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
public void DeleteCar(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Cars
WHERE id = @id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public Car ReadCarById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT
model,
category,
driver_id AS DriverID
FROM Cars
WHERE id = @id";
var car = connection.QueryFirst<Car>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(car));
return car;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<Car> ReadCars()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT
id,
model,
category,
driver_id AS DriverID
FROM Cars";
var cars = connection.Query<Car>(querySelect);
_logger.LogDebug("Найденные объекты: {json}", JsonConvert.SerializeObject(cars));
return cars;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FuelAccounting.Repositories.Implementations;
internal class ConnectionString : IConnectionString
{
string IConnectionString.ConnectionString => "host=localhost;port=5432;database=postgres;username=postgres;password=postgres";
}

View File

@ -1,29 +1,131 @@
using FuelAccounting.Entities;
using Dapper;
using FuelAccounting.Entities;
using FuelAccounting.Entities.Enums;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
namespace FuelAccounting.Repositories.Implementations;
internal class DriverRepository : IDriversRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<DriverRepository> _logger;
public DriverRepository(IConnectionString connectionString, ILogger<DriverRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateDriver(Driver driver)
{
}
public void DeleteDriver(int id)
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(driver));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Drivers (first_name, last_name, driver_licence_category)
VALUES (@FirstName, @LastName, @DriverLicenceCategory)";
connection.Execute(queryInsert, driver);
}
public Driver ReadDriverById(int id)
catch (Exception ex)
{
return Driver.CreateEntity(0, string.Empty, string.Empty, DriverLicenceCategory.None);
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
public IEnumerable<Driver> ReadDrivers()
{
return [];
}
public void UpdateDriver(Driver driver)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(driver));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE Drivers
SET
first_name = @FirstName,
last_name = @LastName,
driver_licence_category = @DriverLicenceCategory
WHERE id = @Id";
connection.Execute(queryUpdate, driver);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
public void DeleteDriver(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Drivers
WHERE id = @id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public Driver ReadDriverById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT
first_name AS FirstName,
last_name AS LastName,
driver_licence_category AS DriverLicenceCategory
FROM Drivers
WHERE id = @Id";
var driver = connection.QueryFirst<Driver>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(driver));
return driver;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<Driver> ReadDrivers()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT
id,
first_name AS FirstName,
last_name AS LastName,
driver_licence_category AS DriverLicenceCategory
FROM Drivers";
var drivers = connection.Query<Driver>(querySelect);
_logger.LogDebug("Найденные объекты: {json}", JsonConvert.SerializeObject(drivers));
return drivers;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
}

View File

@ -1,20 +1,101 @@
using FuelAccounting.Entities;
using Dapper;
using FuelAccounting.Entities;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
namespace FuelAccounting.Repositories.Implementations;
internal class EquipageRepository : IEquipageRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<EquipageRepository> _logger;
public EquipageRepository(IConnectionString connectionString, ILogger<EquipageRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateEquipage(Equipage equipage)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(equipage));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
using var transaction = connection.BeginTransaction();
var queryInsert = @"
INSERT INTO Equipage (car_id, driver_id, shift_id, equipage_date)
VALUES (@CarId, @DriverId, @ShiftId, @EquipageDate)";
connection.Execute(queryInsert, equipage, transaction);
var queryGetLastId = "SELECT MAX(Id) FROM Equipage";
var equipageId = connection.QueryFirst<int>(queryGetLastId, transaction: transaction);
var querySubInsert = @"
INSERT INTO RoutesEquipage (equipage_id, route_id, count)
VALUES (@EquipageId, @RouteId, @Count)";
foreach (var elem in equipage.RoutesEqipage)
{
connection.Execute(querySubInsert, new { EquipageId = equipageId, elem.RouteID, elem.Count }, transaction);
}
transaction.Commit();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteEquipage(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Equipage
WHERE id = @id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public IEnumerable<Equipage> ReadEquipages(DateTime? dateForm = null, DateTime? dateTo = null,
int? carId = null, int? driverId = null, int? shiftId = null, int? routeId = null)
{
return [];
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT
id,
car_id AS CarId,
driver_id AS DriverId,
shift_id AS ShiftId,
equipage_date AS EquipageDate
FROM Equipage";
var equipages = connection.Query<Equipage>(querySelect);
_logger.LogDebug("Найденные объекты: {json}", JsonConvert.SerializeObject(equipages));
return equipages;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
}

View File

@ -1,15 +1,65 @@
using FuelAccounting.Entities;
using Dapper;
using FuelAccounting.Entities;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
namespace FuelAccounting.Repositories.Implementations;
internal class RefuelingRepository : IRefuelingRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<RefuelingRepository> _logger;
public RefuelingRepository(IConnectionString connectionString, ILogger<RefuelingRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateRefueling(Refueling refueling)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(refueling));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Refueling (car_id, km, liters_spent, type_of_fuel, refueling_date)
VALUES (@CarId, @Kilometers, @LitersSpent, @TypeOfFuel, @RefuelingDate)";
connection.Execute(queryInsert, refueling);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public IEnumerable<Refueling> ReadRefuelings(DateTime? dateForm = null, DateTime? dateTo = null, int? carId = null)
{
return [];
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT
id,
car_id AS CarId,
km AS Kilometers,
liters_spent AS LitersSpent,
type_of_fuel AS TypeOfFuel,
refueling_date AS RefuelingDate
FROM Refueling";
var refuelings = connection.Query<Refueling>(querySelect);
_logger.LogDebug("Найденные объекты: {json}", JsonConvert.SerializeObject(refuelings));
return refuelings;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
}

View File

@ -1,28 +1,119 @@
using FuelAccounting.Entities;
using Dapper;
using FuelAccounting.Entities;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
namespace FuelAccounting.Repositories.Implementations;
internal class RouteRepository : IRouteRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<RouteRepository> _logger;
public RouteRepository(IConnectionString connectionString, ILogger<RouteRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateRoute(Route route)
{
}
public void DeleteRoute(int id)
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(route));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Routes (description)
VALUES (@description)";
connection.Execute(queryInsert, route);
}
public Route ReadRouteById(int id)
catch (Exception ex)
{
return Route.CreateEntity(0, string.Empty);
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
public IEnumerable<Route> ReadRoutes()
{
return [];
}
public void UpdateRoute(Route route)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(route));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE Routes
SET
description = @description
WHERE id = @Id";
connection.Execute(queryUpdate, route);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
public void DeleteRoute(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Routes
WHERE id = @id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public Route ReadRouteById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM Routes
WHERE id = @Id";
var route = connection.QueryFirst<Route>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(route));
return route;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<Route> ReadRoutes()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Routes";
var routes = connection.Query<Route>(querySelect);
_logger.LogDebug("Найденные объекты: {json}", JsonConvert.SerializeObject(routes));
return routes;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
}

View File

@ -1,28 +1,128 @@
using FuelAccounting.Entities;
using Dapper;
using FuelAccounting.Entities;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
namespace FuelAccounting.Repositories.Implementations;
internal class ShiftRepository : IShiftRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<ShiftRepository> _logger;
public ShiftRepository(IConnectionString connectionString, ILogger<ShiftRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateShift(Shift shift)
{
}
public void DeleteShift(int id)
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(shift));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Shift (amount_of_hours, description)
VALUES (@AmountOfHours, @Description)";
connection.Execute(queryInsert, shift);
}
public Shift ReadShiftById(int id)
catch (Exception ex)
{
return Shift.CreateEntity(0, 0, string.Empty);
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
public IEnumerable<Shift> ReadShifts()
{
return [];
}
public void UpdateShift(Shift shift)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(shift));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE Shift
SET
amount_of_hours = @AmountOfHours,
description = @Description
WHERE id = @Id";
connection.Execute(queryUpdate, shift);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
public void DeleteShift(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Shift
WHERE id = @id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public Shift ReadShiftById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT
amount_of_hours AS AmountOfHours,
description
FROM Shift
WHERE id = @Id";
var shift = connection.QueryFirst<Shift>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(shift));
return shift;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<Shift> ReadShifts()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT
id,
amount_of_hours AS AmountOfHours,
description
FROM Shift";
var shift = connection.Query<Shift>(querySelect);
_logger.LogDebug("Найденные объекты: {json}", JsonConvert.SerializeObject(shift));
return shift;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
}

View File

@ -0,0 +1,15 @@
{
"Serilog": {
"Using": [ "Serilog.Sinks.File" ],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "Logs/fuel_log.txt",
"rollingInterval": "Day"
}
}
]
}
}