Fix DetectedOperationExportService.ExportAsync exception type/text

This commit is contained in:
ngfrolov 2023-12-26 14:03:31 +05:00
parent fa3de75b85
commit 4c3f638bfb
Signed by: ng.frolov
GPG Key ID: E99907A0357B29A7

View File

@ -12,6 +12,7 @@ using AsbCloudApp.Data.DetectedOperation;
using AsbCloudInfrastructure.Services.DetectOperations.Detectors;
using AsbCloudApp.Repositories;
using Microsoft.AspNetCore.Http.Extensions;
using AsbCloudApp.Exceptions;
namespace AsbCloudInfrastructure.Services.DetectOperations;
@ -57,21 +58,21 @@ public class DetectedOperationExportService
/// <param name="host">хост</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="ArgumentInvalidException"></exception>
public async Task<Stream> ExportAsync(int idWell, string host, CancellationToken cancellationToken)
{
var well = await dbContext.Wells
var well = await dbContext.Set<Well>()
.Include(w => w.Cluster)
.ThenInclude(c => c.Deposit)
.SingleOrDefaultAsync(w => w.Id == idWell, cancellationToken);
.FirstOrDefaultAsync(w => w.Id == idWell, cancellationToken);
if (well is null)
throw new ArgumentNullException(nameof(well));
throw new ArgumentInvalidException(nameof(idWell), $"Well {idWell} does not exist");
if (!well.IdTelemetry.HasValue)
throw new ArgumentNullException(nameof(well));
throw new ArgumentInvalidException(nameof(idWell), $"Well {idWell} has no telemetry");
var operations = await DetectOperationsAsync(well.IdTelemetry.Value, DateTime.UnixEpoch, cancellationToken);
var operations = await DetectOperationsAsync(well.IdTelemetry.Value, DateTime.UnixEpoch, cancellationToken);
return await GenerateExcelFileStreamAsync(well, host, operations, cancellationToken);
}