forked from ddrilling/AsbCloudServer
Merge branch 'dev' into fix/23754474--SignalR-UpdateProcessMap-Method
This commit is contained in:
commit
1a27842e26
@ -41,11 +41,12 @@ public interface IProcessMapPlanBaseRepository<T>: IChangeLogRepository<T>
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<T>> GetChangeLog(int idWell, DateOnly? date, CancellationToken token);
|
Task<IEnumerable<T>> GetChangeLog(int idWell, DateOnly? date, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение записей по параметрам
|
/// Получение записей по параметрам
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request"></param>
|
/// <param name="idWell"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="request"></param>
|
||||||
/// <returns></returns>
|
/// <param name="token"></param>
|
||||||
Task<IEnumerable<T>> Get(ProcessMapPlanBaseRequest request, CancellationToken token);
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<T>> Get(int idWell, ProcessMapPlanBaseRequest request, CancellationToken token);
|
||||||
}
|
}
|
@ -8,12 +8,6 @@ namespace AsbCloudApp.Requests;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ProcessMapPlanBaseRequest: ChangeLogBaseRequest
|
public class ProcessMapPlanBaseRequest: ChangeLogBaseRequest
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Идентификатор скважины
|
|
||||||
/// </summary>
|
|
||||||
[Range(1, int.MaxValue, ErrorMessage = "Id скважины - положительное число")]
|
|
||||||
public int IdWell { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Тип секции
|
/// Тип секции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -89,8 +89,7 @@ public class PeriodicBackgroundWorker : BackgroundService
|
|||||||
where T : Work, new()
|
where T : Work, new()
|
||||||
{
|
{
|
||||||
var work = new T();
|
var work = new T();
|
||||||
var periodic = new WorkPeriodic(work, period);
|
Add(work, period);
|
||||||
works.Add(periodic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -98,14 +98,14 @@ public class ProcessMapPlanBaseRepository<TDto, TEntity> : IProcessMapPlanBaseRe
|
|||||||
return result;
|
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 offset = TimeSpan.FromHours(timezone.Hours);
|
||||||
|
|
||||||
var query = context
|
var query = context
|
||||||
.Set<TEntity>()
|
.Set<TEntity>()
|
||||||
.Where(e => e.IdWell == request.IdWell);
|
.Where(e => e.IdWell == idWell);
|
||||||
|
|
||||||
if(request.IdWellSectionType.HasValue)
|
if(request.IdWellSectionType.HasValue)
|
||||||
query = query.Where(e => e.IdWellSectionType == request.IdWellSectionType);
|
query = query.Where(e => e.IdWellSectionType == request.IdWellSectionType);
|
||||||
|
@ -351,10 +351,7 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
|
|||||||
var offset = TimeSpan.FromHours(timezoneHours);
|
var offset = TimeSpan.FromHours(timezoneHours);
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var request = new ProcessMapPlanBaseRequest
|
var request = new ProcessMapPlanBaseRequest();
|
||||||
{
|
|
||||||
IdWell = dto.IdWell,
|
|
||||||
};
|
|
||||||
var response = await client.Get(dto.IdWell, request);
|
var response = await client.Get(dto.IdWell, request);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
@ -387,8 +384,7 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
|
|||||||
var offset = TimeSpan.FromHours(timezoneHours);
|
var offset = TimeSpan.FromHours(timezoneHours);
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var request = new ProcessMapPlanBaseRequest {
|
var request = new ProcessMapPlanBaseRequest {
|
||||||
IdWell = dto.IdWell,
|
|
||||||
Moment = new DateTimeOffset(3000, 1, 1, 0, 0, 0, 0, TimeSpan.Zero)
|
Moment = new DateTimeOffset(3000, 1, 1, 0, 0, 0, 0, TimeSpan.Zero)
|
||||||
};
|
};
|
||||||
var response = await client.Get(dto.IdWell, request);
|
var response = await client.Get(dto.IdWell, request);
|
||||||
@ -441,7 +437,6 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
|
|||||||
//act
|
//act
|
||||||
var request = new ProcessMapPlanBaseRequest
|
var request = new ProcessMapPlanBaseRequest
|
||||||
{
|
{
|
||||||
IdWell = dto.IdWell,
|
|
||||||
Moment = now.AddMinutes(0.5),
|
Moment = now.AddMinutes(0.5),
|
||||||
};
|
};
|
||||||
var response = await client.Get(dto.IdWell, request);
|
var response = await client.Get(dto.IdWell, request);
|
||||||
@ -449,7 +444,7 @@ public class ProcessMapPlanDrillingControllerTest: 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]
|
||||||
@ -475,7 +470,6 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
|
|||||||
//act
|
//act
|
||||||
var request = new ProcessMapPlanBaseRequest
|
var request = new ProcessMapPlanBaseRequest
|
||||||
{
|
{
|
||||||
IdWell = dto.IdWell,
|
|
||||||
IdWellSectionType = 2,
|
IdWellSectionType = 2,
|
||||||
};
|
};
|
||||||
var response = await client.Get(dto.IdWell, request);
|
var response = await client.Get(dto.IdWell, request);
|
||||||
@ -525,7 +519,6 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
|
|||||||
//act
|
//act
|
||||||
var request = new ProcessMapPlanBaseRequest
|
var request = new ProcessMapPlanBaseRequest
|
||||||
{
|
{
|
||||||
IdWell = dto.IdWell,
|
|
||||||
UpdateFrom = updateFrom,
|
UpdateFrom = updateFrom,
|
||||||
};
|
};
|
||||||
var response = await client.Get(dto.IdWell, request);
|
var response = await client.Get(dto.IdWell, request);
|
||||||
|
@ -55,14 +55,13 @@ public class PeriodicBackgroundWorkerTest
|
|||||||
var stopwatch = Stopwatch.StartNew();
|
var stopwatch = Stopwatch.StartNew();
|
||||||
service.Add(work, period);
|
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));
|
await Task.Delay(TimeSpan.FromMilliseconds(delay));
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.Equal(workCount, result);
|
Assert.True(workCount <= result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Enqueue_Continues_AfterExceptions()
|
public async Task Enqueue_Continues_AfterExceptions()
|
||||||
{
|
{
|
||||||
|
@ -101,9 +101,8 @@ public abstract class ProcessMapPlanBaseController<TDto> : ControllerBase
|
|||||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||||
public async Task<ActionResult<IEnumerable<TDto>>> Get([FromRoute] int idWell, [FromQuery]ProcessMapPlanBaseRequest request, CancellationToken token)
|
public async Task<ActionResult<IEnumerable<TDto>>> Get([FromRoute] int idWell, [FromQuery]ProcessMapPlanBaseRequest request, CancellationToken token)
|
||||||
{
|
{
|
||||||
request.IdWell = idWell;
|
await AssertUserHasAccessToWell(idWell, token);
|
||||||
await AssertUserHasAccessToWell(request.IdWell, token);
|
var result = await repository.Get(idWell, request, token);
|
||||||
var result = await repository.Get(request, token);
|
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user