Fényképek letöltése programból
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user