Some fixes

This commit is contained in:
Piotr Dudek 2025-07-11 10:50:46 +02:00
parent 205246f79f
commit a49af51128
309 changed files with 389 additions and 1330 deletions

2
.gitignore vendored
View File

@ -53,3 +53,5 @@ Thumbs.db
*/obj */obj
Drab/.config Drab/.config
Drab/drab.db Drab/drab.db
Drab/drab.db-shm
Drab/drab.db-wal

View File

@ -3,6 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net9.0-windows</TargetFramework> <TargetFramework>net9.0-windows</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,6 +1,4 @@
using System; namespace Drab.Core.Models;
namespace Drab.Core.Models;
public class Result<TOk, TBad> public class Result<TOk, TBad>
{ {

View File

@ -3,6 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net9.0-windows</TargetFramework> <TargetFramework>net9.0-windows</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,5 +1,4 @@
using System; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
namespace Drab.LocalDb.Entities; namespace Drab.LocalDb.Entities;

View File

@ -1,6 +1,5 @@
using Drab.Logic.Services; using System.Reflection;
using System.IO; using Drab.Logic.Services;
using System.Reflection;
namespace Drab.Logic; namespace Drab.Logic;

View File

@ -3,6 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net9.0-windows</TargetFramework> <TargetFramework>net9.0-windows</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System.Printing"> <Reference Include="System.Printing">
@ -11,21 +12,21 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="FastReport.OpenSource" Version="2025.2.0"/> <PackageReference Include="FastReport.OpenSource" Version="2025.2.0" />
<PackageReference Include="FastReport.OpenSource.Export.PdfSimple" Version="2025.2.0"/> <PackageReference Include="FastReport.OpenSource.Export.PdfSimple" Version="2025.2.0" />
<PackageReference Include="FastReport.OpenSource.Web" Version="2025.2.0"/> <PackageReference Include="FastReport.OpenSource.Web" Version="2025.2.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.2.0"/> <PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.2.0" />
<PackageReference Include="NLog" Version="6.0.1"/> <PackageReference Include="NLog" Version="6.0.1" />
<PackageReference Include="PdfiumViewer" Version="2.13.0"/> <PackageReference Include="PdfiumViewer" Version="2.13.0" />
<PackageReference Include="PdfiumViewer.Native.x86_64.v8-xfa" Version="2018.4.8.256"/> <PackageReference Include="PdfiumViewer.Native.x86_64.v8-xfa" Version="2018.4.8.256" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Drab.Core\Drab.Core.csproj"/> <ProjectReference Include="..\Drab.Core\Drab.Core.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Templates"/> <Folder Include="Templates" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,9 +1,4 @@
using Pcm.Db.Entities; namespace Drab.Logic.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Drab.Logic.Dtos;
public class DokDto public class DokDto
{ {

View File

@ -1,6 +1,4 @@
using Pcm.Db.Entities; namespace Drab.Logic.Dtos;
namespace Drab.Logic.Dtos;
public class MagDto public class MagDto
{ {

View File

@ -1,7 +1,4 @@
using System.Linq; namespace Drab.Logic.Dtos;
using Pcm.Db.Entities;
namespace Drab.Logic.Dtos;
public class PozDokDto public class PozDokDto
{ {

View File

@ -1,6 +1,4 @@
using Pcm.Db.Entities; namespace Drab.Logic.Dtos;
namespace Drab.Logic.Dtos;
public class TowarDto public class TowarDto
{ {

View File

@ -0,0 +1,12 @@
// Global using directives
global using Drab.Core.Configuration;
global using Drab.LocalDb;
global using Drab.LocalDb.Entities;
global using Drab.Logic.Dtos;
global using Drab.Logic.Interfaces;
global using Drab.Logic.Models;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Logging;
global using NLog;
global using Pcm.Db.Entities;

View File

@ -1,6 +1,4 @@
using System.Threading.Tasks; namespace Drab.Logic.Interfaces;
namespace Drab.Logic.Interfaces;
public interface IDbFetcher public interface IDbFetcher
{ {

View File

@ -1,9 +1,4 @@
using Drab.LocalDb.Entities; namespace Drab.Logic.Interfaces;
using Drab.Logic.Dtos;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Drab.Logic.Interfaces;
public interface ILocalOrderStore public interface ILocalOrderStore
{ {

View File

@ -1,7 +1,4 @@
using Drab.Logic.Dtos; namespace Drab.Logic.Interfaces;
using System.Threading.Tasks;
namespace Drab.Logic.Interfaces;
public interface IOrderPdfGenerator public interface IOrderPdfGenerator
{ {

View File

@ -1,7 +1,4 @@
using Drab.Logic.Dtos; namespace Drab.Logic.Interfaces;
using System.Threading.Tasks;
namespace Drab.Logic.Interfaces;
public interface IOrderProcessor public interface IOrderProcessor
{ {

View File

@ -1,8 +1,4 @@
using Drab.Core.Models; using Drab.Core.Models;
using Drab.Logic.Dtos;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Drab.Logic.Interfaces; namespace Drab.Logic.Interfaces;

View File

@ -1,7 +1,4 @@
using Drab.Logic.Models; namespace Drab.Logic.Interfaces;
using System.Threading.Tasks;
namespace Drab.Logic.Interfaces;
public interface IPrintService public interface IPrintService
{ {

View File

@ -1,7 +1,5 @@
using Drab.Logic.Interfaces; using Drab.Logic.Services;
using Drab.Logic.Services;
using Drab.Logic.Utils; using Drab.Logic.Utils;
using Microsoft.Extensions.DependencyInjection;
namespace Drab.Logic.Ioc; namespace Drab.Logic.Ioc;

View File

@ -1,6 +1,4 @@
using System.Drawing; namespace Drab.Logic.Models;
namespace Drab.Logic.Models;
public record PrintDocumentRequest(string FilePath, long DokId); public record PrintDocumentRequest(string FilePath, long DokId);

View File

@ -1,31 +1,10 @@
using System; namespace Drab.Logic.Services;
using Drab.LocalDb;
using Drab.LocalDb.Entities;
using Drab.Logic.Dtos;
using Drab.Logic.Interfaces;
using Microsoft.Extensions.DependencyInjection;
using NLog;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Drab.Logic.Services; public class LocalOrderStore(IServiceScopeFactory serviceScopeFactory) : ILocalOrderStore
public class LocalOrderStore : ILocalOrderStore
{ {
private readonly ILogger _logger;
private readonly IServiceScopeFactory _serviceScopeFactory;
public LocalOrderStore(IServiceScopeFactory serviceScopeFactory)
{
_logger = LogManager.GetCurrentClassLogger();
_serviceScopeFactory = serviceScopeFactory;
}
public async Task<List<OrderDb>> GetAll() public async Task<List<OrderDb>> GetAll()
{ {
using var scope = _serviceScopeFactory.CreateScope(); using var scope = serviceScopeFactory.CreateScope();
await using var dbContext = scope.ServiceProvider.GetService<LocalDbContext>(); await using var dbContext = scope.ServiceProvider.GetService<LocalDbContext>();
var fromDate = DateTime.UtcNow.AddDays(-30); var fromDate = DateTime.UtcNow.AddDays(-30);
@ -38,7 +17,7 @@ public class LocalOrderStore : ILocalOrderStore
public async Task<DokDto> GetOrderById(long dokId) public async Task<DokDto> GetOrderById(long dokId)
{ {
using var scope = _serviceScopeFactory.CreateScope(); using var scope = serviceScopeFactory.CreateScope();
await using var dbContext = scope.ServiceProvider.GetService<LocalDbContext>(); await using var dbContext = scope.ServiceProvider.GetService<LocalDbContext>();
var order = dbContext.Orders.FirstOrDefault(x => x.DokId == dokId); var order = dbContext.Orders.FirstOrDefault(x => x.DokId == dokId);

View File

@ -1,11 +1,4 @@
using System; using Microsoft.Extensions.Hosting;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Drab.LocalDb;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace Drab.Logic.Services; namespace Drab.Logic.Services;
@ -35,21 +28,39 @@ public class OldOrdersCleanupService : BackgroundService
.Where(o => o.Created < threshold) .Where(o => o.Created < threshold)
.ToList(); .ToList();
if (oldOrders.Count != 0) var filesToDelete = oldOrders
.Select(o => Path.Combine(Constants.ReportsOutputPath, o.Filename))
.Where(p => !string.IsNullOrWhiteSpace(p) && File.Exists(p))
.ToList();
foreach (var path in filesToDelete)
{
try
{
File.Delete(path);
}
catch (Exception ex)
{
_logger.LogWarning(ex, "Failed to delete file: {FilePath}", path);
}
}
if (oldOrders.Count > 0)
{ {
dbContext.Orders.RemoveRange(oldOrders); dbContext.Orders.RemoveRange(oldOrders);
await dbContext.SaveChangesAsync(stoppingToken); await dbContext.SaveChangesAsync(stoppingToken);
_logger.LogInformation("Usunięto {OldOrdersCount} starych zamówień.", oldOrders.Count); _logger.LogInformation("Removed {OrderCount} old orders and deleted {FileCount} files.",
oldOrders.Count, filesToDelete.Count);
} }
else else
{ {
_logger.LogInformation("Nie znaleziono starych zamówień do usunięcia."); _logger.LogInformation("Nothing to do.");
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Błąd podczas usuwania starych zamówień."); _logger.LogError(ex, "Error occured:");
} }
await Task.Delay(_interval, stoppingToken); await Task.Delay(_interval, stoppingToken);

View File

@ -1,6 +1,4 @@
using System; namespace Drab.Logic.Services;
namespace Drab.Logic.Services;
public class OrderEventBus public class OrderEventBus
{ {

View File

@ -1,27 +1,14 @@
using Drab.Logic.Dtos; using System.Reflection;
using Drab.Logic.Interfaces;
using FastReport; using FastReport;
using FastReport.Export.PdfSimple; using FastReport.Export.PdfSimple;
using NLog;
using System;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
namespace Drab.Logic.Services; namespace Drab.Logic.Services;
internal class OrderPdfGenerator : IOrderPdfGenerator internal class OrderPdfGenerator(ILogger<OrderPdfGenerator> logger) : IOrderPdfGenerator
{ {
private readonly ILogger _logger;
public OrderPdfGenerator()
{
_logger = LogManager.GetCurrentClassLogger();
}
public Task<string> GenerateOrder(DokDto order) public Task<string> GenerateOrder(DokDto order)
{ {
_logger.Info($"Generate pdf document: {order.NrDok}"); logger.LogInformation("Generate pdf document: {OrderNo}", order.NrDok);
var cleanFilename = order.NrDok.Replace('/', '-'); var cleanFilename = order.NrDok.Replace('/', '-');
var orderFilename = $"Zam_{cleanFilename}_{order.Data:yyyy-MM-dd}_{order.Sklep}_{order.DokId}.pdf"; var orderFilename = $"Zam_{cleanFilename}_{order.Data:yyyy-MM-dd}_{order.Sklep}_{order.DokId}.pdf";
var templatePath = Path.Combine(Constants.ReportsTemplatesPath, "Order.frx"); var templatePath = Path.Combine(Constants.ReportsTemplatesPath, "Order.frx");
@ -44,7 +31,7 @@ internal class OrderPdfGenerator : IOrderPdfGenerator
} }
catch (Exception e) catch (Exception e)
{ {
_logger.Error(e, "Error on generating order document: {OrderNo}", order.NrDok); logger.LogError(e, "Error on generating order document: {OrderNo}", order.NrDok);
return Task.FromResult(string.Empty); return Task.FromResult(string.Empty);
} }
} }

View File

@ -1,20 +1,10 @@
using Drab.LocalDb; using Microsoft.EntityFrameworkCore;
using Drab.LocalDb.Entities;
using Drab.Logic.Dtos;
using Drab.Logic.Interfaces;
using Drab.Logic.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using NLog;
using System;
using System.IO;
using System.Threading.Tasks;
namespace Drab.Logic.Services; namespace Drab.Logic.Services;
public class OrderProcessor : IOrderProcessor public class OrderProcessor : IOrderProcessor
{ {
private readonly ILogger _logger; private readonly ILogger<OrderProcessor> _logger;
private readonly IServiceScopeFactory _serviceScopeFactory; private readonly IServiceScopeFactory _serviceScopeFactory;
private readonly IPrintService _printService; private readonly IPrintService _printService;
private readonly IOrderPdfGenerator _orderPdfGenerator; private readonly IOrderPdfGenerator _orderPdfGenerator;
@ -23,13 +13,13 @@ public class OrderProcessor : IOrderProcessor
public OrderProcessor(IServiceScopeFactory serviceScopeFactory, public OrderProcessor(IServiceScopeFactory serviceScopeFactory,
IPrintService printService, IPrintService printService,
IOrderPdfGenerator orderPdfGenerator, IOrderPdfGenerator orderPdfGenerator,
OrderEventBus eventBus) OrderEventBus eventBus, ILogger<OrderProcessor> logger)
{ {
_logger = LogManager.GetCurrentClassLogger();
_serviceScopeFactory = serviceScopeFactory; _serviceScopeFactory = serviceScopeFactory;
_printService = printService; _printService = printService;
_orderPdfGenerator = orderPdfGenerator; _orderPdfGenerator = orderPdfGenerator;
_eventBus = eventBus; _eventBus = eventBus;
_logger = logger;
} }
public async Task ProcessOrder(DokDto order) public async Task ProcessOrder(DokDto order)
@ -40,7 +30,6 @@ public class OrderProcessor : IOrderProcessor
return; return;
var filePath = await EnsureOrderPdfExists(order, dok); var filePath = await EnsureOrderPdfExists(order, dok);
var printResult = await PrintOrder(order, filePath); var printResult = await PrintOrder(order, filePath);
if (printResult.IsSuccess) if (printResult.IsSuccess)
@ -57,7 +46,7 @@ public class OrderProcessor : IOrderProcessor
if (dok != null) if (dok != null)
return dok; return dok;
_logger.Info("Creating new order - {OrderNo}", order.NrDok); _logger.LogInformation("Creating new order - {OrderNo}", order.NrDok);
dok = new OrderDb dok = new OrderDb
{ {
@ -83,7 +72,7 @@ public class OrderProcessor : IOrderProcessor
return fullPath; return fullPath;
} }
_logger.Info("Generating order file: {OrderNo}", order.NrDok); _logger.LogInformation("Generating order file: {OrderNo}", order.NrDok);
var generatedFilename = await _orderPdfGenerator.GenerateOrder(order); var generatedFilename = await _orderPdfGenerator.GenerateOrder(order);
var newPath = Path.Combine(Constants.ReportsOutputPath, generatedFilename); var newPath = Path.Combine(Constants.ReportsOutputPath, generatedFilename);
@ -98,11 +87,11 @@ public class OrderProcessor : IOrderProcessor
private async Task<PrintDocumentResult> PrintOrder(DokDto order, string filePath) private async Task<PrintDocumentResult> PrintOrder(DokDto order, string filePath)
{ {
_logger.Info("Printing order: {OrderNo}", order.NrDok); _logger.LogInformation("Printing order: {OrderNo}", order.NrDok);
var result = await _printService.PrintPdf(new PrintDocumentRequest(filePath, order.DokId)); var result = await _printService.PrintPdf(new PrintDocumentRequest(filePath, order.DokId));
_logger.Info("Printing result - OrderNo: {OrderNo}, Success: {IsSuccess}, Message: {Message}", _logger.LogInformation("Printing result - OrderNo: {OrderNo}, Success: {IsSuccess}, Message: {Message}",
order.NrDok, result.IsSuccess, result.Message); order.NrDok, result.IsSuccess, result.Message);
return result; return result;
@ -120,7 +109,7 @@ public class OrderProcessor : IOrderProcessor
} }
catch (Exception e) catch (Exception e)
{ {
_logger.Error(e, "Error retrieving order from database"); _logger.LogError(e, "Error retrieving order from database");
return null; return null;
} }
} }

View File

@ -1,45 +1,41 @@
using Drab.Core.Models; using System.Globalization;
using Drab.Logic.Dtos; using Drab.Core.Models;
using Drab.Logic.Interfaces;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using NLog;
using Pcm.Db; using Pcm.Db;
using Pcm.Db.Enums; using Pcm.Db.Enums;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using Drab.Core.Configuration;
namespace Drab.Logic.Services; namespace Drab.Logic.Services;
public class OrdersStore : IOrdersStore, IDisposable public class OrdersStore : IOrdersStore, IDisposable
{ {
private readonly ILogger _logger; private readonly ILogger<OrdersStore> _logger;
private readonly IServiceScopeFactory _serviceScopeFactory; private readonly IServiceScopeFactory _serviceScopeFactory;
private readonly IDrabSettings _drabSettings; private readonly IDrabSettings _drabSettings;
public OrdersStore(IServiceScopeFactory serviceScopeFactory, IDrabSettings drabSettings) public OrdersStore(ILogger<OrdersStore> logger, IServiceScopeFactory serviceScopeFactory, IDrabSettings drabSettings)
{ {
_serviceScopeFactory = serviceScopeFactory; _serviceScopeFactory = serviceScopeFactory;
_drabSettings = drabSettings; _drabSettings = drabSettings;
_logger = LogManager.GetCurrentClassLogger(); _logger = logger;
} }
public async Task<Result<List<DokDto>, string>> FetchOrders() public async Task<Result<List<DokDto>, string>> FetchOrders()
{ {
_logger.Info("Fetch new orders"); _logger.LogInformation("Fetch new orders");
var now = DateTime.Now;
var fallbackDate = now - TimeSpan.FromDays(30);
DateTime date; DateTime date;
try try
{ {
date = DateTime.ParseExact(_drabSettings.IgnoreOrdersBefore, "yyyy-MM-dd", CultureInfo.InvariantCulture); var parsed = DateTime.ParseExact(_drabSettings.IgnoreOrdersBefore, "yyyy-MM-dd", CultureInfo.InvariantCulture);
date = (now - parsed).TotalDays > 30 ? fallbackDate : parsed;
} }
catch catch
{ {
date = DateTime.Now - TimeSpan.FromDays(30); _logger.LogWarning("IgnoreOrdersBefore is invalid, falling back to last 30 days.");
date = fallbackDate;
} }
using var scope = _serviceScopeFactory.CreateScope(); using var scope = _serviceScopeFactory.CreateScope();
@ -67,7 +63,7 @@ public class OrdersStore : IOrdersStore, IDisposable
} }
catch (Exception e) catch (Exception e)
{ {
_logger.Error(e, "Error on fetching orders"); _logger.LogError(e, "Error on fetching orders");
return Result.Failed<List<DokDto>, string>(e.Message); return Result.Failed<List<DokDto>, string>(e.Message);
} }
} }

View File

@ -1,26 +1,11 @@
using Drab.Core.Configuration; using System.Drawing.Printing;
using Drab.Logic.Interfaces;
using Drab.Logic.Models;
using PdfiumViewer;
using System;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Printing; using System.Printing;
using System.Threading.Tasks; using PdfiumViewer;
namespace Drab.Logic.Services; namespace Drab.Logic.Services;
public class PrintService : IPrintService public class PrintService(IDrabSettings drabSettings) : IPrintService
{ {
private readonly IDrabSettings _drabSettings;
public PrintService(IDrabSettings drabSettings)
{
_drabSettings = drabSettings;
}
public async Task<PrintDocumentResult> PrintPdf(PrintDocumentRequest request) public async Task<PrintDocumentResult> PrintPdf(PrintDocumentRequest request)
{ {
try try
@ -46,7 +31,7 @@ public class PrintService : IPrintService
} }
} }
await Task.Delay(TimeSpan.FromSeconds(_drabSettings.PrinterTimeoutSeconds)); await Task.Delay(TimeSpan.FromSeconds(drabSettings.PrinterTimeoutSeconds));
var jobs = GetPrintJobs(request.DokId.ToString()); var jobs = GetPrintJobs(request.DokId.ToString());
if (jobs.Count == 0) if (jobs.Count == 0)

View File

@ -1,12 +1,4 @@
using Drab.Core.Configuration; using Microsoft.Extensions.Hosting;
using Drab.Logic.Interfaces;
using Microsoft.Extensions.DependencyInjection;
using NLog;
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
namespace Drab.Logic.Utils; namespace Drab.Logic.Utils;
@ -15,14 +7,14 @@ public class DbFetcher : BackgroundService
private readonly IDrabSettings _drabSettings; private readonly IDrabSettings _drabSettings;
private readonly IServiceScopeFactory _serviceScopeFactory; private readonly IServiceScopeFactory _serviceScopeFactory;
private readonly IOrderProcessor _orderProcessor; private readonly IOrderProcessor _orderProcessor;
private readonly ILogger _logger; private readonly ILogger<DbFetcher> _logger;
public DbFetcher(IDrabSettings drabSettings, IServiceScopeFactory serviceScopeFactory, IOrderProcessor orderProcessor) public DbFetcher(IDrabSettings drabSettings, IServiceScopeFactory serviceScopeFactory, IOrderProcessor orderProcessor, ILogger<DbFetcher> logger)
{ {
_drabSettings = drabSettings; _drabSettings = drabSettings;
_serviceScopeFactory = serviceScopeFactory; _serviceScopeFactory = serviceScopeFactory;
_orderProcessor = orderProcessor; _orderProcessor = orderProcessor;
_logger = LogManager.GetCurrentClassLogger(); _logger = logger;
} }
protected override Task ExecuteAsync(CancellationToken stoppingToken) protected override Task ExecuteAsync(CancellationToken stoppingToken)
@ -31,12 +23,12 @@ public class DbFetcher : BackgroundService
return Task.CompletedTask; return Task.CompletedTask;
} }
public async Task Start() private async Task Start()
{ {
await Task.Delay(TimeSpan.FromSeconds(2)); await Task.Delay(TimeSpan.FromSeconds(2));
while (true) while (true)
{ {
_logger.Info("Fetch database for new orders"); _logger.LogInformation("Fetch database for new orders");
try try
{ {
using var scope = _serviceScopeFactory.CreateScope(); using var scope = _serviceScopeFactory.CreateScope();
@ -44,14 +36,14 @@ public class DbFetcher : BackgroundService
var result = await orderStore.FetchOrders(); var result = await orderStore.FetchOrders();
if (result.IsNotOk) if (result.IsNotOk)
_logger.Warn($"Fetch orders result failed: {result.Error}"); _logger.LogWarning($"Fetch orders result failed: {result.Error}");
result.Value.ToList() result.Value.ToList()
.ForEach(x => _orderProcessor.ProcessOrder(x)); .ForEach(x => _orderProcessor.ProcessOrder(x));
} }
catch (Exception e) catch (Exception e)
{ {
_logger.Error(e, "Error on fetching new orders data:"); _logger.LogError(e, "Error on fetching new orders data:");
} }
finally finally
{ {

View File

@ -1,4 +1,4 @@
@using Drab.Ui.components @using Drab.Ui.Components
@using Microsoft.AspNetCore.Components.Web @using Microsoft.AspNetCore.Components.Web
@using Radzen @using Radzen
@ -18,7 +18,8 @@
<body> <body>
<Routes @rendermode="RenderMode.InteractiveServer"/> <Routes @rendermode="RenderMode.InteractiveServer"/>
<script src="_content/Radzen.Blazor/Radzen.Blazor.js?v=@(typeof(Colors).Assembly.GetName().Version)"></script> <script src="_content/Radzen.Blazor/Radzen.Blazor.js?v=@(typeof(Colors).Assembly.GetName()
.Version)"></script>
<script src="_framework/blazor.web.js"></script> <script src="_framework/blazor.web.js"></script>
</body> </body>

View File

@ -2,7 +2,7 @@
@using Drab.LocalDb @using Drab.LocalDb
@using Drab.LocalDb.Entities @using Drab.LocalDb.Entities
@using Drab.Logic.Services @using Drab.Logic.Services
@using Drab.Ui.components @using Drab.Ui.Components
@using Radzen @using Radzen
@inject LocalDbContext LocalDbContext @inject LocalDbContext LocalDbContext
@inject DialogService DialogService @inject DialogService DialogService
@ -76,8 +76,8 @@
private async Task RowClick(DataGridRowMouseEventArgs<OrderDb> obj) private async Task RowClick(DataGridRowMouseEventArgs<OrderDb> obj)
{ {
await DialogService.OpenAsync<PdfViewer>($"Zamówienie {obj.Data.OrderNumber} - Sklep {obj.Data.Shop}", await DialogService.OpenAsync<PdfViewer>($"Zamówienie {obj.Data.OrderNumber} - Sklep {obj.Data.Shop}",
new Dictionary<string, object>() {{nameof(PdfViewer.Filename), obj.Data.Filename}}, new Dictionary<string, object> {{nameof(PdfViewer.Filename), obj.Data.Filename}},
new DialogOptions() new DialogOptions
{ {
CloseDialogOnEsc = true, CloseDialogOnEsc = true,
CloseDialogOnOverlayClick = true, CloseDialogOnOverlayClick = true,
@ -94,6 +94,7 @@
{ {
_orders = LocalDbContext.Orders; _orders = LocalDbContext.Orders;
_dataGridRef?.Reload(); _dataGridRef?.Reload();
_dataGridRef?.RefreshDataAsync();
StateHasChanged(); StateHasChanged();
return Task.CompletedTask; return Task.CompletedTask;
}); });

View File

@ -1,8 +1,4 @@
using System.Collections.Generic; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class Akwizytor public class Akwizytor
{ {

View File

@ -1,8 +1,4 @@
using System.Collections.Generic; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class Artykul public class Artykul
{ {

View File

@ -1,7 +1,4 @@
using System.Collections.Generic; using System.Text.Json.Serialization;
using System.Text.Json.Serialization;
#nullable disable
namespace Pcm.Db.Entities; namespace Pcm.Db.Entities;

View File

@ -1,9 +1,4 @@
using System; namespace Pcm.Db.Entities;
using System.Collections.Generic;
#nullable disable
namespace Pcm.Db.Entities;
public class Bank public class Bank
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class Blokadum public class Blokadum
{ {

View File

@ -1,8 +1,4 @@
using System; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class CentrStanZgody public class CentrStanZgody
{ {

View File

@ -1,8 +1,4 @@
using System; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class Cza public class Cza
{ {

View File

@ -1,9 +1,4 @@
using System; namespace Pcm.Db.Entities;
using System.Collections.Generic;
#nullable disable
namespace Pcm.Db.Entities;
public class DefinicjaKodu public class DefinicjaKodu
{ {

View File

@ -1,8 +1,4 @@
using System; using System.Text.Json.Serialization;
using System.Collections.Generic;
using System.Text.Json.Serialization;
#nullable disable
namespace Pcm.Db.Entities; namespace Pcm.Db.Entities;

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class DokDodKth public class DokDodKth
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class DokKasa public class DokKasa
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class DokKontoBankowe public class DokKontoBankowe
{ {

View File

@ -1,7 +1,5 @@
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
#nullable disable
namespace Pcm.Db.Entities; namespace Pcm.Db.Entities;
public class DokKontr public class DokKontr

View File

@ -1,8 +1,4 @@
using System; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class DokKur public class DokKur
{ {

View File

@ -1,8 +1,4 @@
using System; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class DokPunkty public class DokPunkty
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class DokWalutum public class DokWalutum
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class DostProd public class DostProd
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class Dostawca public class Dostawca
{ {

View File

@ -1,9 +1,4 @@
using System; namespace Pcm.Db.Entities;
using System.Collections.Generic;
#nullable disable
namespace Pcm.Db.Entities;
public class DzienRozl public class DzienRozl
{ {

View File

@ -1,8 +1,4 @@
using System; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class DzienRozlParam public class DzienRozlParam
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class FormZgod public class FormZgod
{ {

View File

@ -1,9 +1,4 @@
using System; namespace Pcm.Db.Entities;
using System.Collections.Generic;
#nullable disable
namespace Pcm.Db.Entities;
public class FormaPlatnPos7 public class FormaPlatnPos7
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class FormaPlatnosci public class FormaPlatnosci
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class GrWartosc public class GrWartosc
{ {

View File

@ -1,9 +1,4 @@
using System; namespace Pcm.Db.Entities;
using System.Collections.Generic;
#nullable disable
namespace Pcm.Db.Entities;
public class GrupaAkcyzowa public class GrupaAkcyzowa
{ {

View File

@ -1,8 +1,4 @@
using System.Collections.Generic; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class GrupaTow public class GrupaTow
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class GrupaUz public class GrupaUz
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class HarmCeny public class HarmCeny
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class HarmCykl public class HarmCykl
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class HarmHarm public class HarmHarm
{ {

View File

@ -1,9 +1,4 @@
using System; namespace Pcm.Db.Entities;
using System.Collections.Generic;
#nullable disable
namespace Pcm.Db.Entities;
public class HarmWpi public class HarmWpi
{ {

View File

@ -1,8 +1,4 @@
using System.Collections.Generic; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class Istw public class Istw
{ {

View File

@ -1,8 +1,4 @@
using System.Collections.Generic; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class Jm public class Jm
{ {

View File

@ -1,9 +1,4 @@
using System; namespace Pcm.Db.Entities;
using System.Collections.Generic;
#nullable disable
namespace Pcm.Db.Entities;
public class KartaLoj public class KartaLoj
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class KasKod public class KasKod
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class KasPar public class KasPar
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class KasTow public class KasTow
{ {

View File

@ -1,8 +1,4 @@
using System.Collections.Generic; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class Kasa public class Kasa
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class KasaFormaPlatn public class KasaFormaPlatn
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class KatParam public class KatParam
{ {

View File

@ -1,8 +1,4 @@
using System.Collections.Generic; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class Kategorium public class Kategorium
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class KodDod public class KodDod
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class KodWazony public class KodWazony
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class Komentarz public class Komentarz
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class Konfig public class Konfig
{ {

View File

@ -1,9 +1,4 @@
using System; namespace Pcm.Db.Entities;
using System.Collections.Generic;
#nullable disable
namespace Pcm.Db.Entities;
public class KontoBankowe public class KontoBankowe
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class KontoBankoweKontr public class KontoBankoweKontr
{ {

View File

@ -1,9 +1,4 @@
using System; namespace Pcm.Db.Entities;
using System.Collections.Generic;
#nullable disable
namespace Pcm.Db.Entities;
public class KontoLoj public class KontoLoj
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class KontrOpi public class KontrOpi
{ {

View File

@ -1,8 +1,4 @@
using System; using System.Text.Json.Serialization;
using System.Collections.Generic;
using System.Text.Json.Serialization;
#nullable disable
namespace Pcm.Db.Entities; namespace Pcm.Db.Entities;

View File

@ -1,8 +1,4 @@
using System.Collections.Generic; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class Kraj public class Kraj
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class KrajStawka public class KrajStawka
{ {

View File

@ -1,8 +1,4 @@
using System.Collections.Generic; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class KthParWartosc public class KthParWartosc
{ {

View File

@ -1,8 +1,4 @@
using System.Collections.Generic; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class KthParam public class KthParam
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class KthTypO public class KthTypO
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class KthWartosc public class KthWartosc
{ {

View File

@ -1,8 +1,4 @@
using System; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class KursWaluty public class KursWaluty
{ {

View File

@ -1,8 +1,4 @@
using System; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class LiniaLotnicza public class LiniaLotnicza
{ {

View File

@ -1,9 +1,4 @@
using System; namespace Pcm.Db.Entities;
using System.Collections.Generic;
#nullable disable
namespace Pcm.Db.Entities;
public class LogOperation public class LogOperation
{ {

View File

@ -1,8 +1,4 @@
using System; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class LogTypeDef public class LogTypeDef
{ {

View File

@ -1,8 +1,4 @@
using System; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class LogValChangeNum public class LogValChangeNum
{ {

View File

@ -1,8 +1,4 @@
using System; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class LogValChangeTxt public class LogValChangeTxt
{ {

View File

@ -1,8 +1,4 @@
using System; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class Lotnisko public class Lotnisko
{ {

View File

@ -1,8 +1,4 @@
using System.Collections.Generic; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class Magazyn public class Magazyn
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class MarZakre public class MarZakre
{ {

View File

@ -1,8 +1,4 @@
using System.Collections.Generic; namespace Pcm.Db.Entities;
#nullable disable
namespace Pcm.Db.Entities;
public class Marzownik public class Marzownik
{ {

View File

@ -1,6 +1,4 @@
#nullable disable namespace Pcm.Db.Entities;
namespace Pcm.Db.Entities;
public class Notatki public class Notatki
{ {

Some files were not shown because too many files have changed in this diff Show More