Compare commits

..
Author SHA256 Message Date
Daniel-Garmig f87d6303ea StayExport Tracking - New Stay Export mode: UploadPending
Added a new stay export mode to export pending stays. A date range can be used as optional parameter.
2026-10-12 14:21:36 +02:00
Daniel-Garmig b515f18ca9 StayExport Tracking - StayEntry edit
StayEntries now can be edited:
- Implemented required entityService method.
- Added UI for edit mode in StayEntry details page.
2026-10-11 20:17:57 +02:00
Daniel-Garmig 72cd11caf2 StayExport Tracking - Update Stay upload status when updating export files
- Exported StayEntries (with Export OK) will update it's upload status when the export file is set as "Uploaded".
2026-10-09 13:17:55 +02:00
Daniel-Garmig 54387a6346 StayExport Tracking - StayExportFile ExportDetails new type/format
- Added new class to unify and type the format of StayExportFile.ExportDetails field.

Note: This database migration will set to null all StayExportFile.ExportDetails data. This is required to prevent exceptions due to new formatting.
2026-10-09 12:58:23 +02:00
Daniel-Garmig cf62a0e55e StayExport Tracking - Edit StayExportFile UploadStatus
- Added UI to update UploadStatus for StayExportFiles.
2026-10-09 11:44:45 +02:00
Daniel-Garmig 7b86b2224f StayExportTracking - Edit StayEntry UploadStatus
- Page Details - Added UI to edit UploadStatus.
- Page List - Filter by UploadStatus.
2026-10-07 13:33:24 +02:00
Daniel-Garmig 2f0062b313 StayExportTracking - Changes to Models
- Added new fields to track stay export uploading.
- Added methods in EntityServices to update this fields.
- Show new fields in UI (with required locale).
2026-10-06 14:34:58 +02:00
37 changed files with 1690 additions and 105 deletions

No files matched your search

@@ -0,0 +1,12 @@
<MudText Typo="@TextTypo" Align="Align.Center">
@Title
</MudText>
<MudDivider DividerType="DividerType.Middle" Class="mb-4" />
@code {
[Parameter, EditorRequired]
public string Title { get; set; }
[Parameter]
public Typo TextTypo { get; set; } = Typo.subtitle1;
}
@@ -0,0 +1,62 @@
@using Somnia.GuestLog.Enums.Models
@using Somnia.GuestLog.Models.DTOs
@using Somnia.GuestLog.Services
@inject ILocalizerService Localizer;
<MudDialog>
<TitleContent>
@LanguageLocale.control_UploadStatusSelectorDialog_dialogTitle
</TitleContent>
<DialogContent>
<MudTextField Value="@Localizer.GetEnumValue(CurrentStatus)"
Label="@LanguageLocale.control_UploadStatusSelectorDialog_lbCurrentStatus" FullWidth ReadOnly="true" />
<MudSelect @bind-Value="selectedStatus"
Label="@LanguageLocale.control_UploadStatusSelectorDialog_lbSelectStatus" FullWidth Clearable Required
Error="selectErrorText != null" ErrorText="@selectErrorText">
@foreach (UploadStatus option in Enum.GetValues<UploadStatus>())
{
<MudSelectItem Value="new Nullable<UploadStatus>(option)">
@Localizer.GetEnumValue(option)
</MudSelectItem>
}
</MudSelect>
</DialogContent>
<DialogActions>
<MudButton OnClick="Cancel">
@LanguageLocale.general_btnCancel
</MudButton>
<MudButton Color="Color.Primary" OnClick="Submit">
@LanguageLocale.general_btnSave
</MudButton>
</DialogActions>
</MudDialog>
@code {
[CascadingParameter]
private IMudDialogInstance MudDialog { get; set; } = null!;
[Parameter]
public UploadStatus CurrentStatus { get; set; } = new();
private UploadStatus? selectedStatus = null;
private string? selectErrorText = null;
private void Cancel() => MudDialog.Cancel();
private void Submit()
{
if (selectedStatus == null || selectedStatus == CurrentStatus)
{
selectErrorText = LanguageLocale.general_validation_invalidOption;
return;
}
//Clear errors.
selectErrorText = null;
DialogResult dialogResult = DialogResult.Ok<UploadStatus>(selectedStatus.Value);
MudDialog.Close(dialogResult);
}
}
@@ -1,8 +1,10 @@
@using System.ComponentModel @using System.ComponentModel
@using Somnia.GuestLog.Enums.Models
@using Somnia.GuestLog.Models.DTOs @using Somnia.GuestLog.Models.DTOs
@using Somnia.GuestLog.Services @using Somnia.GuestLog.Services
@inject IDataListService dataListService; @inject IDataListService dataListService;
@inject ILocalizerService Localizer;
<MudForm Model="@Filter" IsTouchedChanged="@(() => FilterChanged.InvokeAsync(Filter))"> <MudForm Model="@Filter" IsTouchedChanged="@(() => FilterChanged.InvokeAsync(Filter))">
<MudStack Row Breakpoint="Breakpoint.LgAndDown" StretchItems="StretchItems.All"> <MudStack Row Breakpoint="Breakpoint.LgAndDown" StretchItems="StretchItems.All">
@@ -26,6 +28,15 @@
</MudSelectItem> </MudSelectItem>
} }
</MudSelect> </MudSelect>
<MudSelect @bind-Value="Filter.StayUploadStatus" Label="@LanguageLocale.dto_StayEntry_StayUploadStatus"
FullWidth Clearable>
@foreach (UploadStatus option in Enum.GetValues<UploadStatus>())
{
<MudSelectItem Value="new Nullable<UploadStatus>(option)">
@Localizer.GetEnumValue(option)
</MudSelectItem>
}
</MudSelect>
</MudStack> </MudStack>
</MudStack> </MudStack>
</MudForm> </MudForm>
@@ -7,18 +7,16 @@
@inject IDataListService dataListService; @inject IDataListService dataListService;
@inject IValidator<StayEntryDTO> stayValidator; @inject IValidator<StayEntryDTO> stayValidator;
@inject IDialogService dialogService; @inject IDialogService dialogService;
@inject IUserMessageService userMessage @inject IUserMessageService userMessage;
@inject ILocalizerService Localizer;
<MudForm @ref="@_form" Model="@Model" Validation="@((stayValidator as StayEntryDTOValidator)!.ValidateValue)" <MudForm @ref="@_form" Model="@Model" Validation="@((stayValidator as StayEntryDTOValidator)!.ValidateValue)"
ReadOnly="@ReadOnly"> ReadOnly="@ReadOnly">
<MudGrid> <MudGrid>
<MudItem xs="12" xl=6> <MudItem xs="12" sm="@stayDetailPanelSize">
<MudPaper Class="pa-4" Elevation="3" Height="100%"> <MudPaper Class="pa-4" Elevation="3" Height="100%">
<MudText Typo="Typo.subtitle1" Align="Align.Center"> <SectionTitle Title="@LanguageLocale.control_StayEntryForm_sectionDetails" />
@LanguageLocale.control_StayEntryForm_sectionDetails
</MudText>
<MudDivider DividerType="DividerType.Middle" Class="mb-4" />
<MudStack Row style="@FieldMarginY"> <MudStack Row style="@FieldMarginY">
<MudDatePicker Date="Model.DateIn" For="@(() => Model.DateIn)" <MudDatePicker Date="Model.DateIn" For="@(() => Model.DateIn)"
@@ -52,12 +50,25 @@
</MudStack> </MudStack>
</MudPaper> </MudPaper>
</MudItem> </MudItem>
<MudItem xs="12" xl=6> @if (FormMode == FormMode.ReadOnly)
{
<MudItem xs="12" sm="3">
<MudPaper Class="pa-4" Elevation="3" Height="100%">
<SectionTitle Title="@LanguageLocale.control_StayEntryForm_sectionUploadStatus" />
<MudTextField Value="@Localizer.GetEnumValue(Model.StayUploadStatus)"
Label="@LanguageLocale.dto_StayEntry_StayUploadStatus" FullWidth ReadOnly />
@if (Model.StayUploadStatusTime != null)
{
<MudTextField @bind-Value="Model.StayUploadStatusTime" For="@(() => Model.StayUploadStatusTime)"
Label="@LanguageLocale.dto_StayEntry_StayUploadStatusTime" FullWidth ReadOnly />
}
</MudPaper>
</MudItem>
}
<MudItem xs="12" xl="12">
<MudPaper Class="pa-4" Elevation="3" Height="100%" Width="100%"> <MudPaper Class="pa-4" Elevation="3" Height="100%" Width="100%">
<MudText Typo="Typo.subtitle1" Align="Align.Center"> <SectionTitle Title="@LanguageLocale.control_StayEntryForm_sectionGuests" />
@LanguageLocale.control_StayEntryForm_sectionGuests
</MudText>
<MudDivider DividerType="DividerType.Middle" Class="mb-4" />
@if (!ReadOnly) @if (!ReadOnly)
{ {
@@ -124,6 +135,7 @@
private bool ReadOnly => FormMode == FormMode.ReadOnly; private bool ReadOnly => FormMode == FormMode.ReadOnly;
private int stayDetailPanelSize => FormMode == FormMode.ReadOnly ? 9 : 12;
private MudForm _form = null!; private MudForm _form = null!;
@@ -149,7 +149,7 @@
{ {
Debug.Assert(_isEditMode == false); Debug.Assert(_isEditMode == false);
userMessage.ShowMessage(LanguageLocale.page_GuestDocDetail_msgEditEnabled, MessageKind.Normal); userMessage.ShowMessage(LanguageLocale.general_msgEditEnabled, MessageKind.Normal);
_isEditMode = true; _isEditMode = true;
} }
@@ -158,7 +158,7 @@
Debug.Assert(_isEditMode == true); Debug.Assert(_isEditMode == true);
var result = await DialogService.ShowMessageBoxAsync( var result = await DialogService.ShowMessageBoxAsync(
LanguageLocale.general_confirmTitle, LanguageLocale.page_GuestDocDetail_msgConfirmCancelEdit, LanguageLocale.general_confirmTitle, LanguageLocale.general_msgConfirmCancelEdit,
yesText: "OK", cancelText: LanguageLocale.general_btnCancel); yesText: "OK", cancelText: LanguageLocale.general_btnCancel);
if (result == null || result.Value == false) if (result == null || result.Value == false)
@@ -179,7 +179,7 @@
Debug.Assert(_isEditMode == true && documentModel is not null); Debug.Assert(_isEditMode == true && documentModel is not null);
var confirmResult = await DialogService.ShowMessageBoxAsync( var confirmResult = await DialogService.ShowMessageBoxAsync(
LanguageLocale.general_confirmTitle, LanguageLocale.page_GuestDocDetail_msgConfirmSaveEdit, LanguageLocale.general_confirmTitle, LanguageLocale.general_msgConfirmSaveEdit,
yesText: "OK", cancelText: LanguageLocale.general_btnCancel); yesText: "OK", cancelText: LanguageLocale.general_btnCancel);
if (confirmResult == null || confirmResult.Value == false) if (confirmResult == null || confirmResult.Value == false)
@@ -195,7 +195,7 @@
Result updateResult = await guestDocService.UpdateDocumentAsync(documentModel); Result updateResult = await guestDocService.UpdateDocumentAsync(documentModel);
if (!updateResult.IsSuccess) if (!updateResult.IsSuccess)
{ {
string errorMsg = string.Format(LanguageLocale.page_GuestDocDetail_msgEditError, documentModel.FullDocument); string errorMsg = string.Format(LanguageLocale.general_msgEditError, documentModel.FullDocument);
userMessage.ShowResultWithMessage(updateResult, errorMsg); userMessage.ShowResultWithMessage(updateResult, errorMsg);
loadingDialog.Close(); loadingDialog.Close();
return; return;
@@ -1,5 +1,6 @@
@attribute [Route($"{GuestConsts.Page_StayEntry_Detail}")] @attribute [Route($"{GuestConsts.Page_StayEntry_Detail}")]
@using Somnia.GuestLog.Enums.Models
@using Somnia.GuestLog.Models.DTOs; @using Somnia.GuestLog.Models.DTOs;
@using Somnia.GuestLog.Services; @using Somnia.GuestLog.Services;
@@ -8,27 +9,67 @@
@inject NavigationManager Navigation @inject NavigationManager Navigation
@inject IGuestDocumentEntityService guestDocService @inject IGuestDocumentEntityService guestDocService
@inject IStayEntryEntityService stayService @inject IStayEntryEntityService stayService
@inject ILocalizerService Localizer;
<PageTitle>Somnia - Guest Docs - Details</PageTitle> <PageTitle>Somnia - Stays - Details</PageTitle>
<MudStack Row="true" Class="my-4"> <MudStack Row="true" Class="my-4">
<MudText Typo="Typo.h4" GutterBottom="true">Stay Entry - "@StayId"</MudText> <MudText Typo="Typo.h4" GutterBottom="true">
@LanguageLocale.page_StayEntryDetail_pageTitle - "@StayId"
</MudText>
<MudSpacer /> <MudSpacer />
@if (_isEditMode)
{
<MudButton Variant="Variant.Filled" Color="Color.Error" Size="Size.Small" StartIcon="@Icons.Material.Filled.Cancel"
OnClick="() => BtnCancelEdit()" Disabled="!_isEditMode">
@LanguageLocale.general_btnCancel
</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Success" Size="Size.Small" StartIcon="@Icons.Material.Filled.Save"
OnClick="() => BtnSaveEdit()" Disabled="!_isEditMode">
@LanguageLocale.general_btnSave
</MudButton>
}
@if (!_isEditMode)
{
<MudButton Variant="Variant.Filled" Color="Color.Success" Size="Size.Small" StartIcon="@Icons.Material.Filled.Edit" <MudButton Variant="Variant.Filled" Color="Color.Success" Size="Size.Small" StartIcon="@Icons.Material.Filled.Edit"
OnClick="() => BtnEdit()" Disabled> OnClick="() => BtnEnableEdit()" Disabled="_isEditMode">
@LanguageLocale.general_btnEdit @LanguageLocale.general_btnEdit
</MudButton> </MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Default" Size="Size.Small" <MudButton Variant="Variant.Filled" Color="Color.Default" Size="Size.Small"
StartIcon="@Icons.Material.Filled.ArrowBack" OnClick="() => BtnReturn()"> StartIcon="@Icons.Material.Filled.ArrowBack" OnClick="() => BtnReturn()">
@LanguageLocale.general_btnReturn @LanguageLocale.general_btnReturn
</MudButton> </MudButton>
}
</MudStack> </MudStack>
@if (stayModel is not null) @if (stayModel is not null)
{ {
<StayEntryForm Model="stayModel" FormMode="FormMode.ReadOnly" /> <StayEntryForm Model="stayModel" FormMode="@_formFormMode" />
<MudText Class="mt-4">@CreateTimeString</MudText>
@if (!_isEditMode)
{
<MudGrid Class="mt-6">
<MudItem xs="6" md="3">
<MudPaper Class="pa-4" Elevation="3" Height="100%">
<MudStack Style="margin-block: 0.5em;">
<MudTextField @bind-Value="stayModel.CreateTime" Label="@LanguageLocale.dto_StayEntry_CreateTime"
FullWidth ReadOnly />
<MudTextField @bind-Value="stayModel.UpdateTime" Label="@LanguageLocale.dto_StayEntry_UpdateTime"
FullWidth ReadOnly />
</MudStack>
</MudPaper>
</MudItem>
<MudItem xs="6" md="3">
<MudPaper Class="pa-4" Elevation="3" Height="100%">
<SectionTitle Title="Actions" />
<MudButton FullWidth OnClick="BtnUpdateUploadStatus">
@LanguageLocale.page_StayEntryList_btnUpdateUploadStatus
</MudButton>
</MudPaper>
</MudItem>
</MudGrid>
}
} }
@@ -42,21 +83,10 @@
StayEntryDTO? stayModel = null; StayEntryDTO? stayModel = null;
private string? CreateTimeString
{
get
{
if (stayModel is null)
{
return null;
}
List<string> textList = []; private bool _isEditMode = false;
textList.Add($"Created at: {stayModel.CreateTime?.ToString() ?? "???"}"); private FormMode _formFormMode => _isEditMode ? FormMode.Edit : FormMode.ReadOnly;
textList.Add($"Last Update Time: {stayModel.UpdateTime?.ToString() ?? "???"}");
return string.Join("; ", textList);
}
}
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@@ -67,6 +97,11 @@
return; return;
} *@ } *@
await LoadModelAsync();
}
private async Task LoadModelAsync()
{
//Get model from db. //Get model from db.
stayModel = await stayService.GetDtoByIdAsync(StayId, queryConfig: new(IncludeGuests: true)); stayModel = await stayService.GetDtoByIdAsync(StayId, queryConfig: new(IncludeGuests: true));
if (stayModel is null) if (stayModel is null)
@@ -77,15 +112,148 @@
} }
} }
private void BtnEdit()
#region Event Handlers
private void BtnEnableEdit()
{ {
userMessage.ShowMessage("Not implemented yet!", MessageKind.Info); Debug.Assert(_isEditMode == false && stayModel != null);
if (stayModel.StayUploadStatus == UploadStatus.Uploaded)
{
userMessage.ShowMessage(LanguageLocale.page_StayEntryDetail_cantEditFinalData, MessageKind.Info);
return;
} }
userMessage.ShowMessage(LanguageLocale.general_msgEditEnabled, MessageKind.Normal);
_isEditMode = true;
}
private async Task BtnCancelEdit()
{
Debug.Assert(_isEditMode == true);
var result = await DialogService.ShowMessageBoxAsync(
LanguageLocale.general_confirmTitle, LanguageLocale.general_msgConfirmCancelEdit,
yesText: "OK", cancelText: LanguageLocale.general_btnCancel);
if (result == null || result.Value == false)
{
// Cancel cancel -> Continue with edit.
return;
}
//Cancel edit -> Reload data from DB.
await LoadModelAsync();
userMessage.ShowMessage(LanguageLocale.general_msgEditCanceled, MessageKind.Normal);
_isEditMode = false;
}
private async Task BtnSaveEdit()
{
Debug.Assert(_isEditMode == true && stayModel is not null);
var confirmResult = await DialogService.ShowMessageBoxAsync(
LanguageLocale.general_confirmTitle, LanguageLocale.general_msgConfirmSaveEdit,
yesText: "OK", cancelText: LanguageLocale.general_btnCancel);
if (confirmResult == null || confirmResult.Value == false)
{
// Cancel save -> Continue with edit.
return;
}
//Show Loading dialog...
var loadingDialog = await DialogService.ShowAsync<LoadingDialog>();
//Save edit.
Result updateResult = await stayService.UpdateEntryAsync(stayModel);
if (!updateResult.IsSuccess)
{
string errorMsg = string.Format(LanguageLocale.general_msgEditError, stayModel.Id);
userMessage.ShowResultWithMessage(updateResult, errorMsg);
loadingDialog.Close();
return;
}
//Reload data from DB.
await LoadModelAsync();
loadingDialog.Close();
userMessage.ShowMessage(LanguageLocale.general_msgEditSaved, MessageKind.Success);
_isEditMode = false;
}
private void BtnReturn() private void BtnReturn()
{ {
string uri = ReturnUrl ?? GuestConsts.Page_StayEntry_List; string uri = ReturnUrl ?? GuestConsts.Page_StayEntry_List;
Navigation.NavigateTo(uri); Navigation.NavigateTo(uri);
} }
private async Task BtnUpdateUploadStatus()
{
Debug.Assert(stayModel != null && stayModel.Id != null);
DialogOptions dialogOptions = new()
{
MaxWidth = MaxWidth.Medium,
FullWidth = true,
BackdropClick = true,
CloseOnEscapeKey = true,
};
bool? confirmed = await DialogService.ShowMessageBoxAsync(
title: LanguageLocale.general_confirmTitle,
message: LanguageLocale.general_confirmAdvanceOperationMsg,
yesText: LanguageLocale.general_btnContinue,
noText: LanguageLocale.general_btnCancel,
options: dialogOptions);
if (confirmed == null || confirmed.Value == false)
{
return;
}
var parameters =
new DialogParameters<UploadStatusSelectorDialog> { { x => x.CurrentStatus, stayModel.StayUploadStatus } };
var dialog = await DialogService.ShowAsync<UploadStatusSelectorDialog>(parameters: parameters, options: dialogOptions);
DialogResult? dialogRs = await dialog.Result;
if (dialogRs is null || dialogRs.Canceled)
{
return;
}
UploadStatus? newUploadStatus = await dialog.GetReturnValueAsync<UploadStatus>();
if (newUploadStatus is null)
{
userMessage.ShowMessage("Error! No upload status selected!", MessageKind.Error);
return;
}
var loadingDialog = await DialogService.ShowAsync<LoadingDialog>();
//Update StayEntry
Result rs = await stayService.UpdateEntryUploadStatusAsync(stayModel.Id.Value, newUploadStatus.Value);
if (!rs.IsSuccess)
{
userMessage.ShowResultWithMessage(rs, "Error updating UploadStatus");
loadingDialog.Close();
return;
}
//Reload model.
await LoadModelAsync();
loadingDialog.Close();
string txtNewStatus = Localizer.GetEnumValue(newUploadStatus);
string successMsg = string.Format(LanguageLocale.page_StayEntryDetail_uploadStatusSuccessMsg, txtNewStatus);
userMessage.ShowMessage(successMsg, MessageKind.Success);
}
#endregion
} }
@@ -8,6 +8,8 @@
@inject IUserMessageService userMessage @inject IUserMessageService userMessage
@inject IDialogService DialogService @inject IDialogService DialogService
@inject IDataListService dataListService; @inject IDataListService dataListService;
@inject ILocalizerService Localizer;
<PageTitle>Somnia - Stay Entries</PageTitle> <PageTitle>Somnia - Stay Entries</PageTitle>
@@ -46,6 +48,8 @@
Property="x => dataListService.GetLocalizedValue(GuestConsts.DataList_PaymentMethods, x.PaymentMethod)" /> Property="x => dataListService.GetLocalizedValue(GuestConsts.DataList_PaymentMethods, x.PaymentMethod)" />
<PropertyColumn Property="x => x.UpdateTime" Title="@LanguageLocale.dto_GuestDocument_UpdateTime" /> <PropertyColumn Property="x => x.UpdateTime" Title="@LanguageLocale.dto_GuestDocument_UpdateTime" />
<PropertyColumn Property="x => Localizer.GetEnumValue(x.StayUploadStatus)"
Title="@LanguageLocale.dto_StayEntry_StayUploadStatus" />
<TemplateColumn CellClass="d-flex justify-between" Title="Options" StickyRight Hideable="false" <TemplateColumn CellClass="d-flex justify-between" Title="Options" StickyRight Hideable="false"
ShowColumnOptions="false"> ShowColumnOptions="false">
@@ -124,6 +128,12 @@
private async Task BtnDeleteItem(StayEntryDTO item) private async Task BtnDeleteItem(StayEntryDTO item)
{ {
if (item.StayUploadStatus == Enums.Models.UploadStatus.Uploaded)
{
userMessage.ShowMessage(LanguageLocale.page_StayEntryList_msgDeleteUploadedStay, MessageKind.Warning);
return;
}
bool? confirmDelete = await _confirmDeleteMsgBox.MsgBox.ShowAsync(); bool? confirmDelete = await _confirmDeleteMsgBox.MsgBox.ShowAsync();
if (confirmDelete is null || confirmDelete.Value == false) if (confirmDelete is null || confirmDelete.Value == false)
@@ -1,6 +1,7 @@
@attribute [Route($"{GuestConsts.Page_StayExport_List}")] @attribute [Route($"{GuestConsts.Page_StayExport_List}")]
@using System.Text.Json; @using System.Text.Json;
@using Somnia.GuestLog.Enums.Models
@using Somnia.GuestLog.Models.DTOs; @using Somnia.GuestLog.Models.DTOs;
@using Somnia.GuestLog.Services; @using Somnia.GuestLog.Services;
@using Somnia.GuestLog.Services.StayExport; @using Somnia.GuestLog.Services.StayExport;
@@ -59,12 +60,18 @@
OnClick="() => ShowExportDetails(context.Item)" /> OnClick="() => ShowExportDetails(context.Item)" />
</CellTemplate> </CellTemplate>
</TemplateColumn> </TemplateColumn>
<PropertyColumn Property="x => Localizer.GetEnumValue(x.FileUploadStatus)"
Title="@LanguageLocale.dto_StayExportFile_FileUploadStatus" />
<PropertyColumn Property="x => x.FileUploadStatusTime"
Title="@LanguageLocale.dto_StayExportFile_FileUploadStatusTime" />
<TemplateColumn CellClass="d-flex justify-between" Title="Options" StickyRight Hideable="false" <TemplateColumn CellClass="d-flex justify-between" Title="Options" StickyRight Hideable="false"
ShowColumnOptions="false"> ShowColumnOptions="false">
<CellTemplate> <CellTemplate>
<MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Download" <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Download"
OnClick="() => BtnDownloadFile(context.Item)" /> OnClick="() => BtnDownloadFile(context.Item)" />
<MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.FileUpload"
OnClick="() => BtnUpdateUploadStatus(context.Item)" />
<MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Delete" <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Delete"
OnClick="() => BtnDeleteItem(context.Item)" /> OnClick="() => BtnDeleteItem(context.Item)" />
</CellTemplate> </CellTemplate>
@@ -86,6 +93,14 @@
private MudDataGrid<StayExportFileDTO> _dataGrid = null!; private MudDataGrid<StayExportFileDTO> _dataGrid = null!;
private ConfirmDeleteMsgBox _confirmDeleteMsgBox = null!; private ConfirmDeleteMsgBox _confirmDeleteMsgBox = null!;
private DialogOptions uploadStatusSelectorDialogOptions = new()
{
MaxWidth = MaxWidth.Medium,
FullWidth = true,
BackdropClick = true,
CloseOnEscapeKey = true,
};
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@@ -128,14 +143,16 @@
private async Task ShowExportDetails(StayExportFileDTO dto) private async Task ShowExportDetails(StayExportFileDTO dto)
{ {
if (string.IsNullOrEmpty(dto.ExportDetails)) if (dto.ExportDetails == null)
{ {
userMessage.ShowMessage("This ExportFile doesn't have any export details", MessageKind.Info); userMessage.ShowMessage("This ExportFile doesn't have any export details", MessageKind.Info);
return; return;
} }
using var jDoc = JsonDocument.Parse(dto.ExportDetails); string jsonDetails = JsonSerializer.Serialize(
string jsonDetails = JsonSerializer.Serialize(jDoc, new JsonSerializerOptions { WriteIndented = true }); value: dto.ExportDetails,
options: new JsonSerializerOptions { WriteIndented = true }
);
await DialogService.ShowMessageBoxAsync("Details", (MarkupString)$"<pre>{jsonDetails}</pre>"); await DialogService.ShowMessageBoxAsync("Details", (MarkupString)$"<pre>{jsonDetails}</pre>");
} }
@@ -173,6 +190,12 @@
private async Task BtnDeleteItem(StayExportFileDTO item) private async Task BtnDeleteItem(StayExportFileDTO item)
{ {
if (item.FileUploadStatus == Enums.Models.UploadStatus.Uploaded)
{
userMessage.ShowMessage(LanguageLocale.page_StayExportList_msgDeleteUploadedFile, MessageKind.Warning);
return;
}
bool? confirmDelete = await _confirmDeleteMsgBox.MsgBox.ShowAsync(); bool? confirmDelete = await _confirmDeleteMsgBox.MsgBox.ShowAsync();
if (confirmDelete is null || confirmDelete.Value == false) if (confirmDelete is null || confirmDelete.Value == false)
@@ -192,6 +215,74 @@
await LoadDataAsync(); await LoadDataAsync();
} }
private async Task BtnUpdateUploadStatus(StayExportFileDTO item)
{
Debug.Assert(item != null && item.Id != null);
//Check current status.
if (item.FileUploadStatus != UploadStatus.Pending)
{
userMessage.ShowMessage(LanguageLocale.page_StayExportList_editUploadStatus_msgNotPending, MessageKind.Warning);
return;
}
//Show UploadStatus selector dialog.
var parameters =
new DialogParameters<UploadStatusSelectorDialog> { { x => x.CurrentStatus, item.FileUploadStatus } };
var dialog = await DialogService.ShowAsync<UploadStatusSelectorDialog>(
parameters: parameters,
options: uploadStatusSelectorDialogOptions);
DialogResult? dialogRs = await dialog.Result;
if (dialogRs is null || dialogRs.Canceled)
{
return;
}
UploadStatus? newUploadStatus = await dialog.GetReturnValueAsync<UploadStatus>();
if (newUploadStatus is null)
{
userMessage.ShowMessage("Error! No upload status selected!", MessageKind.Error);
return;
}
string txtNewStatus = Localizer.GetEnumValue(newUploadStatus);
string confirmMsg = string.Format(LanguageLocale.page_StayExportList_editUploadStatus_msgConfirm,
item.Id.Value, txtNewStatus);
bool? confirmed = await DialogService.ShowMessageBoxAsync(
title: LanguageLocale.general_confirmTitle,
message: confirmMsg,
yesText: LanguageLocale.general_btnContinue,
noText: LanguageLocale.general_btnCancel,
options: uploadStatusSelectorDialogOptions);
if (confirmed == null || confirmed.Value == false)
{
userMessage.ShowMessage(LanguageLocale.general_msgOperationCanceled, MessageKind.Info);
return;
}
var loadingDialog = await DialogService.ShowAsync<LoadingDialog>();
//Update StayEntry
Result rs = await stayExportEntityService.UpdateStayExportUploadStatusAsync(item.Id.Value, newUploadStatus.Value);
if (!rs.IsSuccess)
{
userMessage.ShowResultWithMessage(rs, "Error updating UploadStatus");
loadingDialog.Close();
return;
}
//Reload model.
await LoadDataAsync();
loadingDialog.Close();
string successMsg = string.Format(LanguageLocale.page_StayExportList_editUploadStatus_msgEditSuccess,
item.Id.Value, txtNewStatus);
userMessage.ShowMessage(successMsg, MessageKind.Success);
}
#endregion #endregion
} }
@@ -59,17 +59,25 @@
</MudSelect> </MudSelect>
</MudStack> </MudStack>
</MudPaper> </MudPaper>
@if (_showPeriodFields) @if (periodFieldsMode != PeriodFieldsMode.NotAllowed)
{ {
<MudPaper Class="pa-4" Elevation="3" Height="100%"> <MudPaper Class="pa-4" Elevation="3" Height="100%">
@if (periodFieldsMode == PeriodFieldsMode.Optional)
{
<MudCheckBox @bind-Value="_showOptionalPeriodFields"
Label="@LanguageLocale.page_StayExportNew_chkShowPeriodFields" />
}
@if (periodFieldsMode == PeriodFieldsMode.Required || _showOptionalPeriodFields)
{
<MudStack Row> <MudStack Row>
<MudDatePicker @bind-Date="exportParams.ExportPeriodStart" For="@(() => exportParams.ExportPeriodStart)" <MudDatePicker @bind-Date="exportParams.ExportPeriodStart" For="@(() => exportParams.ExportPeriodStart)"
Label="@LanguageLocale.dto_StayExportParams_ExportPeriodStart" Clearable OpenTo="OpenTo.Date" Editable Label="@LanguageLocale.dto_StayExportParams_ExportPeriodStart" Clearable OpenTo="OpenTo.Date" Editable
AutoClose="true" /> AutoClose="true" Required="periodFieldsMode == PeriodFieldsMode.Required" />
<MudDatePicker @bind-Date="exportParams.ExportPeriodEnd" For="@(() => exportParams.ExportPeriodEnd)" <MudDatePicker @bind-Date="exportParams.ExportPeriodEnd" For="@(() => exportParams.ExportPeriodEnd)"
Label="@LanguageLocale.dto_StayExportParams_ExportPeriodEnd" Clearable OpenTo="OpenTo.Date" Editable Label="@LanguageLocale.dto_StayExportParams_ExportPeriodEnd" Clearable OpenTo="OpenTo.Date" Editable
AutoClose="true" /> AutoClose="true" Required="periodFieldsMode == PeriodFieldsMode.Required" />
</MudStack> </MudStack>
}
</MudPaper> </MudPaper>
} }
@@ -96,10 +104,19 @@
StayExportParamsDTO exportParams = new(); StayExportParamsDTO exportParams = new();
StayExportFileDTO? exportedFile = null; StayExportFileDTO? exportedFile = null;
bool _showPeriodFields => exportParams.ExportType == StayExportParamType.PeriodDateIn; PeriodFieldsMode periodFieldsMode => exportParams.ExportType switch
{
StayExportParamType.PeriodDateIn => PeriodFieldsMode.Required,
StayExportParamType.UploadPending => PeriodFieldsMode.Optional,
_ => PeriodFieldsMode.NotAllowed
};
bool _showOptionalPeriodFields = false;
bool _isExported => exportedFile != null; bool _isExported => exportedFile != null;
#region Event Handlers
private void BtnReturn() private void BtnReturn()
{ {
Navigation.NavigateTo(GuestConsts.Page_StayExport_List); Navigation.NavigateTo(GuestConsts.Page_StayExport_List);
@@ -110,7 +127,7 @@
await _form.ValidateAsync(); await _form.ValidateAsync();
if (!_form.IsValid || exportFormat == null) if (!_form.IsValid || exportFormat == null)
{ {
userMessage.ShowMessage("Invalid Form!", MessageKind.Warning); userMessage.ShowMessage(LanguageLocale.general_validation_invalidForm, MessageKind.Warning);
return; return;
} }
@@ -122,13 +139,13 @@
if (!exportResult.IsSuccess) if (!exportResult.IsSuccess)
{ {
userMessage.ShowResultWithMessage(exportResult, $"Error exporting stays"); userMessage.ShowResultWithMessage(exportResult, LanguageLocale.general_msgUnknownError);
return; return;
} }
userMessage.ShowMessage( string strExportResult = Localizer.GetEnumValue(exportedFile?.ExportResult);
$"Stay exported: {exportResult.ResultCode} with export result: {exportedFile?.ExportResult}", string strMsg = string.Format(LanguageLocale.page_StayExportNew_msgExportOk, strExportResult);
MessageKind.Success); userMessage.ShowMessage(strMsg, MessageKind.Success);
} }
private async Task BtnDownloadExportedFile() private async Task BtnDownloadExportedFile()
@@ -137,7 +154,7 @@
if (string.IsNullOrEmpty(exportedFile.ExportedPath)) if (string.IsNullOrEmpty(exportedFile.ExportedPath))
{ {
userMessage.ShowMessage("Exported File can't be downloaded as no file was saved", MessageKind.Warning); userMessage.ShowMessage(LanguageLocale.page_StayExportNew_msgDownloadErrorNoFile, MessageKind.Warning);
return; return;
} }
@@ -146,7 +163,7 @@
Result loadResult = await ExportService.GetExportedFileAsync(exportedFile, dataStream); Result loadResult = await ExportService.GetExportedFileAsync(exportedFile, dataStream);
if (!loadResult.IsSuccess) if (!loadResult.IsSuccess)
{ {
userMessage.ShowResultWithMessage(loadResult, "Exported File can't be downloaded"); userMessage.ShowResultWithMessage(loadResult, LanguageLocale.page_StayExportNew_msgDownloadError);
return; return;
} }
@@ -156,7 +173,18 @@
var fileName = Path.GetFileName(exportedFile.ExportedPath); var fileName = Path.GetFileName(exportedFile.ExportedPath);
await JS.InvokeVoidAsync("downloadFileFromStream", fileName, streamRef); await JS.InvokeVoidAsync("downloadFileFromStream", fileName, streamRef);
userMessage.ShowMessage("Exported File downloaded!", MessageKind.Success); userMessage.ShowMessage(LanguageLocale.page_StayExportNew_msgDownloadOk, MessageKind.Success);
} }
#endregion
#region Internal Models
private enum PeriodFieldsMode
{
NotAllowed, Optional, Required
}
#endregion
} }
@@ -0,0 +1,7 @@
namespace Somnia.GuestLog.Enums.Models;
public enum StayExportDetailsStayEntryResult
{
OK = 0,
Error = 1
}
@@ -3,4 +3,5 @@ namespace Somnia.GuestLog.Enums.Models;
public enum StayExportParamType public enum StayExportParamType
{ {
PeriodDateIn = 0, PeriodDateIn = 0,
UploadPending = 1,
} }
@@ -0,0 +1,8 @@
namespace Somnia.GuestLog.Enums.Models;
public enum UploadStatus
{
Pending = 0,
Uploaded = 1,
Skipped = 2,
}
@@ -8,8 +8,11 @@ public enum ResultCode
FailedValidation, FailedValidation,
NotFound, NotFound,
FileStorageError, FileStorageError,
NoPendingChanges,
DataIsFinal,
//Specific Codes //Specific Codes
GuestInStay, GuestInStay,
GuestCurrentlyInStay, GuestCurrentlyInStay,
UploadStatusIsFinal,
} }
@@ -30,6 +30,10 @@ public class StayEntryEntityConfig : IEntityTypeConfiguration<StayEntry>
.IsRequired() .IsRequired()
.HasMaxLength(5); .HasMaxLength(5);
builder.Property(e => e.StayUploadStatus)
.IsRequired();
builder.Property(e => e.StayUploadStatusTime)
.HasColumnType(DbConsts.DbType_Timestamptz);
builder.Property(e => e.CreateTime) builder.Property(e => e.CreateTime)
.IsRequired() .IsRequired()
@@ -25,12 +25,18 @@ public class StayExportFileEntityConfig : IEntityTypeConfiguration<StayExportFil
builder.Property(e => e.ExportedPath) builder.Property(e => e.ExportedPath)
.HasMaxLength(256); .HasMaxLength(256);
builder.Property(e => e.ExportDetails) builder.ComplexProperty(e => e.ExportDetails, e =>
.HasColumnType(DbConsts.DbType_jsonb); {
e.ToJson();
});
builder.Property(e => e.ExportTime) builder.Property(e => e.ExportTime)
.IsRequired() .IsRequired()
.HasColumnType(DbConsts.DbType_Timestamptz); .HasColumnType(DbConsts.DbType_Timestamptz);
builder.Property(e => e.FileUploadStatus)
.IsRequired();
builder.Property(e => e.FileUploadStatusTime)
.HasColumnType(DbConsts.DbType_Timestamptz);
} }
} }
@@ -0,0 +1,264 @@
// <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("20261006112835_StayEntry_StayExport_AddUploadStatusFields")]
partial class StayEntry_StayExport_AddUploadStatusFields
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.12")
.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<int>("StayUploadStatus")
.HasColumnType("integer");
b.Property<DateTime?>("StayUploadStatusTime")
.HasColumnType("timestamp with time zone");
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.Property<int>("FileUploadStatus")
.HasColumnType("integer");
b.Property<DateTime?>("FileUploadStatusTime")
.HasColumnType("timestamp with time zone");
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,86 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Somnia.GuestLog.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class StayEntry_StayExport_AddUploadStatusFields : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
// TABLE - StayExportFile
//Create column as nullable
migrationBuilder.AddColumn<int>(
name: "FileUploadStatus",
table: "StayExportFile",
type: "integer",
nullable: true);
//Update all to Pending.
migrationBuilder.Sql("""UPDATE "StayExportFile" SET "FileUploadStatus" = 0;""");
//Alter column to not nullable
migrationBuilder.AlterColumn<int>(
name: "FileUploadStatus",
table: "StayExportFile",
nullable: false,
oldNullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "FileUploadStatusTime",
table: "StayExportFile",
type: "timestamp with time zone",
nullable: true);
// TABLE - StayEntry
//Create column as nullable
migrationBuilder.AddColumn<int>(
name: "StayUploadStatus",
table: "StayEntry",
type: "integer",
nullable: true);
//Update all to Pending.
migrationBuilder.Sql("""UPDATE "StayEntry" SET "StayUploadStatus" = 0;""");
//Alter column to not nullable
migrationBuilder.AlterColumn<int>(
name: "StayUploadStatus",
table: "StayEntry",
nullable: false,
oldNullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "StayUploadStatusTime",
table: "StayEntry",
type: "timestamp with time zone",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "FileUploadStatus",
table: "StayExportFile");
migrationBuilder.DropColumn(
name: "FileUploadStatusTime",
table: "StayExportFile");
migrationBuilder.DropColumn(
name: "StayUploadStatus",
table: "StayEntry");
migrationBuilder.DropColumn(
name: "StayUploadStatusTime",
table: "StayEntry");
}
}
}
@@ -0,0 +1,283 @@
// <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("20261009104234_StayExportFile_ExportDetails_UpdatedFormat")]
partial class StayExportFile_ExportDetails_UpdatedFormat
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.12")
.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<int>("StayUploadStatus")
.HasColumnType("integer");
b.Property<DateTime?>("StayUploadStatusTime")
.HasColumnType("timestamp with time zone");
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<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.Property<int>("FileUploadStatus")
.HasColumnType("integer");
b.Property<DateTime?>("FileUploadStatusTime")
.HasColumnType("timestamp with time zone");
b.ComplexProperty(typeof(Dictionary<string, object>), "ExportDetails", "Somnia.GuestLog.Models.Entities.StayExportFile.ExportDetails#StayExportDetails", b1 =>
{
b1.Property<int?>("ExportedStayCount");
b1.Property<int?>("StayErrorCount");
b1.ComplexCollection(typeof(List<Dictionary<string, object>>), "StayEntries", "Somnia.GuestLog.Models.Entities.StayExportFile.ExportDetails#StayExportDetails.StayEntries#StayExportDetailsStayEntry", b2 =>
{
b2.IsRequired();
b2.Property<string>("Details");
b2.Property<int>("ExportResult");
b2.Property<long>("StayEntryId");
});
b1
.ToJson("ExportDetails")
.HasColumnType("jsonb");
});
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,23 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Somnia.GuestLog.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class StayExportFile_ExportDetails_UpdatedFormat : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
//Update all StayExportFiles ExportDetails to NULL to prevent format errors when parsing the new types.
migrationBuilder.Sql("""UPDATE "StayExportFile" SET "ExportDetails" = NULL;""");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
//Nothing to do. Data can't be recovered!
}
}
}
@@ -18,7 +18,7 @@ namespace Somnia.GuestLog.Infrastructure.Migrations
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "10.0.7") .HasAnnotation("ProductVersion", "10.0.12")
.HasAnnotation("Proxies:ChangeTracking", false) .HasAnnotation("Proxies:ChangeTracking", false)
.HasAnnotation("Proxies:CheckEquality", false) .HasAnnotation("Proxies:CheckEquality", false)
.HasAnnotation("Proxies:LazyLoading", true) .HasAnnotation("Proxies:LazyLoading", true)
@@ -177,6 +177,12 @@ namespace Somnia.GuestLog.Infrastructure.Migrations
.HasMaxLength(32) .HasMaxLength(32)
.HasColumnType("character varying(32)"); .HasColumnType("character varying(32)");
b.Property<int>("StayUploadStatus")
.HasColumnType("integer");
b.Property<DateTime?>("StayUploadStatusTime")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("UpdateTime") b.Property<DateTime>("UpdateTime")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp with time zone");
@@ -193,9 +199,6 @@ namespace Somnia.GuestLog.Infrastructure.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<string>("ExportDetails")
.HasColumnType("jsonb");
b.Property<int>("ExportFormat") b.Property<int>("ExportFormat")
.HasColumnType("integer"); .HasColumnType("integer");
@@ -209,6 +212,34 @@ namespace Somnia.GuestLog.Infrastructure.Migrations
.HasMaxLength(256) .HasMaxLength(256)
.HasColumnType("character varying(256)"); .HasColumnType("character varying(256)");
b.Property<int>("FileUploadStatus")
.HasColumnType("integer");
b.Property<DateTime?>("FileUploadStatusTime")
.HasColumnType("timestamp with time zone");
b.ComplexProperty(typeof(Dictionary<string, object>), "ExportDetails", "Somnia.GuestLog.Models.Entities.StayExportFile.ExportDetails#StayExportDetails", b1 =>
{
b1.Property<int?>("ExportedStayCount");
b1.Property<int?>("StayErrorCount");
b1.ComplexCollection(typeof(List<Dictionary<string, object>>), "StayEntries", "Somnia.GuestLog.Models.Entities.StayExportFile.ExportDetails#StayExportDetails.StayEntries#StayExportDetailsStayEntry", b2 =>
{
b2.IsRequired();
b2.Property<string>("Details");
b2.Property<int>("ExportResult");
b2.Property<long>("StayEntryId");
});
b1
.ToJson("ExportDetails")
.HasColumnType("jsonb");
});
b.ComplexProperty(typeof(Dictionary<string, object>), "ExportParams", "Somnia.GuestLog.Models.Entities.StayExportFile.ExportParams#StayExportParams", b1 => b.ComplexProperty(typeof(Dictionary<string, object>), "ExportParams", "Somnia.GuestLog.Models.Entities.StayExportFile.ExportParams#StayExportParams", b1 =>
{ {
b1.IsRequired(); b1.IsRequired();
@@ -1,3 +1,5 @@
using Somnia.GuestLog.Enums.Models;
namespace Somnia.GuestLog.Models.DTOs; namespace Somnia.GuestLog.Models.DTOs;
public class StayEntryDTO public class StayEntryDTO
@@ -12,6 +14,10 @@ public class StayEntryDTO
public string? PaymentMethod { get; set; } public string? PaymentMethod { get; set; }
public UploadStatus StayUploadStatus { get; set; }
public DateTime? StayUploadStatusTime { get; set; }
public List<GuestDocumentDTO>? GuestDocuments { get; set; } = null; public List<GuestDocumentDTO>? GuestDocuments { get; set; } = null;
@@ -1,3 +1,5 @@
using Somnia.GuestLog.Enums.Models;
namespace Somnia.GuestLog.Models.DTOs; namespace Somnia.GuestLog.Models.DTOs;
public class StayEntryFilterDTO public class StayEntryFilterDTO
@@ -7,4 +9,6 @@ public class StayEntryFilterDTO
public string? RoomNumber { get; set; } public string? RoomNumber { get; set; }
public string? PaymentMethod { get; set; } public string? PaymentMethod { get; set; }
public UploadStatus? StayUploadStatus { get; set; }
} }
@@ -14,10 +14,14 @@ public class StayExportFileDTO
public string? ExportedPath { get; set; } public string? ExportedPath { get; set; }
public string? ExportDetails { get; set; } public StayExportDetailsDTO? ExportDetails { get; set; }
public DateTime? ExportTime { get; set; } public DateTime? ExportTime { get; set; }
public UploadStatus FileUploadStatus { get; set; }
public DateTime? FileUploadStatusTime { get; set; }
} }
public class StayExportParamsDTO public class StayExportParamsDTO
@@ -27,3 +31,18 @@ public class StayExportParamsDTO
public DateTime? ExportPeriodStart { get; set; } public DateTime? ExportPeriodStart { get; set; }
public DateTime? ExportPeriodEnd { get; set; } public DateTime? ExportPeriodEnd { get; set; }
} }
public class StayExportDetailsDTO
{
public int? ExportedStayCount { get; set; }
public int? StayErrorCount { get; set; }
public List<StayExportDetailsStayEntryDTO> StayEntries { get; set; } = [];
}
public class StayExportDetailsStayEntryDTO
{
public required long StayEntryId { get; set; }
public required StayExportDetailsStayEntryResult ExportResult { get; set; }
public string? Details { get; set; }
}
@@ -1,3 +1,5 @@
using Somnia.GuestLog.Enums.Models;
namespace Somnia.GuestLog.Models.Entities; namespace Somnia.GuestLog.Models.Entities;
public class StayEntry : BaseEntity public class StayEntry : BaseEntity
@@ -12,6 +14,19 @@ public class StayEntry : BaseEntity
public required string PaymentMethod { get; set; } public required string PaymentMethod { get; set; }
/// <summary>
/// StayEntry upload status to upstream system.
/// </summary>
public required UploadStatus StayUploadStatus { get; set; }
/// <summary>
/// Date/Time of last StayUploadStatus update
/// Will be null when status hadn't been updated
/// </summary>
public DateTime? StayUploadStatusTime { get; set; }
public virtual ICollection<GuestDocument> GuestDocuments { get; } = []; public virtual ICollection<GuestDocument> GuestDocuments { get; } = [];
@@ -0,0 +1,27 @@
using Somnia.GuestLog.Enums.Models;
using Somnia.GuestLog.Infrastructure;
namespace Somnia.GuestLog.Models.Entities;
/// <summary>
/// This class store details and extra information about the exported data of a StayExportFile.
/// </summary>
public class StayExportDetails : BaseEntity
{
public int? ExportedStayCount { get; set; }
public int? StayErrorCount { get; set; }
public List<StayExportDetailsStayEntry> StayEntries { get; set; } = [];
public override string GetFullKey() => DbConsts.PK_NotApply;
}
/// <summary>
/// Export details for each exported stayEntry in a StayExportFile.
/// </summary>
public class StayExportDetailsStayEntry
{
public required long StayEntryId { get; set; }
public required StayExportDetailsStayEntryResult ExportResult { get; set; }
public string? Details { get; set; }
}
@@ -21,7 +21,7 @@ public class StayExportFile : BaseEntity
/// A JSON column to store details about the exported file. /// A JSON column to store details about the exported file.
/// This details can contain information about errors, which stays where included, etc. /// This details can contain information about errors, which stays where included, etc.
/// </summary> /// </summary>
public string? ExportDetails { get; set; } public StayExportDetails? ExportDetails { get; set; }
/// <summary> /// <summary>
/// Date/Time when export file was generated. /// Date/Time when export file was generated.
@@ -29,5 +29,17 @@ public class StayExportFile : BaseEntity
public required DateTime ExportTime { get; set; } public required DateTime ExportTime { get; set; }
/// <summary>
/// ExportFile upload status to upstream system.
/// </summary>
public required UploadStatus FileUploadStatus { get; set; }
/// <summary>
/// Date/Time of last FileUploadStatus update
/// Will be null when status hadn't been updated
/// </summary>
public DateTime? FileUploadStatusTime { get; set; }
public override string GetFullKey() => $"{Id}"; public override string GetFullKey() => $"{Id}";
} }
+27 -1
View File
@@ -45,6 +45,8 @@ internal static class EntityMapping
RoomCount = entity.RoomCount, RoomCount = entity.RoomCount,
RoomNumber = entity.RoomNumber, RoomNumber = entity.RoomNumber,
PaymentMethod = entity.PaymentMethod, PaymentMethod = entity.PaymentMethod,
StayUploadStatus = entity.StayUploadStatus,
StayUploadStatusTime = entity.StayUploadStatusTime?.ToLocalTime(),
CreateTime = entity.CreateTime.ToLocalTime(), CreateTime = entity.CreateTime.ToLocalTime(),
UpdateTime = entity.UpdateTime.ToLocalTime(), UpdateTime = entity.UpdateTime.ToLocalTime(),
GuestDocuments = includeGuests ? [.. entity.GuestDocuments.Select(e => MapGuestDocumentEntityToDTO(e))] : null, GuestDocuments = includeGuests ? [.. entity.GuestDocuments.Select(e => MapGuestDocumentEntityToDTO(e))] : null,
@@ -60,6 +62,28 @@ internal static class EntityMapping
ExportPeriodEnd = entity.ExportParams.ExportPeriodEnd, ExportPeriodEnd = entity.ExportParams.ExportPeriodEnd,
}; };
StayExportDetailsDTO? detailsDTO = null;
if (entity.ExportDetails != null)
{
List<StayExportDetailsStayEntryDTO> entriesDto = [];
foreach (var entry in entity.ExportDetails.StayEntries)
{
entriesDto.Add(new()
{
StayEntryId = entry.StayEntryId,
ExportResult = entry.ExportResult,
Details = entry.Details,
});
}
detailsDTO = new()
{
ExportedStayCount = entity.ExportDetails.ExportedStayCount,
StayErrorCount = entity.ExportDetails.StayErrorCount,
StayEntries = entriesDto,
};
}
return new() return new()
{ {
Id = entity.Id, Id = entity.Id,
@@ -67,8 +91,10 @@ internal static class EntityMapping
ExportParams = exportParamsDto, ExportParams = exportParamsDto,
ExportResult = entity.ExportResult, ExportResult = entity.ExportResult,
ExportedPath = entity.ExportedPath, ExportedPath = entity.ExportedPath,
ExportDetails = entity.ExportDetails, ExportDetails = detailsDTO,
ExportTime = entity.ExportTime.ToLocalTime(), ExportTime = entity.ExportTime.ToLocalTime(),
FileUploadStatus = entity.FileUploadStatus,
FileUploadStatusTime = entity.FileUploadStatusTime?.ToLocalTime(),
}; };
} }
@@ -153,6 +153,8 @@
<data name="dto.StayEntry.GuestDocuments" xml:space="preserve"><value>Huéspedes</value></data> <data name="dto.StayEntry.GuestDocuments" xml:space="preserve"><value>Huéspedes</value></data>
<data name="dto.StayEntry.CreateTime" xml:space="preserve"><value>Fecha Creación</value></data> <data name="dto.StayEntry.CreateTime" xml:space="preserve"><value>Fecha Creación</value></data>
<data name="dto.StayEntry.UpdateTime" xml:space="preserve"><value>Fecha Modificación</value></data> <data name="dto.StayEntry.UpdateTime" xml:space="preserve"><value>Fecha Modificación</value></data>
<data name="dto.StayEntry.StayUploadStatus" xml:space="preserve"><value>Estado Envío</value></data>
<data name="dto.StayEntry.StayUploadStatusTime" xml:space="preserve"><value>Fecha Envío</value></data>
<data name="dto.StayExportFile.Id" xml:space="preserve"><value>Id</value></data> <data name="dto.StayExportFile.Id" xml:space="preserve"><value>Id</value></data>
<data name="dto.StayExportFile.ExportFormat" xml:space="preserve"><value>Formato Exportación</value></data> <data name="dto.StayExportFile.ExportFormat" xml:space="preserve"><value>Formato Exportación</value></data>
@@ -161,6 +163,8 @@
<data name="dto.StayExportFile.ExportedPath" xml:space="preserve"><value>Ruta Exportación</value></data> <data name="dto.StayExportFile.ExportedPath" xml:space="preserve"><value>Ruta Exportación</value></data>
<data name="dto.StayExportFile.ExportDetails" xml:space="preserve"><value>Detalles Exportación</value></data> <data name="dto.StayExportFile.ExportDetails" xml:space="preserve"><value>Detalles Exportación</value></data>
<data name="dto.StayExportFile.ExportTime" xml:space="preserve"><value>Fecha Exportación</value></data> <data name="dto.StayExportFile.ExportTime" xml:space="preserve"><value>Fecha Exportación</value></data>
<data name="dto.StayExportFile.FileUploadStatus" xml:space="preserve"><value>Estado Envío</value></data>
<data name="dto.StayExportFile.FileUploadStatusTime" xml:space="preserve"><value>Fecha Envío</value></data>
<data name="dto.StayExportParams.ExportType" xml:space="preserve"><value>Tipo Exportación</value></data> <data name="dto.StayExportParams.ExportType" xml:space="preserve"><value>Tipo Exportación</value></data>
<data name="dto.StayExportParams.ExportPeriodStart" xml:space="preserve"><value>Fecha Desde</value></data> <data name="dto.StayExportParams.ExportPeriodStart" xml:space="preserve"><value>Fecha Desde</value></data>
@@ -173,6 +177,7 @@
<data name="general.inProgressMsg" xml:space="preserve"><value>En Progreso...</value></data> <data name="general.inProgressMsg" xml:space="preserve"><value>En Progreso...</value></data>
<data name="general.ConfigureColumns" xml:space="preserve"><value>Configurar Columnas</value></data> <data name="general.ConfigureColumns" xml:space="preserve"><value>Configurar Columnas</value></data>
<data name="general.confirmDeleteMsg" xml:space="preserve"><value>¡Eliminar no se puede deshacer!</value></data> <data name="general.confirmDeleteMsg" xml:space="preserve"><value>¡Eliminar no se puede deshacer!</value></data>
<data name="general.confirmAdvanceOperationMsg" xml:space="preserve"><value>Operación Avanzada. Sólo continuar si sabes lo que estás haciendo</value></data>
<data name="general.confirmTitle" xml:space="preserve"><value>¿Confirmar?</value></data> <data name="general.confirmTitle" xml:space="preserve"><value>¿Confirmar?</value></data>
<data name="general.btnDelete" xml:space="preserve"><value>Eliminar</value></data> <data name="general.btnDelete" xml:space="preserve"><value>Eliminar</value></data>
<data name="general.btnCreate" xml:space="preserve"><value>Crear</value></data> <data name="general.btnCreate" xml:space="preserve"><value>Crear</value></data>
@@ -180,8 +185,9 @@
<data name="general.btnReturn" xml:space="preserve"><value>Volver</value></data> <data name="general.btnReturn" xml:space="preserve"><value>Volver</value></data>
<data name="general.btnClose" xml:space="preserve"><value>Cerrar</value></data> <data name="general.btnClose" xml:space="preserve"><value>Cerrar</value></data>
<data name="general.btnSearch" xml:space="preserve"><value>Buscar</value></data> <data name="general.btnSearch" xml:space="preserve"><value>Buscar</value></data>
<data name="general.btnSave" xml:space="preserve"><value>Guaradar</value></data> <data name="general.btnSave" xml:space="preserve"><value>Guardar</value></data>
<data name="general.btnCancel" xml:space="preserve"><value>Cancelar</value></data> <data name="general.btnCancel" xml:space="preserve"><value>Cancelar</value></data>
<data name="general.btnContinue" xml:space="preserve"><value>Continuar</value></data>
<data name="general.noResults" xml:space="preserve"><value>No hay resultados</value></data> <data name="general.noResults" xml:space="preserve"><value>No hay resultados</value></data>
<data name="general.showAllElements" xml:space="preserve"><value>Mostrar todos los elementos</value></data> <data name="general.showAllElements" xml:space="preserve"><value>Mostrar todos los elementos</value></data>
<data name="general.wildcardHelperText" xml:space="preserve"><value>Usa '%' como comodín</value></data> <data name="general.wildcardHelperText" xml:space="preserve"><value>Usa '%' como comodín</value></data>
@@ -190,6 +196,12 @@
<data name="general.loading" xml:space="preserve"><value>Cargando...</value></data> <data name="general.loading" xml:space="preserve"><value>Cargando...</value></data>
<data name="general.msgEditSaved" xml:space="preserve"><value>Cambios Guardados...</value></data> <data name="general.msgEditSaved" xml:space="preserve"><value>Cambios Guardados...</value></data>
<data name="general.msgEditCanceled" xml:space="preserve"><value>¡Edición cancelada!</value></data> <data name="general.msgEditCanceled" xml:space="preserve"><value>¡Edición cancelada!</value></data>
<data name="general.msgOperationCanceled" xml:space="preserve"><value>¡Operación Cancelada!</value></data>
<data name="general.msgEditEnabled" xml:space="preserve"><value>Se ha entrado en modo edición</value></data>
<data name="general.msgConfirmSaveEdit" xml:space="preserve"><value>¿Guardar los cambios?</value></data>
<data name="general.msgConfirmCancelEdit" xml:space="preserve"><value>¿Desea cancelar y salir sin guardar?. ¡Se perderán los cambios!</value></data>
<data name="general.msgEditError" xml:space="preserve"><value>Error al guardar los cambios para la entidad '{0}'</value></data>
<data name="general.msgUnknownError" xml:space="preserve"><value>Se ha producido un error inesperado</value></data>
<data name="general.languageSelector" xml:space="preserve"><value>Idioma</value></data> <data name="general.languageSelector" xml:space="preserve"><value>Idioma</value></data>
<data name="general.address.address" xml:space="preserve"><value>Dirección</value></data> <data name="general.address.address" xml:space="preserve"><value>Dirección</value></data>
@@ -200,6 +212,8 @@
<data name="general.address.zipCode" xml:space="preserve"><value>Código Postal</value></data> <data name="general.address.zipCode" xml:space="preserve"><value>Código Postal</value></data>
<data name="general.validation.invalidFormat" xml:space="preserve"><value>Formato invalido</value></data> <data name="general.validation.invalidFormat" xml:space="preserve"><value>Formato invalido</value></data>
<data name="general.validation.invalidForm" xml:space="preserve"><value>El formulario tiene errores</value></data>
<data name="general.validation.invalidOption" xml:space="preserve"><value>Opción inválida</value></data>
<!-- Common codes --> <!-- Common codes -->
<data name="enum.ResultCode.Ok" xml:space="preserve"><value>OK</value></data> <data name="enum.ResultCode.Ok" xml:space="preserve"><value>OK</value></data>
@@ -207,9 +221,12 @@
<data name="enum.ResultCode.FailedValidation" xml:space="preserve"><value>Fallo de validación de datos</value></data> <data name="enum.ResultCode.FailedValidation" xml:space="preserve"><value>Fallo de validación de datos</value></data>
<data name="enum.ResultCode.NotFound" xml:space="preserve"><value>¡No encontrado!</value></data> <data name="enum.ResultCode.NotFound" xml:space="preserve"><value>¡No encontrado!</value></data>
<data name="enum.ResultCode.FileStorageError" xml:space="preserve"><value>Error de almacenamiento de ficheros</value></data> <data name="enum.ResultCode.FileStorageError" xml:space="preserve"><value>Error de almacenamiento de ficheros</value></data>
<data name="enum.ResultCode.NoPendingChanges" xml:space="preserve"><value>Sin cambios pendientes</value></data>
<data name="enum.ResultCode.DataIsFinal" xml:space="preserve"><value>Datos finales. No se pueden editar o eliminar</value></data>
<!-- Specific codes --> <!-- Specific codes -->
<data name="enum.ResultCode.GuestInStay" xml:space="preserve"><value>Huésped (ID: '{0}') está en una Estancia.</value></data> <data name="enum.ResultCode.GuestInStay" xml:space="preserve"><value>Huésped (ID: '{0}') está en una Estancia.</value></data>
<data name="enum.ResultCode.GuestCurrentlyInStay" xml:space="preserve"><value>Huésped (ID: '{0}') ya está en una estancia en el periodo: {1}</value></data> <data name="enum.ResultCode.GuestCurrentlyInStay" xml:space="preserve"><value>Huésped (ID: '{0}') ya está en una estancia en el periodo: {1}</value></data>
<data name="enum.ResultCode.UploadStatusIsFinal" xml:space="preserve"><value>El estado de envío actual ('{0}') es final y no se puede cambiar</value></data>
<data name="enum.StayExportFileResult.OK" xml:space="preserve"><value>OK</value></data> <data name="enum.StayExportFileResult.OK" xml:space="preserve"><value>OK</value></data>
<data name="enum.StayExportFileResult.NoData" xml:space="preserve"><value>Sin datos</value></data> <data name="enum.StayExportFileResult.NoData" xml:space="preserve"><value>Sin datos</value></data>
@@ -219,7 +236,12 @@
<data name="enum.StayExportFormat.GuestLogJson" xml:space="preserve"><value>GuestLog JSON</value></data> <data name="enum.StayExportFormat.GuestLogJson" xml:space="preserve"><value>GuestLog JSON</value></data>
<data name="enum.StayExportFormat.SpainParteViajeros" xml:space="preserve"><value>Spain Parte Viajeros</value></data> <data name="enum.StayExportFormat.SpainParteViajeros" xml:space="preserve"><value>Spain Parte Viajeros</value></data>
<data name="enum.StayExportParamType.PeriodDateIn" xml:space="preserve"><value>'Date Entrada' Estancia</value></data> <data name="enum.StayExportParamType.PeriodDateIn" xml:space="preserve"><value>'Fecha Entrada' Estancia</value></data>
<data name="enum.StayExportParamType.UploadPending" xml:space="preserve"><value>Estancias pendientes de envío</value></data>
<data name="enum.UploadStatus.Pending" xml:space="preserve"><value>Pendiente</value></data>
<data name="enum.UploadStatus.Uploaded" xml:space="preserve"><value>Enviado</value></data>
<data name="enum.UploadStatus.Skipped" xml:space="preserve"><value>Omitido</value></data>
<data name="navMenu.GuestDocumentList" xml:space="preserve"><value>Huéspedes</value></data> <data name="navMenu.GuestDocumentList" xml:space="preserve"><value>Huéspedes</value></data>
@@ -234,22 +256,32 @@
<data name="page.GuestDocNew.msgAlreadyExists" xml:space="preserve"><value>¡Ya existe un huésped con este documento!</value></data> <data name="page.GuestDocNew.msgAlreadyExists" xml:space="preserve"><value>¡Ya existe un huésped con este documento!</value></data>
<data name="page.GuestDocNew.btnGoExistingDoc" xml:space="preserve"><value>Ver huésped existente</value></data> <data name="page.GuestDocNew.btnGoExistingDoc" xml:space="preserve"><value>Ver huésped existente</value></data>
<data name="page.GuestDocDetail.msgEditEnabled" xml:space="preserve"><value>Se ha entrado en modo edición</value></data>
<data name="page.GuestDocDetail.msgConfirmSaveEdit" xml:space="preserve"><value>Guardar cambios en el documento</value></data>
<data name="page.GuestDocDetail.msgConfirmCancelEdit" xml:space="preserve"><value>Cancelar edición. Se perderán los cambios</value></data>
<data name="page.GuestDocDetail.msgEditError" xml:space="preserve"><value>Error al guardar el documento '{0}'</value></data>
<data name="page.StayEntryList.pageTitle" xml:space="preserve"><value>Lista Estancias</value></data> <data name="page.StayEntryList.pageTitle" xml:space="preserve"><value>Lista Estancias</value></data>
<data name="page.StayEntryList.entryList" xml:space="preserve"><value>Lista Estancias</value></data> <data name="page.StayEntryList.entryList" xml:space="preserve"><value>Lista Estancias</value></data>
<data name="page.StayEntryList.btnNewStay" xml:space="preserve"><value>Nueva Estancia</value></data> <data name="page.StayEntryList.btnNewStay" xml:space="preserve"><value>Nueva Estancia</value></data>
<data name="page.StayEntryList.msgDeleteUploadedStay" xml:space="preserve"><value>No se puede eliminar una estancia que ha sido enviada</value></data>
<data name="page.StayEntryList.btnUpdateUploadStatus" xml:space="preserve"><value>Modificar Estado de envío</value></data>
<data name="page.StayEntryDetail.pageTitle" xml:space="preserve"><value>Estancia</value></data>
<data name="page.StayEntryDetail.cantEditFinalData" xml:space="preserve"><value>Esta estancia no se puede editar: Ya ha sido enviada</value></data>
<data name="page.StayEntryDetail.uploadStatusSuccessMsg" xml:space="preserve"><value>Estado de envío modificado. Nuevo estado: '{0}'</value></data>
<data name="page.StayEntryNew.pageTitle" xml:space="preserve"><value>Nueva Estancia</value></data> <data name="page.StayEntryNew.pageTitle" xml:space="preserve"><value>Nueva Estancia</value></data>
<data name="page.StayExportList.pageTitle" xml:space="preserve"><value>Exportación de Estancias</value></data> <data name="page.StayExportList.pageTitle" xml:space="preserve"><value>Exportación de Estancias</value></data>
<data name="page.StayExportList.exportList" xml:space="preserve"><value>Listado de Exportaciones</value></data> <data name="page.StayExportList.exportList" xml:space="preserve"><value>Listado de Exportaciones</value></data>
<data name="page.StayExportList.btnNewExport" xml:space="preserve"><value>Nueva Exportación</value></data> <data name="page.StayExportList.btnNewExport" xml:space="preserve"><value>Nueva Exportación</value></data>
<data name="page.StayExportList.msgDeleteUploadedFile" xml:space="preserve"><value>No se puede eliminar una exporación que ha sido enviada</value></data>
<data name="page.StayExportList.editUploadStatus.msgNotPending" xml:space="preserve"><value>El estado de envío sólo se puede modificar en ficheros con estado "Pendiente"</value></data>
<data name="page.StayExportList.editUploadStatus.msgConfirm" xml:space="preserve"><value>Seguro que desea actualizar el estado de envío del fichero de exportación ID: '{0}' a estado '{1}'. ¡Esta operación es definitiva y NO se puede deshacer! ¡El estado de envío de las estancias exportadas también será actualidado!</value></data>
<data name="page.StayExportList.editUploadStatus.msgEditSuccess" xml:space="preserve"><value>Fichero Exportación (ID: '{0}'): Estado de envío actualizado al estado: '{1}'</value></data>
<data name="page.StayExportNew.pageTitle" xml:space="preserve"><value>Nueva Exportación de Estancias</value></data> <data name="page.StayExportNew.pageTitle" xml:space="preserve"><value>Nueva Exportación de Estancias</value></data>
<data name="page.StayExportNew.chkShowPeriodFields" xml:space="preserve"><value>Establecer rango de fechas</value></data>
<data name="page.StayExportNew.msgExportOk" xml:space="preserve"><value>Exportación completada con resultado: {0}</value></data>
<data name="page.StayExportNew.msgDownloadError" xml:space="preserve"><value>Error al descargar el fichero</value></data>
<data name="page.StayExportNew.msgDownloadErrorNoFile" xml:space="preserve"><value>No se puede descargar el fichero: Esta exportación no tiene un fichero asociado</value></data>
<data name="page.StayExportNew.msgDownloadOk" xml:space="preserve"><value>Fichero descargado</value></data>
<data name="control.GuestDocForm.sectionDocument" xml:space="preserve"><value>Datos Documento</value></data> <data name="control.GuestDocForm.sectionDocument" xml:space="preserve"><value>Datos Documento</value></data>
@@ -260,6 +292,7 @@
<data name="control.StayEntryForm.sectionDetails" xml:space="preserve"><value>Detalles estancia</value></data> <data name="control.StayEntryForm.sectionDetails" xml:space="preserve"><value>Detalles estancia</value></data>
<data name="control.StayEntryForm.sectionGuests" xml:space="preserve"><value>Lista de Huéspedes</value></data> <data name="control.StayEntryForm.sectionGuests" xml:space="preserve"><value>Lista de Huéspedes</value></data>
<data name="control.StayEntryForm.sectionUploadStatus" xml:space="preserve"><value>Estado de envío</value></data>
<data name="control.StayEntryForm.btnAddGuest" xml:space="preserve"><value>Añadir Huésped</value></data> <data name="control.StayEntryForm.btnAddGuest" xml:space="preserve"><value>Añadir Huésped</value></data>
<data name="control.AddressQueryDialog.dialogTitle" xml:space="preserve"><value>Buscar dirección</value></data> <data name="control.AddressQueryDialog.dialogTitle" xml:space="preserve"><value>Buscar dirección</value></data>
@@ -271,4 +304,8 @@
<data name="control.GuestDocumentSearchDialog.btnSelectDocument" xml:space="preserve"><value>Usar Huésped</value></data> <data name="control.GuestDocumentSearchDialog.btnSelectDocument" xml:space="preserve"><value>Usar Huésped</value></data>
<data name="control.GuestDocumentSearchDialog.txtSuggestedGuests" xml:space="preserve"><value>Huéspedes sugeridos</value></data> <data name="control.GuestDocumentSearchDialog.txtSuggestedGuests" xml:space="preserve"><value>Huéspedes sugeridos</value></data>
<data name="control.UploadStatusSelectorDialog.dialogTitle" xml:space="preserve"><value>Modificar estado de envío</value></data>
<data name="control.UploadStatusSelectorDialog.lbCurrentStatus" xml:space="preserve"><value>Estado de envío actual</value></data>
<data name="control.UploadStatusSelectorDialog.lbSelectStatus" xml:space="preserve"><value>Nuevo estado de envío</value></data>
</root> </root>
@@ -122,6 +122,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089</value> Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="dto.GuestDocument.Id" xml:space="preserve"><value>ID</value></data> <data name="dto.GuestDocument.Id" xml:space="preserve"><value>ID</value></data>
<data name="dto.GuestDocument.Version" xml:space="preserve"><value>Version</value></data> <data name="dto.GuestDocument.Version" xml:space="preserve"><value>Version</value></data>
<data name="dto.GuestDocument.DocumentType" xml:space="preserve"><value>Document Type</value></data> <data name="dto.GuestDocument.DocumentType" xml:space="preserve"><value>Document Type</value></data>
@@ -152,6 +153,8 @@
<data name="dto.StayEntry.GuestDocuments" xml:space="preserve"><value>Guests</value></data> <data name="dto.StayEntry.GuestDocuments" xml:space="preserve"><value>Guests</value></data>
<data name="dto.StayEntry.CreateTime" xml:space="preserve"><value>Creation Time</value></data> <data name="dto.StayEntry.CreateTime" xml:space="preserve"><value>Creation Time</value></data>
<data name="dto.StayEntry.UpdateTime" xml:space="preserve"><value>Update Time</value></data> <data name="dto.StayEntry.UpdateTime" xml:space="preserve"><value>Update Time</value></data>
<data name="dto.StayEntry.StayUploadStatus" xml:space="preserve"><value>Upload Status</value></data>
<data name="dto.StayEntry.StayUploadStatusTime" xml:space="preserve"><value>Upload Status Time</value></data>
<data name="dto.StayExportFile.Id" xml:space="preserve"><value>Id</value></data> <data name="dto.StayExportFile.Id" xml:space="preserve"><value>Id</value></data>
<data name="dto.StayExportFile.ExportFormat" xml:space="preserve"><value>Export Format</value></data> <data name="dto.StayExportFile.ExportFormat" xml:space="preserve"><value>Export Format</value></data>
@@ -160,6 +163,8 @@
<data name="dto.StayExportFile.ExportedPath" xml:space="preserve"><value>Export Path</value></data> <data name="dto.StayExportFile.ExportedPath" xml:space="preserve"><value>Export Path</value></data>
<data name="dto.StayExportFile.ExportDetails" xml:space="preserve"><value>Export Details</value></data> <data name="dto.StayExportFile.ExportDetails" xml:space="preserve"><value>Export Details</value></data>
<data name="dto.StayExportFile.ExportTime" xml:space="preserve"><value>Export Time</value></data> <data name="dto.StayExportFile.ExportTime" xml:space="preserve"><value>Export Time</value></data>
<data name="dto.StayExportFile.FileUploadStatus" xml:space="preserve"><value>Upload Status</value></data>
<data name="dto.StayExportFile.FileUploadStatusTime" xml:space="preserve"><value>Upload Status Time</value></data>
<data name="dto.StayExportParams.ExportType" xml:space="preserve"><value>Export Type</value></data> <data name="dto.StayExportParams.ExportType" xml:space="preserve"><value>Export Type</value></data>
<data name="dto.StayExportParams.ExportPeriodStart" xml:space="preserve"><value>Date From</value></data> <data name="dto.StayExportParams.ExportPeriodStart" xml:space="preserve"><value>Date From</value></data>
@@ -172,6 +177,7 @@
<data name="general.inProgressMsg" xml:space="preserve"><value>In Progress...</value></data> <data name="general.inProgressMsg" xml:space="preserve"><value>In Progress...</value></data>
<data name="general.ConfigureColumns" xml:space="preserve"><value>Configure Columns</value></data> <data name="general.ConfigureColumns" xml:space="preserve"><value>Configure Columns</value></data>
<data name="general.confirmDeleteMsg" xml:space="preserve"><value>Deleting can not be undone!</value></data> <data name="general.confirmDeleteMsg" xml:space="preserve"><value>Deleting can not be undone!</value></data>
<data name="general.confirmAdvanceOperationMsg" xml:space="preserve"><value>Advanced operation. Only proceed if you know what you are doing</value></data>
<data name="general.confirmTitle" xml:space="preserve"><value>Confirm?</value></data> <data name="general.confirmTitle" xml:space="preserve"><value>Confirm?</value></data>
<data name="general.btnDelete" xml:space="preserve"><value>Delete</value></data> <data name="general.btnDelete" xml:space="preserve"><value>Delete</value></data>
<data name="general.btnCreate" xml:space="preserve"><value>Create</value></data> <data name="general.btnCreate" xml:space="preserve"><value>Create</value></data>
@@ -181,6 +187,7 @@
<data name="general.btnSearch" xml:space="preserve"><value>Search</value></data> <data name="general.btnSearch" xml:space="preserve"><value>Search</value></data>
<data name="general.btnSave" xml:space="preserve"><value>Save</value></data> <data name="general.btnSave" xml:space="preserve"><value>Save</value></data>
<data name="general.btnCancel" xml:space="preserve"><value>Cancel</value></data> <data name="general.btnCancel" xml:space="preserve"><value>Cancel</value></data>
<data name="general.btnContinue" xml:space="preserve"><value>Continue</value></data>
<data name="general.noResults" xml:space="preserve"><value>No Results!</value></data> <data name="general.noResults" xml:space="preserve"><value>No Results!</value></data>
<data name="general.showAllElements" xml:space="preserve"><value>Show all elements</value></data> <data name="general.showAllElements" xml:space="preserve"><value>Show all elements</value></data>
<data name="general.wildcardHelperText" xml:space="preserve"><value>Use '%' as wildcard</value></data> <data name="general.wildcardHelperText" xml:space="preserve"><value>Use '%' as wildcard</value></data>
@@ -189,6 +196,12 @@
<data name="general.loading" xml:space="preserve"><value>Loading...</value></data> <data name="general.loading" xml:space="preserve"><value>Loading...</value></data>
<data name="general.msgEditSaved" xml:space="preserve"><value>Changes saved...</value></data> <data name="general.msgEditSaved" xml:space="preserve"><value>Changes saved...</value></data>
<data name="general.msgEditCanceled" xml:space="preserve"><value>Edit Canceled!</value></data> <data name="general.msgEditCanceled" xml:space="preserve"><value>Edit Canceled!</value></data>
<data name="general.msgOperationCanceled" xml:space="preserve"><value>Operation Canceled!</value></data>
<data name="general.msgEditEnabled" xml:space="preserve"><value>Entered Edit mode</value></data>
<data name="general.msgConfirmSaveEdit" xml:space="preserve"><value>Save changes</value></data>
<data name="general.msgConfirmCancelEdit" xml:space="preserve"><value>Cancel edit. Changes will be lost!</value></data>
<data name="general.msgEditError" xml:space="preserve"><value>Error saving changes to db for entity '{0}'</value></data>
<data name="general.msgUnknownError" xml:space="preserve"><value>Unknown error!</value></data>
<data name="general.languageSelector" xml:space="preserve"><value>Language</value></data> <data name="general.languageSelector" xml:space="preserve"><value>Language</value></data>
<data name="general.address.address" xml:space="preserve"><value>Address</value></data> <data name="general.address.address" xml:space="preserve"><value>Address</value></data>
@@ -199,6 +212,8 @@
<data name="general.address.zipCode" xml:space="preserve"><value>Zip Code</value></data> <data name="general.address.zipCode" xml:space="preserve"><value>Zip Code</value></data>
<data name="general.validation.invalidFormat" xml:space="preserve"><value>Invalid Format</value></data> <data name="general.validation.invalidFormat" xml:space="preserve"><value>Invalid Format</value></data>
<data name="general.validation.invalidForm" xml:space="preserve"><value>Invalid Form</value></data>
<data name="general.validation.invalidOption" xml:space="preserve"><value>Invalid Option</value></data>
<!-- Common codes --> <!-- Common codes -->
<data name="enum.ResultCode.Ok" xml:space="preserve"><value>OK</value></data> <data name="enum.ResultCode.Ok" xml:space="preserve"><value>OK</value></data>
@@ -206,9 +221,12 @@
<data name="enum.ResultCode.FailedValidation" xml:space="preserve"><value>Failed entity validation</value></data> <data name="enum.ResultCode.FailedValidation" xml:space="preserve"><value>Failed entity validation</value></data>
<data name="enum.ResultCode.NotFound" xml:space="preserve"><value>Not found</value></data> <data name="enum.ResultCode.NotFound" xml:space="preserve"><value>Not found</value></data>
<data name="enum.ResultCode.FileStorageError" xml:space="preserve"><value>File Storage Error</value></data> <data name="enum.ResultCode.FileStorageError" xml:space="preserve"><value>File Storage Error</value></data>
<data name="enum.ResultCode.NoPendingChanges" xml:space="preserve"><value>No pending changes to apply</value></data>
<data name="enum.ResultCode.DataIsFinal" xml:space="preserve"><value>Data is final. Can't be modified or deleted</value></data>
<!-- Specific codes --> <!-- Specific codes -->
<data name="enum.ResultCode.GuestInStay" xml:space="preserve"><value>Guest (ID: '{0}') is in a stay.</value></data> <data name="enum.ResultCode.GuestInStay" xml:space="preserve"><value>Guest (ID: '{0}') is in a stay.</value></data>
<data name="enum.ResultCode.GuestCurrentlyInStay" xml:space="preserve"><value>Guest (ID: '{0}') is already in one stay during the period: {1}</value></data> <data name="enum.ResultCode.GuestCurrentlyInStay" xml:space="preserve"><value>Guest (ID: '{0}') is already in one stay during the period: {1}</value></data>
<data name="enum.ResultCode.UploadStatusIsFinal" xml:space="preserve"><value>Current upload status ('{0}') is final and can't be changed</value></data>
<data name="enum.StayExportFileResult.OK" xml:space="preserve"><value>OK</value></data> <data name="enum.StayExportFileResult.OK" xml:space="preserve"><value>OK</value></data>
<data name="enum.StayExportFileResult.NoData" xml:space="preserve"><value>No Data</value></data> <data name="enum.StayExportFileResult.NoData" xml:space="preserve"><value>No Data</value></data>
@@ -219,6 +237,11 @@
<data name="enum.StayExportFormat.SpainParteViajeros" xml:space="preserve"><value>Spain Parte Viajeros</value></data> <data name="enum.StayExportFormat.SpainParteViajeros" xml:space="preserve"><value>Spain Parte Viajeros</value></data>
<data name="enum.StayExportParamType.PeriodDateIn" xml:space="preserve"><value>Stay 'Date In' Period</value></data> <data name="enum.StayExportParamType.PeriodDateIn" xml:space="preserve"><value>Stay 'Date In' Period</value></data>
<data name="enum.StayExportParamType.UploadPending" xml:space="preserve"><value>Upload Pending Stays</value></data>
<data name="enum.UploadStatus.Pending" xml:space="preserve"><value>Pending</value></data>
<data name="enum.UploadStatus.Uploaded" xml:space="preserve"><value>Uploaded</value></data>
<data name="enum.UploadStatus.Skipped" xml:space="preserve"><value>Skipped</value></data>
<data name="navMenu.GuestDocumentList" xml:space="preserve"><value>Guests</value></data> <data name="navMenu.GuestDocumentList" xml:space="preserve"><value>Guests</value></data>
@@ -233,22 +256,32 @@
<data name="page.GuestDocNew.msgAlreadyExists" xml:space="preserve"><value>This Guest Document Already exists!!</value></data> <data name="page.GuestDocNew.msgAlreadyExists" xml:space="preserve"><value>This Guest Document Already exists!!</value></data>
<data name="page.GuestDocNew.btnGoExistingDoc" xml:space="preserve"><value>Go to existing document</value></data> <data name="page.GuestDocNew.btnGoExistingDoc" xml:space="preserve"><value>Go to existing document</value></data>
<data name="page.GuestDocDetail.msgEditEnabled" xml:space="preserve"><value>Entered Edit mode</value></data>
<data name="page.GuestDocDetail.msgConfirmSaveEdit" xml:space="preserve"><value>Save changes to GuestDocument</value></data>
<data name="page.GuestDocDetail.msgConfirmCancelEdit" xml:space="preserve"><value>Cancel edit. Changes will be lost!</value></data>
<data name="page.GuestDocDetail.msgEditError" xml:space="preserve"><value>Error saving Document '{0}'</value></data>
<data name="page.StayEntryList.pageTitle" xml:space="preserve"><value>Stay Entries</value></data> <data name="page.StayEntryList.pageTitle" xml:space="preserve"><value>Stay Entries</value></data>
<data name="page.StayEntryList.entryList" xml:space="preserve"><value>Entry List</value></data> <data name="page.StayEntryList.entryList" xml:space="preserve"><value>Entry List</value></data>
<data name="page.StayEntryList.btnNewStay" xml:space="preserve"><value>New Stay</value></data> <data name="page.StayEntryList.btnNewStay" xml:space="preserve"><value>New Stay</value></data>
<data name="page.StayEntryList.msgDeleteUploadedStay" xml:space="preserve"><value>A StayEntry can't be deleted after it has been uploaded!</value></data>
<data name="page.StayEntryList.btnUpdateUploadStatus" xml:space="preserve"><value>Update Upload Status</value></data>
<data name="page.StayEntryDetail.pageTitle" xml:space="preserve"><value>Stay Entry</value></data>
<data name="page.StayEntryDetail.cantEditFinalData" xml:space="preserve"><value>Stay can't be edited: it's already uploaded!</value></data>
<data name="page.StayEntryDetail.uploadStatusSuccessMsg" xml:space="preserve"><value>Upload status updated. New Status: '{0}'</value></data>
<data name="page.StayEntryNew.pageTitle" xml:space="preserve"><value>New Stay</value></data> <data name="page.StayEntryNew.pageTitle" xml:space="preserve"><value>New Stay</value></data>
<data name="page.StayExportList.pageTitle" xml:space="preserve"><value>Stay Export Files</value></data> <data name="page.StayExportList.pageTitle" xml:space="preserve"><value>Stay Export Files</value></data>
<data name="page.StayExportList.exportList" xml:space="preserve"><value>Export List</value></data> <data name="page.StayExportList.exportList" xml:space="preserve"><value>Export List</value></data>
<data name="page.StayExportList.btnNewExport" xml:space="preserve"><value>New Export</value></data> <data name="page.StayExportList.btnNewExport" xml:space="preserve"><value>New Export</value></data>
<data name="page.StayExportList.msgDeleteUploadedFile" xml:space="preserve"><value>A uploaded file can't be deleted!</value></data>
<data name="page.StayExportList.editUploadStatus.msgNotPending" xml:space="preserve"><value>Upload status only can be edited for "pending" files!</value></data>
<data name="page.StayExportList.editUploadStatus.msgConfirm" xml:space="preserve"><value>Are you sure you want to change upload status for Export file ID: '{0}' to '{1}'. This operation can't be undone! Exported Stay entries will update as well!</value></data>
<data name="page.StayExportList.editUploadStatus.msgEditSuccess" xml:space="preserve"><value>ExportFile (ID: '{0}'): Upload status updated to '{1}'</value></data>
<data name="page.StayExportNew.pageTitle" xml:space="preserve"><value>New Stay Export</value></data> <data name="page.StayExportNew.pageTitle" xml:space="preserve"><value>New Stay Export</value></data>
<data name="page.StayExportNew.chkShowPeriodFields" xml:space="preserve"><value>Use custom date range</value></data>
<data name="page.StayExportNew.msgExportOk" xml:space="preserve"><value>Stay export completed with result: {0}</value></data>
<data name="page.StayExportNew.msgDownloadError" xml:space="preserve"><value>Error downloading export file</value></data>
<data name="page.StayExportNew.msgDownloadErrorNoFile" xml:space="preserve"><value>Export file can't be downloaded: no file associated with the export</value></data>
<data name="page.StayExportNew.msgDownloadOk" xml:space="preserve"><value>Export file downloaded</value></data>
<data name="control.GuestDocForm.sectionDocument" xml:space="preserve"><value>Document Details</value></data> <data name="control.GuestDocForm.sectionDocument" xml:space="preserve"><value>Document Details</value></data>
@@ -259,6 +292,7 @@
<data name="control.StayEntryForm.sectionDetails" xml:space="preserve"><value>Stay Details</value></data> <data name="control.StayEntryForm.sectionDetails" xml:space="preserve"><value>Stay Details</value></data>
<data name="control.StayEntryForm.sectionGuests" xml:space="preserve"><value>Guest List</value></data> <data name="control.StayEntryForm.sectionGuests" xml:space="preserve"><value>Guest List</value></data>
<data name="control.StayEntryForm.sectionUploadStatus" xml:space="preserve"><value>Upload Status</value></data>
<data name="control.StayEntryForm.btnAddGuest" xml:space="preserve"><value>Add Guest</value></data> <data name="control.StayEntryForm.btnAddGuest" xml:space="preserve"><value>Add Guest</value></data>
<data name="control.AddressQueryDialog.dialogTitle" xml:space="preserve"><value>Search Address</value></data> <data name="control.AddressQueryDialog.dialogTitle" xml:space="preserve"><value>Search Address</value></data>
@@ -270,4 +304,8 @@
<data name="control.GuestDocumentSearchDialog.btnSelectDocument" xml:space="preserve"><value>Use Guest</value></data> <data name="control.GuestDocumentSearchDialog.btnSelectDocument" xml:space="preserve"><value>Use Guest</value></data>
<data name="control.GuestDocumentSearchDialog.txtSuggestedGuests" xml:space="preserve"><value>Suggested Guests</value></data> <data name="control.GuestDocumentSearchDialog.txtSuggestedGuests" xml:space="preserve"><value>Suggested Guests</value></data>
<data name="control.UploadStatusSelectorDialog.dialogTitle" xml:space="preserve"><value>Edit Upload Status</value></data>
<data name="control.UploadStatusSelectorDialog.lbCurrentStatus" xml:space="preserve"><value>Current Upload Status</value></data>
<data name="control.UploadStatusSelectorDialog.lbSelectStatus" xml:space="preserve"><value>New Upload Status</value></data>
</root> </root>
@@ -1,3 +1,4 @@
using Somnia.GuestLog.Enums.Models;
using Somnia.GuestLog.Models.DTOs; using Somnia.GuestLog.Models.DTOs;
using Somnia.GuestLog.Models.QueryConfigs; using Somnia.GuestLog.Models.QueryConfigs;
@@ -10,6 +11,13 @@ public interface IStayEntryEntityService
public Task<Result> DeleteEntryAsync(StayEntryDTO dto); public Task<Result> DeleteEntryAsync(StayEntryDTO dto);
public Task<Result> DeleteEntryAsync(long id); public Task<Result> DeleteEntryAsync(long id);
/// <summary>
/// Update StayEntry Upload Status.
/// </summary>
/// <param name="id">StayEntry ID to update</param>
/// <param name="newStatus">New Upload Status</param>
public Task<Result> UpdateEntryUploadStatusAsync(long id, UploadStatus newStatus);
public Task<StayEntryDTO?> GetDtoByIdAsync(long id, StayEntryQueryConfig? queryConfig = null); public Task<StayEntryDTO?> GetDtoByIdAsync(long id, StayEntryQueryConfig? queryConfig = null);
public Task<IEnumerable<StayEntryDTO>> GetDtoListAsync(StayEntryQueryConfig? queryConfig = null); public Task<IEnumerable<StayEntryDTO>> GetDtoListAsync(StayEntryQueryConfig? queryConfig = null);
public Task<IEnumerable<StayEntryDTO>> GetDtoListByFilterAsync(StayEntryFilterDTO filter, int limit = 0, StayEntryQueryConfig? queryConfig = null); public Task<IEnumerable<StayEntryDTO>> GetDtoListByFilterAsync(StayEntryFilterDTO filter, int limit = 0, StayEntryQueryConfig? queryConfig = null);
@@ -1,3 +1,4 @@
using Somnia.GuestLog.Enums.Models;
using Somnia.GuestLog.Models.DTOs; using Somnia.GuestLog.Models.DTOs;
namespace Somnia.GuestLog.Services.Entity; namespace Somnia.GuestLog.Services.Entity;
@@ -5,7 +6,6 @@ namespace Somnia.GuestLog.Services.Entity;
public interface IStayExportFileEntityService public interface IStayExportFileEntityService
{ {
public Task<Result> CreateStayExportAsync(StayExportFileDTO dto); public Task<Result> CreateStayExportAsync(StayExportFileDTO dto);
public Task<Result> UpdateStayExportAsync(StayExportFileDTO dto);
/// <summary> /// <summary>
/// Delete StayExport entry from DB. /// Delete StayExport entry from DB.
@@ -13,6 +13,15 @@ public interface IStayExportFileEntityService
/// </summary> /// </summary>
public Task<Result> DeleteStayExportAsync(StayExportFileDTO dto); public Task<Result> DeleteStayExportAsync(StayExportFileDTO dto);
/// <summary>
/// Update StayExport FileUploadStatus and execute required operations.
/// Only StayExport with UploadStatus "Pending" can be updated.
/// </summary>
/// <param name="id">ID of the StayExportFile to update</param>
/// <param name="newStatus">New UploadStatus</param>
public Task<Result> UpdateStayExportUploadStatusAsync(long id, UploadStatus newStatus);
public Task<StayExportFileDTO?> GetDtoByIdAsync(long id); public Task<StayExportFileDTO?> GetDtoByIdAsync(long id);
//public Task<IEnumerable<StayExportFileDTO>> GetDtoListByFilterAsync(StayExportFileFilterDTO filter, int limit = 0); //public Task<IEnumerable<StayExportFileDTO>> GetDtoListByFilterAsync(StayExportFileFilterDTO filter, int limit = 0);
public Task<IEnumerable<StayExportFileDTO>> GetDtoListAsync(int limit = 0); public Task<IEnumerable<StayExportFileDTO>> GetDtoListAsync(int limit = 0);
@@ -1,5 +1,7 @@
using FluentStorage.Utils.Extensions;
using FluentValidation; using FluentValidation;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Somnia.GuestLog.Enums.Models;
using Somnia.GuestLog.Enums.Services; using Somnia.GuestLog.Enums.Services;
using Somnia.GuestLog.Infrastructure; using Somnia.GuestLog.Infrastructure;
using Somnia.GuestLog.Models; using Somnia.GuestLog.Models;
@@ -35,6 +37,8 @@ public class StayEntryEntityService(
RoomCount = dto.RoomCount!.Value, RoomCount = dto.RoomCount!.Value,
RoomNumber = dto.RoomNumber, RoomNumber = dto.RoomNumber,
PaymentMethod = dto.PaymentMethod!, PaymentMethod = dto.PaymentMethod!,
StayUploadStatus = UploadStatus.Pending,
StayUploadStatusTime = null,
CreateTime = createTime, CreateTime = createTime,
UpdateTime = createTime, UpdateTime = createTime,
}; };
@@ -76,9 +80,91 @@ public class StayEntryEntityService(
} }
} }
public Task<Result> UpdateEntryAsync(StayEntryDTO updatedDto) public async Task<Result> UpdateEntryAsync(StayEntryDTO updatedDto)
{ {
throw new NotImplementedException(); var valResult = dtoValidator.Validate(updatedDto);
if (!valResult.IsValid)
{
logger.LogWarning("StayEntryService - UpdateEntryAsync: Dto validation failed. Fix the errors: {errorList}", valResult.Errors);
return Result.Fail(ResultCode.FailedValidation);
}
try
{
using var dbContext = contextFactory.CreateDbContext();
//Get current entity from DB.
StayEntry? dbItem = await dbContext.StayEntries
.Where(e => e.Id == updatedDto.Id)
.Include(e => e.GuestDocuments)
.SingleAsync();
if (dbItem == null)
{
logger.LogWarning("StayEntryService - UpdateEntryAsync: Error updating StayEntry (ID: '{id}'): StayEntry not found!", updatedDto.Id);
return Result.Fail(ResultCode.NotFound);
}
if (dbItem.StayUploadStatus == UploadStatus.Uploaded)
{
logger.LogWarning("StayEntryService - UpdateEntryAsync: StayEntry (ID: '{id}') can't be updated: StayEntry is already uploaded!", updatedDto.Id);
return Result.Fail(ResultCode.DataIsFinal);
}
DateTime updateTime = DateTime.UtcNow;
StayEntry updatedItem = new()
{
Id = dbItem.Id,
DateIn = updatedDto.DateIn!.Value.ToUniversalTime(),
DateOut = updatedDto.DateOut!.Value.ToUniversalTime(),
RoomCount = updatedDto.RoomCount!.Value,
RoomNumber = updatedDto.RoomNumber,
PaymentMethod = updatedDto.PaymentMethod!,
StayUploadStatus = dbItem.StayUploadStatus,
StayUploadStatusTime = dbItem.StayUploadStatusTime,
CreateTime = dbItem.CreateTime,
UpdateTime = updateTime,
};
dbContext.Entry(dbItem).CurrentValues.SetValues(updatedItem);
//Update GuestDocuments
if (updatedDto.GuestDocuments != null)
{
var updatedGuestDocIdList = updatedDto.GuestDocuments.Select(e => e.Id);
List<GuestDocument> updatedDbGuests = await dbContext.GuestDocuments
.Where(e => updatedGuestDocIdList.Contains(e.Id))
.ToListAsync();
foreach (GuestDocument guest in updatedDbGuests)
{
//Skip check for guests already in the stay.
if (dbItem.GuestDocuments.Any(e => e.Id == guest.Id))
{
continue;
}
//Check if Guest is already in other stay during the same period.
bool isInOtherStay = await this.IsGuestInStayInPeriod(guest.Id, updatedItem.DateIn, updatedItem.DateOut);
if (isInOtherStay)
{
string period = $"{updatedItem.DateIn}-{updatedItem.DateOut}";
return Result.FailWithContext(ResultCode.GuestCurrentlyInStay, guest.FullDocument, period);
}
}
dbItem.GuestDocuments.Clear();
dbItem.GuestDocuments.AddRange(updatedDbGuests);
}
var result = await dbContext.SaveChangesAsync();
logger.LogInformation("StayEntryService - UpdateEntryAsync: StayEntry Updated OK {id}", dbItem.GetFullKey());
return Result.Ok();
}
catch (Exception ex)
{
logger.LogError(ex, "StayEntryService - UpdateEntryAsync: Error updating StayEntry: '{id}'", updatedDto.Id);
return Result.FailUnknownError();
}
} }
public async Task<Result> DeleteEntryAsync(StayEntryDTO dto) public async Task<Result> DeleteEntryAsync(StayEntryDTO dto)
@@ -101,6 +187,11 @@ public class StayEntryEntityService(
return Result.Fail(ResultCode.NotFound); return Result.Fail(ResultCode.NotFound);
} }
if (dbItem.StayUploadStatus == UploadStatus.Uploaded)
{
return Result.Fail(ResultCode.DataIsFinal);
}
try try
{ {
dbContext.StayEntries.Remove(dbItem); dbContext.StayEntries.Remove(dbItem);
@@ -116,6 +207,42 @@ public class StayEntryEntityService(
} }
} }
public async Task<Result> UpdateEntryUploadStatusAsync(long id, UploadStatus newStatus)
{
using var dbContext = contextFactory.CreateDbContext();
StayEntry? dbItem = await dbContext.StayEntries.FindAsync(id);
if (dbItem == null)
{
return Result.Fail(ResultCode.NotFound);
}
if (dbItem.StayUploadStatus == newStatus)
{
return Result.Fail(ResultCode.NoPendingChanges);
}
try
{
//Update Status
dbItem.StayUploadStatus = newStatus;
dbItem.StayUploadStatusTime = DateTime.UtcNow;
await dbContext.SaveChangesAsync();
logger.LogInformation("StayEntryService - UpdateEntryUploadStatusAsync: StayEntry ('{id}') UploadStatus updated to '{status}'",
dbItem.GetFullKey(), newStatus);
return Result.Ok();
}
catch (Exception ex)
{
logger.LogError(ex, "StayEntryService - UpdateEntryUploadStatusAsync: Error updating StayEntry UploadStatus");
return Result.FailUnknownError();
}
}
public async Task<StayEntryDTO?> GetDtoByIdAsync(long id, StayEntryQueryConfig? queryConfig = null) public async Task<StayEntryDTO?> GetDtoByIdAsync(long id, StayEntryQueryConfig? queryConfig = null)
{ {
using var dbContext = contextFactory.CreateDbContext(); using var dbContext = contextFactory.CreateDbContext();
@@ -154,6 +281,8 @@ public class StayEntryEntityService(
e => EF.Functions.Like(e.RoomNumber, $"%{filter.RoomNumber}%")); e => EF.Functions.Like(e.RoomNumber, $"%{filter.RoomNumber}%"));
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.WhereIf(filter.StayUploadStatus != null,
e => e.StayUploadStatus == filter.StayUploadStatus);
query = query.OrderByDescending(e => e.DateIn) query = query.OrderByDescending(e => e.DateIn)
.ThenByDescending(e => e.UpdateTime); .ThenByDescending(e => e.UpdateTime);
@@ -214,5 +343,10 @@ public class StayEntryEntityService(
return EntityMapping.MapStayEntryEntityToDTO(dbItem, queryConfig.IncludeGuests); return EntityMapping.MapStayEntryEntityToDTO(dbItem, queryConfig.IncludeGuests);
} }
private static string? GetValueOrNull(string? dtoValue)
{
return string.IsNullOrWhiteSpace(dtoValue) ? null : dtoValue;
}
#endregion #endregion
} }
@@ -1,5 +1,6 @@
using FluentValidation; using FluentValidation;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Somnia.GuestLog.Enums.Models;
using Somnia.GuestLog.Enums.Services; using Somnia.GuestLog.Enums.Services;
using Somnia.GuestLog.Infrastructure; using Somnia.GuestLog.Infrastructure;
using Somnia.GuestLog.Models; using Somnia.GuestLog.Models;
@@ -30,14 +31,17 @@ public class StayExportFileEntityService(
} }
StayExportParams exportParams = GetExportParamsFromDTO(dto.ExportParams); StayExportParams exportParams = GetExportParamsFromDTO(dto.ExportParams);
StayExportDetails? exportDetails = GetExportDetailsFromDTO(dto.ExportDetails);
StayExportFile dbItem = new() StayExportFile dbItem = new()
{ {
ExportFormat = dto.ExportFormat.Value, ExportFormat = dto.ExportFormat.Value,
ExportParams = exportParams, ExportParams = exportParams,
ExportResult = dto.ExportResult.Value, ExportResult = dto.ExportResult.Value,
ExportedPath = dto.ExportedPath, ExportedPath = dto.ExportedPath,
ExportDetails = dto.ExportDetails, ExportDetails = exportDetails,
ExportTime = dto.ExportTime?.ToUniversalTime() ?? DateTime.UtcNow, ExportTime = dto.ExportTime?.ToUniversalTime() ?? DateTime.UtcNow,
FileUploadStatus = UploadStatus.Pending,
FileUploadStatusTime = null
}; };
try try
@@ -58,13 +62,13 @@ public class StayExportFileEntityService(
} }
} }
public Task<Result> UpdateStayExportAsync(StayExportFileDTO dto)
{
throw new NotImplementedException();
}
public async Task<Result> DeleteStayExportAsync(StayExportFileDTO dto) public async Task<Result> DeleteStayExportAsync(StayExportFileDTO dto)
{ {
if (dto.FileUploadStatus == UploadStatus.Uploaded)
{
return Result.Fail(ResultCode.DataIsFinal);
}
try try
{ {
using var dbContext = contextFactory.CreateDbContext(); using var dbContext = contextFactory.CreateDbContext();
@@ -91,6 +95,73 @@ public class StayExportFileEntityService(
} }
public async Task<Result> UpdateStayExportUploadStatusAsync(long id, UploadStatus newStatus)
{
//Try get StayExport
using var dbContext = contextFactory.CreateDbContext();
StayExportFile? dbItem = await dbContext.StayExportFiles
.Where(e => e.Id == id)
.FirstOrDefaultAsync();
if (dbItem == null)
{
return Result.Fail(ResultCode.NotFound);
}
if (dbItem.FileUploadStatus == newStatus)
{
return Result.Fail(ResultCode.NoPendingChanges);
}
//Status can be updated only when current status is "Pending"
if (dbItem.FileUploadStatus != UploadStatus.Pending)
{
return Result.FailWithContext(ResultCode.UploadStatusIsFinal, context: dbItem.FileUploadStatus);
}
try
{
DateTime dtNow = DateTime.UtcNow;
//Update UploadStatus of StayEntries when new status is "Uploaded".
if (newStatus == UploadStatus.Uploaded && dbItem.ExportDetails != null)
{
//Only StayEntries exported OK will be updated!
IEnumerable<long> stayEntryIds = dbItem.ExportDetails.StayEntries
.Where(e => e.ExportResult == StayExportDetailsStayEntryResult.OK)
.Select(e => e.StayEntryId);
//Make Update
int updatedCount = await dbContext.StayEntries
.Where(e => stayEntryIds.Contains(e.Id))
.ExecuteUpdateAsync(u =>
{
u.SetProperty(p => p.StayUploadStatus, UploadStatus.Uploaded);
u.SetProperty(p => p.StayUploadStatusTime, dtNow);
});
logger.LogInformation("StayExportFileService - UpdateStayExportUploadStatusAsync: StayEntry UploadStatus updated to 'Uploaded' for {count} entries: '{entryList}'",
updatedCount, string.Join(", ", stayEntryIds));
}
//Update Status
dbItem.FileUploadStatus = newStatus;
dbItem.FileUploadStatusTime = dtNow;
await dbContext.SaveChangesAsync();
logger.LogInformation("StayExportFileService - UpdateStayExportUploadStatusAsync: StayExport ('{id}') UploadStatus updated to '{status}'",
dbItem.GetFullKey(), newStatus);
return Result.Ok();
}
catch (Exception ex)
{
logger.LogError(ex, "StayExportFileService - UpdateStayExportUploadStatusAsync: Error updating StayExport UploadStatus");
return Result.FailUnknownError();
}
}
public async Task<StayExportFileDTO?> GetDtoByIdAsync(long id) public async Task<StayExportFileDTO?> GetDtoByIdAsync(long id)
{ {
using var dbContext = contextFactory.CreateDbContext(); using var dbContext = contextFactory.CreateDbContext();
@@ -137,5 +208,32 @@ public class StayExportFileEntityService(
}; };
} }
private static StayExportDetails? GetExportDetailsFromDTO(StayExportDetailsDTO? dto)
{
if (dto == null)
{
return null;
}
//Get all entries
List<StayExportDetailsStayEntry> entries = [];
foreach (var entry in dto.StayEntries)
{
entries.Add(new()
{
StayEntryId = entry.StayEntryId,
ExportResult = entry.ExportResult,
Details = entry.Details
});
}
return new()
{
ExportedStayCount = dto.ExportedStayCount,
StayErrorCount = dto.StayErrorCount,
StayEntries = entries
};
}
#endregion #endregion
} }
@@ -14,6 +14,6 @@ public interface IStayExportFormatProvider
/// </summary> /// </summary>
/// <param name="stayList">List of Stays to export</param> /// <param name="stayList">List of Stays to export</param>
/// <param name="dataStream">Stream to copy exported data.</param> /// <param name="dataStream">Stream to copy exported data.</param>
public Task<(StayExportFileResult fileResult, string? exportDetails)> ExportDataAsync(IEnumerable<StayEntryDTO> stayList, Stream dataStream); public Task<(StayExportFileResult fileResult, List<StayExportDetailsStayEntryDTO> detailsEntries)> ExportDataAsync(IEnumerable<StayEntryDTO> stayList, Stream dataStream);
} }
@@ -13,18 +13,27 @@ public class StayExportProviderJson : IStayExportFormatProvider
=> $"{Enum.GetName(GetFormat())}_{exportTime.ToFileTimeUtc()}.{fileExtension}"; => $"{Enum.GetName(GetFormat())}_{exportTime.ToFileTimeUtc()}.{fileExtension}";
public async Task<(StayExportFileResult fileResult, string? exportDetails)> ExportDataAsync(IEnumerable<StayEntryDTO> stayList, Stream dataStream) public async Task<(StayExportFileResult fileResult, List<StayExportDetailsStayEntryDTO> detailsEntries)> ExportDataAsync(IEnumerable<StayEntryDTO> stayList, Stream dataStream)
{ {
if (!stayList.Any()) if (!stayList.Any())
{ {
return (fileResult: StayExportFileResult.NoData, exportDetails: null); return (fileResult: StayExportFileResult.NoData, detailsEntries: []);
} }
// Convert to JSON. // Convert to JSON.
await JsonSerializer.SerializeAsync(dataStream, stayList); await JsonSerializer.SerializeAsync(dataStream, stayList);
List<string> exportDetails = [.. stayList.Where(s => s.Id != null).Select(s => s.Id?.ToString() ?? "")]; List<StayExportDetailsStayEntryDTO> details = [];
string details = JsonSerializer.Serialize(exportDetails); foreach (var stay in stayList)
return (fileResult: StayExportFileResult.OK, exportDetails: details); {
details.Add(new()
{
StayEntryId = stay.Id!.Value,
ExportResult = StayExportDetailsStayEntryResult.OK,
Details = null
});
}
return (fileResult: StayExportFileResult.OK, detailsEntries: details);
} }
} }
@@ -1,5 +1,4 @@
using System.Diagnostics; using System.Diagnostics;
using System.Text.Json;
using System.Xml.Serialization; using System.Xml.Serialization;
using FluentValidation; using FluentValidation;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
@@ -18,9 +17,6 @@ public class StayExportProviderSpainParteViajeros(
{ {
private const string fileExtension = "xml"; private const string fileExtension = "xml";
private const string ExportDetailsResult_Error = "Error";
private const string ExportDetailsResult_Ok = "Ok";
private const string PersonRole = "VI"; private const string PersonRole = "VI";
private const string PersonRelation = "OT"; private const string PersonRelation = "OT";
@@ -41,20 +37,20 @@ public class StayExportProviderSpainParteViajeros(
public string GetFilename(DateTime exportTime) public string GetFilename(DateTime exportTime)
=> $"{Enum.GetName(GetFormat())}_{exportTime.ToFileTimeUtc()}.{fileExtension}"; => $"{Enum.GetName(GetFormat())}_{exportTime.ToFileTimeUtc()}.{fileExtension}";
public async Task<(StayExportFileResult fileResult, string? exportDetails)> ExportDataAsync(IEnumerable<StayEntryDTO> stayList, Stream dataStream) public async Task<(StayExportFileResult fileResult, List<StayExportDetailsStayEntryDTO> detailsEntries)> ExportDataAsync(IEnumerable<StayEntryDTO> stayList, Stream dataStream)
{ {
if (string.IsNullOrEmpty(config.CodigoEstablecimiento)) if (string.IsNullOrEmpty(config.CodigoEstablecimiento))
{ {
logger.LogError("StayExportProviderSpainParteViajeros - Config error: CodigoEstablecimiento is not configured!"); logger.LogError("StayExportProviderSpainParteViajeros - Config error: CodigoEstablecimiento is not configured!");
return (fileResult: StayExportFileResult.ExportError, exportDetails: null); return (fileResult: StayExportFileResult.ExportError, detailsEntries: []);
} }
if (!stayList.Any()) if (!stayList.Any())
{ {
return (fileResult: StayExportFileResult.NoData, exportDetails: null); return (fileResult: StayExportFileResult.NoData, detailsEntries: []);
} }
List<StayExportDetails> stayExportDetails = []; List<StayExportDetailsStayEntryDTO> stayExportDetails = [];
ComunicacionValidator comunicacionValidator = new(); ComunicacionValidator comunicacionValidator = new();
List<Comunicacion> comunicacionsList = []; List<Comunicacion> comunicacionsList = [];
@@ -64,7 +60,12 @@ public class StayExportProviderSpainParteViajeros(
if (comunicacion == null) if (comunicacion == null)
{ {
logger.LogWarning("StayExportProviderSpainParteViajeros - Stay (ID: {id}) can't be exported: Error: {code}", stay.Id, errorMsg); logger.LogWarning("StayExportProviderSpainParteViajeros - Stay (ID: {id}) can't be exported: Error: {code}", stay.Id, errorMsg);
stayExportDetails.Add(new(StayId: stay.Id ?? -1, ExportResult: ExportDetailsResult_Error, Details: errorMsg)); stayExportDetails.Add(new()
{
StayEntryId = stay.Id ?? -1,
ExportResult = StayExportDetailsStayEntryResult.Error,
Details = errorMsg
});
continue; continue;
} }
@@ -72,13 +73,23 @@ public class StayExportProviderSpainParteViajeros(
if (!errors.IsValid) if (!errors.IsValid)
{ {
logger.LogWarning("StayExportProviderSpainParteViajeros - Stay (ID: {id}) is invalid: Errors: {errors}", stay.Id, errors.Errors); logger.LogWarning("StayExportProviderSpainParteViajeros - Stay (ID: {id}) is invalid: Errors: {errors}", stay.Id, errors.Errors);
stayExportDetails.Add(new(StayId: stay.Id ?? -1, ExportResult: ExportDetailsResult_Error, Details: errors.ToString())); stayExportDetails.Add(new()
{
StayEntryId = stay.Id ?? -1,
ExportResult = StayExportDetailsStayEntryResult.Error,
Details = errors.ToString()
});
continue; continue;
} }
comunicacionsList.Add(comunicacion); comunicacionsList.Add(comunicacion);
logger.LogInformation("StayExportProviderSpainParteViajeros - Stay (ID: {id}) Exported OK", stay.Id); logger.LogInformation("StayExportProviderSpainParteViajeros - Stay (ID: {id}) Exported OK", stay.Id);
stayExportDetails.Add(new(StayId: stay.Id ?? -1, ExportResult: ExportDetailsResult_Ok, Details: null)); stayExportDetails.Add(new()
{
StayEntryId = stay.Id ?? -1,
ExportResult = StayExportDetailsStayEntryResult.OK,
Details = null
});
} }
Peticion peticion = new() Peticion peticion = new()
@@ -97,8 +108,7 @@ public class StayExportProviderSpainParteViajeros(
XmlSerializer serializer = new(typeof(Peticion)); XmlSerializer serializer = new(typeof(Peticion));
serializer.Serialize(stream: dataStream, o: peticion, namespaces: docNamespaces); serializer.Serialize(stream: dataStream, o: peticion, namespaces: docNamespaces);
string details = JsonSerializer.Serialize(stayExportDetails); return (fileResult: StayExportFileResult.OK, detailsEntries: stayExportDetails);
return (fileResult: StayExportFileResult.OK, exportDetails: details);
} }
#region Internal Methods #region Internal Methods
@@ -325,8 +335,6 @@ public class StayExportProviderSpainParteViajeros(
#region Export Data Classes #region Export Data Classes
private record StayExportDetails(long StayId, string ExportResult, string? Details);
[XmlRoot(ElementName = "peticion", Namespace = XmlNamespace_Peticion)] [XmlRoot(ElementName = "peticion", Namespace = XmlNamespace_Peticion)]
public class Peticion public class Peticion
{ {
@@ -58,7 +58,14 @@ public class StayExportService(
{ {
//Create Format provider and export data to stream. //Create Format provider and export data to stream.
var provider = providerFactory.GetProvider(format); var provider = providerFactory.GetProvider(format);
(exportResult, stayExport.ExportDetails) = await provider.ExportDataAsync(stayList, exportedDataStream); (exportResult, List<StayExportDetailsStayEntryDTO> entriesDetails) = await provider.ExportDataAsync(stayList, exportedDataStream);
stayExport.ExportDetails = new()
{
ExportedStayCount = entriesDetails.Count,
StayErrorCount = entriesDetails.Count(e => e.ExportResult == StayExportDetailsStayEntryResult.Error),
StayEntries = entriesDetails
};
// "Rewind" stream so it can be read from the begining when uploading. // "Rewind" stream so it can be read from the begining when uploading.
exportedDataStream.Seek(0, SeekOrigin.Begin); exportedDataStream.Seek(0, SeekOrigin.Begin);
@@ -187,6 +194,8 @@ public class StayExportService(
private async Task<IEnumerable<StayEntryDTO>> GetStaysToExportByParamsAsync(StayExportParamsDTO exportParams) private async Task<IEnumerable<StayEntryDTO>> GetStaysToExportByParamsAsync(StayExportParamsDTO exportParams)
{ {
StayEntryFilterDTO? filter = null;
//Todo - Improve type selection (when there are more types). //Todo - Improve type selection (when there are more types).
if (exportParams.ExportType == StayExportParamType.PeriodDateIn) if (exportParams.ExportType == StayExportParamType.PeriodDateIn)
{ {
@@ -196,11 +205,27 @@ public class StayExportService(
} }
//Get Stays in period -> Local time should be used so it match with entities local-time. //Get Stays in period -> Local time should be used so it match with entities local-time.
StayEntryFilterDTO filter = new() filter = new()
{ {
DateInStart = exportParams.ExportPeriodStart, DateInStart = exportParams.ExportPeriodStart,
DateInEnd = exportParams.ExportPeriodEnd DateInEnd = exportParams.ExportPeriodEnd
}; };
}
if (exportParams.ExportType == StayExportParamType.UploadPending)
{
//Get Stays in period -> Local time should be used so it match with entities local-time.
filter = new()
{
//Start-End dates may be null
DateInStart = exportParams.ExportPeriodStart,
DateInEnd = exportParams.ExportPeriodEnd,
StayUploadStatus = UploadStatus.Pending,
};
}
if (filter != null)
{
return await stayEntityService.GetDtoListByFilterAsync(filter, limit: 0, queryConfig: queryConfig); return await stayEntityService.GetDtoListByFilterAsync(filter, limit: 0, queryConfig: queryConfig);
} }