diff --git a/AsbCloudApp/Repositories/IWellOperationRepository.cs b/AsbCloudApp/Repositories/IWellOperationRepository.cs
index 2ac586aa..cf277304 100644
--- a/AsbCloudApp/Repositories/IWellOperationRepository.cs
+++ b/AsbCloudApp/Repositories/IWellOperationRepository.cs
@@ -2,7 +2,6 @@
using AsbCloudApp.Requests;
using System;
using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
using System.Threading;
using System.Threading.Tasks;
@@ -13,14 +12,6 @@ namespace AsbCloudApp.Repositories
///
public interface IWellOperationRepository
{
- //TODO: replace all references
- ///
- /// список названий операций
- ///
- ///
- [Obsolete("use IWellOperationCategoryRepository.GetCategories(bool includeParents)")]
- IEnumerable GetCategories(bool includeParents);
-
///
/// Список секций
///
diff --git a/AsbCloudInfrastructure/Repository/WellOperationRepository.cs b/AsbCloudInfrastructure/Repository/WellOperationRepository.cs
index c6edb30b..57bf3768 100644
--- a/AsbCloudInfrastructure/Repository/WellOperationRepository.cs
+++ b/AsbCloudInfrastructure/Repository/WellOperationRepository.cs
@@ -23,7 +23,6 @@ namespace AsbCloudInfrastructure.Repository;
public class WellOperationRepository : IWellOperationRepository
{
private const string KeyCacheSections = "OperationsBySectionSummarties";
- private const int Gap = 90;
private readonly IAsbCloudDbContext db;
private readonly IMemoryCache memoryCache;
@@ -38,13 +37,6 @@ public class WellOperationRepository : IWellOperationRepository
this.wellOperationCategoryRepository = wellOperationCategoryRepository;
}
- ///
- public IEnumerable GetCategories(bool includeParents)
- {
- return wellOperationCategoryRepository.Get(includeParents);
- }
-
- ///
public IEnumerable GetSectionTypes() =>
memoryCache
.GetOrCreateBasic(db.Set())
@@ -272,7 +264,7 @@ public class WellOperationRepository : IWellOperationRepository
DurationDepth = o.DepthEnd - o.DepthStart
})
.ToListAsync(token);
- var parentRelationDictionary = GetCategories(true)
+ var parentRelationDictionary = wellOperationCategoryRepository.Get(true)
.ToDictionary(c => c.Id, c => new
{
c.Name,
diff --git a/AsbCloudInfrastructure/Services/WellOperationImport/WellOperationExportService.cs b/AsbCloudInfrastructure/Services/WellOperationImport/WellOperationExportService.cs
index 5ce7a2e2..142b751f 100644
--- a/AsbCloudInfrastructure/Services/WellOperationImport/WellOperationExportService.cs
+++ b/AsbCloudInfrastructure/Services/WellOperationImport/WellOperationExportService.cs
@@ -19,15 +19,19 @@ public class WellOperationExportService : IWellOperationExportService
private readonly IWellOperationRepository wellOperationRepository;
private readonly IWellService wellService;
private readonly IWellOperationImportTemplateService wellOperationImportTemplateService;
+ private readonly IWellOperationCategoryRepository wellOperationCategoryRepository;
- public WellOperationExportService(IWellOperationRepository wellOperationRepository,
+ public WellOperationExportService(
+ IWellOperationRepository wellOperationRepository,
IWellService wellService,
- IWellOperationImportTemplateService wellOperationImportTemplateService)
+ IWellOperationImportTemplateService wellOperationImportTemplateService,
+ IWellOperationCategoryRepository wellOperationCategoryRepository)
{
this.wellOperationRepository = wellOperationRepository;
this.wellService = wellService;
this.wellOperationImportTemplateService = wellOperationImportTemplateService;
- }
+ this.wellOperationCategoryRepository = wellOperationCategoryRepository;
+ }
public async Task ExportAsync(int idWell, CancellationToken cancellationToken)
{
@@ -76,7 +80,7 @@ public class WellOperationExportService : IWellOperationExportService
var operationsToArray = operations.ToArray();
var sections = wellOperationRepository.GetSectionTypes();
- var categories = wellOperationRepository.GetCategories(false);
+ var categories = wellOperationCategoryRepository.Get(false);
for (int i = 0; i < operationsToArray.Length; i++)
{
diff --git a/AsbCloudInfrastructure/Services/WellOperationImport/WellOperationImportService.cs b/AsbCloudInfrastructure/Services/WellOperationImport/WellOperationImportService.cs
index 800979e5..6ad227a3 100644
--- a/AsbCloudInfrastructure/Services/WellOperationImport/WellOperationImportService.cs
+++ b/AsbCloudInfrastructure/Services/WellOperationImport/WellOperationImportService.cs
@@ -14,24 +14,28 @@ public class WellOperationImportService : IWellOperationImportService
{
private readonly IWellService wellService;
private readonly IWellOperationRepository wellOperationRepository;
-
- private static readonly DateTime dateLimitMin = new(2001, 1, 1, 0, 0, 0);
+ private readonly IWellOperationCategoryRepository wellOperationCategoryRepository;
+ private static readonly DateTime dateLimitMin = new(2001, 1, 1, 0, 0, 0);
private static readonly DateTime dateLimitMax = new(2099, 1, 1, 0, 0, 0);
private static readonly TimeSpan drillingDurationLimitMax = TimeSpan.FromDays(366);
- public WellOperationImportService(IWellService wellService,
- IWellOperationRepository wellOperationRepository)
+ public WellOperationImportService(
+ IWellService wellService,
+ IWellOperationRepository wellOperationRepository,
+ IWellOperationCategoryRepository wellOperationCategoryRepository
+ )
{
this.wellService = wellService;
this.wellOperationRepository = wellOperationRepository;
- }
+ this.wellOperationCategoryRepository = wellOperationCategoryRepository;
+ }
public IEnumerable Import(int idWell, int idUser, int idType, SheetDto sheet)
{
var validationErrors = new List();
var sections = wellOperationRepository.GetSectionTypes();
- var categories = wellOperationRepository.GetCategories(false);
+ var categories = wellOperationCategoryRepository.Get(false);
var wellOperations = new List();
@@ -83,7 +87,9 @@ public class WellOperationImportService : IWellOperationImportService
IdUser = idUser,
IdType = idType,
IdWellSectionType = section.Id,
+ WellSectionTypeName = section.Caption,
IdCategory = category.Id,
+ CategoryName = category.Name,
CategoryInfo = row.CategoryInfo,
DepthStart = row.DepthStart,
DepthEnd = row.DepthEnd,
diff --git a/AsbCloudWebApi.Tests/Services/WellOperationExport/WellOperationExportServiceTest.cs b/AsbCloudWebApi.Tests/Services/WellOperationExport/WellOperationExportServiceTest.cs
index 3d66aab9..e58adda7 100644
--- a/AsbCloudWebApi.Tests/Services/WellOperationExport/WellOperationExportServiceTest.cs
+++ b/AsbCloudWebApi.Tests/Services/WellOperationExport/WellOperationExportServiceTest.cs
@@ -5,6 +5,7 @@ using AsbCloudApp.Requests;
using AsbCloudApp.Services;
using AsbCloudApp.Services.WellOperationImport;
using AsbCloudDb.Model;
+using AsbCloudInfrastructure.Repository;
using AsbCloudInfrastructure.Services.WellOperationImport;
using AsbCloudInfrastructure.Services.WellOperationImport.FileParser;
using NSubstitute;
@@ -27,6 +28,7 @@ namespace AsbCloudWebApi.Tests.Services.WellOperationExport
private IWellService wellService;
private IWellOperationRepository wellOperationRepository;
+ private IWellOperationCategoryRepository wellOperationCategoryRepository;
private IWellOperationImportTemplateService wellOperationImportTemplateService;
private WellOperationExportService wellOperationExportService;
private WellOperationImportService wellOperationImportService;
@@ -114,46 +116,46 @@ namespace AsbCloudWebApi.Tests.Services.WellOperationExport
{
wellService = Substitute.For();
wellOperationRepository = Substitute.For();
+ wellOperationCategoryRepository = Substitute.For();
wellOperationImportTemplateService = new WellOperationImportTemplateService();
- wellOperationExportService = new WellOperationExportService(wellOperationRepository, wellService, wellOperationImportTemplateService);
+ wellOperationExportService = new WellOperationExportService(wellOperationRepository, wellService, wellOperationImportTemplateService, wellOperationCategoryRepository);
- wellOperationImportService = new WellOperationImportService(wellService, wellOperationRepository);
+ wellOperationImportService = new WellOperationImportService(wellService, wellOperationRepository, wellOperationCategoryRepository);
wellOperationDefaultExcelParser = new WellOperationDefaultExcelParser();
this.output = output;
}
-#warning Test Check_Exported_WellOperations_With_Operations_In_Db Fails and commented for debug deployment task
- //[Fact]
- //public async Task Check_Exported_WellOperations_With_Operations_In_Db()
- //{
- // wellService.GetTimezone(idWell).Returns(new SimpleTimezoneDto()
- // {
- // Hours = 5
- // });
+ [Fact]
+ public async Task Check_Exported_WellOperations_With_Operations_In_Db()
+ {
+ wellService.GetTimezone(idWell).Returns(new SimpleTimezoneDto()
+ {
+ Hours = 5
+ });
- // var localOperations = operations.ToArray();
- // foreach (var operation in localOperations)
- // operation.Id = 0;
+ var localOperations = operations.ToArray();
+ foreach (var operation in localOperations)
+ operation.Id = 0;
- // wellOperationRepository.GetAsync(Arg.Any(), Arg.Any())
- // .ReturnsForAnyArgs(localOperations);
- // wellOperationRepository.GetSectionTypes().Returns(sectionTypes);
- // wellOperationRepository.GetCategories(false).Returns(categories);
+ wellOperationRepository.GetAsync(Arg.Any(), Arg.Any())
+ .ReturnsForAnyArgs(localOperations);
+ wellOperationRepository.GetSectionTypes().Returns(sectionTypes);
+ wellOperationCategoryRepository.Get(false).Returns(categories);
- // var stream = await wellOperationExportService.ExportAsync(idWell, CancellationToken.None);
+ var stream = await wellOperationExportService.ExportAsync(idWell, CancellationToken.None);
- // var options = new WellOperationImportDefaultOptionsDto
- // {
- // IdType = WellOperation.IdOperationTypePlan
- // };
- // var sheet = wellOperationDefaultExcelParser.Parse(stream, options);
- // var result = wellOperationImportService.Import(idWell, 1, options.IdType, sheet);
+ var options = new WellOperationImportDefaultOptionsDto
+ {
+ IdType = WellOperation.IdOperationTypePlan
+ };
+ var sheet = wellOperationDefaultExcelParser.Parse(stream, options);
+ var result = wellOperationImportService.Import(idWell, 1, options.IdType, sheet);
- // var expected = JsonSerializer.Serialize(localOperations);
- // var actual = JsonSerializer.Serialize(result);
+ var expected = JsonSerializer.Serialize(localOperations);
+ var actual = JsonSerializer.Serialize(result);
- // Assert.Equal(expected, actual);
- //}
+ Assert.Equal(expected, actual);
+ }
[Fact]
public void TestDataContainsNotDefaultProps()
diff --git a/AsbCloudWebApi/Controllers/WellOperationController.cs b/AsbCloudWebApi/Controllers/WellOperationController.cs
index 0d53a4ad..d624e89a 100644
--- a/AsbCloudWebApi/Controllers/WellOperationController.cs
+++ b/AsbCloudWebApi/Controllers/WellOperationController.cs
@@ -35,6 +35,7 @@ namespace AsbCloudWebApi.Controllers
private readonly IWellOperationExportService wellOperationExportService;
private readonly IWellOperationImportTemplateService wellOperationImportTemplateService;
private readonly IWellOperationImportService wellOperationImportService;
+ private readonly IWellOperationCategoryRepository wellOperationCategoryRepository;
private readonly IWellOperationExcelParser wellOperationDefaultExcelParser;
private readonly IWellOperationExcelParser wellOperationGazpromKhantosExcelParser;
private readonly IUserRepository userRepository;
@@ -44,6 +45,7 @@ namespace AsbCloudWebApi.Controllers
IWellOperationImportTemplateService wellOperationImportTemplateService,
IWellOperationExportService wellOperationExportService,
IWellOperationImportService wellOperationImportService,
+ IWellOperationCategoryRepository wellOperationCategoryRepository,
IWellOperationExcelParser wellOperationDefaultExcelParser,
IWellOperationExcelParser wellOperationGazpromKhantosExcelParser,
IUserRepository userRepository)
@@ -53,6 +55,7 @@ namespace AsbCloudWebApi.Controllers
this.wellOperationImportTemplateService = wellOperationImportTemplateService;
this.wellOperationExportService = wellOperationExportService;
this.wellOperationImportService = wellOperationImportService;
+ this.wellOperationCategoryRepository = wellOperationCategoryRepository;
this.wellOperationDefaultExcelParser = wellOperationDefaultExcelParser;
this.wellOperationGazpromKhantosExcelParser = wellOperationGazpromKhantosExcelParser;
this.userRepository = userRepository;
@@ -81,7 +84,7 @@ namespace AsbCloudWebApi.Controllers
[ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetCategories(bool includeParents = true)
{
- var result = operationRepository.GetCategories(includeParents);
+ var result = wellOperationCategoryRepository.Get(includeParents);
return Ok(result);
}
@@ -163,7 +166,7 @@ namespace AsbCloudWebApi.Controllers
}
///
- /// Статистика операций по скважине, группированая по категориям
+ /// Статистика операций по скважине, группированная по категориям
///
/// id скважины
///