diff --git a/.gitignore b/.gitignore index c017382..6911a0c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,7 @@ NuGet/ *.user *.suo -# Lokalna konfiguracja wdrożeniowa; wzorcowa konfiguracja znajduje się w źródłach. +# Lokalne konfiguracje wdrożeniowe; repozytorium zawiera wyłącznie wzorzec. +src/SmartB2B.Enova.Service/config/enova.json +release/config/enova.json release/config/enova.local.json diff --git a/README.md b/README.md index cf3eb68..aba3bfc 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Dedykowana usługa Windows zastępująca proces Node na stanowiskach z enova365. ## Konfiguracja -Plik `config/enova.json` zawiera portal WAMP, ścieżkę instalacji, alias bazy, operatora, definicję dokumentu, magazyn domyślny i tryb zapisu. +Plik `config/enova.json` zawiera portal WAMP, ścieżkę instalacji, alias bazy, operatora, definicję dokumentu, magazyn domyślny i tryb zapisu. Repozytorium oraz paczka zawierają tylko `config/enova.json.sample`. Skrypt instalacyjny kopiuje wzorzec do `config/enova.json` wyłącznie wtedy, gdy lokalna konfiguracja jeszcze nie istnieje. Sekrety nie są przechowywane w JSON-ie. Konto usługi musi widzieć dwie zmienne środowiskowe maszyny: @@ -38,7 +38,7 @@ Ostrzeżenie `NU1603` dotyczące `Soneta.Generator` jest takie samo jak w dział Kontrola konfiguracji i dynamicznego ładowania, bez zapisu do bazy: ```powershell -.\src\SmartB2B.Enova.Service\bin\Debug\net8.0\SmartB2B.Enova.Service.exe --check-config +.\src\SmartB2B.Enova.Service\bin\Debug\net8.0\SmartB2B.Enova.Service.exe --config .\src\SmartB2B.Enova.Service\bin\Debug\net8.0\config\enova.json.sample --check-config ``` ## Publikacja i instalacja @@ -47,9 +47,9 @@ Kontrola konfiguracji i dynamicznego ładowania, bez zapisu do bazy: .\publish.ps1 ``` -Skrypt odtwarza katalog `release` z hostem, adapterem, konfiguracją i WinSW. Istniejąca konfiguracja `release/config/enova.json` jest zachowywana. Repozytorium zawiera również gotowy, skompilowany katalog `release`, więc na komputerze produkcyjnym nie trzeba instalować SDK. Przed instalacją: +Skrypt odtwarza katalog `release` z hostem, adapterem, wzorcem konfiguracji i WinSW. Repozytorium zawiera również gotowy, skompilowany katalog `release`, więc na komputerze produkcyjnym nie trzeba instalować SDK. Przed instalacją: -1. Skopiuj katalog `release` na komputer produkcyjny i uzupełnij `release/config/enova.json`. +1. Skopiuj katalog `release` na komputer produkcyjny. Możesz skopiować `release/config/enova.json.sample` do `release/config/enova.json` i uzupełnić go przed instalacją; jeżeli tego nie zrobisz, `install.cmd` utworzy plik automatycznie. 2. Ustaw sekrety maszyny. 3. Zatrzymaj starą usługę Node dla tego samego portalu WAMP. 4. Skonfiguruj usługę do pracy pod dedykowanym kontem Windows, które potrafi uruchomić Enovę, widzi jej bazę i licencję. @@ -66,3 +66,7 @@ Wycofanie polega na uruchomieniu `daemon/uninstall.cmd` i ponownym uruchomieniu - Diagnostyka: `eu.smartb2b.sync.get_version`, `get_info`, `get_log`, `get_error_log`. Kod produkcyjny, testy oraz gotowa wersja instalacyjna znajdują się w tym repozytorium. + +## Automatyczne aktualizacje + +Przy starcie WinSW pobiera pliki aplikacji z `https://demo.smartb2b.eu/files/smartb2b-sync-enova/` zgodnie z listą `` w `daemon/smartb2bsync-enova.xml`. Aktualizowane są program, biblioteki, adapter Enovy, skrypty, manifest usługi i `config/enova.json.sample`. Lokalny `config/enova.json` nie występuje na liście i nie jest nadpisywany. Sam `smartb2bsync-enova.exe` jest programem rozruchowym WinSW, dlatego nie aktualizuje samego siebie podczas pracy. `publish.ps1` porównuje zawartość gotowej paczki z manifestem i przerywa publikowanie, jeżeli którejkolwiek pozycji brakuje po jednej ze stron. diff --git a/daemon/install.cmd b/daemon/install.cmd index 3003f9c..be98290 100644 --- a/daemon/install.cmd +++ b/daemon/install.cmd @@ -7,6 +7,16 @@ if not exist "smartb2bsync-enova.exe" ( exit /b 1 ) +if not exist "..\config" mkdir "..\config" +if not exist "..\config\enova.json" ( + if not exist "..\config\enova.json.sample" ( + echo Brak ..\config\enova.json.sample. + exit /b 1 + ) + copy /Y "..\config\enova.json.sample" "..\config\enova.json" >nul + echo Utworzono lokalna konfiguracje ..\config\enova.json. +) + smartb2bsync-enova.exe install if errorlevel 1 exit /b %errorlevel% diff --git a/daemon/smartb2bsync-enova.xml b/daemon/smartb2bsync-enova.xml index 753f535..2a10562 100644 --- a/daemon/smartb2bsync-enova.xml +++ b/daemon/smartb2bsync-enova.xml @@ -10,4 +10,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/publish.ps1 b/publish.ps1 index c98271f..15690f5 100644 --- a/publish.ps1 +++ b/publish.ps1 @@ -21,12 +21,6 @@ $daemonSource = Join-Path $PSScriptRoot "daemon" $winSwSource = Resolve-Path (Join-Path $daemonSource "smartb2bsync-enova.exe") $output = [System.IO.Path]::GetFullPath($OutputPath) $daemonOutput = Join-Path $output "daemon" -$existingConfigurationPath = Join-Path $output "config\enova.json" -$existingConfiguration = if (Test-Path -LiteralPath $existingConfigurationPath) { - [System.IO.File]::ReadAllText($existingConfigurationPath) -} else { - $null -} if ($output -eq [System.IO.Path]::GetPathRoot($output) -or $output.Length -lt 10) { throw "Niebezpieczna ścieżka wyjściowa: $output" @@ -49,11 +43,23 @@ Copy-Item (Join-Path $daemonSource "smartb2bsync-enova.xml") $daemonOutput -Forc Copy-Item (Join-Path $daemonSource "install.cmd") $daemonOutput -Force Copy-Item (Join-Path $daemonSource "uninstall.cmd") $daemonOutput -Force -if ($null -ne $existingConfiguration) { - [System.IO.File]::WriteAllText( - (Join-Path $output "config\enova.json"), - $existingConfiguration, - [System.Text.UTF8Encoding]::new($false)) +$downloadBaseUrl = "https://demo.smartb2b.eu/files/smartb2b-sync-enova/" +[xml]$manifest = Get-Content -Raw (Join-Path $daemonOutput "smartb2bsync-enova.xml") +$downloadedFiles = @( + $manifest.service.download | + ForEach-Object { $_.from.Substring($downloadBaseUrl.Length).Replace('/', '\') } | + Sort-Object +) +$packagedFiles = @( + Get-ChildItem -Recurse -File $output | + ForEach-Object { $_.FullName.Substring($output.Length).TrimStart('\') } | + Where-Object { $_ -ne "daemon\smartb2bsync-enova.exe" } | + Sort-Object +) +$manifestDifferences = @(Compare-Object $packagedFiles $downloadedFiles) +if ($manifestDifferences.Count -ne 0) { + $details = $manifestDifferences | ForEach-Object { "$($_.SideIndicator) $($_.InputObject)" } + throw "Lista plików nie odpowiada paczce:`n$($details -join "`n")" } Write-Host "Gotowa usługa: $output" diff --git a/release/SmartB2B.Enova.Contracts.dll b/release/SmartB2B.Enova.Contracts.dll index a9d8aec..c680eb4 100644 Binary files a/release/SmartB2B.Enova.Contracts.dll and b/release/SmartB2B.Enova.Contracts.dll differ diff --git a/release/SmartB2B.Enova.Contracts.pdb b/release/SmartB2B.Enova.Contracts.pdb index b0cc275..4fbbca9 100644 Binary files a/release/SmartB2B.Enova.Contracts.pdb and b/release/SmartB2B.Enova.Contracts.pdb differ diff --git a/release/SmartB2B.Enova.Service.dll b/release/SmartB2B.Enova.Service.dll index 8fad37b..2ba3fdf 100644 Binary files a/release/SmartB2B.Enova.Service.dll and b/release/SmartB2B.Enova.Service.dll differ diff --git a/release/SmartB2B.Enova.Service.exe b/release/SmartB2B.Enova.Service.exe index f100565..fa0cab7 100644 Binary files a/release/SmartB2B.Enova.Service.exe and b/release/SmartB2B.Enova.Service.exe differ diff --git a/release/SmartB2B.Enova.Service.pdb b/release/SmartB2B.Enova.Service.pdb index b5e340f..7720eed 100644 Binary files a/release/SmartB2B.Enova.Service.pdb and b/release/SmartB2B.Enova.Service.pdb differ diff --git a/release/adapters/SmartB2B.Enova.Adapter.dll b/release/adapters/SmartB2B.Enova.Adapter.dll index e941e30..8991425 100644 Binary files a/release/adapters/SmartB2B.Enova.Adapter.dll and b/release/adapters/SmartB2B.Enova.Adapter.dll differ diff --git a/release/config/enova.json b/release/config/enova.json.sample similarity index 100% rename from release/config/enova.json rename to release/config/enova.json.sample diff --git a/release/daemon/install.cmd b/release/daemon/install.cmd index 3003f9c..be98290 100644 --- a/release/daemon/install.cmd +++ b/release/daemon/install.cmd @@ -7,6 +7,16 @@ if not exist "smartb2bsync-enova.exe" ( exit /b 1 ) +if not exist "..\config" mkdir "..\config" +if not exist "..\config\enova.json" ( + if not exist "..\config\enova.json.sample" ( + echo Brak ..\config\enova.json.sample. + exit /b 1 + ) + copy /Y "..\config\enova.json.sample" "..\config\enova.json" >nul + echo Utworzono lokalna konfiguracje ..\config\enova.json. +) + smartb2bsync-enova.exe install if errorlevel 1 exit /b %errorlevel% diff --git a/release/daemon/smartb2bsync-enova.xml b/release/daemon/smartb2bsync-enova.xml index 753f535..2a10562 100644 --- a/release/daemon/smartb2bsync-enova.xml +++ b/release/daemon/smartb2bsync-enova.xml @@ -10,4 +10,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SmartB2B.Enova.Service/SmartB2B.Enova.Service.csproj b/src/SmartB2B.Enova.Service/SmartB2B.Enova.Service.csproj index b78b08e..22fbe0e 100644 --- a/src/SmartB2B.Enova.Service/SmartB2B.Enova.Service.csproj +++ b/src/SmartB2B.Enova.Service/SmartB2B.Enova.Service.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/SmartB2B.Enova.Service/config/enova.json b/src/SmartB2B.Enova.Service/config/enova.json.sample similarity index 100% rename from src/SmartB2B.Enova.Service/config/enova.json rename to src/SmartB2B.Enova.Service/config/enova.json.sample