Compare commits

..
5 Commits
Author SHA256 Message Date
Daniel-Garmig dc85319da5 StayExport - SpainParteViajerosProvider - Fixes in export format
- Added required XML Namespace (ns2)
- Reorder some elements.
- Fix collection serializations.
- Fix gender code mapping.
- Improve some error messages.
- CodigoMunicipioCatastro - Add padding to codes to follow required format.
2026-09-10 15:05:05 +02:00
Daniel-Garmig 0abdfcd683 GuestDocument - Improvements to GuestDocument creation:
- IssueDate is now Nullable. Is not required for DNI and NIE document types.
- Improvements in SupportNumber for NIE documents.
- Address search can now be skipped.
2026-09-10 11:53:41 +02:00
Daniel-Garmig ae2ea51060 Small fixes and improvements:
- Show app version on Sidebar.
- StayEntryForm - Remove unnecesary refs to components.
- Fixed some result and log messages in entity services.
2026-09-10 11:26:21 +02:00
Daniel-Garmig dcd5bb2aad Deploy configuration
- Added tasks for publishing as container image.
- Improvements for deployment: Db migrations on startup, reverse-proxy forward headers, and DataProtect management.
- Added deploy example using docker-compose.
2026-09-09 17:50:27 +02:00
Daniel-Garmig fb2e00f06c Added Serilog for improved logs
- Logs will be shown by console and stored in files.
2026-09-08 21:13:35 +02:00
26 changed files with 693 additions and 79 deletions
+9
View File
@@ -0,0 +1,9 @@
{
"files.associations": {
"appsettings*.json": "jsonc",
"*_config.json": "jsonc",
"*_config.json.sample": "jsonc"
},
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "modificationsIfAvailable",
}
+36
View File
@@ -0,0 +1,36 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "dotnet",
"task": "build",
"group": "build",
"problemMatcher": [],
"label": "Build Somnia.GuestLog"
},
{
"label": "Publish Container Image",
"type": "shell",
"command": "dotnet",
"args": [
"publish",
"-c",
"Release",
"--os",
"linux",
"--arch",
"x64",
"-p:PublishProfile=DefaultContainer"
],
"options": {
"cwd": "${workspaceFolder}/src/Somnia.GuestLog"
},
"group": "build",
"presentation": {
"reveal": "always"
}
},
]
}
+23
View File
@@ -0,0 +1,23 @@
# Somnia.GuestLog Deployment
## Deploy using docker-compose
Use [docker-compose file](docker-compose.yaml) as example. Configure required enviroment variables.
Notes:
- By default, HTTP-only is deploy. Uncomment required sections to enable HTTPS (and mount required certs).
- Reverse-proxies should work?
[To-Be-Improved]
## Manually update registry
Container images are built by CI/CD pipelines and uploaded to the registry (**not yet!**).
If required, a image can be manually built and uploaded to the registry (for testing or development purposes):
```sh
podman push [IMAGE_ID] [REGISTRY]/somnia/somnia-guestlog:[TAG]
# Example:
podman push localhost/somnia-guestlog:latest gitea.uberelectronnetwork.cc/somnia/somnia-guestlog:devbuild
```
+66
View File
@@ -0,0 +1,66 @@
services:
database:
environment:
POSTGRES_DB: ${POSTGRES_DB:-SomniaGuestLog}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-NotAStrongPassword}
POSTGRES_USER: ${POSTGRES_USER:-somnia}
healthcheck:
retries: 5
start_period: 60s
test:
- CMD
- pg_isready
timeout: 5s
image: postgres:18-alpine
volumes:
- somniaguestlog_database_data:/var/lib/postgresql:rw
somnia-guestlog:
depends_on:
- database
environment:
SOMNIA_ConnectionStrings__DbSomniaGuestLog: Host=database;Port=5432;Username=${POSTGRES_USER:-somnia};Password=${POSTGRES_PASSWORD:-NotAStrongPassword};Database=${POSTGRES_DB:-SomniaGuestLog}
# Configure path for data protection keys. This path must persists between container restarts (use a mount or a volume).
SOMNIA_DataProtectionDir: /SomniaGuestLog/dataprotection
ASPNETCORE_URLS: "http://+:8080"
# Somnia AddressQuery Service - START
SOMNIA_AddressQuery__Provider: "Nominatim"
# Override if required.
# SOMNIA_AddressQuery__ServiceURL: ""
# SOMNIA_AddressQuery__ApiKey: ""
SOMNIA_AddressQuery__UserAgent: Somnia-GuestLog-Dev-Container
SOMNIA_AddressQuery__ResultLang: es
# Somnia AddressQuery Service - END
SOMNIA_StayExport__ExportStorageConnectionString: disk://path=/SomniaGuestLog/StayExportFiles
# Somnia StayExport - SpainParteViajeros Provider - START
# Override vars if required
# SOMNIA_StayExportSpainParteViajeros__InternetAvailable: true
# SOMNIA_StayExportSpainParteViajeros__CodigoEstablecimiento: 123123123
# Somnia StayExport - SpainParteViajeros Provider - END
# Enable for HTTPS - START
# ASPNETCORE_URLS: "https://+:8090;http://+:8080"
# ASPNETCORE_HTTPS_PORTS: 8090
# ASPNETCORE_Kestrel__Certificates__Default__Password: ${CERTIFICATE_CREDENTIAL:-}
# ASPNETCORE_Kestrel__Certificates__Default__Path: /https/aspnetapp.pfx
# Enable for HTTPS - END
image: localhost/somnia-guestlog:latest
# image: gitea.uberelectronnetwork.cc/somnia/somnia-guestlog:devbuild
ports:
- protocol: tcp
published: 8080
target: 8080
# Enable for HTTPS
# - protocol: tcp
# published: 8090
# target: 8090
restart: unless-stopped
volumes:
- somniaguestlog_app_data:/SomniaGuestLog
# Enable for HTTPS and configure path to your certificate.
# - ${HOME}/.aspnet/https:/https/
volumes:
somniaguestlog_database_data: Null
somniaguestlog_app_data: Null
+7
View File
@@ -12,6 +12,13 @@
<PackageVersion Include="Grpc.AspNetCore" Version="2.64.0" /> <PackageVersion Include="Grpc.AspNetCore" Version="2.64.0" />
<PackageVersion Include="Microsoft.Extensions.Localization" Version="10.0.9" /> <PackageVersion Include="Microsoft.Extensions.Localization" Version="10.0.9" />
<PackageVersion Include="MudBlazor" Version="9.4.0" /> <PackageVersion Include="MudBlazor" Version="9.4.0" />
<PackageVersion Include="Serilog" Version="4.4.0" />
<PackageVersion Include="Serilog.Enrichers.Process" Version="3.0.0" />
<PackageVersion Include="Serilog.Enrichers.Thread" Version="4.0.0" />
<PackageVersion Include="Serilog.Extensions.Hosting" Version="10.0.0" />
<PackageVersion Include="Serilog.Settings.Configuration" Version="10.0.1" />
<PackageVersion Include="Serilog.Sinks.Console" Version="6.1.1" />
<PackageVersion Include="Serilog.Sinks.File" Version="7.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageVersion Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="10.0.7" /> <PackageVersion Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="10.0.7" />
+8
View File
@@ -0,0 +1,8 @@
namespace Somnia.GuestLog;
public static class AppSettings
{
public const string AppName = "Somnia-GuestLog-dev";
public const string AppVersion = "v0.0.0-dev"; //2026-09-08
}
@@ -6,53 +6,61 @@
@inject IDataListService dataListService; @inject IDataListService dataListService;
@inject IValidator<GuestDocumentDTO> guestDocValidator; @inject IValidator<GuestDocumentDTO> guestDocValidator;
@inject IUserMessageService userMessage;
<MudForm @ref="@_form" Model="@Model" Validation="@((guestDocValidator as GuestDocumentDTOValidator)!.ValidateValue)" ValidationDelay="0" <MudForm @ref="@_form" Model="@Model" Validation="@((guestDocValidator as GuestDocumentDTOValidator)!.ValidateValue)"
ReadOnly="@ReadOnly"> ValidationDelay="0" ReadOnly="@ReadOnly">
<MudGrid> <MudGrid>
<MudItem xs="12" md="6"> <MudItem xs="12" md="6">
<MudPaper Class="pa-4" Elevation="3" Height="100%"> <MudPaper Class="pa-4" Elevation="3" Height="100%">
<MudText Typo="Typo.subtitle1" Align="Align.Center">@LanguageLocale.control_GuestDocForm_sectionDocument</MudText> <MudText Typo="Typo.subtitle1" Align="Align.Center">
@LanguageLocale.control_GuestDocForm_sectionDocument
</MudText>
<MudDivider DividerType="DividerType.Middle" Class="mb-4" /> <MudDivider DividerType="DividerType.Middle" Class="mb-4" />
<MudStack Row style="@FieldMarginY"> <MudStack Row style="@FieldMarginY">
<MudSelect @bind-Value="Model.DocumentType" For="@(() => Model.DocumentType)" Label="@LanguageLocale.dto_GuestDocument_DocumentType" <MudSelect @bind-Value="Model.DocumentType" For="@(() => Model.DocumentType)"
Required ReadOnly="@ReadOnlyDocId"> Label="@LanguageLocale.dto_GuestDocument_DocumentType" Required ReadOnly="@ReadOnlyDocId">
@foreach (string docType in dataListService.GetDataListByName(GuestConsts.DataList_DocumentTypes)) @foreach (string docType in
dataListService.GetDataListByName(GuestConsts.DataList_DocumentTypes))
{ {
<MudSelectItem Value="docType"> <MudSelectItem Value="docType">
@dataListService.GetLocalizedValue(GuestConsts.DataList_DocumentTypes, docType) @dataListService.GetLocalizedValue(GuestConsts.DataList_DocumentTypes, docType)
</MudSelectItem> </MudSelectItem>
} }
</MudSelect> </MudSelect>
<MudTextField @bind-Value="Model.DocumentNum" For="@(() => Model.DocumentNum)" Label="@LanguageLocale.dto_GuestDocument_DocumentNum" <MudTextField @bind-Value="Model.DocumentNum" For="@(() => Model.DocumentNum)"
Required ReadOnly="@ReadOnlyDocId" /> Label="@LanguageLocale.dto_GuestDocument_DocumentNum" Required ReadOnly="@ReadOnlyDocId" />
</MudStack> </MudStack>
<MudStack Row style="@FieldMarginY"> <MudStack Row style="@FieldMarginY">
<MudDatePicker @bind-Date="Model.IssueDate" For="@(() => Model.IssueDate)" Label="@LanguageLocale.dto_GuestDocument_IssueDate" <MudDatePicker @bind-Date="Model.IssueDate" For="@(() => Model.IssueDate)"
Clearable OpenTo="OpenTo.Year" Editable /> Label="@LanguageLocale.dto_GuestDocument_IssueDate" Clearable OpenTo="OpenTo.Year" Editable />
<MudTextField @bind-Value="Model.SupportNum" For="@(() => Model.SupportNum)" Label="@LanguageLocale.dto_GuestDocument_SupportNum" <MudTextField @bind-Value="Model.SupportNum" For="@(() => Model.SupportNum)"
Required="@isSuportNumberRequired" Mask="@(new PatternMask("aaa000000"))" Label="@LanguageLocale.dto_GuestDocument_SupportNum" Required="@isSuportNumberRequired"
Mask="SuportNumberPatternMask"
OnBlur="@(() => Model.SupportNum = Model.SupportNum?.ToUpper())" /> OnBlur="@(() => Model.SupportNum = Model.SupportNum?.ToUpper())" />
</MudStack> </MudStack>
<MudAutocomplete T="string" @bind-Value="Model.Nationality" For="@(() => Model.Nationality)" Label="@LanguageLocale.dto_GuestDocument_Nationality" <MudAutocomplete T="string" @bind-Value="Model.Nationality" For="@(() => Model.Nationality)"
SearchFunc="@SearchCountryCodes" ToStringFunc="@(e=> string.IsNullOrEmpty(e) ? "" : @dataListService.GetLocalizedValue(GuestConsts.DataList_CountryCodes, e))" Label="@LanguageLocale.dto_GuestDocument_Nationality" SearchFunc="@SearchCountryCodes"
SelectValueOnTab="true" AdornmentIcon="@Icons.Material.Filled.Search" ToStringFunc="@(e=> string.IsNullOrEmpty(e) ? "" : @dataListService.GetLocalizedValue(GuestConsts.DataList_CountryCodes, e))"
style="@FieldMarginY" /> SelectValueOnTab="true" AdornmentIcon="@Icons.Material.Filled.Search" style="@FieldMarginY"
Required />
</MudPaper> </MudPaper>
</MudItem> </MudItem>
<MudItem xs="12" md="6"> <MudItem xs="12" md="6">
<MudPaper Class="pa-4" Elevation="3" Height="100%"> <MudPaper Class="pa-4" Elevation="3" Height="100%">
<MudText Typo="Typo.subtitle1" Align="Align.Center">@LanguageLocale.control_GuestDocForm_sectionGuest</MudText> <MudText Typo="Typo.subtitle1" Align="Align.Center">
@LanguageLocale.control_GuestDocForm_sectionGuest
</MudText>
<MudDivider DividerType="DividerType.Middle" Class="mb-4" /> <MudDivider DividerType="DividerType.Middle" Class="mb-4" />
<MudTextField @bind-Value="Model.Name" For="@(() => Model.Name)" <MudTextField @bind-Value="Model.Name" For="@(() => Model.Name)" Required
Label="@LanguageLocale.dto_GuestDocument_Name" Label="@LanguageLocale.dto_GuestDocument_Name"
OnBlur="@(() => Model.Name = Model.Name?.ToUpper())" /> OnBlur="@(() => Model.Name = Model.Name?.ToUpper())" />
<MudTextField @bind-Value="Model.Surname" For="@(() => Model.Surname)" <MudTextField @bind-Value="Model.Surname" For="@(() => Model.Surname)" Required
Label="@LanguageLocale.dto_GuestDocument_Surname" Label="@LanguageLocale.dto_GuestDocument_Surname"
OnBlur="@(() => Model.Surname = Model.Surname?.ToUpper())" /> OnBlur="@(() => Model.Surname = Model.Surname?.ToUpper())" />
<MudTextField @bind-Value="Model.Surname2" For="@(() => Model.Surname2)" <MudTextField @bind-Value="Model.Surname2" For="@(() => Model.Surname2)"
@@ -60,11 +68,14 @@
OnBlur="@(() => Model.Surname2 = Model.Surname2?.ToUpper())" /> OnBlur="@(() => Model.Surname2 = Model.Surname2?.ToUpper())" />
<MudStack Row style="@FieldMarginY"> <MudStack Row style="@FieldMarginY">
<MudDatePicker @bind-Date="Model.BirthDate" For="@(() => Model.BirthDate)" Label="@LanguageLocale.dto_GuestDocument_BirthDate" <MudDatePicker @bind-Date="Model.BirthDate" For="@(() => Model.BirthDate)"
Clearable OpenTo="OpenTo.Year" Editable /> Label="@LanguageLocale.dto_GuestDocument_BirthDate" OpenTo="OpenTo.Year" Clearable Required
Editable />
<MudSelect @bind-Value="Model.Gender" For="@(() => Model.Gender)" Label="@LanguageLocale.dto_GuestDocument_Gender"> <MudSelect @bind-Value="Model.Gender" For="@(() => Model.Gender)"
@foreach (string gender in dataListService.GetDataListByName(GuestConsts.DataList_GenderOptions)) Label="@LanguageLocale.dto_GuestDocument_Gender">
@foreach (string gender in
dataListService.GetDataListByName(GuestConsts.DataList_GenderOptions))
{ {
<MudSelectItem Value="gender"> <MudSelectItem Value="gender">
@dataListService.GetLocalizedValue(GuestConsts.DataList_GenderOptions, gender) @dataListService.GetLocalizedValue(GuestConsts.DataList_GenderOptions, gender)
@@ -77,30 +88,37 @@
<MudItem xs="12" md="6"> <MudItem xs="12" md="6">
<MudPaper Class="pa-4" Elevation="3" Height="100%"> <MudPaper Class="pa-4" Elevation="3" Height="100%">
<MudText Typo="Typo.subtitle1" Align="Align.Center">@LanguageLocale.control_GuestDocForm_sectionContact</MudText> <MudText Typo="Typo.subtitle1" Align="Align.Center">
@LanguageLocale.control_GuestDocForm_sectionContact
</MudText>
<MudDivider DividerType="DividerType.Middle" Class="mb-4" /> <MudDivider DividerType="DividerType.Middle" Class="mb-4" />
<MudStack Row> <MudStack Row>
<MudTextField @bind-Value="Model.PhoneNumber" For="@(() => Model.PhoneNumber)" <MudTextField @bind-Value="Model.PhoneNumber" For="@(() => Model.PhoneNumber)"
Label="@LanguageLocale.dto_GuestDocument_PhoneNumber" Label="@LanguageLocale.dto_GuestDocument_PhoneNumber" InputType="InputType.Telephone" />
InputType="InputType.Telephone" />
<MudTextField @bind-Value="Model.EmailAddress" For="@(() => Model.EmailAddress)" <MudTextField @bind-Value="Model.EmailAddress" For="@(() => Model.EmailAddress)"
Label="@LanguageLocale.dto_GuestDocument_EmailAddress" Label="@LanguageLocale.dto_GuestDocument_EmailAddress" InputType="InputType.Email" />
InputType="InputType.Email" />
</MudStack> </MudStack>
</MudPaper> </MudPaper>
</MudItem> </MudItem>
<MudItem xs="12" md="6"> <MudItem xs="12" md="6">
<MudPaper Class="pa-4" Elevation="3" Height="100%"> <MudPaper Class="pa-4" Elevation="3" Height="100%">
<MudText Typo="Typo.subtitle1" Align="Align.Center">@LanguageLocale.control_GuestDocForm_sectionAddress</MudText> <MudText Typo="Typo.subtitle1" Align="Align.Center">
@LanguageLocale.control_GuestDocForm_sectionAddress
</MudText>
<MudDivider DividerType="DividerType.Middle" Class="mb-4" /> <MudDivider DividerType="DividerType.Middle" Class="mb-4" />
@if (!ReadOnly) @if (!ReadOnly)
{ {
<MudButton OnClick="BtnOpenAddressSearchDialog" Variant="Variant.Outlined" FullWidth="true" Class="mb-2"> <MudStack Row>
<MudButton OnClick="BtnOpenAddressSearchDialog" Variant="Variant.Outlined" FullWidth="true"
Class="mb-2">
@LanguageLocale.control_GuestDocForm_btnSearchAddress @LanguageLocale.control_GuestDocForm_btnSearchAddress
</MudButton> </MudButton>
<MudIconButton OnClick="BtnSkipAddressSearch" Variant="Variant.Outlined" Disabled="!ReadOnlyAddress"
Icon="@Icons.Material.Filled.SkipNext" Class="mb-2" />
</MudStack>
} }
<MudTextField @bind-Value="Model.Address" For="@(() => Model.Address)" <MudTextField @bind-Value="Model.Address" For="@(() => Model.Address)"
@@ -116,7 +134,8 @@
<MudStack Row style="@FieldMarginY"> <MudStack Row style="@FieldMarginY">
<MudAutocomplete T="string" @bind-Value="Model.AddressCountry" For="@(() => Model.AddressCountry)" <MudAutocomplete T="string" @bind-Value="Model.AddressCountry" For="@(() => Model.AddressCountry)"
Label="@LanguageLocale.general_address_country" ReadOnly="@ReadOnlyAddress" Label="@LanguageLocale.general_address_country" ReadOnly="@ReadOnlyAddress"
SearchFunc="@SearchCountryCodes" ToStringFunc="@(e=> string.IsNullOrEmpty(e) ? "" : @dataListService.GetLocalizedValue(GuestConsts.DataList_CountryCodes, e))" SearchFunc="@SearchCountryCodes"
ToStringFunc="@(e=> string.IsNullOrEmpty(e) ? "" : @dataListService.GetLocalizedValue(GuestConsts.DataList_CountryCodes, e))"
SelectValueOnTab="true" AdornmentIcon="@Icons.Material.Filled.Search" /> SelectValueOnTab="true" AdornmentIcon="@Icons.Material.Filled.Search" />
<MudTextField @bind-Value="Model.ZipCode" For="@(() => Model.ZipCode)" <MudTextField @bind-Value="Model.ZipCode" For="@(() => Model.ZipCode)"
@@ -155,7 +174,20 @@
private Dictionary<string, string>? countryDict = null; private Dictionary<string, string>? countryDict = null;
private bool isSuportNumberRequired { get => Model?.Nationality == GuestConsts.CountryCode_ESP; } private bool isSuportNumberRequired
{
get => Model?.DocumentType == GuestConsts.DocumentType_DNI
|| Model?.DocumentType == GuestConsts.DocumentType_NIE;
}
private PatternMask SuportNumberPatternMask
{
get => Model?.DocumentType switch
{
GuestConsts.DocumentType_DNI => new PatternMask("aaa000000"),
GuestConsts.DocumentType_NIE => new PatternMask("a00000000"),
_ => new PatternMask("")
};
}
private string CreateTimeString private string CreateTimeString
{ {
get get
@@ -237,6 +269,14 @@
ReadOnlyAddress = ReadOnly; ReadOnlyAddress = ReadOnly;
} }
private async Task BtnSkipAddressSearch()
{
userMessage.ShowMessage("Address search skipped! Address is editable now", MessageKind.Info);
//Make Address editable (if the form is editable).
ReadOnlyAddress = ReadOnly;
}
#endregion #endregion
} }
@@ -21,12 +21,12 @@
<MudDivider DividerType="DividerType.Middle" Class="mb-4" /> <MudDivider DividerType="DividerType.Middle" Class="mb-4" />
<MudStack Row style="@FieldMarginY"> <MudStack Row style="@FieldMarginY">
<MudDatePicker @ref="_datePickerDateIn" @bind-Date="Model.DateIn" For="@(() => Model.DateIn)" <MudDatePicker @bind-Date="Model.DateIn" For="@(() => Model.DateIn)"
Label="@LanguageLocale.dto_StayEntry_DateIn" Clearable OpenTo="OpenTo.Date" Editable Label="@LanguageLocale.dto_StayEntry_DateIn" Clearable OpenTo="OpenTo.Date" Editable
AutoClose="true" /> AutoClose="true" />
<MudTimePicker Time="Model.DateIn?.TimeOfDay" Label=" " Editable <MudTimePicker Time="Model.DateIn?.TimeOfDay" Label=" " Editable
TimeChanged="@((newVal) => Model.DateIn = GetDateTimeFromDateAndTime(Model.DateIn, newVal))" /> TimeChanged="@((newVal) => Model.DateIn = GetDateTimeFromDateAndTime(Model.DateIn, newVal))" />
<MudDatePicker @ref="_datePickerDateOut" @bind-Date="Model.DateOut" For="@(() => Model.DateOut)" <MudDatePicker @bind-Date="Model.DateOut" For="@(() => Model.DateOut)"
Label="@LanguageLocale.dto_StayEntry_DateOut" Clearable OpenTo="OpenTo.Date" Editable Label="@LanguageLocale.dto_StayEntry_DateOut" Clearable OpenTo="OpenTo.Date" Editable
AutoClose="true" /> AutoClose="true" />
<MudTimePicker Time="Model.DateOut?.TimeOfDay" Label=" " Editable <MudTimePicker Time="Model.DateOut?.TimeOfDay" Label=" " Editable
@@ -125,8 +125,6 @@
private MudForm _form = null!; private MudForm _form = null!;
private MudDatePicker _datePickerDateIn = null!;
private MudDatePicker _datePickerDateOut = null!;
private const string FieldMarginY = "margin-block: 0.5em"; private const string FieldMarginY = "margin-block: 0.5em";
private IEnumerable<string> PaymentMethodSet private IEnumerable<string> PaymentMethodSet
@@ -22,6 +22,10 @@
</MudAppBar> </MudAppBar>
<MudDrawer id="nav-drawer" @bind-Open="_drawerOpen" ClipMode="DrawerClipMode.Docked" Elevation="2"> <MudDrawer id="nav-drawer" @bind-Open="_drawerOpen" ClipMode="DrawerClipMode.Docked" Elevation="2">
<NavMenu /> <NavMenu />
<MudSpacer />
<MudText Typo="Typo.caption" Class="mx-2" GutterBottom>
@AppSettings.AppName - @AppSettings.AppVersion
</MudText>
</MudDrawer> </MudDrawer>
<MudMainContent Class="pt-16 pa-4"> <MudMainContent Class="pt-16 pa-4">
@Body @Body
@@ -0,0 +1,50 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"Serilog": {
"Using": [
"Serilog.Sinks.Console",
"Serilog.Sinks.File"
],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"Microsoft.EntityFrameworkCore.Database.Command": "Warning"
}
},
"Enrich": [
"FromLogContext",
"WithThreadId",
"WithProcessId"
],
"Properties": {
"ApplicationName": "Somnia-GuestLog"
},
"WriteTo": [
{
"Name": "Console",
"Args": {
"restrictedToMinimumLevel": "Information"
}
},
{
"Name": "File",
"Args": {
// Logs data path
"path": "/SomniaGuestLog/logs/log_.log",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{ProcessId}-{ThreadId}] [{Level}] {JobKey}{Message}{NewLine}{Exception}",
"rollingInterval": "Day",
"rollOnFileSizeLimit": true,
"fileSizeLimitBytes": 1073741824,
"retainedFileCountLimit": 30,
"restrictedToMinimumLevel": "Information"
}
}
]
}
}
@@ -0,0 +1,252 @@
// <auto-generated />
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Somnia.GuestLog.Infrastructure;
#nullable disable
namespace Somnia.GuestLog.Infrastructure.Migrations
{
[DbContext(typeof(GuestLogContext))]
[Migration("20260910093310_GuestDocument_IssueDate_MakeNullable")]
partial class GuestDocument_IssueDate_MakeNullable
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.7")
.HasAnnotation("Proxies:ChangeTracking", false)
.HasAnnotation("Proxies:CheckEquality", false)
.HasAnnotation("Proxies:LazyLoading", true)
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("GuestDocumentStayEntry", b =>
{
b.Property<long>("StayEntryId")
.HasColumnType("bigint");
b.Property<long>("GuestDocumentsId")
.HasColumnType("bigint");
b.Property<int>("GuestDocumentsVersion")
.HasColumnType("integer");
b.HasKey("StayEntryId", "GuestDocumentsId", "GuestDocumentsVersion");
b.HasIndex("GuestDocumentsId", "GuestDocumentsVersion");
b.ToTable("GuestDocumentStayEntry");
});
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.GuestDocument", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<int>("Version")
.HasColumnType("integer");
b.Property<DateOnly>("BirthDate")
.HasColumnType("date");
b.Property<DateTime>("CreateTime")
.HasColumnType("timestamp(3) with time zone");
b.Property<string>("DocumentNum")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<string>("DocumentType")
.IsRequired()
.HasMaxLength(8)
.HasColumnType("character varying(8)");
b.Property<string>("EmailAddress")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("Gender")
.HasMaxLength(1)
.HasColumnType("character varying(1)");
b.Property<bool>("IsLastVersion")
.HasColumnType("boolean");
b.Property<DateOnly?>("IssueDate")
.HasColumnType("date");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<string>("Nationality")
.IsRequired()
.HasMaxLength(3)
.HasColumnType("character varying(3)");
b.Property<string>("PhoneNumber")
.HasMaxLength(32)
.HasColumnType("character varying(32)");
b.Property<string>("SupportNum")
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<string>("Surname")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<string>("Surname2")
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<DateTime>("UpdateTime")
.HasColumnType("timestamp(3) with time zone");
b.ComplexProperty(typeof(Dictionary<string, object>), "AddressDetails", "Somnia.GuestLog.Models.Entities.GuestDocument.AddressDetails#GuestAddress", b1 =>
{
b1.Property<string>("Address")
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b1.Property<string>("AddressCity")
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b1.Property<string>("AddressCountry")
.IsRequired()
.HasMaxLength(3)
.HasColumnType("character varying(3)");
b1.Property<string>("AddressProvince")
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b1.Property<string>("AddressState")
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b1.Property<string>("ZipCode")
.HasMaxLength(12)
.HasColumnType("character varying(12)");
});
b.HasKey("Id", "Version");
b.ToTable("GuestDocument", (string)null);
});
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.StayEntry", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<DateTime>("CreateTime")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("DateIn")
.HasColumnType("timestamp(0) with time zone");
b.Property<DateTime>("DateOut")
.HasColumnType("timestamp(0) with time zone");
b.Property<string>("PaymentMethod")
.IsRequired()
.HasMaxLength(5)
.HasColumnType("character varying(5)");
b.Property<int>("RoomCount")
.HasColumnType("integer");
b.Property<string>("RoomNumber")
.HasMaxLength(32)
.HasColumnType("character varying(32)");
b.Property<DateTime>("UpdateTime")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.ToTable("StayEntry", (string)null);
});
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.StayExportFile", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<string>("ExportDetails")
.HasColumnType("jsonb");
b.Property<int>("ExportFormat")
.HasColumnType("integer");
b.Property<int>("ExportResult")
.HasColumnType("integer");
b.Property<DateTime>("ExportTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("ExportedPath")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.ComplexProperty(typeof(Dictionary<string, object>), "ExportParams", "Somnia.GuestLog.Models.Entities.StayExportFile.ExportParams#StayExportParams", b1 =>
{
b1.IsRequired();
b1.Property<DateTime?>("ExportPeriodEnd");
b1.Property<DateTime?>("ExportPeriodStart");
b1.Property<int>("ExportType");
b1
.ToJson("ExportParams")
.HasColumnType("jsonb");
});
b.HasKey("Id");
b.ToTable("StayExportFile", (string)null);
});
modelBuilder.Entity("GuestDocumentStayEntry", b =>
{
b.HasOne("Somnia.GuestLog.Models.Entities.StayEntry", null)
.WithMany()
.HasForeignKey("StayEntryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Somnia.GuestLog.Models.Entities.GuestDocument", null)
.WithMany()
.HasForeignKey("GuestDocumentsId", "GuestDocumentsVersion")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,42 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Somnia.GuestLog.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class GuestDocument_IssueDate_MakeNullable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateOnly>(
name: "IssueDate",
table: "GuestDocument",
type: "date",
nullable: true,
oldClrType: typeof(DateOnly),
oldType: "date");
//Make null any IssueDate column with "default" value:
migrationBuilder.Sql("""UPDATE "GuestDocument" SET "IssueDate" = NULL WHERE "IssueDate" = '1970-01-01';""");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
//Set value to all IssueDate null columns.
migrationBuilder.Sql("""UPDATE "GuestDocument" SET "IssueDate" = '1970-01-01' WHERE "IssueDate" IS NULL;""");
migrationBuilder.AlterColumn<DateOnly>(
name: "IssueDate",
table: "GuestDocument",
type: "date",
nullable: false,
oldClrType: typeof(DateOnly),
oldType: "date",
oldNullable: true);
}
}
}
@@ -82,7 +82,7 @@ namespace Somnia.GuestLog.Infrastructure.Migrations
b.Property<bool>("IsLastVersion") b.Property<bool>("IsLastVersion")
.HasColumnType("boolean"); .HasColumnType("boolean");
b.Property<DateOnly>("IssueDate") b.Property<DateOnly?>("IssueDate")
.HasColumnType("date"); .HasColumnType("date");
b.Property<string>("Name") b.Property<string>("Name")
@@ -8,7 +8,7 @@ public class GuestDocument : BaseEntity
public required string DocumentType { get; set; } public required string DocumentType { get; set; }
public required string DocumentNum { get; set; } public required string DocumentNum { get; set; }
public required DateOnly IssueDate { get; set; } public required DateOnly? IssueDate { get; set; }
public string? SupportNum { get; set; } public string? SupportNum { get; set; }
public required string Nationality { get; set; } public required string Nationality { get; set; }
@@ -33,4 +33,5 @@ public class GuestDocument : BaseEntity
public override string GetFullKey() => $"{Id}-{Version}"; public override string GetFullKey() => $"{Id}-{Version}";
public string FullDocument => $"{DocumentType}-{DocumentNum}";
} }
+1 -1
View File
@@ -14,7 +14,7 @@ internal static class EntityMapping
Version = entity.Version, Version = entity.Version,
DocumentType = entity.DocumentType, DocumentType = entity.DocumentType,
DocumentNum = entity.DocumentNum, DocumentNum = entity.DocumentNum,
IssueDate = entity.IssueDate.ToDateTime(TimeOnly.MinValue), IssueDate = entity.IssueDate?.ToDateTime(TimeOnly.MinValue) ?? null,
SupportNum = entity.SupportNum, SupportNum = entity.SupportNum,
Nationality = entity.Nationality, Nationality = entity.Nationality,
Name = entity.Name, Name = entity.Name,
+46
View File
@@ -1,9 +1,14 @@
using FluentStorage; using FluentStorage;
using FluentValidation; using FluentValidation;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Localization; using Microsoft.AspNetCore.Localization;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Diagnostics;
using MudBlazor.Services; using MudBlazor.Services;
using Serilog;
using Serilog.Extensions.Logging;
using Somnia.GuestLog;
using Somnia.GuestLog.Components; using Somnia.GuestLog.Components;
using Somnia.GuestLog.Infrastructure; using Somnia.GuestLog.Infrastructure;
using Somnia.GuestLog.Models.Configuration; using Somnia.GuestLog.Models.Configuration;
@@ -18,6 +23,34 @@ using Somnia.GuestLog.Validators;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
//Load config files.
builder.Configuration.AddJsonFile("Config/log_Config.json", optional: false, reloadOnChange: false);
builder.Configuration.AddEnvironmentVariables("SOMNIA_");
//Create and configure Logger (Serilog)
var serilog = new LoggerConfiguration()
.ReadFrom.Configuration(builder.Configuration)
.CreateLogger();
builder.Services.AddSerilog(serilog);
var logger = new SerilogLoggerFactory(serilog).CreateLogger<Program>();
logger.LogInformation("\n\n\n -------------- Starting {appName} {appVersion} --------------", AppSettings.AppName, AppSettings.AppVersion);
if (!builder.Environment.IsDevelopment())
{
string dataProtectionPath = builder.Configuration.GetValue<string>("DataProtectionDir", defaultValue: "/SomniaGuestLog/dataprotection");
builder.Services.AddDataProtection()
.PersistKeysToFileSystem(new DirectoryInfo(dataProtectionPath))
.SetApplicationName("SomniaGuestLog");
}
builder.Services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders =
ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto | ForwardedHeaders.XForwardedHost;
});
var connectionStringGuestLog = builder.Configuration.GetConnectionString("DbSomniaGuestLog") var connectionStringGuestLog = builder.Configuration.GetConnectionString("DbSomniaGuestLog")
?? throw new InvalidOperationException("Connection string 'DbSomniaGuestLog' not found."); ?? throw new InvalidOperationException("Connection string 'DbSomniaGuestLog' not found.");
builder.Services.AddDbContextFactory<GuestLogContext>(options => builder.Services.AddDbContextFactory<GuestLogContext>(options =>
@@ -85,6 +118,8 @@ builder.Services.AddOptions<StayExportSpainParteViajerosConfig>()
var app = builder.Build(); var app = builder.Build();
app.UseForwardedHeaders();
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment()) if (app.Environment.IsDevelopment())
{ {
@@ -119,4 +154,15 @@ app.MapRazorComponents<App>()
//Activate S3 storage. //Activate S3 storage.
AwsS3Storage.Use(); AwsS3Storage.Use();
//Run database migrations
bool runMigrationsOnStartup = builder.Configuration.GetValue<bool>("RunDatabaseMigrationOnStartup", defaultValue: true);
if (runMigrationsOnStartup)
{
logger.LogInformation("Running database migrations...");
using var scope = app.Services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<GuestLogContext>();
await db.Database.MigrateAsync();
logger.LogInformation("Database migrations OK");
}
app.Run(); app.Run();
@@ -44,7 +44,7 @@ public class GuestDocumentEntityService(
Version = GuestConsts.GuestDocument_FirstVersion, Version = GuestConsts.GuestDocument_FirstVersion,
DocumentType = dto.DocumentType!, DocumentType = dto.DocumentType!,
DocumentNum = dto.DocumentNum!, DocumentNum = dto.DocumentNum!,
IssueDate = DateOnly.FromDateTime(dto.IssueDate!.Value), IssueDate = dto.IssueDate != null ? DateOnly.FromDateTime(dto.IssueDate!.Value) : null,
SupportNum = dto.SupportNum, SupportNum = dto.SupportNum,
Nationality = dto.Nationality!, Nationality = dto.Nationality!,
Name = dto.Name!, Name = dto.Name!,
@@ -56,7 +56,7 @@ public class StayEntryEntityService(
if (isInOtherStay) if (isInOtherStay)
{ {
string period = $"{dbStay.DateIn}-{dbStay.DateOut}"; string period = $"{dbStay.DateIn}-{dbStay.DateOut}";
return Result.FailWithContext(ResultCode.GuestCurrentlyInStay, dbGuest.GetFullKey(), period); return Result.FailWithContext(ResultCode.GuestCurrentlyInStay, dbGuest.FullDocument, period);
} }
//Add dbGuest to dbStay. //Add dbGuest to dbStay.
@@ -155,7 +155,8 @@ public class StayEntryEntityService(
query = query.WhereIf(!string.IsNullOrEmpty(filter.PaymentMethod), query = query.WhereIf(!string.IsNullOrEmpty(filter.PaymentMethod),
e => e.PaymentMethod == filter.PaymentMethod); e => e.PaymentMethod == filter.PaymentMethod);
query = query.OrderByDescending(e => e.DateIn); query = query.OrderByDescending(e => e.DateIn)
.ThenByDescending(e => e.UpdateTime);
if (limit > 0) if (limit > 0)
{ {
@@ -46,12 +46,14 @@ public class StayExportFileEntityService(
await dbContext.AddAsync(dbItem); await dbContext.AddAsync(dbItem);
await dbContext.SaveChangesAsync(); await dbContext.SaveChangesAsync();
logger.LogInformation("StayExportFileService - CreateStayExportAsync: GuestDocument Created: '{id}'", dbItem.GetFullKey()); logger.LogInformation(
"StayExportFileService - CreateStayExportAsync: StayExport Created (ID: '{id}') with result: '{result}'",
dbItem.GetFullKey(), dbItem.ExportResult);
return Result.Ok(); return Result.Ok();
} }
catch (Exception ex) catch (Exception ex)
{ {
logger.LogError(ex, "StayExportFileService - CreateStayExportAsync: Error creating GuestDocument"); logger.LogError(ex, "StayExportFileService - CreateStayExportAsync: Error creating StayExport");
return Result.FailUnknownError(); return Result.FailUnknownError();
} }
} }
@@ -83,7 +85,7 @@ public class StayExportFileEntityService(
} }
catch (Exception ex) catch (Exception ex)
{ {
logger.LogError(ex, "StayExportFileService - DeleteStayExportAsync: Error creating GuestDocument"); logger.LogError(ex, "StayExportFileService - DeleteStayExportAsync: Error deleting StayExport");
return Result.FailUnknownError(); return Result.FailUnknownError();
} }
} }
@@ -63,7 +63,7 @@ public class SpainCodigoMunicipioCatastroService(
return null; return null;
} }
string finalCode = $"{codIne.codigoProvincia}{codIne.codigoMunicipio}"; string finalCode = $"{codIne.codigoProvincia.PadLeft(2, '0')}{codIne.codigoMunicipio.PadLeft(3, '0')}";
codigoMunicipioCache.Add(cacheKey, finalCode); codigoMunicipioCache.Add(cacheKey, finalCode);
return finalCode; return finalCode;
@@ -32,6 +32,7 @@ public class StayExportProviderSpainParteViajeros(
private const string PersonDireccionPais_ESP = "ESP"; private const string PersonDireccionPais_ESP = "ESP";
private const string XmlNamespace_Peticion = "http://www.neg.hospedajes.mir.es/altaParteHospedaje"; private const string XmlNamespace_Peticion = "http://www.neg.hospedajes.mir.es/altaParteHospedaje";
private const string XmlNamespace_Peticion_Prefix = "ns2";
private readonly StayExportSpainParteViajerosConfig config = configOptions.Value; private readonly StayExportSpainParteViajerosConfig config = configOptions.Value;
@@ -89,8 +90,12 @@ public class StayExportProviderSpainParteViajeros(
} }
}; };
//Create XmlSerializerNamespaces to add prefix-namespace pairs.
var docNamespaces = new XmlSerializerNamespaces();
docNamespaces.Add(XmlNamespace_Peticion_Prefix, XmlNamespace_Peticion);
XmlSerializer serializer = new(typeof(Peticion)); XmlSerializer serializer = new(typeof(Peticion));
serializer.Serialize(dataStream, peticion); serializer.Serialize(stream: dataStream, o: peticion, namespaces: docNamespaces);
string details = JsonSerializer.Serialize(stayExportDetails); string details = JsonSerializer.Serialize(stayExportDetails);
return (fileResult: StayExportFileResult.OK, exportDetails: details); return (fileResult: StayExportFileResult.OK, exportDetails: details);
@@ -146,7 +151,7 @@ public class StayExportProviderSpainParteViajeros(
{ {
return ( return (
comunicacion: null, comunicacion: null,
errorMsg: "Can't get codigo municio" errorMsg: $"Can't get codigo municipio for {doc.AddressProvince}-{doc.AddressCity} in doc {doc.FullDocument}"
); );
} }
} }
@@ -197,7 +202,7 @@ public class StayExportProviderSpainParteViajeros(
return doc.Gender switch return doc.Gender switch
{ {
GuestConsts.GenderOptions_MALE => "H", GuestConsts.GenderOptions_MALE => "H",
GuestConsts.GenderOptions_FEMALE => "F", GuestConsts.GenderOptions_FEMALE => "M",
null => null, null => null,
_ => "O" _ => "O"
}; };
@@ -212,6 +217,7 @@ public class StayExportProviderSpainParteViajeros(
{ {
if (string.IsNullOrEmpty(doc.AddressCity) || string.IsNullOrEmpty(doc.AddressProvince)) if (string.IsNullOrEmpty(doc.AddressCity) || string.IsNullOrEmpty(doc.AddressProvince))
{ {
logger.LogWarning("Found doc ({docNum}) without full address", doc.FullDocument);
return null; return null;
} }
@@ -324,6 +330,7 @@ public class StayExportProviderSpainParteViajeros(
[XmlRoot(ElementName = "peticion", Namespace = XmlNamespace_Peticion)] [XmlRoot(ElementName = "peticion", Namespace = XmlNamespace_Peticion)]
public class Peticion public class Peticion
{ {
[XmlElement(Namespace = "")]
public required Solicitud solicitud; public required Solicitud solicitud;
} }
@@ -331,17 +338,20 @@ public class StayExportProviderSpainParteViajeros(
public class Solicitud public class Solicitud
{ {
public required string codigoEstablecimiento; public required string codigoEstablecimiento;
[XmlElement(ElementName = "comunicacion")]
public required List<Comunicacion> comunicacion; public required List<Comunicacion> comunicacion;
} }
[XmlRoot(ElementName = "comunicacion")]
public class Comunicacion public class Comunicacion
{ {
[XmlElement(ElementName = "contrato")]
public required Contrato contrato; public required Contrato contrato;
[XmlElement(ElementName = "persona")]
public required List<Persona> persona; public required List<Persona> persona;
} }
[XmlRoot(ElementName = "contrato")]
public class Contrato public class Contrato
{ {
public required string referencia; public required string referencia;
@@ -363,7 +373,6 @@ public class StayExportProviderSpainParteViajeros(
public required Pago pago; public required Pago pago;
} }
[XmlRoot(ElementName = "persona")]
public class Persona public class Persona
{ {
public required string rol; public required string rol;
@@ -379,12 +388,13 @@ public class StayExportProviderSpainParteViajeros(
public required string nacionalidad; public required string nacionalidad;
public required string sexo; public required string sexo;
// BLOQUE DIRECCION
public required Direccion direccion;
public string? telefono; public string? telefono;
public string? correo; public string? correo;
public required string parentesco; public required string parentesco;
// BLOQUE DIRECCION
public required Direccion direccion;
} }
public class Pago public class Pago
@@ -7,11 +7,23 @@
<BlazorDisableThrowNavigationException>true</BlazorDisableThrowNavigationException> <BlazorDisableThrowNavigationException>true</BlazorDisableThrowNavigationException>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<PublishProfile>DefaultContainer</PublishProfile>
<ContainerImageFormat>OCI</ContainerImageFormat>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="FluentStorage" /> <PackageReference Include="FluentStorage" />
<PackageReference Include="FluentStorage.AWS" /> <PackageReference Include="FluentStorage.AWS" />
<PackageReference Include="FluentValidation" /> <PackageReference Include="FluentValidation" />
<PackageReference Include="MudBlazor" /> <PackageReference Include="MudBlazor" />
<PackageReference Include="Serilog" />
<PackageReference Include="Serilog.Enrichers.Process" />
<PackageReference Include="Serilog.Enrichers.Thread" />
<PackageReference Include="Serilog.Extensions.Hosting" />
<PackageReference Include="Serilog.Settings.Configuration" />
<PackageReference Include="Serilog.Sinks.Console" />
<PackageReference Include="Serilog.Sinks.File" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
+3 -1
View File
@@ -11,7 +11,9 @@ public static partial class RegexUtils
public static partial Regex RegexNieFormat(); public static partial Regex RegexNieFormat();
[GeneratedRegex("^[A-Z]{3}[0-9]{6}$")] [GeneratedRegex("^[A-Z]{3}[0-9]{6}$")]
public static partial Regex RegexGuestDocSuportNumber(); public static partial Regex RegexGuestDocSupportNumberDNI();
[GeneratedRegex("^E[0-9]{8}$")]
public static partial Regex RegexGuestDocSupportNumberNIE();
[GeneratedRegex(@"^\+?\d{1,4}?[-.\s]?\(?\d{1,3}?\)?[-.\s]?\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,9}$")] [GeneratedRegex(@"^\+?\d{1,4}?[-.\s]?\(?\d{1,3}?\)?[-.\s]?\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,9}$")]
public static partial Regex RegexPhoneNumber(); public static partial Regex RegexPhoneNumber();
@@ -22,14 +22,22 @@ public class GuestDocumentDTOValidator : ValueValidator<GuestDocumentDTO>
.Length(6, 32); .Length(6, 32);
RuleFor(x => x.IssueDate) RuleFor(x => x.IssueDate)
.Cascade(CascadeMode.Stop)
.NotEmpty() .NotEmpty()
.When(x => x.Nationality != GuestConsts.CountryCode_ESP)
.LessThanOrEqualTo(DateTime.Today); .LessThanOrEqualTo(DateTime.Today);
RuleFor(x => x.SupportNum) RuleFor(x => x.SupportNum)
.Cascade(CascadeMode.Stop) .Cascade(CascadeMode.Stop)
.NotEmpty() .NotEmpty()
.Matches(RegexUtils.RegexGuestDocSuportNumber()).WithMessage("Invalid Format. Expected 'AAA000000'.") .Matches(RegexUtils.RegexGuestDocSupportNumberDNI()).WithMessage("Invalid Format for DNI. Expected 'AAA000000'.")
.When(x => x.Nationality == GuestConsts.CountryCode_ESP); .When(x => x.DocumentType == GuestConsts.DocumentType_DNI);
RuleFor(x => x.SupportNum)
.Cascade(CascadeMode.Stop)
.NotEmpty()
.Matches(RegexUtils.RegexGuestDocSupportNumberNIE()).WithMessage("Invalid Format for NIE. Expected 'E00000000'.")
.When(x => x.DocumentType == GuestConsts.DocumentType_NIE);
RuleFor(x => x.Name) RuleFor(x => x.Name)
.NotEmpty() .NotEmpty()
@@ -4,5 +4,6 @@
"Default": "Information", "Default": "Information",
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning"
} }
} },
"RunDatabaseMigrationOnStartup": false
} }
+2 -6
View File
@@ -2,12 +2,8 @@
"ConnectionStrings": { "ConnectionStrings": {
"DbSomniaGuestLog": "Host=localhost;Port=5432;Username=postgres;Password=P@ssw0rd;Database=SomniaGuestLog" "DbSomniaGuestLog": "Host=localhost;Port=5432;Username=postgres;Password=P@ssw0rd;Database=SomniaGuestLog"
}, },
"Logging": { "RunDatabaseMigrationOnStartup": true,
"LogLevel": { "DataProtectionDir": "/SomniaGuestLog/dataprotection",
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*", "AllowedHosts": "*",
"AddressQuery": { "AddressQuery": {
"EnableAddressQuery": true, "EnableAddressQuery": true,