Merge branch 'dev' into fix/23754474--SignalR-UpdateProcessMap-Method

This commit is contained in:
on.nemtina 2024-01-22 14:43:36 +05:00
commit 1a27842e26
7 changed files with 19 additions and 34 deletions

View File

@ -44,8 +44,9 @@ public interface IProcessMapPlanBaseRepository<T>: IChangeLogRepository<T>
/// <summary>
/// Получение записей по параметрам
/// </summary>
/// <param name="idWell"></param>
/// <param name="request"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<IEnumerable<T>> Get(ProcessMapPlanBaseRequest request, CancellationToken token);
Task<IEnumerable<T>> Get(int idWell, ProcessMapPlanBaseRequest request, CancellationToken token);
}

View File

@ -8,12 +8,6 @@ namespace AsbCloudApp.Requests;
/// </summary>
public class ProcessMapPlanBaseRequest: ChangeLogBaseRequest
{
/// <summary>
/// Идентификатор скважины
/// </summary>
[Range(1, int.MaxValue, ErrorMessage = "Id скважины - положительное число")]
public int IdWell { get; set; }
/// <summary>
/// Тип секции
/// </summary>

View File

@ -89,8 +89,7 @@ public class PeriodicBackgroundWorker : BackgroundService
where T : Work, new()
{
var work = new T();
var periodic = new WorkPeriodic(work, period);
works.Add(periodic);
Add(work, period);
}
/// <summary>

View File

@ -98,14 +98,14 @@ public class ProcessMapPlanBaseRepository<TDto, TEntity> : IProcessMapPlanBaseRe
return result;
}
public async Task<IEnumerable<TDto>> Get(ProcessMapPlanBaseRequest request, CancellationToken token)
public async Task<IEnumerable<TDto>> Get(int idWell, ProcessMapPlanBaseRequest request, CancellationToken token)
{
var timezone = wellService.GetTimezone(request.IdWell);
var timezone = wellService.GetTimezone(idWell);
var offset = TimeSpan.FromHours(timezone.Hours);
var query = context
.Set<TEntity>()
.Where(e => e.IdWell == request.IdWell);
.Where(e => e.IdWell == idWell);
if(request.IdWellSectionType.HasValue)
query = query.Where(e => e.IdWellSectionType == request.IdWellSectionType);

View File

@ -351,10 +351,7 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
var offset = TimeSpan.FromHours(timezoneHours);
//act
var request = new ProcessMapPlanBaseRequest
{
IdWell = dto.IdWell,
};
var request = new ProcessMapPlanBaseRequest();
var response = await client.Get(dto.IdWell, request);
//assert
@ -388,7 +385,6 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
//act
var request = new ProcessMapPlanBaseRequest {
IdWell = dto.IdWell,
Moment = new DateTimeOffset(3000, 1, 1, 0, 0, 0, 0, TimeSpan.Zero)
};
var response = await client.Get(dto.IdWell, request);
@ -441,7 +437,6 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
//act
var request = new ProcessMapPlanBaseRequest
{
IdWell = dto.IdWell,
Moment = now.AddMinutes(0.5),
};
var response = await client.Get(dto.IdWell, request);
@ -449,7 +444,7 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
//assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.NotNull(response.Content);
Assert.Equal(1, response.Content.Count());
Assert.Single(response.Content);
}
[Fact]
@ -475,7 +470,6 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
//act
var request = new ProcessMapPlanBaseRequest
{
IdWell = dto.IdWell,
IdWellSectionType = 2,
};
var response = await client.Get(dto.IdWell, request);
@ -525,7 +519,6 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
//act
var request = new ProcessMapPlanBaseRequest
{
IdWell = dto.IdWell,
UpdateFrom = updateFrom,
};
var response = await client.Get(dto.IdWell, request);

View File

@ -55,14 +55,13 @@ public class PeriodicBackgroundWorkerTest
var stopwatch = Stopwatch.StartNew();
service.Add(work, period);
var delay = periodMs / 20 + periodMs * workCount - stopwatch.ElapsedMilliseconds;
var delay = (periodMs / 20) + (periodMs * workCount) - stopwatch.ElapsedMilliseconds;
await Task.Delay(TimeSpan.FromMilliseconds(delay));
//assert
Assert.Equal(workCount, result);
Assert.True(workCount <= result);
}
[Fact]
public async Task Enqueue_Continues_AfterExceptions()
{

View File

@ -101,9 +101,8 @@ public abstract class ProcessMapPlanBaseController<TDto> : ControllerBase
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
public async Task<ActionResult<IEnumerable<TDto>>> Get([FromRoute] int idWell, [FromQuery]ProcessMapPlanBaseRequest request, CancellationToken token)
{
request.IdWell = idWell;
await AssertUserHasAccessToWell(request.IdWell, token);
var result = await repository.Get(request, token);
await AssertUserHasAccessToWell(idWell, token);
var result = await repository.Get(idWell, request, token);
return Ok(result);
}