Le foto venivano zippate tutte in un unico allegato: oltre i 100 MB i servizi rifiutavano l'invio (MaxUploadSizeExceededException) e, costruendo tutto in RAM sul thread della UI, il dispositivo si bloccava. - Invio diviso in più email da massimo ~40 MB ciascuna - Zip scritti su disco una parte alla volta e caricati in streaming - Preparazione in background, avanzamento "parte X di N" - Richiesta se includere le foto, con il loro peso (default: solo i log) - Database inviato insieme al file -wal - Avviso subito se si è offline Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
70 lines
2.1 KiB
C#
70 lines
2.1 KiB
C#
using System.Text;
|
|
using System.Text.Json;
|
|
using IntegryApiClient.Core.Domain.RestClient.Contacts;
|
|
using Microsoft.Extensions.Logging;
|
|
using SteUp.Shared.Core.Dto;
|
|
using SteUp.Shared.Core.Helpers;
|
|
using SteUp.Shared.Core.Interface.IntegryApi;
|
|
|
|
namespace SteUp.Shared.Core.Services;
|
|
|
|
public class IntegryApiService(
|
|
IIntegryApiRestClient integryApiRestClient,
|
|
ILogger<IntegryApiService> logger) : IIntegryApiService
|
|
{
|
|
public async Task<bool> SystemOk()
|
|
{
|
|
try
|
|
{
|
|
await integryApiRestClient.Get<object>("system/ok");
|
|
return true;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
logger.LogError(e, e.Message);
|
|
Console.WriteLine(e.Message);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public Task<List<StbActivityTyperDto>?> SuggestActivityDescription(string activityTypeId) =>
|
|
integryApiRestClient.AuthorizedGet<List<StbActivityTyperDto>?>("activity/suggestActivityDescription",
|
|
new Dictionary<string, object>
|
|
{
|
|
{ "activityType", activityTypeId }
|
|
}
|
|
);
|
|
|
|
public async Task SendEmail(SendEmailDto sendEmail)
|
|
{
|
|
using var content = new MultipartFormDataContent();
|
|
|
|
try
|
|
{
|
|
foreach (var a in sendEmail.Attachments ?? [])
|
|
{
|
|
var mediaType = a.FileName.EndsWith(".zip", StringComparison.OrdinalIgnoreCase)
|
|
? "application/zip"
|
|
: "application/octet-stream";
|
|
content.Add(new FileHttpContent(a.FilePath, mediaType), "allegati", a.FileName);
|
|
}
|
|
|
|
content.Add(
|
|
new StringContent(
|
|
JsonSerializer.Serialize(sendEmail),
|
|
Encoding.UTF8,
|
|
"application/json"
|
|
),
|
|
"request"
|
|
);
|
|
|
|
await integryApiRestClient.AuthorizedPost<object>("sendEmailNew", content);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine(e);
|
|
logger.LogError(e, e.Message);
|
|
throw;
|
|
}
|
|
}
|
|
} |