Fix gestione allegati e creato metodo di esportazione log

This commit is contained in:
2026-03-04 11:51:42 +01:00
parent 3760e38c8d
commit 2d938fb210
26 changed files with 986 additions and 384 deletions

View File

@@ -1,6 +1,8 @@
using IntegryApiClient.Core.Domain.Abstraction.Contracts.Account;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using IntegryApiClient.Core.Domain.RestClient.Contacts;
using MudBlazor;
using Microsoft.Extensions.Logging;
using SteUp.Shared.Core.Dto;
using SteUp.Shared.Core.Interface.IntegryApi;
@@ -8,7 +10,7 @@ namespace SteUp.Shared.Core.Services;
public class IntegryApiService(
IIntegryApiRestClient integryApiRestClient,
IUserSession userSession) : IIntegryApiService
ILogger<IntegryApiService> logger) : IIntegryApiService
{
public async Task<bool> SystemOk()
{
@@ -19,6 +21,7 @@ public class IntegryApiService(
}
catch (Exception e)
{
logger.LogError(e, e.Message);
Console.WriteLine(e.Message);
return false;
}
@@ -31,4 +34,44 @@ public class IntegryApiService(
{ "activityType", activityTypeId }
}
);
public async Task SendEmail(SendEmailDto sendEmail)
{
var content = new MultipartFormDataContent();
try
{
if (sendEmail.Attachments != null)
{
foreach (var a in sendEmail.Attachments)
{
var fileContent = new ByteArrayContent(a.FileContent);
fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data");
content.Add(fileContent, "allegati", a.FileName);
}
}
sendEmail.Attachments = null;
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;
}
finally
{
content.Dispose();
}
}
}

View File

@@ -56,16 +56,17 @@ public class IntegrySteupService(IIntegryApiRestClient integryApiRestClient) : I
#endregion
public Task UploadFile(string activityId, byte[] file, string fileName)
public async Task UploadFile(string activityId, byte[] file, string fileName)
{
var queryParams = new Dictionary<string, object> { { "activityId", activityId } };
using var content = new MultipartFormDataContent();
var content = new MultipartFormDataContent();
var fileContent = new ByteArrayContent(file);
fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data");
content.Add(fileContent, "file", fileName);
return integryApiRestClient.Post<object>($"{BaseRequest}/uploadAttachment", content, queryParams!);
await integryApiRestClient.Post<object>($"{BaseRequest}/uploadAttachment", content, queryParams!);
content.Dispose();
}
public Task DeleteScheda(string activityId) =>