diff --git a/AsbCloudApp/Services/IFileService.cs b/AsbCloudApp/Services/IFileService.cs
index c6f299c3..a83d6d5c 100644
--- a/AsbCloudApp/Services/IFileService.cs
+++ b/AsbCloudApp/Services/IFileService.cs
@@ -157,5 +157,30 @@ namespace AsbCloudApp.Services
///
///
Task GetByMarkId(int idMark, CancellationToken token);
+
+ ///
+ /// пометить метки файлов как удаленные
+ ///
+ ///
+ ///
+ ///
+ Task MarkFileMarkAsDeletedAsync(IEnumerable idsMarks, CancellationToken token);
+
+ ///
+ /// Получение файлов по скважине
+ ///
+ ///
+ ///
+ ///
+ Task> GetInfosByWellIdAsync(int idWell, CancellationToken token);
+
+ ///
+ /// Получить файлы определенной категории
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task> GetInfosByCategoryAsync(int idWell, int idCategory, CancellationToken token);
}
}
diff --git a/AsbCloudInfrastructure/DependencyInjection.cs b/AsbCloudInfrastructure/DependencyInjection.cs
index e86a314b..f178b648 100644
--- a/AsbCloudInfrastructure/DependencyInjection.cs
+++ b/AsbCloudInfrastructure/DependencyInjection.cs
@@ -106,7 +106,6 @@ namespace AsbCloudInfrastructure
services.AddTransient();
services.AddTransient();
services.AddTransient();
- services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
@@ -155,6 +154,7 @@ namespace AsbCloudInfrastructure
dbSet => dbSet
.Include(c => c.Wells)
.Include(c => c.Deposit))); // может быть включен в сервис ClusterService
+ services.AddTransient();
// Subsystem service
services.AddTransient, CrudCacheServiceBase>();
services.AddTransient();
diff --git a/AsbCloudInfrastructure/Services/DrillingProgram/DrillingProgramService.cs b/AsbCloudInfrastructure/Services/DrillingProgram/DrillingProgramService.cs
index c1973c11..0e840524 100644
--- a/AsbCloudInfrastructure/Services/DrillingProgram/DrillingProgramService.cs
+++ b/AsbCloudInfrastructure/Services/DrillingProgram/DrillingProgramService.cs
@@ -23,7 +23,6 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
private readonly IFileService fileService;
private readonly IUserService userService;
private readonly IWellService wellService;
- private readonly IFileRepository fileRepository;
private readonly IConfiguration configuration;
private readonly IBackgroundWorkerService backgroundWorker;
private readonly IEmailService emailService;
@@ -54,7 +53,6 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
IFileService fileService,
IUserService userService,
IWellService wellService,
- IFileRepository fileRepository,
IConfiguration configuration,
IBackgroundWorkerService backgroundWorker,
IEmailService emailService)
@@ -63,7 +61,6 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
this.fileService = fileService;
this.userService = userService;
this.wellService = wellService;
- this.fileRepository = fileRepository;
this.configuration = configuration;
this.backgroundWorker = backgroundWorker;
this.connectionString = configuration.GetConnectionString("DefaultConnection");
@@ -312,9 +309,9 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
.Select(m => m.Id);
if (oldMarksIds?.Any() == true)
- await fileRepository.MarkFileMarkAsDeletedAsync(oldMarksIds, token);
+ await fileService.MarkFileMarkAsDeletedAsync(oldMarksIds, token);
- var result = await fileRepository.CreateFileMarkAsync(fileMarkDto, idUser, token)
+ var result = await fileService.CreateFileMarkAsync(fileMarkDto, idUser, token)
.ConfigureAwait(false);
if (fileMarkDto.IdMarkType == idMarkTypeReject)
@@ -344,7 +341,7 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
public async Task MarkAsDeletedFileMarkAsync(int idMark,
CancellationToken token)
{
- var fileInfo = await fileRepository.GetByMarkId(idMark, token)
+ var fileInfo = await fileService.GetByMarkId(idMark, token)
.ConfigureAwait(false);
if (fileInfo.IdCategory < idFileCategoryDrillingProgramPartsStart ||
@@ -483,6 +480,7 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram
.UseNpgsql(connectionString)
.Options;
using var context = new AsbCloudDbContext(contextOptions);
+ var fileRepository = new FileRepository(context);
var fileService = new FileService(fileRepository);
var files = state.Parts.Select(p => fileService.GetUrl(p.File));
DrillingProgramMaker.UniteExcelFiles(files, tempResultFilePath, state.Parts, well);
diff --git a/AsbCloudInfrastructure/Services/FileService.cs b/AsbCloudInfrastructure/Services/FileService.cs
index 5f01fc22..cdfed260 100644
--- a/AsbCloudInfrastructure/Services/FileService.cs
+++ b/AsbCloudInfrastructure/Services/FileService.cs
@@ -183,5 +183,17 @@ namespace AsbCloudInfrastructure.Services
public async Task GetByMarkId(int idMark, CancellationToken token)
=> await fileRepository.GetByMarkId(idMark, token)
.ConfigureAwait(false);
+
+ public async Task MarkFileMarkAsDeletedAsync(IEnumerable idsMarks, CancellationToken token)
+ => await fileRepository.MarkFileMarkAsDeletedAsync(idsMarks, token)
+ .ConfigureAwait(false);
+
+ public async Task> GetInfosByWellIdAsync(int idWell, CancellationToken token)
+ => await fileRepository.GetInfosByWellIdAsync(idWell, token)
+ .ConfigureAwait(false);
+
+ public async Task> GetInfosByCategoryAsync(int idWell, int idCategory, CancellationToken token)
+ => await fileRepository.GetInfosByCategoryAsync(idWell, idCategory, token)
+ .ConfigureAwait(false);
}
}
diff --git a/AsbCloudInfrastructure/Services/ReportService.cs b/AsbCloudInfrastructure/Services/ReportService.cs
index 6265f6c6..53d8653a 100644
--- a/AsbCloudInfrastructure/Services/ReportService.cs
+++ b/AsbCloudInfrastructure/Services/ReportService.cs
@@ -22,17 +22,15 @@ namespace AsbCloudInfrastructure.Services
private readonly ITelemetryService telemetryService;
private readonly IWellService wellService;
private readonly IBackgroundWorkerService backgroundWorkerService;
- private readonly IFileRepository fileRepository;
public ReportService(IAsbCloudDbContext db, IConfiguration configuration,
- ITelemetryService telemetryService, IWellService wellService, IBackgroundWorkerService backgroundWorkerService, IFileRepository fileRepository)
+ ITelemetryService telemetryService, IWellService wellService, IBackgroundWorkerService backgroundWorkerService)
{
this.db = db;
this.connectionString = configuration.GetConnectionString("DefaultConnection");
this.wellService = wellService;
this.backgroundWorkerService = backgroundWorkerService;
this.telemetryService = telemetryService;
- this.fileRepository = fileRepository;
ReportCategoryId = db.FileCategories.AsNoTracking()
.FirstOrDefault(c =>
c.Name.Equals("Рапорт")).Id;
@@ -68,6 +66,7 @@ namespace AsbCloudInfrastructure.Services
};
generator.Make(reportFileName);
+ var fileRepository = new FileRepository(context);
var fileService = new FileService(fileRepository);
var fileInfo = await fileService.MoveAsync(idWell, idUser, ReportCategoryId, reportFileName, reportFileName, token);
diff --git a/AsbCloudInfrastructure/Services/WellFinalDocumentsService.cs b/AsbCloudInfrastructure/Services/WellFinalDocumentsService.cs
index dc90128c..4d5f6427 100644
--- a/AsbCloudInfrastructure/Services/WellFinalDocumentsService.cs
+++ b/AsbCloudInfrastructure/Services/WellFinalDocumentsService.cs
@@ -28,7 +28,6 @@ namespace AsbCloudInfrastructure.Services
private readonly IConfiguration configuration;
private readonly IEmailService emailService;
private readonly IFileCategoryService fileCategoryService;
- private readonly IFileRepository fileRepository;
private const int FileServiceThrewException = -1;
@@ -38,8 +37,7 @@ namespace AsbCloudInfrastructure.Services
IWellService wellService,
IConfiguration configuration,
IEmailService emailService,
- IFileCategoryService fileCategoryService,
- IFileRepository fileRepository)
+ IFileCategoryService fileCategoryService)
{
this.context = context;
this.fileService = fileService;
@@ -48,7 +46,6 @@ namespace AsbCloudInfrastructure.Services
this.configuration = configuration;
this.emailService = emailService;
this.fileCategoryService = fileCategoryService;
- this.fileRepository = fileRepository;
}
public async Task UpdateRangeAsync(int idWell, IEnumerable? dtos, CancellationToken token)
@@ -98,7 +95,7 @@ namespace AsbCloudInfrastructure.Services
var categoriesIds = entitiesGroups
.Select(g => g.Key);
- var files = (await fileRepository
+ var files = (await fileService
.GetInfosByWellIdAsync(idWell, token)
.ConfigureAwait(false))
.Where(f => categoriesIds.Contains(f.IdCategory))
@@ -165,7 +162,7 @@ namespace AsbCloudInfrastructure.Services
public async Task GetFilesHistoryByIdCategory(int idWell, int idCategory, CancellationToken token)
{
- var files = await fileRepository.GetInfosByCategoryAsync(idWell, idCategory, token).ConfigureAwait(false);
+ var files = await fileService.GetInfosByCategoryAsync(idWell, idCategory, token).ConfigureAwait(false);
return new WellFinalDocumentsHistoryDto {
IdWell = idWell,
diff --git a/AsbCloudWebApi.Tests/ServicesTests/DrillingProgramServiceTest.cs b/AsbCloudWebApi.Tests/ServicesTests/DrillingProgramServiceTest.cs
index dfe19eaa..949c8c46 100644
--- a/AsbCloudWebApi.Tests/ServicesTests/DrillingProgramServiceTest.cs
+++ b/AsbCloudWebApi.Tests/ServicesTests/DrillingProgramServiceTest.cs
@@ -81,7 +81,6 @@ namespace AsbCloudWebApi.Tests.ServicesTests
private readonly Mock fileServiceMock;
private readonly Mock userServiceMock;
private readonly Mock wellServiceMock;
- private readonly Mock fileRepository;
private readonly Mock configurationMock;
private readonly Mock backgroundWorkerMock;
private readonly Mock emailService;
@@ -101,7 +100,6 @@ namespace AsbCloudWebApi.Tests.ServicesTests
fileServiceMock = new Mock();
userServiceMock = new Mock();
wellServiceMock = new Mock();
- fileRepository = new Mock();
configurationMock = new Mock();
backgroundWorkerMock = new Mock();
}
@@ -114,7 +112,6 @@ namespace AsbCloudWebApi.Tests.ServicesTests
fileServiceMock.Object,
userServiceMock.Object,
wellServiceMock.Object,
- fileRepository.Object,
configurationMock.Object,
backgroundWorkerMock.Object,
emailService.Object);
@@ -132,7 +129,6 @@ namespace AsbCloudWebApi.Tests.ServicesTests
fileServiceMock.Object,
userServiceMock.Object,
wellServiceMock.Object,
- fileRepository.Object,
configurationMock.Object,
backgroundWorkerMock.Object,
emailService.Object);
@@ -152,7 +148,6 @@ namespace AsbCloudWebApi.Tests.ServicesTests
fileServiceMock.Object,
userServiceMock.Object,
wellServiceMock.Object,
- fileRepository.Object,
configurationMock.Object,
backgroundWorkerMock.Object,
emailService.Object);
@@ -176,7 +171,6 @@ namespace AsbCloudWebApi.Tests.ServicesTests
fileServiceMock.Object,
userServiceMock.Object,
wellServiceMock.Object,
- fileRepository.Object,
configurationMock.Object,
backgroundWorkerMock.Object,
emailService.Object);
@@ -212,7 +206,6 @@ namespace AsbCloudWebApi.Tests.ServicesTests
fileServiceMock.Object,
userServiceMock.Object,
wellServiceMock.Object,
- fileRepository.Object,
configurationMock.Object,
backgroundWorkerMock.Object,
emailService.Object);
@@ -239,7 +232,6 @@ namespace AsbCloudWebApi.Tests.ServicesTests
fileServiceMock.Object,
userServiceMock.Object,
wellServiceMock.Object,
- fileRepository.Object,
configurationMock.Object,
backgroundWorkerMock.Object,
emailService.Object);
@@ -271,7 +263,6 @@ namespace AsbCloudWebApi.Tests.ServicesTests
fileServiceMock.Object,
userServiceMock.Object,
wellServiceMock.Object,
- fileRepository.Object,
configurationMock.Object,
backgroundWorkerMock.Object,
emailService.Object);
@@ -310,7 +301,6 @@ namespace AsbCloudWebApi.Tests.ServicesTests
fileServiceMock.Object,
userServiceMock.Object,
wellServiceMock.Object,
- fileRepository.Object,
configurationMock.Object,
backgroundWorkerMock.Object,
emailService.Object);
@@ -338,7 +328,6 @@ namespace AsbCloudWebApi.Tests.ServicesTests
fileServiceMock.Object,
userServiceMock.Object,
wellServiceMock.Object,
- fileRepository.Object,
configurationMock.Object,
backgroundWorkerMock.Object,
emailService.Object);
@@ -366,7 +355,6 @@ namespace AsbCloudWebApi.Tests.ServicesTests
fileServiceMock.Object,
userServiceMock.Object,
wellServiceMock.Object,
- fileRepository.Object,
configurationMock.Object,
backgroundWorkerMock.Object,
emailService.Object);
@@ -397,7 +385,6 @@ namespace AsbCloudWebApi.Tests.ServicesTests
fileServiceMock.Object,
userServiceMock.Object,
wellServiceMock.Object,
- fileRepository.Object,
configurationMock.Object,
backgroundWorkerMock.Object,
emailService.Object);
diff --git a/AsbCloudWebApi.Tests/ServicesTests/WellFinalDocumentsServiceTest.cs b/AsbCloudWebApi.Tests/ServicesTests/WellFinalDocumentsServiceTest.cs
index 1957091d..ac53a5b9 100644
--- a/AsbCloudWebApi.Tests/ServicesTests/WellFinalDocumentsServiceTest.cs
+++ b/AsbCloudWebApi.Tests/ServicesTests/WellFinalDocumentsServiceTest.cs
@@ -23,7 +23,6 @@ namespace AsbCloudWebApi.Tests.ServicesTests
private readonly Mock configurationMock;
private readonly Mock emailServiceMock;
private readonly Mock fileCategoryService;
- private readonly Mock fileRepository;
private readonly IEnumerable users = new List {
new UserDto {
@@ -53,7 +52,6 @@ namespace AsbCloudWebApi.Tests.ServicesTests
configurationMock = new Mock();
emailServiceMock = new Mock();
fileCategoryService = new Mock();
- fileRepository = new Mock();
service = new WellFinalDocumentsService(
context: context,
@@ -62,8 +60,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
wellService: wellServiceMock.Object,
configuration: configurationMock.Object,
emailService: emailServiceMock.Object,
- fileCategoryService: fileCategoryService.Object,
- fileRepository.Object);
+ fileCategoryService: fileCategoryService.Object);
}
~WellFinalDocumentsServiceTest()