New version

This commit is contained in:
2025-07-11 00:18:14 +02:00
parent 6b6c90272c
commit 49038de2b5
341 changed files with 18364 additions and 0 deletions

35
Drab/Drab.csproj Normal file
View File

@@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<TargetFramework>net9.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.7"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.7"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.7"/>
<PackageReference Include="NLog" Version="6.0.1"/>
<PackageReference Include="NLog.Web.AspNetCore" Version="6.0.1"/>
<PackageReference Include="Radzen.Blazor" Version="7.1.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Drab.Core\Drab.Core.csproj"/>
<ProjectReference Include="..\Drab.Logic\Drab.Logic.csproj"/>
<ProjectReference Include="..\Pcm.Db\Pcm.Db.csproj"/>
</ItemGroup>
<ItemGroup>
<Content Update="wwwroot\css\common.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

10
Drab/Drab.csproj.user Normal file
View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup>
<ActiveDebugProfile>Drab</ActiveDebugProfile>
<NameOfLastUsedPublishProfile>C:\__Repozytorium\DRAB\Drab\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
</PropertyGroup>
</Project>

18
Drab/FileController.cs Normal file
View File

@@ -0,0 +1,18 @@
using Microsoft.AspNetCore.Mvc;
namespace Drab;
[ApiController]
public class FileController : ControllerBase
{
[HttpGet("/pdf/{filename}")]
public IActionResult Get([FromRoute] string filename)
{
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Orders", filename);
if (!System.IO.File.Exists(filePath))
return NotFound();
return File(System.IO.File.OpenRead(filePath), "application/pdf");
}
}

79
Drab/Program.cs Normal file
View File

@@ -0,0 +1,79 @@
using System.Net;
using Drab.Core.Configuration;
using Drab.Core.Ioc;
using Drab.LocalDb;
using Drab.LocalDb.IoC;
using Drab.Logic.Ioc;
using Drab.Logic.Services;
using Drab.Ui;
using Microsoft.EntityFrameworkCore;
using NLog.Extensions.Logging;
using Pcm.Db.Ioc;
using Radzen;
var builder = WebApplication.CreateBuilder(args);
var configurationBuilder = new ConfigurationBuilder()
.SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
var configuration = configurationBuilder.Build();
var port = int.Parse(builder.WebHost.GetSetting("ListenPort") ?? "5010");
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
builder.Services.AddLogging(loggingBuilder =>
{
loggingBuilder.ClearProviders();
loggingBuilder.AddConfiguration(configuration.GetSection("Logging"));
loggingBuilder.AddNLog("nlog.config");
});
var drabSettings = configuration.GetSection(DrabSettings.SectionName).Get<DrabSettings>();
var localDbSettings = configuration.GetSection(LocalDbConfiguration.SectionName).Get<LocalDbConfiguration>();
builder.Services.AddLocalDatabase(localDbSettings);
var dbConfig = configuration.GetSection(PcmDbConfiguration.SectionName).Get<PcmDbConfiguration>();
builder.Services.AddPcmDatabase(dbConfig);
builder.Services.AddDrabCore(drabSettings);
builder.Services.AddDrabLogic();
builder.Services.AddHostedService<OldOrdersCleanupService>();
builder.Services.AddRadzenComponents();
builder.Services.AddControllers().AddControllersAsServices();
builder.WebHost
.UseKestrel(options =>
{
options.Listen(IPAddress.Any, port);
})
.UseContentRoot(Directory.GetCurrentDirectory());
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
app.UseHsts();
}
app.UseStaticFiles();
app.UseRouting();
app.UseAntiforgery();
app.MapControllers();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
if (!Directory.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Orders")))
{
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Orders"));
}
var scope = app.Services.GetService<IServiceScopeFactory>();
using (var scopeProvider = scope.CreateScope())
{
await using var context = scopeProvider.ServiceProvider.GetRequiredService<LocalDbContext>();
await context.Database.MigrateAsync();
}
app.Run();

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<DeleteExistingFiles>true</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\Release\publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<_TargetId>Folder</_TargetId>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>net6.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishSingleFile>false</PublishSingleFile>
<PublishReadyToRun>true</PublishReadyToRun>
<ProjectGuid>64d48cef-6b5e-42ca-a6ab-10fcc15e1288</ProjectGuid>
<SelfContained>true</SelfContained>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<_PublishTargetUrl>C:\__Repozytorium\DRAB\Drab\bin\Release\publish\</_PublishTargetUrl>
<History>True|2023-02-21T14:54:18.7590581Z;True|2023-02-18T14:13:57.9596803+01:00;False|2023-02-18T14:12:47.7973484+01:00;False|2023-02-18T14:11:56.4748109+01:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,28 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:26177",
"sslPort": 44338
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Drab": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": false,
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

25
Drab/Ui/App.razor Normal file
View File

@@ -0,0 +1,25 @@
@using Drab.Ui.components
@using Microsoft.AspNetCore.Components.Web
@using Radzen
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<base href="/"/>
<RadzenTheme Theme="standard" @rendermode="RenderMode.InteractiveServer"/>
<link rel="stylesheet" href="/css/common.css"/>
<ImportMap/>
<title>Brzęczek - Zamówienia</title>
<HeadOutlet/>
</head>
<body>
<Routes @rendermode="RenderMode.InteractiveServer"/>
<script src="_content/Radzen.Blazor/Radzen.Blazor.js?v=@(typeof(Colors).Assembly.GetName().Version)"></script>
<script src="_framework/blazor.web.js"></script>
</body>
</html>

109
Drab/Ui/Pages/Index.razor Normal file
View File

@@ -0,0 +1,109 @@
@page "/"
@using Drab.LocalDb
@using Drab.LocalDb.Entities
@using Drab.Logic.Services
@using Drab.Ui.components
@using Radzen
@inject LocalDbContext LocalDbContext
@inject DialogService DialogService
@inject OrderEventBus EventBus
@implements IDisposable
<RadzenDataGrid Data="@_orders"
TItem="OrderDb"
@ref="_dataGridRef"
AllowFiltering="true"
AllowColumnResize="false"
AllowAlternatingRows="false"
AllowColumnReorder="false"
Density="Density.Default"
FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive"
AllowSorting="true"
PageSize="20"
AllowPaging="true"
GridLines="DataGridGridLines.Both"
PagerHorizontalAlign="HorizontalAlign.Center"
ShowPagingSummary="true"
LogicalFilterOperator="LogicalFilterOperator.Or"
SelectionMode="DataGridSelectionMode.Single"
RowClick="@(RowClick)">
<Columns>
<RadzenDataGridColumn Property="@nameof(OrderDb.Shop)"
Filterable="true"
Title="Sklep"
Width="200px"
FilterMode="FilterMode.CheckBoxList"/>
<RadzenDataGridColumn Property="@nameof(OrderDb.Created)"
Title="Data"
Filterable="false"
SortOrder="SortOrder.Descending"
TextAlign="TextAlign.Center"
Width="160px"/>
<RadzenDataGridColumn Property="@nameof(OrderDb.IsPrinted)"
Title="Wydrukowane"
FilterMode="FilterMode.CheckBoxList"
TextAlign="TextAlign.Center"
Width="100px">
<Template Context="order">
@if (order.IsPrinted)
{
<RadzenIcon IconStyle="IconStyle.Success" Icon="check_circle"/>
}
else
{
<RadzenIcon IconStyle="IconStyle.Danger" Icon="highlight_off"/>
}
</Template>
</RadzenDataGridColumn>
<RadzenDataGridColumn Property="@nameof(OrderDb.OrderNumber)"
FilterMode="FilterMode.CheckBoxList"
Title="Numer"
Width="150px"/>
</Columns>
</RadzenDataGrid>
@code {
IQueryable<OrderDb> _orders;
private RadzenDataGrid<OrderDb>? _dataGridRef;
protected override void OnInitialized()
{
EventBus.OrdersChanged += OnOrdersChanged;
_orders = LocalDbContext.Orders;
}
private async Task RowClick(DataGridRowMouseEventArgs<OrderDb> obj)
{
await DialogService.OpenAsync<PdfViewer>($"Zamówienie {obj.Data.OrderNumber} - Sklep {obj.Data.Shop}",
new Dictionary<string, object>() {{nameof(PdfViewer.Filename), obj.Data.Filename}},
new DialogOptions()
{
CloseDialogOnEsc = true,
CloseDialogOnOverlayClick = true,
Resizable = false,
Draggable = false,
Width = "80%",
Height = "90vh"
});
}
private void OnOrdersChanged()
{
InvokeAsync(() =>
{
_orders = LocalDbContext.Orders;
_dataGridRef?.Reload();
StateHasChanged();
return Task.CompletedTask;
});
}
public void Dispose()
{
EventBus.OrdersChanged -= OnOrdersChanged;
LocalDbContext?.Dispose();
DialogService?.Dispose();
}
}

1
Drab/Ui/_Imports.razor Normal file
View File

@@ -0,0 +1 @@
@using Radzen.Blazor

View File

@@ -0,0 +1,18 @@
@inherits LayoutComponentBase
<RadzenLayout>
<RadzenBody>
<div class="rz-p-0" style="margin: auto; width: 100%; max-width: 1900px !important;">
@Body
</div>
</RadzenBody>
</RadzenLayout>
<div id="blazor-error-ui" data-nosnippet>
An unhandled error has occurred.
<a href="." class="reload">Reload</a>
<span class="dismiss">🗙</span>
</div>
<RadzenDialog/>
<RadzenNotification/>
<RadzenTooltip/>
<RadzenContextMenu/>

View File

@@ -0,0 +1,9 @@
<object data="@($"/pdf/{Filename}")"
style="width: 100%; height: 80vh; border: 1px solid gray"
type="application/pdf" width="100%" height="500px">
</object>
@code {
[Parameter]
public string Filename { get; set; } = string.Empty;
}

View File

@@ -0,0 +1,12 @@
@using Microsoft.AspNetCore.Components.Routing
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="routeData" DefaultLayout="@typeof(MainLayout)"/>
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>404 nie znaleziono strony</p>
</LayoutView>
</NotFound>
</Router>

1
Drab/add migration.txt Normal file
View File

@@ -0,0 +1 @@
dotnet ef migrations add Initial --project ..\Drab.LocalDb\Drab.LocalDb.csproj --context LocalDbContext

View File

@@ -0,0 +1,10 @@
{
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

26
Drab/appsettings.json Normal file
View File

@@ -0,0 +1,26 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"ListenPort": 80,
"AllowedHosts": "*",
"DrabSettings": {
"DbPollingFrequencyInSeconds": 180,
"PrinterTimeoutSeconds": 30,
"IgnoreOrdersBefore": "2025-07-11"
},
"PcmDbSettings": {
"Host": "192.168.200.6",
"Port": "1433",
"User": "sa",
"Password": "10Coma123",
"Database": "BRZECZEK"
},
"LocalDbConnection": {
"ConnectionString": "Data Source=.\\drab.db"
}
}

33
Drab/nlog.config Normal file
View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
throwExceptions="false">
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
</extensions>
<variable name="logDirectory" value="${basedir}/logs"/>
<variable name="maxLogFiles" value="60"/>
<targets>
<default-wrapper xsi:type="AsyncWrapper" overflowAction="Block" timeToSleepBetweenBatches="0"/>
<target name="File"
xsi:type="File"
fileName="${logDirectory}/${shortdate}.log"
encoding="UTF-8"
keepFileOpen="True"
maxArchiveFiles="${maxLogFiles}"
layout="${date:format=yyyy-MM-dd HH\:mm\:ss.ffffK} | ${level:uppercase=true} | ${logger:uppercase=true} | ${message}${onexception:${newline}${exception:format=ToString,StackTrace:maxInnerFaultLevel=5:innerFormat=ToString,StackTrace}}"/>
<target name="Console" xsi:type="ColoredConsole"
layout="${date:format=yyyy-MM-dd HH\:mm\:ss.ffffK} | ${level:uppercase=true} | ${logger:uppercase=true} | ${message}${onexception:${newline}${exception:format=ToString,StackTrace:maxInnerFaultLevel=5:innerFormat=ToString,StackTrace}}"/>
</targets>
<rules>
<logger name="Microsoft.Hosting.Lifetime" minlevel="Info" writeTo="File, Console" final="true"/>
<logger name="Microsoft.*" maxlevel="Info" final="true"/>
<logger name="System.Net.Http.*" maxlevel="Info" final="true"/>
<logger name="*" minlevel="Debug" writeTo="File, Console"/>
</rules>
</nlog>

View File

@@ -0,0 +1,37 @@
html, body {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
background-image: none !important;
width: 100% !important;
margin: auto;
}
.blazor-error-boundary {
background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
padding: 1rem 1rem 1rem 3.7rem;
color: white;
}
.blazor-error-boundary::after {
content: "An error has occurred."
}
#blazor-error-ui {
color-scheme: light only;
background: lightyellow;
bottom: 0;
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
box-sizing: border-box;
display: none;
left: 0;
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
position: fixed;
width: 100%;
z-index: 1000;
}
#blazor-error-ui .dismiss {
cursor: pointer;
position: absolute;
right: 0.75rem;
top: 0.5rem;
}