PDF készítés DevExpressel.
This commit is contained in:
@@ -115,7 +115,8 @@
|
||||
$('#tbCheckListHeadersPage').on('click', '.pdf-btn', function ()
|
||||
{
|
||||
const row = table.row($(this).closest('tr')).data();
|
||||
window.location.href = `@Url.Page("./CheckListHeaderEditPage")?id=${row.id}`;
|
||||
window.location.href = `@Url.Page("./CheckListHeaderPage")?handler=CreatePDF&id=${row.id}`;
|
||||
|
||||
});
|
||||
|
||||
$('#tbCheckListHeadersPage').on('click', '.delete-btn', function ()
|
||||
|
||||
+25
-2
@@ -22,14 +22,37 @@ namespace WorkFlowCheck.Web.Pages.CheckList.CheckListHeader
|
||||
}
|
||||
public async Task OnGet()
|
||||
{
|
||||
CheckStatus = _checkListService.GetCheckStatus();
|
||||
CheckStatus = _checkListService.GetCheckStatus();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<JsonResult> OnGetLoadCheckListHeaders()
|
||||
{
|
||||
var results = await _checkListService.GetAllCheckListHeaderAsync();
|
||||
return new JsonResult(new { data = results });
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetCreatePDF(int id)
|
||||
{
|
||||
var checkListHeaderDTO = await _checkListService.GetCheckListHeader(id);
|
||||
|
||||
var response = await _checkListService.CreatePDF(id);
|
||||
|
||||
if (response.IsSuccess)
|
||||
{
|
||||
var timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
||||
var fileName = $"PH_{timestamp}_{checkListHeaderDTO.Id}.pdf";
|
||||
var result = new FileContentResult(response.Data, "application/pdf")
|
||||
{
|
||||
FileDownloadName = fileName,
|
||||
FileContents = response.Data
|
||||
};
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new JsonResult(new { success = false });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace WorkFlowCheck.Web.Services
|
||||
public CheckListService(HttpClient httpClient, IConfiguration configuration, IHttpContextAccessor httpContextAccessor) : base(httpClient, configuration, httpContextAccessor)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<CheckListHeaderDTO>> GetAllCheckListHeaderAsync()
|
||||
{
|
||||
var endpoint = $"{_httpClient.BaseAddress}api/CheckList/GetAllCheckListHeaders";
|
||||
@@ -60,6 +60,27 @@ namespace WorkFlowCheck.Web.Services
|
||||
}
|
||||
public async Task<ApiResponseDTO<CheckListHeaderDTO>> UpdateCheckListHeader(CheckListHeaderDTO checkListHeaderDTO) => throw new NotImplementedException();
|
||||
|
||||
public async Task<ApiResponseDTO<byte[]>> CreatePDF(int id)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<byte[]>();
|
||||
var endpoint = $"{_httpClient.BaseAddress}api/CheckList/CreatePDF/{id}";
|
||||
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;
|
||||
}
|
||||
|
||||
public async Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateHeaderAsync()
|
||||
{
|
||||
@@ -250,5 +271,5 @@ namespace WorkFlowCheck.Web.Services
|
||||
.GetCustomAttribute<DisplayAttribute>()?.Name ?? enumValue.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace WorkFlowCheck.Web.Services.Interfaces
|
||||
Task<CheckListHeaderDTO> GetCheckListHeader(int id);
|
||||
Task<List<CheckListHeaderDTO>> GetAllCheckListHeaderAsync();
|
||||
Task<ApiResponseDTO<CheckListHeaderDTO>> UpdateCheckListHeader(CheckListHeaderDTO checkListHeaderDTO);
|
||||
Task<ApiResponseDTO<byte[]>> CreatePDF(int id);
|
||||
|
||||
Task<CheckListTemplateHeaderDTO> GetCheckListTemplateHeader(int id);
|
||||
Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateHeaderAsync();
|
||||
|
||||
Reference in New Issue
Block a user