Fix gestione allegati e creato metodo di esportazione log
This commit is contained in:
@@ -8,6 +8,7 @@ public interface ISteupDataService
|
||||
Task Init();
|
||||
Task<bool> CanOpenNewInspection();
|
||||
void RegisterAppVersion();
|
||||
Task CheckAndUpdateStatus();
|
||||
|
||||
List<PuntoVenditaDto> PuntiVenditaList { get; }
|
||||
InspectionPageState InspectionPageState { get; set; }
|
||||
|
||||
@@ -34,7 +34,7 @@ public class SteupDataService(
|
||||
);
|
||||
}
|
||||
|
||||
private async Task CheckAndUpdateStatus()
|
||||
public async Task CheckAndUpdateStatus()
|
||||
{
|
||||
var ispezioni = await ispezioniService.GetAllIspezioniWithSchedeAsync();
|
||||
var listActivityId = ispezioni
|
||||
|
||||
33
SteUp.Shared/Core/Dto/SendEmailDto.cs
Normal file
33
SteUp.Shared/Core/Dto/SendEmailDto.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace SteUp.Shared.Core.Dto;
|
||||
|
||||
public class SendEmailDto
|
||||
{
|
||||
[JsonPropertyName("from")]
|
||||
public string? From { get; set; }
|
||||
|
||||
[JsonPropertyName("fromName")]
|
||||
public string? FromName { get; set; }
|
||||
|
||||
[JsonPropertyName("to")]
|
||||
public string? To { get; set; }
|
||||
|
||||
[JsonPropertyName("subject")]
|
||||
public string? Subject { get; set; }
|
||||
|
||||
[JsonPropertyName("msgText")]
|
||||
public string? MsgText { get; set; }
|
||||
|
||||
[JsonPropertyName("html")]
|
||||
public bool IsHtml { get; set; }
|
||||
|
||||
[JsonPropertyName("attachments")]
|
||||
public List<AttachmentsDto>? Attachments { get; set; }
|
||||
|
||||
public class AttachmentsDto
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public byte[] FileContent { get; set; } = [];
|
||||
}
|
||||
}
|
||||
@@ -7,4 +7,6 @@ public interface IIntegryApiService
|
||||
Task<bool> SystemOk();
|
||||
|
||||
Task<List<StbActivityTyperDto>?> SuggestActivityDescription(string activityTypeId);
|
||||
|
||||
Task SendEmail(SendEmailDto sendEmail);
|
||||
}
|
||||
@@ -24,6 +24,7 @@ public interface IIspezioniService
|
||||
Task<Scheda?> GetSchedaWithIspezioneAsync(int schedaId);
|
||||
Task<bool> UpdateSchedaAsync(Scheda scheda);
|
||||
Task<bool> UpdateActivityIdSchedaAsync(int schedaId, string? activityId);
|
||||
Task<bool> UpdateFileListSchedaAsync(int schedaId, List<string>? imageNames);
|
||||
Task<bool> DeleteSchedaAsync(int schedaId);
|
||||
Task<int> DeleteAllSchedeOfIspezioneAsync(string codMdep, DateTime data, string rilevatore);
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using SteUp.Shared.Core.Dto;
|
||||
using SteUp.Shared.Core.Entities;
|
||||
using SteUp.Shared.Core.Dto;
|
||||
|
||||
namespace SteUp.Shared.Core.Interface.System;
|
||||
|
||||
@@ -7,22 +6,4 @@ public interface IAttachedService
|
||||
{
|
||||
Task<AttachedDto?> SelectImageFromCamera();
|
||||
Task<List<AttachedDto>?> SelectImageFromGallery();
|
||||
|
||||
Task<List<AttachedDto>?> GetInspectionFiles(Ispezione ispezione, List<string> fileNameFilter,
|
||||
bool includeToUpload = true, CancellationToken ct = default);
|
||||
|
||||
Task<string?> SaveInspectionFile(Ispezione ispezione, byte[] file, string fileName, CancellationToken ct = default);
|
||||
|
||||
bool RemoveInspectionFile(Ispezione ispezione, string fileName, bool removeAlsoFromFinal = true,
|
||||
bool removeAlsoFromToUpload = true);
|
||||
|
||||
Task<bool> MoveInspectionFileFromToUploadToFinal(Ispezione ispezione, string fileName, bool overwrite = true,
|
||||
CancellationToken ct = default);
|
||||
|
||||
Task<string> SaveToTempStorage(Stream file, string fileName, CancellationToken ct = default);
|
||||
Task CleanTempStorageAsync(CancellationToken ct = default);
|
||||
Task OpenFile(string fileName, string filePath);
|
||||
|
||||
Task<(string originalUrl, string thumbUrl)> SaveAndCreateThumbAsync(byte[] bytes, string fileName,
|
||||
CancellationToken ct = default);
|
||||
}
|
||||
29
SteUp.Shared/Core/Interface/System/IFileManager.cs
Normal file
29
SteUp.Shared/Core/Interface/System/IFileManager.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using SteUp.Shared.Core.Dto;
|
||||
using SteUp.Shared.Core.Entities;
|
||||
|
||||
namespace SteUp.Shared.Core.Interface.System;
|
||||
|
||||
public interface IFileManager
|
||||
{
|
||||
Task<List<AttachedDto>?> GetInspectionFiles(Ispezione ispezione, List<string> fileNameFilter,
|
||||
bool includeToUpload = true, CancellationToken ct = default);
|
||||
|
||||
Task<string?> SaveInspectionFile(Ispezione ispezione, byte[] file, string fileName, CancellationToken ct = default);
|
||||
|
||||
string GetFileToUploadDir(Ispezione ispezione, string fileName);
|
||||
|
||||
bool RemoveInspectionFile(Ispezione ispezione, string fileName, bool removeAlsoFromFinal = true,
|
||||
bool removeAlsoFromToUpload = true);
|
||||
|
||||
Task<string?> MoveInspectionFileFromToUploadToFinal(Ispezione ispezione, string fileName, bool overwrite = true,
|
||||
CancellationToken ct = default);
|
||||
|
||||
Task<string> SaveToTempStorage(Stream file, string fileName, CancellationToken ct = default);
|
||||
Task CleanTempStorageAsync(CancellationToken ct = default);
|
||||
Task OpenFile(string fileName, string filePath);
|
||||
|
||||
Task<(string originalUrl, string thumbUrl)> SaveAndCreateThumbAsync(byte[] bytes, string fileName,
|
||||
CancellationToken ct = default);
|
||||
|
||||
List<SendEmailDto.AttachmentsDto> GetFileForExport();
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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) =>
|
||||
|
||||
Reference in New Issue
Block a user