Fényképek letöltése programból

This commit is contained in:
2025-04-16 12:34:00 +02:00
parent 335f00367d
commit a1d683b955
10 changed files with 326 additions and 6 deletions
@@ -0,0 +1,10 @@
using WorkFlowCheck.Common.DTO;
namespace WorkFlowCheck.Web.Services.Interfaces
{
public interface ISystemService
{
Task<List<ImageFileDTO>> GetAllImageFilesAsync();
Task<ApiResponseDTO<byte[]>> DownloadFile(string filename);
}
}
@@ -0,0 +1,55 @@
using Serilog;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.Web.Services.Interfaces;
namespace WorkFlowCheck.Web.Services
{
public class SystemService:BaseService, ISystemService
{
public SystemService(HttpClient httpClient, IConfiguration configuration, IHttpContextAccessor httpContextAccessor) : base(httpClient, configuration, httpContextAccessor)
{
}
public async Task<List<ImageFileDTO>> GetAllImageFilesAsync()
{
var endpoint = $"{_httpClient.BaseAddress}api/System/GetAllImageFiles";
var retVal = new List<ImageFileDTO>();
try
{
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<List<ImageFileDTO>>>(endpoint);
if (response != null)
{
if (response.IsSuccess)
{
return response.Data;
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
public async Task<ApiResponseDTO<byte[]>> DownloadFile(string filename)
{
var retVal = new ApiResponseDTO<byte[]>();
var endpoint = $"{_httpClient.BaseAddress}api/System/DownloadFile/{filename}";
try
{
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<byte[]>>(endpoint);
if (response != null)
{
if (response.IsSuccess)
{
return response;
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
}
}