SHA256
Compare commits
1
Commits
7b8020879b
...
StayExport
| Author | SHA256 | Date | |
|---|---|---|---|
|
|
9ec87d56da |
@@ -52,8 +52,13 @@
|
||||
</TemplateColumn>
|
||||
<PropertyColumn Property="x => Localizer.GetEnumValue(x.ExportResult)"
|
||||
Title="@LanguageLocale.dto_StayExportFile_ExportResult" />
|
||||
<PropertyColumn Property="x => x.ExportedPath" Title="@LanguageLocale.dto_StayExportFile_ExportedPath" Hidden />
|
||||
<PropertyColumn Property="x => x.ExportTime" Title="@LanguageLocale.dto_StayExportFile_ExportTime" />
|
||||
<TemplateColumn Title="@LanguageLocale.dto_StayExportFile_ExportDetails">
|
||||
<CellTemplate>
|
||||
<MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Info"
|
||||
OnClick="() => ShowExportDetails(context.Item)" />
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
|
||||
<TemplateColumn CellClass="d-flex justify-between" Title="Options" StickyRight Hideable="false"
|
||||
ShowColumnOptions="false">
|
||||
@@ -118,7 +123,21 @@
|
||||
{
|
||||
string jsonParams = JsonSerializer.Serialize(dto.ExportParams, options: new() { WriteIndented = true });
|
||||
|
||||
await DialogService.ShowMessageBoxAsync("Details", jsonParams);
|
||||
await DialogService.ShowMessageBoxAsync("Details", (MarkupString)$"<pre>{jsonParams}</pre>");
|
||||
}
|
||||
|
||||
private async Task ShowExportDetails(StayExportFileDTO dto)
|
||||
{
|
||||
if (string.IsNullOrEmpty(dto.ExportDetails))
|
||||
{
|
||||
userMessage.ShowMessage("This ExportFile doesn't have any export details", MessageKind.Info);
|
||||
return;
|
||||
}
|
||||
|
||||
using var jDoc = JsonDocument.Parse(dto.ExportDetails);
|
||||
string jsonDetails = JsonSerializer.Serialize(jDoc, new JsonSerializerOptions { WriteIndented = true });
|
||||
|
||||
await DialogService.ShowMessageBoxAsync("Details", (MarkupString)$"<pre>{jsonDetails}</pre>");
|
||||
}
|
||||
|
||||
private async Task BtnDownloadFile(StayExportFileDTO item)
|
||||
|
||||
@@ -6,5 +6,7 @@ public static class DbConsts
|
||||
public const string DbType_Timestamptz_0 = "timestamp(0) with time zone";
|
||||
public const string DbType_Timestamptz_3 = "timestamp(3) with time zone";
|
||||
|
||||
public const string DbType_jsonb = "jsonb";
|
||||
|
||||
public const string PK_NotApply = "N/A";
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ public class StayExportFileEntityConfig : IEntityTypeConfiguration<StayExportFil
|
||||
builder.Property(e => e.ExportedPath)
|
||||
.HasMaxLength(256);
|
||||
|
||||
builder.Property(e => e.ExportDetails)
|
||||
.HasColumnType(DbConsts.DbType_jsonb);
|
||||
|
||||
|
||||
builder.Property(e => e.ExportTime)
|
||||
.IsRequired()
|
||||
|
||||
+252
@@ -0,0 +1,252 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using Somnia.GuestLog.Infrastructure;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
{
|
||||
[DbContext(typeof(GuestLogContext))]
|
||||
[Migration("20260908172441_StayExportFile_AddColumn_ExportDetails")]
|
||||
partial class StayExportFile_AddColumn_ExportDetails
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "10.0.7")
|
||||
.HasAnnotation("Proxies:ChangeTracking", false)
|
||||
.HasAnnotation("Proxies:CheckEquality", false)
|
||||
.HasAnnotation("Proxies:LazyLoading", true)
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("GuestDocumentStayEntry", b =>
|
||||
{
|
||||
b.Property<long>("StayEntryId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("GuestDocumentsId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("GuestDocumentsVersion")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("StayEntryId", "GuestDocumentsId", "GuestDocumentsVersion");
|
||||
|
||||
b.HasIndex("GuestDocumentsId", "GuestDocumentsVersion");
|
||||
|
||||
b.ToTable("GuestDocumentStayEntry");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.GuestDocument", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<int>("Version")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateOnly>("BirthDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("timestamp(3) with time zone");
|
||||
|
||||
b.Property<string>("DocumentNum")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("DocumentType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(8)
|
||||
.HasColumnType("character varying(8)");
|
||||
|
||||
b.Property<string>("EmailAddress")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<string>("Gender")
|
||||
.HasMaxLength(1)
|
||||
.HasColumnType("character varying(1)");
|
||||
|
||||
b.Property<bool>("IsLastVersion")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<DateOnly>("IssueDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("Nationality")
|
||||
.IsRequired()
|
||||
.HasMaxLength(3)
|
||||
.HasColumnType("character varying(3)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)");
|
||||
|
||||
b.Property<string>("SupportNum")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("character varying(10)");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("Surname2")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("timestamp(3) with time zone");
|
||||
|
||||
b.ComplexProperty(typeof(Dictionary<string, object>), "AddressDetails", "Somnia.GuestLog.Models.Entities.GuestDocument.AddressDetails#GuestAddress", b1 =>
|
||||
{
|
||||
b1.Property<string>("Address")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressCity")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressCountry")
|
||||
.IsRequired()
|
||||
.HasMaxLength(3)
|
||||
.HasColumnType("character varying(3)");
|
||||
|
||||
b1.Property<string>("AddressProvince")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressState")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("ZipCode")
|
||||
.HasMaxLength(12)
|
||||
.HasColumnType("character varying(12)");
|
||||
});
|
||||
|
||||
b.HasKey("Id", "Version");
|
||||
|
||||
b.ToTable("GuestDocument", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.StayEntry", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("DateIn")
|
||||
.HasColumnType("timestamp(0) with time zone");
|
||||
|
||||
b.Property<DateTime>("DateOut")
|
||||
.HasColumnType("timestamp(0) with time zone");
|
||||
|
||||
b.Property<string>("PaymentMethod")
|
||||
.IsRequired()
|
||||
.HasMaxLength(5)
|
||||
.HasColumnType("character varying(5)");
|
||||
|
||||
b.Property<int>("RoomCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("RoomNumber")
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("StayEntry", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.StayExportFile", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<string>("ExportDetails")
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<int>("ExportFormat")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ExportResult")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("ExportTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("ExportedPath")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.ComplexProperty(typeof(Dictionary<string, object>), "ExportParams", "Somnia.GuestLog.Models.Entities.StayExportFile.ExportParams#StayExportParams", b1 =>
|
||||
{
|
||||
b1.IsRequired();
|
||||
|
||||
b1.Property<DateTime?>("ExportPeriodEnd");
|
||||
|
||||
b1.Property<DateTime?>("ExportPeriodStart");
|
||||
|
||||
b1.Property<int>("ExportType");
|
||||
|
||||
b1
|
||||
.ToJson("ExportParams")
|
||||
.HasColumnType("jsonb");
|
||||
});
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("StayExportFile", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GuestDocumentStayEntry", b =>
|
||||
{
|
||||
b.HasOne("Somnia.GuestLog.Models.Entities.StayEntry", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("StayEntryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Somnia.GuestLog.Models.Entities.GuestDocument", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("GuestDocumentsId", "GuestDocumentsVersion")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class StayExportFile_AddColumn_ExportDetails : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ExportDetails",
|
||||
table: "StayExportFile",
|
||||
type: "jsonb",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ExportDetails",
|
||||
table: "StayExportFile");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -193,6 +193,9 @@ namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<string>("ExportDetails")
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<int>("ExportFormat")
|
||||
.HasColumnType("integer");
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ public class StayExportFileDTO
|
||||
|
||||
public string? ExportedPath { get; set; }
|
||||
|
||||
public string? ExportDetails { get; set; }
|
||||
|
||||
|
||||
public DateTime? ExportTime { get; set; }
|
||||
}
|
||||
|
||||
@@ -17,6 +17,11 @@ public class StayExportFile : BaseEntity
|
||||
/// </summary>
|
||||
public string? ExportedPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A JSON column to store details about the exported file.
|
||||
/// This details can contain information about errors, which stays where included, etc.
|
||||
/// </summary>
|
||||
public string? ExportDetails { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Date/Time when export file was generated.
|
||||
|
||||
@@ -67,6 +67,7 @@ internal static class EntityMapping
|
||||
ExportParams = exportParamsDto,
|
||||
ExportResult = entity.ExportResult,
|
||||
ExportedPath = entity.ExportedPath,
|
||||
ExportDetails = entity.ExportDetails,
|
||||
ExportTime = entity.ExportTime,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using FluentStorage;
|
||||
using FluentValidation;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -115,4 +116,7 @@ app.MapStaticAssets();
|
||||
app.MapRazorComponents<App>()
|
||||
.AddInteractiveServerRenderMode();
|
||||
|
||||
//Activate S3 storage.
|
||||
AwsS3Storage.Use();
|
||||
|
||||
app.Run();
|
||||
|
||||
@@ -154,6 +154,7 @@
|
||||
<data name="dto.StayExportFile.ExportParams" xml:space="preserve"><value>Export Params</value></data>
|
||||
<data name="dto.StayExportFile.ExportResult" xml:space="preserve"><value>Export Result</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.ExportTime" xml:space="preserve"><value>Export Time</value></data>
|
||||
|
||||
<data name="dto.StayExportParams.ExportType" xml:space="preserve"><value>Export Type</value></data>
|
||||
|
||||
@@ -36,6 +36,7 @@ public class StayExportFileEntityService(
|
||||
ExportParams = exportParams,
|
||||
ExportResult = dto.ExportResult.Value,
|
||||
ExportedPath = dto.ExportedPath,
|
||||
ExportDetails = dto.ExportDetails,
|
||||
ExportTime = dto.ExportTime?.ToUniversalTime() ?? DateTime.UtcNow,
|
||||
};
|
||||
|
||||
|
||||
@@ -14,6 +14,6 @@ public interface IStayExportFormatProvider
|
||||
/// </summary>
|
||||
/// <param name="stayList">List of Stays to export</param>
|
||||
/// <param name="dataStream">Stream to copy exported data.</param>
|
||||
public Task<StayExportFileResult> ExportDataAsync(IEnumerable<StayEntryDTO> stayList, Stream dataStream);
|
||||
public Task<(StayExportFileResult fileResult, string? exportDetails)> ExportDataAsync(IEnumerable<StayEntryDTO> stayList, Stream dataStream);
|
||||
|
||||
}
|
||||
@@ -13,15 +13,18 @@ public class StayExportProviderJson : IStayExportFormatProvider
|
||||
=> $"{Enum.GetName(GetFormat())}_{exportTime.ToFileTimeUtc()}.{fileExtension}";
|
||||
|
||||
|
||||
public async Task<StayExportFileResult> ExportDataAsync(IEnumerable<StayEntryDTO> stayList, Stream dataStream)
|
||||
public async Task<(StayExportFileResult fileResult, string? exportDetails)> ExportDataAsync(IEnumerable<StayEntryDTO> stayList, Stream dataStream)
|
||||
{
|
||||
if (!stayList.Any())
|
||||
{
|
||||
return StayExportFileResult.NoData;
|
||||
return (fileResult: StayExportFileResult.NoData, exportDetails: null);
|
||||
}
|
||||
|
||||
// Convert to JSON.
|
||||
await JsonSerializer.SerializeAsync(dataStream, stayList);
|
||||
return StayExportFileResult.OK;
|
||||
|
||||
List<string> exportDetails = [.. stayList.Where(s => s.Id != null).Select(s => s.Id?.ToString() ?? "")];
|
||||
string details = JsonSerializer.Serialize(exportDetails);
|
||||
return (fileResult: StayExportFileResult.OK, exportDetails: details);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using System.Text.Json;
|
||||
using System.Xml.Serialization;
|
||||
using FluentValidation;
|
||||
using Microsoft.Extensions.Options;
|
||||
@@ -17,6 +18,9 @@ public class StayExportProviderSpainParteViajeros(
|
||||
{
|
||||
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 PersonRelation = "OT";
|
||||
|
||||
@@ -31,32 +35,35 @@ public class StayExportProviderSpainParteViajeros(
|
||||
|
||||
private readonly StayExportSpainParteViajerosConfig config = configOptions.Value;
|
||||
|
||||
|
||||
public StayExportFormat GetFormat() => StayExportFormat.SpainParteViajeros;
|
||||
public string GetFilename(DateTime exportTime)
|
||||
=> $"{Enum.GetName(GetFormat())}_{exportTime.ToFileTimeUtc()}.{fileExtension}";
|
||||
|
||||
public async Task<StayExportFileResult> ExportDataAsync(IEnumerable<StayEntryDTO> stayList, Stream dataStream)
|
||||
public async Task<(StayExportFileResult fileResult, string? exportDetails)> ExportDataAsync(IEnumerable<StayEntryDTO> stayList, Stream dataStream)
|
||||
{
|
||||
if (string.IsNullOrEmpty(config.CodigoEstablecimiento))
|
||||
{
|
||||
logger.LogError("StayExportProviderSpainParteViajeros - Config error: CodigoEstablecimiento is not configured!");
|
||||
return StayExportFileResult.ExportError;
|
||||
return (fileResult: StayExportFileResult.ExportError, exportDetails: null);
|
||||
}
|
||||
|
||||
if (!stayList.Any())
|
||||
{
|
||||
return StayExportFileResult.NoData;
|
||||
return (fileResult: StayExportFileResult.NoData, exportDetails: null);
|
||||
}
|
||||
|
||||
List<StayExportDetails> stayExportDetails = [];
|
||||
ComunicacionValidator comunicacionValidator = new();
|
||||
|
||||
List<Comunicacion> comunicacionsList = [];
|
||||
foreach (StayEntryDTO stay in stayList)
|
||||
{
|
||||
(Comunicacion? comunicacion, string code) = await GetComunicacionFromStay(stay);
|
||||
(Comunicacion? comunicacion, string errorMsg) = await GetComunicacionFromStay(stay);
|
||||
if (comunicacion == null)
|
||||
{
|
||||
logger.LogWarning("StayExportProviderSpainParteViajeros - Stay (ID: {id}) can't be exported: Code: {code}", stay.Id, code);
|
||||
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));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -64,11 +71,13 @@ public class StayExportProviderSpainParteViajeros(
|
||||
if (!errors.IsValid)
|
||||
{
|
||||
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()));
|
||||
continue;
|
||||
}
|
||||
|
||||
comunicacionsList.Add(comunicacion);
|
||||
logger.LogInformation("StayExportProviderSpainParteViajeros - Stay (ID: {id}) Exported OK", stay.Id);
|
||||
stayExportDetails.Add(new(StayId: stay.Id ?? -1, ExportResult: ExportDetailsResult_Ok, Details: null));
|
||||
}
|
||||
|
||||
Peticion peticion = new()
|
||||
@@ -83,12 +92,13 @@ public class StayExportProviderSpainParteViajeros(
|
||||
XmlSerializer serializer = new(typeof(Peticion));
|
||||
serializer.Serialize(dataStream, peticion);
|
||||
|
||||
return StayExportFileResult.OK;
|
||||
string details = JsonSerializer.Serialize(stayExportDetails);
|
||||
return (fileResult: StayExportFileResult.OK, exportDetails: details);
|
||||
}
|
||||
|
||||
#region Internal Methods
|
||||
|
||||
private async Task<(Comunicacion? comunicacion, string code)> GetComunicacionFromStay(StayEntryDTO stay)
|
||||
private async Task<(Comunicacion? comunicacion, string errorMsg)> GetComunicacionFromStay(StayEntryDTO stay)
|
||||
{
|
||||
Debug.Assert(stay.Id != null
|
||||
&& stay.DateIn != null
|
||||
@@ -136,7 +146,7 @@ public class StayExportProviderSpainParteViajeros(
|
||||
{
|
||||
return (
|
||||
comunicacion: null,
|
||||
code: "NoCodigoMunicipio"
|
||||
errorMsg: "Can't get codigo municio"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -167,7 +177,7 @@ public class StayExportProviderSpainParteViajeros(
|
||||
contrato = contrato,
|
||||
persona = personasList
|
||||
},
|
||||
code: "OK");
|
||||
errorMsg: "OK");
|
||||
}
|
||||
|
||||
private static string? GetTipoDocumentoFromGuest(GuestDocumentDTO doc)
|
||||
@@ -309,6 +319,8 @@ public class StayExportProviderSpainParteViajeros(
|
||||
|
||||
#region Export Data Classes
|
||||
|
||||
private record StayExportDetails(long StayId, string ExportResult, string? Details);
|
||||
|
||||
[XmlRoot(ElementName = "peticion", Namespace = XmlNamespace_Peticion)]
|
||||
public class Peticion
|
||||
{
|
||||
|
||||
@@ -58,7 +58,7 @@ public class StayExportService(
|
||||
{
|
||||
//Create Format provider and export data to stream.
|
||||
var provider = providerFactory.GetProvider(format);
|
||||
exportResult = await provider.ExportDataAsync(stayList, exportedDataStream);
|
||||
(exportResult, stayExport.ExportDetails) = await provider.ExportDataAsync(stayList, exportedDataStream);
|
||||
|
||||
// "Rewind" stream so it can be read from the begining when uploading.
|
||||
exportedDataStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
Reference in New Issue
Block a user