forked from ddrilling/AsbCloudServer
Отправка данных об ошибке, если файл по какой-то причине не сформирован
This commit is contained in:
parent
82bcb509d3
commit
063096e236
@ -5,18 +5,8 @@ namespace AsbCloudApp.Data.Progress;
|
||||
/// <summary>
|
||||
/// DTO прогресса с ошибкой
|
||||
/// </summary>
|
||||
public class ProgressExceptionDto
|
||||
public class ProgressExceptionDto : ProgressDto
|
||||
{
|
||||
/// <summary>
|
||||
/// прогресс 0 - 100%
|
||||
/// </summary>
|
||||
public float Progress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// название текущей операции генерации
|
||||
/// </summary>
|
||||
public string? Operation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Отображаемый текст ошибки
|
||||
/// </summary>
|
||||
|
@ -8,5 +8,5 @@ public class ReportProgressFinalDto : ReportProgressDto
|
||||
/// <summary>
|
||||
/// файл
|
||||
/// </summary>
|
||||
public FileInfoDto? file { get; set; }
|
||||
public FileInfoDto file { get; set; } = null!;
|
||||
}
|
||||
|
@ -54,13 +54,15 @@ public class ReportService : IReportService
|
||||
progressHandler.Invoke(state, work.Id);
|
||||
}, token);
|
||||
|
||||
backgroundWorkerService.Enqueue(work);
|
||||
|
||||
progressHandler.Invoke(new ReportProgressDto
|
||||
{
|
||||
Operation = "Ожидает начала в очереди.",
|
||||
Progress = 0f,
|
||||
}, work.Id);
|
||||
|
||||
backgroundWorkerService.Enqueue(work);
|
||||
|
||||
|
||||
return work.Id;
|
||||
}
|
||||
|
||||
@ -153,6 +155,20 @@ public class ReportService : IReportService
|
||||
|
||||
var fileInfo = (await fileService.MoveAsync(idWell, idUser, ReportCategoryId, reportFileName, reportFileName, token))!;
|
||||
|
||||
if (fileInfo == null)
|
||||
{
|
||||
var state = new ProgressExceptionDto
|
||||
{
|
||||
Operation = "error",
|
||||
Progress = 0f,
|
||||
Message = "Не удалось сгенерировать файл отчёта",
|
||||
Exception = new FileNotFoundException(),
|
||||
};
|
||||
progressHandler(state, workId);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
progressHandler(new ReportProgressFinalDto()
|
||||
{
|
||||
Operation = "done",
|
||||
|
Loading…
Reference in New Issue
Block a user