Merge branch 'dev' into feature/change-log-refactoring

This commit is contained in:
on.nemtina 2024-05-29 09:25:11 +05:00
commit 305da7828a
29 changed files with 170 additions and 148 deletions

View File

@ -3,6 +3,9 @@ using AsbCloudApp.Data.WellOperation;
namespace AsbCloudApp.Data namespace AsbCloudApp.Data
{ {
/// <summary>
/// dto для хранения данных статистики сауб
/// </summary>
public class DataSaubStatDto:IId public class DataSaubStatDto:IId
{ {
/// <summary> /// <summary>

View File

@ -72,7 +72,7 @@ public class ProcessMapPlanReamDto : ProcessMapPlanBaseDto, IValidatableObject
public double Torque { get; set; } public double Torque { get; set; }
/// <inheritdoc/> /// <inheritdoc/>
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) public override IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{ {
if (DepthEnd < DepthStart) if (DepthEnd < DepthStart)
yield return new ValidationResult( yield return new ValidationResult(

View File

@ -5,18 +5,8 @@ namespace AsbCloudApp.Data.Progress;
/// <summary> /// <summary>
/// DTO прогресса с ошибкой /// DTO прогресса с ошибкой
/// </summary> /// </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>
/// Отображаемый текст ошибки /// Отображаемый текст ошибки
/// </summary> /// </summary>

View File

@ -8,5 +8,5 @@ public class ReportProgressFinalDto : ReportProgressDto
/// <summary> /// <summary>
/// файл /// файл
/// </summary> /// </summary>
public FileInfoDto file { get; set; } public FileInfoDto file { get; set; } = null!;
} }

View File

@ -4,6 +4,9 @@ using System.ComponentModel.DataAnnotations;
namespace AsbCloudApp.Data.WellOperation; namespace AsbCloudApp.Data.WellOperation;
/// <summary>
/// Операция по скважине
/// </summary>
public class WellOperationDto : ItemInfoDto, public class WellOperationDto : ItemInfoDto,
IId, IId,
IWellRelated, IWellRelated,

View File

@ -70,6 +70,13 @@ namespace AsbCloudApp.Services
/// <param name="token"></param> /// <param name="token"></param>
/// <returns></returns> /// <returns></returns>
Task<int> MergeAsync(int from, int to, CancellationToken token); Task<int> MergeAsync(int from, int to, CancellationToken token);
/// <summary>
/// Получить телеметрию по последней дате
/// </summary>
/// <param name="from"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<Stream> GetTelemetriesInfoByLastData(DateTimeOffset from, CancellationToken token); Task<Stream> GetTelemetriesInfoByLastData(DateTimeOffset from, CancellationToken token);
} }
} }

View File

@ -62,6 +62,7 @@
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="2.1.21" /> <PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="2.1.21" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="7.2.0" /> <PackageReference Include="Microsoft.IdentityModel.Tokens" Version="7.2.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.2.0" /> <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.2.0" />
</ItemGroup> </ItemGroup>

View File

@ -46,14 +46,15 @@ namespace AsbCloudInfrastructure
/// <returns></returns> /// <returns></returns>
public static Task<IEnumerable<T>> GetOrCreateBasicAsync<T>(this IMemoryCache memoryCache, Func<CancellationToken, Task<IEnumerable<T>>> getterAsync, CancellationToken token) public static Task<IEnumerable<T>> GetOrCreateBasicAsync<T>(this IMemoryCache memoryCache, Func<CancellationToken, Task<IEnumerable<T>>> getterAsync, CancellationToken token)
{ {
var key = typeof(T).FullName; var key = typeof(T).FullName!;
var cache = memoryCache.GetOrCreateAsync(key, async (cacheEntry) => { var cache = memoryCache.GetOrCreateAsync(key, async (cacheEntry) =>
{
cacheEntry.AbsoluteExpirationRelativeToNow = CacheOlescence; cacheEntry.AbsoluteExpirationRelativeToNow = CacheOlescence;
cacheEntry.SlidingExpiration = CacheOlescence; cacheEntry.SlidingExpiration = CacheOlescence;
var entities = await getterAsync(token); var entities = await getterAsync(token);
return entities; return entities;
}); });
return cache; return cache!;
} }
/// <summary> /// <summary>
@ -83,13 +84,14 @@ namespace AsbCloudInfrastructure
/// <returns></returns> /// <returns></returns>
public static IEnumerable<T> GetOrCreateBasic<T>(this IMemoryCache memoryCache, Func<IEnumerable<T>> getter) public static IEnumerable<T> GetOrCreateBasic<T>(this IMemoryCache memoryCache, Func<IEnumerable<T>> getter)
{ {
var key = typeof(T).FullName; var key = typeof(T).FullName!;
var cache = memoryCache.GetOrCreate(key, cacheEntry => { var cache = memoryCache.GetOrCreate(key, cacheEntry =>
{
cacheEntry.AbsoluteExpirationRelativeToNow = CacheOlescence; cacheEntry.AbsoluteExpirationRelativeToNow = CacheOlescence;
cacheEntry.SlidingExpiration = CacheOlescence; cacheEntry.SlidingExpiration = CacheOlescence;
return getter(); return getter();
}); });
return cache; return cache!;
} }
/// <summary> /// <summary>
@ -101,7 +103,8 @@ namespace AsbCloudInfrastructure
public static void DropBasic<T>(this IMemoryCache memoryCache) public static void DropBasic<T>(this IMemoryCache memoryCache)
where T : class where T : class
{ {
var key = typeof(T).FullName; var key = typeof(T).FullName!;
memoryCache.Remove(key); memoryCache.Remove(key);
} }
} }

View File

@ -43,7 +43,7 @@ namespace AsbCloudInfrastructure.Repository
cacheEntry.Value = entities; cacheEntry.Value = entities;
return entities; return entities;
}); });
return cache; return cache!;
} }
protected virtual Task<IEnumerable<TEntity>> GetCacheAsync(CancellationToken token) protected virtual Task<IEnumerable<TEntity>> GetCacheAsync(CancellationToken token)

View File

@ -77,7 +77,7 @@ public class NotificationRepository : CrudRepositoryBase<NotificationDto, Notifi
.ToArrayAsync(cancellationToken); .ToArrayAsync(cancellationToken);
} }
public async Task<int> UpdateRangeAsync(IEnumerable<NotificationDto> notifications, CancellationToken cancellationToken) public override async Task<int> UpdateRangeAsync(IEnumerable<NotificationDto> notifications, CancellationToken cancellationToken)
{ {
if (!notifications.Any()) if (!notifications.Any())
return 0; return 0;

View File

@ -2,6 +2,7 @@
using AsbCloudApp.Exceptions; using AsbCloudApp.Exceptions;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using System; using System;
using System.Configuration;
using System.IO; using System.IO;
namespace AsbCloudInfrastructure.Services.Email namespace AsbCloudInfrastructure.Services.Email
@ -9,17 +10,24 @@ namespace AsbCloudInfrastructure.Services.Email
public class BaseFactory public class BaseFactory
{ {
private readonly string platformName; protected readonly string platformName;
private readonly string platformUrl; protected readonly string platformUrl;
private readonly string companyName; protected readonly string companyName;
private readonly string supportMail; protected readonly string supportMail;
public BaseFactory(IConfiguration configuration) public BaseFactory(IConfiguration configuration)
{ {
platformName = configuration.GetValue("email:platformName", "Цифровое бурение"); platformName = configuration.GetValue<string>("email:platformName")
platformUrl = configuration.GetValue("email:platformUrl", "https://cloud.digitaldrilling.ru/"); ?? throw new ConfigurationErrorsException("email:platformName не определен");
companyName = configuration.GetValue("email:companyName", "ООО \"Цифровое бурение\"");
supportMail = configuration.GetValue("email:supportMail", "support@digitaldrilling.ru"); platformUrl = configuration.GetValue<string>("email:platformUrl")
?? throw new ConfigurationErrorsException("email:platformUrl не определен");
companyName = configuration.GetValue<string>("email:companyName")
?? throw new ConfigurationErrorsException("email:companyName не определен");
supportMail = configuration.GetValue<string>("email:supportMail")
?? throw new ConfigurationErrorsException("email:supportMail не определен");
} }
public static string GetOrEmptyImageBase64(string resourceFileName) public static string GetOrEmptyImageBase64(string resourceFileName)
@ -37,7 +45,7 @@ namespace AsbCloudInfrastructure.Services.Email
{ {
System.Diagnostics.Trace.TraceWarning($"GetOrEmptyImageBase64(). File {logoFilePath} not found."); System.Diagnostics.Trace.TraceWarning($"GetOrEmptyImageBase64(). File {logoFilePath} not found.");
return string.Empty; return string.Empty;
} }
var imageBytes = File.ReadAllBytes(logoFilePath); var imageBytes = File.ReadAllBytes(logoFilePath);
var format = Path.GetExtension(resourceFileName).Trim('.'); var format = Path.GetExtension(resourceFileName).Trim('.');

View File

@ -4,83 +4,79 @@ using Microsoft.Extensions.Configuration;
namespace AsbCloudInfrastructure.Services.Email namespace AsbCloudInfrastructure.Services.Email
{ {
class DrillingMailBodyFactory : BaseFactory class DrillingMailBodyFactory : BaseFactory
{ {
private readonly string platformName;
private readonly string platformUrl;
public DrillingMailBodyFactory(IConfiguration configuration) public DrillingMailBodyFactory(IConfiguration configuration)
: base(configuration) : base(configuration)
{ {
platformName = configuration.GetValue("email:platformName", "Цифровое бурение"); }
platformUrl = configuration.GetValue("email:platformUrl", "https://cloud.digitaldrilling.ru/");
}
public override string MakeSubject(WellDto well, string action) public override string MakeSubject(WellDto well, string action)
{ {
var subj = $"{well.Deposit}, {well.Cluster}, {well.Caption}. Программа бурения. {action}"; var subj = $"{well.Deposit}, {well.Cluster}, {well.Caption}. Программа бурения. {action}";
return subj; return subj;
} }
public string MakeMailBodyForNewPublisher(WellDto well, string publisherName, string documentCategory) public string MakeMailBodyForNewPublisher(WellDto well, string publisherName, string documentCategory)
{
var drillingProgramHref = MakeDrillingProgramHref(well);
var body = $"<html><body><h2>Здравствуйте, {publisherName}.</h2>" +
$"На портале {platformName} началось создание программы бурения скважины {drillingProgramHref}," +
$" куст {well.Cluster}, месторождение {well.Deposit}." +
$"<br><br>От вас ожидается загрузка на портал документа «{documentCategory}» в формате excel (*.xlsx)." +
MakeSignatue() +
$"</body></html>";
return body;
}
public string MakeMailBodyForApproverNewFile(WellDto well, string approverName, int idFile, string fileName)
{ {
var drillingProgramHref = MakeDrillingProgramHref(well); var drillingProgramHref = MakeDrillingProgramHref(well);
var body = $"<html><body><h2>Здравствуйте, {approverName}.</h2>" + var body = $"<html><body><h2>Здравствуйте, {publisherName}.</h2>" +
$"На портал {platformName} загружен документ {fileName}" + $"На портале {platformName} началось создание программы бурения скважины {drillingProgramHref}," +
$" для согласования при создании программы бурения скважины {drillingProgramHref}, куст ({well.Cluster})" + $" куст {well.Cluster}, месторождение {well.Deposit}." +
$", месторождение ({well.Deposit}).<br>" + $"<br><br>От вас ожидается загрузка на портал документа «{documentCategory}» в формате excel (*.xlsx)." +
MakeSignatue() + MakeSignatue() +
$"</body></html>"; $"</body></html>";
return body; return body;
} }
public string MakeMailBodyForPublisherOnReject(WellDto well, string publisherName, int idFile, string fileName, FileMarkDto fileMark) public string MakeMailBodyForApproverNewFile(WellDto well, string approverName, int idFile, string fileName)
{
var drillingProgramHref = MakeDrillingProgramHref(well);
var body = $"<html><body><h2>Здравствуйте, {publisherName}.</h2>" +
$"На портале {platformName} отклонен загруженный вами документ {fileName} " +
$" по программе бурения скважины {drillingProgramHref}," +
$" куст {well.Cluster}, месторождение {well.Deposit}." +
$" Комментарий согласующего ({fileMark.User?.Name} {fileMark.User?.Surname}):<br>{fileMark.Comment}" +
MakeSignatue() +
$"</body></html>";
return body;
}
public string MakeMailBodyForPublisherOnFullAccept(WellDto well, string publisherName, int idFile, string fileName)
{
var drillingProgramHref = MakeDrillingProgramHref(well);
var body = $"<html><body><h2>Здравствуйте, {publisherName}.</h2>" +
$"На портале {platformName} полностью согласован документ {fileName} " +
$" по программе бурения скважины {drillingProgramHref}," +
$" куст {well.Cluster}, месторождение {well.Deposit}." +
MakeSignatue() +
$"</body></html>";
return body;
}
private string MakeDrillingProgramHref(WellDto well)
{ {
var drillingProgramUrl = $"{platformUrl}/well/{well.Id}/drillingProgram"; var drillingProgramHref = MakeDrillingProgramHref(well);
var drillingProgramHref = MakeHref(drillingProgramUrl, well.Caption);
return drillingProgramHref; var body = $"<html><body><h2>Здравствуйте, {approverName}.</h2>" +
} $"На портал {platformName} загружен документ {fileName}" +
} $" для согласования при создании программы бурения скважины {drillingProgramHref}, куст ({well.Cluster})" +
$", месторождение ({well.Deposit}).<br>" +
MakeSignatue() +
$"</body></html>";
return body;
}
public string MakeMailBodyForPublisherOnReject(WellDto well, string publisherName, int idFile, string fileName, FileMarkDto fileMark)
{
var drillingProgramHref = MakeDrillingProgramHref(well);
var body = $"<html><body><h2>Здравствуйте, {publisherName}.</h2>" +
$"На портале {platformName} отклонен загруженный вами документ {fileName} " +
$" по программе бурения скважины {drillingProgramHref}," +
$" куст {well.Cluster}, месторождение {well.Deposit}." +
$" Комментарий согласующего ({fileMark.User?.Name} {fileMark.User?.Surname}):<br>{fileMark.Comment}" +
MakeSignatue() +
$"</body></html>";
return body;
}
public string MakeMailBodyForPublisherOnFullAccept(WellDto well, string publisherName, int idFile, string fileName)
{
var drillingProgramHref = MakeDrillingProgramHref(well);
var body = $"<html><body><h2>Здравствуйте, {publisherName}.</h2>" +
$"На портале {platformName} полностью согласован документ {fileName} " +
$" по программе бурения скважины {drillingProgramHref}," +
$" куст {well.Cluster}, месторождение {well.Deposit}." +
MakeSignatue() +
$"</body></html>";
return body;
}
private string MakeDrillingProgramHref(WellDto well)
{
var drillingProgramUrl = $"{platformUrl}/well/{well.Id}/drillingProgram";
var drillingProgramHref = MakeHref(drillingProgramUrl, well.Caption);
return drillingProgramHref;
}
}
} }

View File

@ -4,6 +4,7 @@ using AsbCloudApp.Repositories;
using AsbCloudApp.Services.Notifications; using AsbCloudApp.Services.Notifications;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Net.Mail; using System.Net.Mail;
@ -29,9 +30,14 @@ namespace AsbCloudInfrastructure.Services.Email
{ {
this.userRepository = userRepository; this.userRepository = userRepository;
this.sender = configuration.GetValue("email:sender", string.Empty); this.sender = configuration.GetValue<string>("email:sender")
this.smtpPassword = configuration.GetValue("email:password", string.Empty); ?? throw new ConfigurationErrorsException("email:sender не определен");
this.smtpServer = configuration.GetValue("email:smtpServer", string.Empty);
this.smtpPassword = configuration.GetValue<string>("email:password")
?? throw new ConfigurationErrorsException("email:password не определен");
this.smtpServer = configuration.GetValue<string>("email:smtpServer")
?? throw new ConfigurationErrorsException("email:smtpServer не определен");
var configError = string.IsNullOrEmpty(this.sender) || var configError = string.IsNullOrEmpty(this.sender) ||
string.IsNullOrEmpty(this.smtpPassword) || string.IsNullOrEmpty(this.smtpPassword) ||

View File

@ -9,12 +9,11 @@ namespace AsbCloudInfrastructure
class WellFinalDocumentMailBodyFactory : BaseFactory class WellFinalDocumentMailBodyFactory : BaseFactory
{ {
private readonly string platformName;
public WellFinalDocumentMailBodyFactory(IConfiguration configuration) public WellFinalDocumentMailBodyFactory(IConfiguration configuration)
: base(configuration) : base(configuration)
{ {
platformName = configuration.GetValue("email:platformName", "Цифровое бурение");
} }
public override string MakeSubject(WellDto well, string action) public override string MakeSubject(WellDto well, string action)

View File

@ -1,11 +1,11 @@
using AsbCloudApp.Data; using AsbCloudApp.Data;
using AsbCloudApp.Repositories; using AsbCloudApp.Repositories;
using AsbCloudApp.Services; using AsbCloudApp.Services;
using Microsoft.Extensions.Configuration;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
namespace AsbCloudInfrastructure.Services; namespace AsbCloudInfrastructure.Services;
@ -14,7 +14,7 @@ namespace AsbCloudInfrastructure.Services;
/// </summary> /// </summary>
public class HelpPageService : IHelpPageService public class HelpPageService : IHelpPageService
{ {
private readonly string directoryNameHelpPageFiles; private readonly string directoryNameHelpPageFiles;
private readonly IHelpPageRepository helpPageRepository; private readonly IHelpPageRepository helpPageRepository;
private readonly IFileStorageRepository fileStorageRepository; private readonly IFileStorageRepository fileStorageRepository;
@ -27,13 +27,10 @@ public class HelpPageService : IHelpPageService
public HelpPageService(IHelpPageRepository helpPageRepository, public HelpPageService(IHelpPageRepository helpPageRepository,
IFileStorageRepository fileStorageRepository, IFileStorageRepository fileStorageRepository,
IConfiguration configuration) IConfiguration configuration)
{ {
this.helpPageRepository = helpPageRepository; this.helpPageRepository = helpPageRepository;
this.fileStorageRepository = fileStorageRepository; this.fileStorageRepository = fileStorageRepository;
directoryNameHelpPageFiles = configuration.GetValue<string>("DirectoryNameHelpPageFiles"); directoryNameHelpPageFiles = configuration.GetValue("DirectoryNameHelpPageFiles", "helpPages")!;
if (string.IsNullOrWhiteSpace(directoryNameHelpPageFiles))
directoryNameHelpPageFiles = "helpPages";
} }
/// <summary> /// <summary>
@ -45,17 +42,17 @@ public class HelpPageService : IHelpPageService
/// <param name="fileStream"></param> /// <param name="fileStream"></param>
/// <param name="cancellationToken"></param> /// <param name="cancellationToken"></param>
/// <returns></returns> /// <returns></returns>
public async Task<int> AddOrUpdateAsync(string urlPage, public async Task<int> AddOrUpdateAsync(string urlPage,
int idCategory, int idCategory,
string fileName, string fileName,
Stream fileStream, Stream fileStream,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
var helpPage = await helpPageRepository.GetOrDefaultByUrlPageAndIdCategoryAsync(urlPage, var helpPage = await helpPageRepository.GetOrDefaultByUrlPageAndIdCategoryAsync(urlPage,
idCategory, idCategory,
cancellationToken); cancellationToken);
if(helpPage is not null) if (helpPage is not null)
{ {
await UpdateFileAsync(helpPage, await UpdateFileAsync(helpPage,
idCategory, idCategory,
@ -86,12 +83,12 @@ public class HelpPageService : IHelpPageService
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
pageKey = WebUtility.UrlDecode(pageKey); pageKey = WebUtility.UrlDecode(pageKey);
var helpPage = await helpPageRepository.GetOrDefaultByUrlPageAndIdCategoryAsync(pageKey, var helpPage = await helpPageRepository.GetOrDefaultByUrlPageAndIdCategoryAsync(pageKey,
idCategory, idCategory,
cancellationToken); cancellationToken);
if(helpPage is null) if (helpPage is null)
return null; return null;
string filePath = fileStorageRepository.GetFilePath(directoryNameHelpPageFiles, string filePath = fileStorageRepository.GetFilePath(directoryNameHelpPageFiles,

View File

@ -35,10 +35,7 @@ public class ManualCatalogService : IManualCatalogService
this.fileStorageRepository = fileStorageRepository; this.fileStorageRepository = fileStorageRepository;
this.manualDirectoryRepository = manualDirectoryRepository; this.manualDirectoryRepository = manualDirectoryRepository;
this.manualRepository = manualRepository; this.manualRepository = manualRepository;
directoryFiles = configuration.GetValue<string>("DirectoryManualFiles"); directoryFiles = configuration.GetValue<string>("DirectoryManualFiles", "manuals")!;
if (string.IsNullOrWhiteSpace(directoryFiles))
directoryFiles = "manuals";
} }
public async Task<int> SaveFileAsync(int idDirectory, int idAuthor, string name, Stream stream, CancellationToken cancellationToken) public async Task<int> SaveFileAsync(int idDirectory, int idAuthor, string name, Stream stream, CancellationToken cancellationToken)

View File

@ -38,7 +38,7 @@ namespace AsbCloudInfrastructure.Services
.ToDictionaryAsync(e => e.Id, e => e.Name, token); .ToDictionaryAsync(e => e.Id, e => e.Name, token);
return entities; return entities;
}); });
return cache; return cache!;
} }
public async Task<MeasureDto?> GetLastOrDefaultAsync(int idWell, int idCategory, CancellationToken token) public async Task<MeasureDto?> GetLastOrDefaultAsync(int idWell, int idCategory, CancellationToken token)

View File

@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
@ -36,7 +37,8 @@ namespace AsbCloudInfrastructure.Services
private ReduceSamplingService(IConfiguration configuration) private ReduceSamplingService(IConfiguration configuration)
{ {
connectionString = configuration.GetConnectionString("DefaultConnection"); connectionString = configuration.GetConnectionString("DefaultConnection")
?? throw new ConfigurationErrorsException("DefaultConnection не определен");
} }
~ReduceSamplingService() ~ReduceSamplingService()

View File

@ -54,13 +54,14 @@ public class ReportService : IReportService
progressHandler.Invoke(state, work.Id); progressHandler.Invoke(state, work.Id);
}, token); }, token);
backgroundWorkerService.Enqueue(work);
progressHandler.Invoke(new ReportProgressDto progressHandler.Invoke(new ReportProgressDto
{ {
Operation = "Ожидает начала в очереди.", Operation = "Ожидает начала в очереди.",
Progress = 0f, Progress = 0f,
}, work.Id); }, work.Id);
backgroundWorkerService.Enqueue(work);
return work.Id; return work.Id;
} }
@ -153,6 +154,20 @@ public class ReportService : IReportService
var fileInfo = (await fileService.MoveAsync(idWell, idUser, ReportCategoryId, reportFileName, reportFileName, token))!; var fileInfo = (await fileService.MoveAsync(idWell, idUser, ReportCategoryId, reportFileName, reportFileName, token))!;
if (fileInfo == null)
{
var state = new ProgressExceptionDto
{
Operation = "error",
Progress = 100f,
Message = "Не удалось сгенерировать файл отчёта",
Exception = new FileNotFoundException(),
};
progressHandler(state, workId);
return;
}
progressHandler(new ReportProgressFinalDto() progressHandler(new ReportProgressFinalDto()
{ {
Operation = "done", Operation = "done",

View File

@ -84,7 +84,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
var entities = db.Set<TelemetryUser>().ToArray(); var entities = db.Set<TelemetryUser>().ToArray();
return entities; return entities;
}); });
return cache; return cache!;
} }
private void DropCache() private void DropCache()

View File

@ -21,7 +21,7 @@ public interface IDrillTestControllerClient
int id, int id,
CancellationToken cancellationToken); CancellationToken cancellationToken);
[HttpGet("/api/well/{idWell}/DrillTest/all")] [Get("/api/well/{idWell}/DrillTest/all")]
Task<IApiResponse<PaginationContainer<DrillTestReportInfoDto>>> GetListAsync( Task<IApiResponse<PaginationContainer<DrillTestReportInfoDto>>> GetListAsync(
int idWell, int idWell,
FileReportRequest request, FileReportRequest request,

View File

@ -55,7 +55,6 @@ public class DetectedOperationControllerTests : BaseIntegrationTest
//assert //assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.NotNull(response.Content);
Assert.Equal(1, response.Content); Assert.Equal(1, response.Content);
} }
@ -76,7 +75,6 @@ public class DetectedOperationControllerTests : BaseIntegrationTest
//assert //assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.NotNull(response.Content);
Assert.Equal(1, response.Content); Assert.Equal(1, response.Content);
} }
@ -112,7 +110,6 @@ public class DetectedOperationControllerTests : BaseIntegrationTest
//assert //assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.NotNull(response.Content);
Assert.Equal(1, response.Content); Assert.Equal(1, response.Content);
} }

View File

@ -77,7 +77,7 @@ public class ProcessMapReportDrillingControllerTest : BaseIntegrationTest
//assert //assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.NotNull(response.Content); Assert.NotNull(response.Content);
Assert.Equal(1, response.Content.Count()); Assert.Single(response.Content);
} }
[Fact] [Fact]

View File

@ -118,7 +118,7 @@ public class WellOperationControllerTest : BaseIntegrationTest
var response = await client.GetPageOperationsAsync(well.Id, request); var response = await client.GetPageOperationsAsync(well.Id, request);
//assert //assert
Assert.Equal(response.StatusCode, HttpStatusCode.OK); Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.NotNull(response.Content); Assert.NotNull(response.Content);
var totalExpected = response.Content.Count - pageSize * pageIndex; var totalExpected = response.Content.Count - pageSize * pageIndex;
@ -230,10 +230,8 @@ public class WellOperationControllerTest : BaseIntegrationTest
Assert.True(notExistedInDb.Count() == 0); Assert.True(notExistedInDb.Count() == 0);
} }
[Theory] [Fact]
[InlineData(WellOperation.IdOperationTypePlan)] public async Task GetPageOperationsAsyncWithDaysAndNpv_returns_success()
[InlineData(WellOperation.IdOperationTypeFact)]
public async Task GetPageOperationsAsyncWithDaysAndNpv_returns_success(int idType)
{ {
//arrange //arrange
const int pageSize = 10; const int pageSize = 10;

View File

@ -48,7 +48,7 @@ public class BackgroundWorkerTest
backgroundWorker.Enqueue(work); backgroundWorker.Enqueue(work);
} }
await backgroundWorker.ExecuteTask; await backgroundWorker.ExecuteTask!;
//assert //assert
Assert.Equal(workCount, result); Assert.Equal(workCount, result);
@ -79,7 +79,7 @@ public class BackgroundWorkerTest
backgroundWorker.Enqueue(badWork); backgroundWorker.Enqueue(badWork);
backgroundWorker.Enqueue(goodWork); backgroundWorker.Enqueue(goodWork);
await backgroundWorker.ExecuteTask; await backgroundWorker.ExecuteTask!;
//assert //assert
Assert.Equal(expectadResult, result); Assert.Equal(expectadResult, result);
@ -109,7 +109,7 @@ public class BackgroundWorkerTest
var removed = backgroundWorker.TryRemoveFromQueue((workCount - 1).ToString()); var removed = backgroundWorker.TryRemoveFromQueue((workCount - 1).ToString());
await backgroundWorker.ExecuteTask; await backgroundWorker.ExecuteTask!;
//assert //assert
Assert.True(removed); Assert.True(removed);

View File

@ -1,13 +1,13 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using AsbCloudApp.Data; using AsbCloudApp.Data;
using AsbCloudApp.Repositories; using AsbCloudApp.Repositories;
using AsbCloudInfrastructure.Services; using AsbCloudInfrastructure.Services;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using NSubstitute; using NSubstitute;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Xunit; using Xunit;
namespace AsbCloudWebApi.Tests.Services; namespace AsbCloudWebApi.Tests.Services;
@ -18,7 +18,7 @@ public class HelpPageServiceTest
private const string fileName = "Справка_для_страницы_test.pdf"; private const string fileName = "Справка_для_страницы_test.pdf";
private const int idCategory = 20000; private const int idCategory = 20000;
private static Dictionary<string, string> configSettings = new() private static Dictionary<string, string?> configSettings = new()
{ {
{ "DirectoryNameHelpPageFiles", "helpPages" } { "DirectoryNameHelpPageFiles", "helpPages" }
}; };

View File

@ -43,7 +43,7 @@ namespace AsbCloudWebApi.Tests.Services.Notification
Surname = "Test", Surname = "Test",
}; };
private static Dictionary<string, string> configSettings = new() private static Dictionary<string, string?> configSettings = new()
{ {
{ "email:sender", "bot@digitaldrilling.ru" }, { "email:sender", "bot@digitaldrilling.ru" },
{ "email:password", "8wZrXSfP" }, { "email:password", "8wZrXSfP" },

View File

@ -46,9 +46,9 @@ namespace AsbCloudWebApi.Controllers
var drillers = schedulePage var drillers = schedulePage
.Select(s => s.Driller) .Select(s => s.Driller)
.Where(d => d is not null) .Where(d => d is not null)
.GroupBy(d => d.Id) .GroupBy(d => d!.Id)
.Select(group => group.First()) .Select(group => group.First())
.OrderBy(d => d.Surname); .OrderBy(d => d!.Surname);
return Ok(drillers); return Ok(drillers);
} }

View File

@ -114,7 +114,7 @@ public static class Extensions
/// <summary> /// <summary>
/// Получение Excel /// Получение Excel
/// </summary> /// </summary>
/// <param name="files"></param> /// <param name="file"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="ArgumentInvalidException"></exception> /// <exception cref="ArgumentInvalidException"></exception>
public static Stream GetExcelFile(this IFormFile file) public static Stream GetExcelFile(this IFormFile file)