Merge pull request 'Сделал обязательный CancellationToken в контроллерах' (#68) from feature/required_cancellation_token into dev

Reviewed-on: http://test.digitaldrilling.ru:8080/DDrilling/AsbCloudServer/pulls/68
Reviewed-by: Никита Фролов <ng.frolov@digitaldrilling.ru>
This commit is contained in:
Никита Фролов 2023-07-04 15:10:27 +05:00
commit b92945db91
22 changed files with 157 additions and 110 deletions

View File

@ -0,0 +1,24 @@
using System;
namespace AsbCloudApp.Requests;
/// <summary>
/// Параметры запроса для получения загруженных данных ГТИ по скважине
/// </summary>
public class GtrWithGetDataRequest
{
/// <summary>
/// Дата начала выборки.По умолчанию: текущее время - IntervalSec
/// </summary>
public DateTime? Begin { get; set; }
/// <summary>
/// Интервал времени даты начала выборки, секунды
/// </summary>
public int IntervalSec { get; set; } = 600;
/// <summary>
/// Желаемое количество точек. Если в выборке точек будет больше, то выборка будет прорежена.
/// </summary>
public int ApproxPointsCount { get; set; } = 1024;
}

View File

@ -0,0 +1,29 @@
using System;
namespace AsbCloudApp.Requests;
/// <summary>
/// Параметры для создания отчёта и получения прогнозируемого количества страниц будущего отчета
/// </summary>
public class ReportParametersRequest
{
/// <summary>
/// Шаг интервала
/// </summary>
public int StepSeconds { get; set; }
/// <summary>
/// формат отчета (0-PDF, 1-LAS)
/// </summary>
public int Format { get; set; }
/// <summary>
/// Дата начала интервала
/// </summary>
public DateTime Begin { get; set; } = default;
/// <summary>
/// Дата окончания интервала
/// </summary>
public DateTime End { get; set; } = default;
}

View File

@ -31,7 +31,7 @@ namespace AsbCloudWebApi.Controllers
[HttpPost] [HttpPost]
[Route("/merge/{idFrom}/{idTo}")] [Route("/merge/{idFrom}/{idTo}")]
[Permission] [Permission]
public async Task<IActionResult> MergeTelemetriesAsync(int idFrom, int idTo, CancellationToken token = default) public async Task<IActionResult> MergeTelemetriesAsync(int idFrom, int idTo, CancellationToken token)
{ {
var count = await telemetryService.MergeAsync(idFrom, idTo, token) var count = await telemetryService.MergeAsync(idFrom, idTo, token)
.ConfigureAwait(false); .ConfigureAwait(false);

View File

@ -38,7 +38,7 @@ namespace AsbCloudWebApi.Controllers
[HttpPost("login")] [HttpPost("login")]
[SwaggerOperation(OperationId = "login")] [SwaggerOperation(OperationId = "login")]
[ProducesResponseType(typeof(UserTokenDto), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(UserTokenDto), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> LoginAsync([FromBody] AuthDto auth, CancellationToken token = default) public async Task<IActionResult> LoginAsync([FromBody] AuthDto auth, CancellationToken token)
{ {
var userToken = await authService.LoginAsync(auth.Login, auth.Password, token); var userToken = await authService.LoginAsync(auth.Login, auth.Password, token);
@ -55,7 +55,7 @@ namespace AsbCloudWebApi.Controllers
[Authorize] [Authorize]
[HttpGet("refresh")] [HttpGet("refresh")]
[ProducesResponseType(typeof(UserTokenDto), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(UserTokenDto), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> RefreshAsync(CancellationToken token = default) public async Task<IActionResult> RefreshAsync(CancellationToken token)
{ {
var userToken = await authService.RefreshAsync(User, token); var userToken = await authService.RefreshAsync(User, token);

View File

@ -31,7 +31,7 @@ namespace AsbCloudWebApi.Controllers
[HttpGet] [HttpGet]
[Permission] [Permission]
[ProducesResponseType(typeof(IEnumerable<DepositDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<DepositDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetDepositsAsync(CancellationToken token = default) public async Task<IActionResult> GetDepositsAsync(CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
@ -51,7 +51,7 @@ namespace AsbCloudWebApi.Controllers
[HttpGet("drillParamsWells")] [HttpGet("drillParamsWells")]
[Permission] [Permission]
[ProducesResponseType(typeof(IEnumerable<DepositDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<DepositDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetDepositsDrillParamsAsync(CancellationToken token = default) public async Task<IActionResult> GetDepositsDrillParamsAsync(CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
@ -73,7 +73,7 @@ namespace AsbCloudWebApi.Controllers
[Permission] [Permission]
[ProducesResponseType(typeof(IEnumerable<ClusterDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<ClusterDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetClustersAsync(int depositId, public async Task<IActionResult> GetClustersAsync(int depositId,
CancellationToken token = default) CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();

View File

@ -196,7 +196,7 @@ namespace AsbCloudWebApi.Controllers
[HttpPost("part/{idFileCategory}/user")] [HttpPost("part/{idFileCategory}/user")]
[Permission] [Permission]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> AddUserAsync(int idWell, [Required] int idUser, int idFileCategory, [Required] int idUserRole, CancellationToken token = default) public async Task<IActionResult> AddUserAsync(int idWell, [Required] int idUser, int idFileCategory, [Required] int idUserRole, CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
int? idUserEditor = User.GetUserId(); int? idUserEditor = User.GetUserId();
@ -224,7 +224,7 @@ namespace AsbCloudWebApi.Controllers
[HttpDelete("part/{idFileCategory}/user/{idUser}")] [HttpDelete("part/{idFileCategory}/user/{idUser}")]
[Permission] [Permission]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> RemoveUserAsync(int idWell, int idUser, int idFileCategory, [Required] int idUserRole, CancellationToken token = default) public async Task<IActionResult> RemoveUserAsync(int idWell, int idUser, int idFileCategory, [Required] int idUserRole, CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
int? idUserEditor = User.GetUserId(); int? idUserEditor = User.GetUserId();

View File

@ -7,8 +7,6 @@ using Microsoft.AspNetCore.Mvc;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using AsbCloudDb.Model;
using AsbCloudInfrastructure.Repository;
using AsbCloudApp.Repositories; using AsbCloudApp.Repositories;
namespace AsbCloudWebApi.Controllers namespace AsbCloudWebApi.Controllers
@ -44,7 +42,7 @@ namespace AsbCloudWebApi.Controllers
[Permission] [Permission]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> SaveFilesAsync(int idWell, int idCategory, public async Task<IActionResult> SaveFilesAsync(int idWell, int idCategory,
[FromForm] IFormFileCollection files, [FromServices] IUserRepository userRepository, CancellationToken token = default) [FromForm] IFormFileCollection files, [FromServices] IUserRepository userRepository, CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
int? idUser = User.GetUserId(); int? idUser = User.GetUserId();
@ -81,7 +79,7 @@ namespace AsbCloudWebApi.Controllers
[ProducesResponseType(typeof(PaginationContainer<FileInfoDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(PaginationContainer<FileInfoDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetFilesInfoAsync( public async Task<IActionResult> GetFilesInfoAsync(
[FromQuery] FileRequest request, [FromQuery] FileRequest request,
CancellationToken token = default) CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
@ -108,7 +106,7 @@ namespace AsbCloudWebApi.Controllers
[Permission] [Permission]
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetFileAsync( public async Task<IActionResult> GetFileAsync(
int idFile, CancellationToken token = default) int idFile, CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
@ -142,7 +140,7 @@ namespace AsbCloudWebApi.Controllers
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> DeleteAsync(int idWell, int idFile, public async Task<IActionResult> DeleteAsync(int idWell, int idFile,
[FromServices] IUserRepository userRepository, [FromServices] IUserRepository userRepository,
CancellationToken token = default) CancellationToken token)
{ {
int? idUser = User.GetUserId(); int? idUser = User.GetUserId();
@ -174,7 +172,7 @@ namespace AsbCloudWebApi.Controllers
/// <returns></returns> /// <returns></returns>
[HttpPost("fileMark")] [HttpPost("fileMark")]
[Permission] [Permission]
public async Task<IActionResult> CreateFileMarkAsync(int idWell, FileMarkDto markDto, CancellationToken token = default) public async Task<IActionResult> CreateFileMarkAsync(int idWell, FileMarkDto markDto, CancellationToken token)
{ {
var idCompany = User.GetCompanyId(); var idCompany = User.GetCompanyId();
@ -202,7 +200,7 @@ namespace AsbCloudWebApi.Controllers
[Permission] [Permission]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> DeleteFileMarkAsync(int idWell, int idMark, public async Task<IActionResult> DeleteFileMarkAsync(int idWell, int idMark,
CancellationToken token = default) CancellationToken token)
{ {
var idCompany = User.GetCompanyId(); var idCompany = User.GetCompanyId();
@ -226,7 +224,7 @@ namespace AsbCloudWebApi.Controllers
[Route("/api/files/{idFile}")] [Route("/api/files/{idFile}")]
[Permission] [Permission]
[ProducesResponseType(typeof(FileInfoDto), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(FileInfoDto), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetFileInfoAsync([FromRoute] int idFile, CancellationToken token = default) public async Task<IActionResult> GetFileInfoAsync([FromRoute] int idFile, CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();

View File

@ -32,7 +32,7 @@ namespace AsbCloudWebApi.Controllers
/// <returns></returns> /// <returns></returns>
[HttpGet("stat")] [HttpGet("stat")]
[ProducesResponseType(typeof(IEnumerable<LimitingParameterDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<LimitingParameterDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetStatAsync([FromQuery] LimitingParameterRequest request, CancellationToken token = default) public async Task<IActionResult> GetStatAsync([FromQuery] LimitingParameterRequest request, CancellationToken token)
{ {
if (!await UserHasAccesToWellAsync(request.IdWell, token)) if (!await UserHasAccesToWellAsync(request.IdWell, token))
return Forbid(); return Forbid();

View File

@ -27,7 +27,7 @@ namespace AsbCloudWebApi.Controllers
[HttpGet] [HttpGet]
[Permission] [Permission]
[Route("categories")] [Route("categories")]
public async Task<IActionResult> GetCategoriesAsync([FromRoute] int idWell, CancellationToken token = default) public async Task<IActionResult> GetCategoriesAsync([FromRoute] int idWell, CancellationToken token)
{ {
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
@ -39,7 +39,7 @@ namespace AsbCloudWebApi.Controllers
[HttpGet] [HttpGet]
[Permission] [Permission]
[Route("last/{idCategory}")] [Route("last/{idCategory}")]
public async Task<IActionResult> GetLastAsync([FromRoute] int idWell, [FromRoute] int idCategory, CancellationToken token = default) public async Task<IActionResult> GetLastAsync([FromRoute] int idWell, [FromRoute] int idCategory, CancellationToken token)
{ {
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
@ -58,7 +58,8 @@ namespace AsbCloudWebApi.Controllers
[HttpGet] [HttpGet]
[Permission] [Permission]
[Route("history")] [Route("history")]
public async Task<IActionResult> GetHisoryAsync([FromRoute] int idWell, int? idCategory = null, CancellationToken token = default) public async Task<IActionResult> GetHisoryAsync([FromRoute] int idWell, CancellationToken token,
int? idCategory = null)
{ {
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
@ -69,7 +70,7 @@ namespace AsbCloudWebApi.Controllers
[HttpPost] [HttpPost]
[Permission] [Permission]
public async Task<IActionResult> InsertAsync([FromRoute] int idWell, MeasureDto data, CancellationToken token = default) public async Task<IActionResult> InsertAsync([FromRoute] int idWell, MeasureDto data, CancellationToken token)
{ {
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
@ -80,7 +81,7 @@ namespace AsbCloudWebApi.Controllers
[HttpPut] [HttpPut]
[Permission] [Permission]
public async Task<IActionResult> UpdateAsync([FromRoute] int idWell, MeasureDto data, CancellationToken token = default) public async Task<IActionResult> UpdateAsync([FromRoute] int idWell, MeasureDto data, CancellationToken token)
{ {
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
@ -92,7 +93,7 @@ namespace AsbCloudWebApi.Controllers
[HttpDelete] [HttpDelete]
[Permission] [Permission]
[Route("history/{idData}")] [Route("history/{idData}")]
public async Task<IActionResult> MarkAsDeleteAsync([FromRoute] int idWell, [FromRoute] int idData, CancellationToken token = default) public async Task<IActionResult> MarkAsDeleteAsync([FromRoute] int idWell, [FromRoute] int idData, CancellationToken token)
{ {
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
@ -101,7 +102,7 @@ namespace AsbCloudWebApi.Controllers
return Ok(result); return Ok(result);
} }
private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token = default) private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
return idCompany is not null && await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, return idCompany is not null && await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,

View File

@ -37,7 +37,7 @@ namespace AsbCloudWebApi.Controllers
[Permission] [Permission]
[ProducesResponseType(typeof(ClusterRopStatDto), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(ClusterRopStatDto), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetClusterRopStatByIdWellAsync([FromRoute] int idWell, public async Task<IActionResult> GetClusterRopStatByIdWellAsync([FromRoute] int idWell,
CancellationToken token = default) CancellationToken token)
{ {
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
@ -58,7 +58,7 @@ namespace AsbCloudWebApi.Controllers
[ProducesResponseType(typeof(ClusterRopStatDto), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(ClusterRopStatDto), (int)System.Net.HttpStatusCode.OK)]
[AllowAnonymous] [AllowAnonymous]
public async Task<IActionResult> GetClusterRopStatByUidAsync([FromRoute] string uid, public async Task<IActionResult> GetClusterRopStatByUidAsync([FromRoute] string uid,
CancellationToken token = default) CancellationToken token)
{ {
var idWell = wellService.TelemetryService.GetIdWellByTelemetryUid(uid); var idWell = wellService.TelemetryService.GetIdWellByTelemetryUid(uid);
@ -82,7 +82,7 @@ namespace AsbCloudWebApi.Controllers
[Permission] [Permission]
[ProducesResponseType(typeof(StatClusterDto), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(StatClusterDto), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetStatClusterAsync(int idCluster, public async Task<IActionResult> GetStatClusterAsync(int idCluster,
CancellationToken token = default) CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
if (idCompany is null) if (idCompany is null)
@ -128,7 +128,7 @@ namespace AsbCloudWebApi.Controllers
[Permission] [Permission]
[ProducesResponseType(typeof(StatWellDto), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(StatWellDto), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetStatWellAsync(int idWell, public async Task<IActionResult> GetStatWellAsync(int idWell,
CancellationToken token = default) CancellationToken token)
{ {
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
@ -149,7 +149,7 @@ namespace AsbCloudWebApi.Controllers
[Permission] [Permission]
[ProducesResponseType(typeof(IEnumerable<PlanFactPredictBase<WellOperationDto>>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<PlanFactPredictBase<WellOperationDto>>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetTvdAsync(int idWell, public async Task<IActionResult> GetTvdAsync(int idWell,
CancellationToken token = default) CancellationToken token)
{ {
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
@ -159,7 +159,7 @@ namespace AsbCloudWebApi.Controllers
return Ok(result); return Ok(result);
} }
private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token = default) private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
return idCompany is not null && await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, return idCompany is not null && await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,

View File

@ -61,7 +61,7 @@ namespace AsbCloudWebApi.Controllers
[HttpGet] [HttpGet]
[Route("export")] [Route("export")]
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> ExportAsync([FromRoute] int idWell, CancellationToken token = default) public async Task<IActionResult> ExportAsync([FromRoute] int idWell, CancellationToken token)
{ {
if (!await CanUserAccessToWellAsync(idWell, if (!await CanUserAccessToWellAsync(idWell,
token).ConfigureAwait(false)) token).ConfigureAwait(false))
@ -120,7 +120,7 @@ namespace AsbCloudWebApi.Controllers
[HttpGet] [HttpGet]
[Route("getRows")] [Route("getRows")]
[ProducesResponseType(typeof(IEnumerable<TrajectoryGeoPlanDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<TrajectoryGeoPlanDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetAsync([FromRoute] int idWell, CancellationToken token = default) public async Task<IActionResult> GetAsync([FromRoute] int idWell, CancellationToken token)
{ {
if (!await CanUserAccessToWellAsync(idWell, if (!await CanUserAccessToWellAsync(idWell,
token).ConfigureAwait(false)) token).ConfigureAwait(false))
@ -140,7 +140,7 @@ namespace AsbCloudWebApi.Controllers
[Route("addRow")] [Route("addRow")]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> AddAsync(int idWell, [FromBody] TrajectoryGeoPlanDto row, public async Task<IActionResult> AddAsync(int idWell, [FromBody] TrajectoryGeoPlanDto row,
CancellationToken token = default) CancellationToken token)
{ {
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
@ -164,7 +164,7 @@ namespace AsbCloudWebApi.Controllers
[Route("addRangeRows")] [Route("addRangeRows")]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> AddRangeAsync(int idWell, [FromBody] IEnumerable<TrajectoryGeoPlanDto> rows, public async Task<IActionResult> AddRangeAsync(int idWell, [FromBody] IEnumerable<TrajectoryGeoPlanDto> rows,
CancellationToken token = default) CancellationToken token)
{ {
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
@ -191,7 +191,7 @@ namespace AsbCloudWebApi.Controllers
[HttpPut("{idRow}")] [HttpPut("{idRow}")]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> UpdateAsync(int idWell, int idRow, public async Task<IActionResult> UpdateAsync(int idWell, int idRow,
[FromBody] TrajectoryGeoPlanDto row, CancellationToken token = default) [FromBody] TrajectoryGeoPlanDto row, CancellationToken token)
{ {
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
@ -214,7 +214,7 @@ namespace AsbCloudWebApi.Controllers
/// <returns>количество успешно удаленных строк из БД</returns> /// <returns>количество успешно удаленных строк из БД</returns>
[HttpDelete("{idRow}")] [HttpDelete("{idRow}")]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> DeleteAsync(int idWell, int idRow, CancellationToken token = default) public async Task<IActionResult> DeleteAsync(int idWell, int idRow, CancellationToken token)
{ {
if (!await CanUserAccessToWellAsync(idWell, if (!await CanUserAccessToWellAsync(idWell,
token).ConfigureAwait(false)) token).ConfigureAwait(false))
@ -243,7 +243,7 @@ namespace AsbCloudWebApi.Controllers
return Ok(result); return Ok(result);
} }
private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token = default) private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
return idCompany is not null && await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, return idCompany is not null && await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,

View File

@ -3,10 +3,11 @@ using AsbCloudApp.Services;
using AsbCloudWebApi.SignalR; using AsbCloudWebApi.SignalR;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using AsbCloudApp.Requests;
namespace AsbCloudWebApi.Controllers namespace AsbCloudWebApi.Controllers
{ {
@ -34,19 +35,16 @@ namespace AsbCloudWebApi.Controllers
/// <summary> /// <summary>
/// Создает отчет по скважине с указанными параметрами /// Создает отчет по скважине с указанными параметрами
/// </summary> /// </summary>
/// <param name="idWell">id скважины</param> /// <param name="idWell">Id скважины</param>
/// <param name="stepSeconds">шаг интервала</param> /// <param name="request">Параметры запроса</param>
/// <param name="format">формат отчета (0-PDF, 1-LAS)</param>
/// <param name="begin">дата начала интервала</param>
/// <param name="end">дата окончания интервала</param>
/// <param name="token">Токен для отмены задачи</param> /// <param name="token">Токен для отмены задачи</param>
/// <returns>id фоновой задачи формирования отчета</returns> /// <returns>id фоновой задачи формирования отчета</returns>
[HttpPost] [HttpPost]
[Permission] [Permission]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> CreateReportAsync(int idWell, int stepSeconds, int format, public async Task<IActionResult> CreateReportAsync([Required] int idWell,
DateTime begin = default, DateTime end = default, [FromQuery] ReportParametersRequest request,
CancellationToken token = default) CancellationToken token)
{ {
var idCompany = User.GetCompanyId(); var idCompany = User.GetCompanyId();
var idUser = User.GetUserId(); var idUser = User.GetUserId();
@ -54,8 +52,8 @@ namespace AsbCloudWebApi.Controllers
if ((idCompany is null) || (idUser is null)) if ((idCompany is null) || (idUser is null))
return Forbid(); return Forbid();
if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
idWell, token).ConfigureAwait(false)) idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
void HandleReportProgressAsync(object progress, string id) => void HandleReportProgressAsync(object progress, string id) =>
@ -69,7 +67,7 @@ namespace AsbCloudWebApi.Controllers
}, token); }, token);
var id = reportService.EnqueueCreateReportWork(idWell, (int)idUser, var id = reportService.EnqueueCreateReportWork(idWell, (int)idUser,
stepSeconds, format, begin, end, HandleReportProgressAsync); request.StepSeconds, request.Format, request.Begin, request.End, HandleReportProgressAsync);
return Ok(id); return Ok(id);
} }
@ -83,7 +81,7 @@ namespace AsbCloudWebApi.Controllers
[HttpGet] [HttpGet]
[Permission] [Permission]
[ProducesResponseType(typeof(IEnumerable<string>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<string>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetAllReportsNamesByWellAsync(int idWell, CancellationToken token = default) public async Task<IActionResult> GetAllReportsNamesByWellAsync(int idWell, CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
@ -102,32 +100,29 @@ namespace AsbCloudWebApi.Controllers
/// <summary> /// <summary>
/// Возвращает прогнозируемое количество страниц будущего отчета /// Возвращает прогнозируемое количество страниц будущего отчета
/// </summary> /// </summary>
/// <param name="idWell">id скважины</param> /// <param name="idWell">Id скважины</param>
/// <param name="begin">дата начала интервала</param> /// <param name="request">Параметры запроса</param>
/// <param name="end">дата окончания интервала</param>
/// <param name="stepSeconds">шаг интервала</param>
/// <param name="format">формат отчета (0-PDF, 1-LAS)</param>
/// <param name="token">Токен для отмены задачи</param> /// <param name="token">Токен для отмены задачи</param>
/// <returns>прогнозируемое кол-во страниц отчета</returns> /// <returns>прогнозируемое кол-во страниц отчета</returns>
[HttpGet] [HttpGet]
[Route("reportSize")] [Route("reportSize")]
[Permission] [Permission]
[ProducesResponseType(typeof(string), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(string), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetReportSizeAsync(int idWell, public async Task<IActionResult> GetReportSizeAsync([Required] int idWell,
int stepSeconds, int format, DateTime begin = default, [FromQuery] ReportParametersRequest request,
DateTime end = default, CancellationToken token = default) CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
if (idCompany is null) if (idCompany is null)
return Forbid(); return Forbid();
if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, if (!await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
idWell, token).ConfigureAwait(false)) idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
int reportSize = reportService.GetReportPagesCount(idWell, int reportSize = reportService.GetReportPagesCount(idWell,
begin, end, stepSeconds, format); request.Begin, request.End, request.StepSeconds, request.Format);
return Ok(reportSize); return Ok(reportSize);
} }
@ -142,7 +137,7 @@ namespace AsbCloudWebApi.Controllers
[Route("datesRange")] [Route("datesRange")]
[Permission] [Permission]
[ProducesResponseType(typeof(DatesRangeDto), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(DatesRangeDto), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetReportsDateRangeAsync(int idWell, CancellationToken token = default) public async Task<IActionResult> GetReportsDateRangeAsync(int idWell, CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();

View File

@ -5,7 +5,6 @@ using AsbCloudApp.Services;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -38,7 +37,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
/// <returns></returns> /// <returns></returns>
[HttpGet("categories")] [HttpGet("categories")]
[ProducesResponseType(typeof(IEnumerable<WellOperationCategoryDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<WellOperationCategoryDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetCategoriesAsync([FromQuery] int? idWell, CancellationToken token = default) public async Task<IActionResult> GetCategoriesAsync([FromQuery] int? idWell, CancellationToken token)
{ {
var result = await detectedOperationService.GetCategoriesAsync(idWell, token); var result = await detectedOperationService.GetCategoriesAsync(idWell, token);
return Ok(result); return Ok(result);
@ -54,7 +53,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
[ProducesResponseType(typeof(DetectedOperationListDto), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(DetectedOperationListDto), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetAsync( public async Task<IActionResult> GetAsync(
[FromQuery] DetectedOperationRequest request, [FromQuery] DetectedOperationRequest request,
CancellationToken token = default) CancellationToken token)
{ {
if (!await UserHasAccesToWellAsync(request.IdWell, token)) if (!await UserHasAccesToWellAsync(request.IdWell, token))
return Forbid(); return Forbid();
@ -73,7 +72,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
[ProducesResponseType(typeof(IEnumerable<DetectedOperationStatDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<DetectedOperationStatDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetStatAsync( public async Task<IActionResult> GetStatAsync(
[FromQuery] DetectedOperationRequest request, [FromQuery] DetectedOperationRequest request,
CancellationToken token = default) CancellationToken token)
{ {
if (!await UserHasAccesToWellAsync(request.IdWell, token)) if (!await UserHasAccesToWellAsync(request.IdWell, token))
return Forbid(); return Forbid();
@ -125,7 +124,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
[Route("export")] [Route("export")]
[Permission] [Permission]
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> ExportAsync(int? idWell, int? idCluster, CancellationToken token = default) public async Task<IActionResult> ExportAsync(int? idWell, int? idCluster, CancellationToken token)
{ {
if (idCluster is null && idWell is null) if (idCluster is null && idWell is null)
return this.MakeBadRequest(nameof(idWell), $"One of {nameof(idWell)} or {nameof(idCluster)} mast be set."); return this.MakeBadRequest(nameof(idWell), $"One of {nameof(idWell)} or {nameof(idCluster)} mast be set.");

View File

@ -1,14 +1,14 @@
using AsbCloudApp.Data.GTR; using AsbCloudApp.Data.GTR;
using AsbCloudApp.Repositories; using AsbCloudApp.Repositories;
using AsbCloudApp.Services; using AsbCloudApp.Services;
using AsbCloudDb.Model;
using AsbCloudWebApi.SignalR; using AsbCloudWebApi.SignalR;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using AsbCloudApp.Requests;
namespace AsbCloudWebApi.Controllers.SAUB namespace AsbCloudWebApi.Controllers.SAUB
{ {
@ -40,16 +40,15 @@ namespace AsbCloudWebApi.Controllers.SAUB
/// <summary> /// <summary>
/// Получить загруженные данные ГТИ по скважине /// Получить загруженные данные ГТИ по скважине
/// </summary> /// </summary>
/// <param name = "idWell" > id скважины</param> /// <param name="idWell">Id скважины</param>
/// <param name = "begin" > дата начала выборки.По умолчанию: текущее время - intervalSec</param> /// <param name="request">Параметры запроса</param>
/// <param name = "intervalSec" > интервал времени даты начала выборки, секунды</param> /// <param name = "token" >Токен завершения задачи</param>
/// <param name = "approxPointsCount" > желаемое количество точек. Если в выборке точек будет больше, то выборка будет прорежена.</param>
/// <param name = "token" > Токен завершения задачи</param>
/// <returns></returns> /// <returns></returns>
[HttpGet("{idWell}")] [HttpGet("{idWell}")]
[Permission] [Permission]
public async Task<ActionResult<IEnumerable<WitsRecordDto>>> GetDataAsync(int idWell, DateTime? begin, public async Task<ActionResult<IEnumerable<WitsRecordDto>>> GetDataAsync([Required] int idWell,
int intervalSec = 600, int approxPointsCount = 1024, CancellationToken token = default) [FromQuery] GtrWithGetDataRequest request,
CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
@ -62,8 +61,8 @@ namespace AsbCloudWebApi.Controllers.SAUB
if (!isCompanyOwnsWell) if (!isCompanyOwnsWell)
return Forbid(); return Forbid();
var content = await gtrRepository.GetAsync(idWell, begin, var content = await gtrRepository.GetAsync(idWell, request.Begin,
intervalSec, approxPointsCount, token).ConfigureAwait(false); request.IntervalSec, request.ApproxPointsCount, token).ConfigureAwait(false);
return Ok(content); return Ok(content);
} }
@ -107,7 +106,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
public async Task<IActionResult> PostDataAsync( public async Task<IActionResult> PostDataAsync(
string uid, string uid,
[FromBody] IEnumerable<WitsRecordDto> dtos, [FromBody] IEnumerable<WitsRecordDto> dtos,
CancellationToken token = default) CancellationToken token)
{ {
var telemetry = telemetryService.GetOrCreateTelemetryByUid(uid); var telemetry = telemetryService.GetOrCreateTelemetryByUid(uid);
await gtrRepository.SaveDataAsync(telemetry.Id, dtos, token).ConfigureAwait(false); await gtrRepository.SaveDataAsync(telemetry.Id, dtos, token).ConfigureAwait(false);

View File

@ -2,8 +2,6 @@
using AsbCloudApp.Requests; using AsbCloudApp.Requests;
using AsbCloudApp.Services; using AsbCloudApp.Services;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -38,7 +36,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
public async Task<IActionResult> GetMessagesAsync( public async Task<IActionResult> GetMessagesAsync(
[FromRoute] int idWell, [FromRoute] int idWell,
[FromQuery] MessageRequestBase request, [FromQuery] MessageRequestBase request,
CancellationToken token = default) CancellationToken token)
{ {
if (!await UserHasAccesToWellAsync(idWell, token)) if (!await UserHasAccesToWellAsync(idWell, token))
@ -70,7 +68,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
[Route("datesRange")] [Route("datesRange")]
[Permission] [Permission]
[ProducesResponseType(typeof(DatesRangeDto), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(DatesRangeDto), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetMessagesDateRangeAsync(int idWell, CancellationToken token = default) public async Task<IActionResult> GetMessagesDateRangeAsync(int idWell, CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();

View File

@ -51,7 +51,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
[HttpPost("api/well/{idWell}/setpoints")] [HttpPost("api/well/{idWell}/setpoints")]
[Permission] [Permission]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> InsertAsync(int idWell, SetpointsRequestDto setpoints, CancellationToken token = default) public async Task<IActionResult> InsertAsync(int idWell, SetpointsRequestDto setpoints, CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
int? idUser = User.GetUserId(); int? idUser = User.GetUserId();
@ -90,7 +90,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
[HttpGet("api/well/{idWell}/setpoints")] [HttpGet("api/well/{idWell}/setpoints")]
[Permission] [Permission]
[ProducesResponseType(typeof(IEnumerable<SetpointsRequestDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<SetpointsRequestDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetByIdWellAsync([FromRoute] int idWell, CancellationToken token = default) public async Task<IActionResult> GetByIdWellAsync([FromRoute] int idWell, CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
int? idUser = User.GetUserId(); int? idUser = User.GetUserId();
@ -116,7 +116,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
[HttpPut("api/telemetry/{uid}/setpoints/{id}")] [HttpPut("api/telemetry/{uid}/setpoints/{id}")]
[ProducesResponseType(typeof(SetpointsRequestDto), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(SetpointsRequestDto), (int)System.Net.HttpStatusCode.OK)]
[AllowAnonymous] [AllowAnonymous]
public async Task<IActionResult> UpdateByTelemetryUidAsync([FromRoute] string uid, int id, SetpointsRequestDto setpointsRequestDto, CancellationToken token = default) public async Task<IActionResult> UpdateByTelemetryUidAsync([FromRoute] string uid, int id, SetpointsRequestDto setpointsRequestDto, CancellationToken token)
{ {
var result = await setpointsService.UpdateStateAsync(setpointsRequestDto, token) var result = await setpointsService.UpdateStateAsync(setpointsRequestDto, token)
.ConfigureAwait(false); .ConfigureAwait(false);
@ -134,7 +134,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
[HttpGet("api/telemetry/{uid}/setpoints")] [HttpGet("api/telemetry/{uid}/setpoints")]
[ProducesResponseType(typeof(IEnumerable<SetpointsRequestDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<SetpointsRequestDto>), (int)System.Net.HttpStatusCode.OK)]
[AllowAnonymous] [AllowAnonymous]
public async Task<IActionResult> GetByTelemetryUidAsync([FromRoute] string uid, CancellationToken token = default) public async Task<IActionResult> GetByTelemetryUidAsync([FromRoute] string uid, CancellationToken token)
{ {
var result = await setpointsService.GetForPanelAsync(uid, token) var result = await setpointsService.GetForPanelAsync(uid, token)
.ConfigureAwait(false); .ConfigureAwait(false);
@ -151,7 +151,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
/// <returns>1 - удалено, 0 и меньше - не удалено</returns> /// <returns>1 - удалено, 0 и меньше - не удалено</returns>
[HttpDelete("api/well/{idWell}/setpoints/{id}")] [HttpDelete("api/well/{idWell}/setpoints/{id}")]
[Permission] [Permission]
public async Task<IActionResult> TryDeleteByIdWellAsync(int idWell, int id, CancellationToken token = default) public async Task<IActionResult> TryDeleteByIdWellAsync(int idWell, int id, CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
int? idUser = User.GetUserId(); int? idUser = User.GetUserId();

View File

@ -48,7 +48,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
[Route("{uid}")] [Route("{uid}")]
[AllowAnonymous] [AllowAnonymous]
public virtual async Task<IActionResult> PostDataAsync(string uid, [FromBody] IEnumerable<TDto> dtos, public virtual async Task<IActionResult> PostDataAsync(string uid, [FromBody] IEnumerable<TDto> dtos,
CancellationToken token = default) CancellationToken token)
{ {
await telemetryDataService.UpdateDataAsync(uid, dtos, token).ConfigureAwait(false); await telemetryDataService.UpdateDataAsync(uid, dtos, token).ConfigureAwait(false);
@ -72,8 +72,12 @@ namespace AsbCloudWebApi.Controllers.SAUB
/// <returns></returns> /// <returns></returns>
[HttpGet("{idWell}")] [HttpGet("{idWell}")]
[Permission] [Permission]
public virtual async Task<ActionResult<IEnumerable<TDto>>> GetDataAsync(int idWell, DateTime begin = default, public virtual async Task<ActionResult<IEnumerable<TDto>>> GetDataAsync(int idWell,
int intervalSec = 600, int approxPointsCount = 1024, CancellationToken token = default) DateTime begin = default,
int intervalSec = 600,
int approxPointsCount = 1024,
//TODO: сделать cancellationToken обязательным
CancellationToken token = default)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
@ -103,7 +107,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
[Permission] [Permission]
[ProducesResponseType(typeof(DatesRangeDto), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(DatesRangeDto), (int)System.Net.HttpStatusCode.OK)]
public virtual async Task<ActionResult<DatesRangeDto>> GetDataDatesRangeAsync(int idWell, public virtual async Task<ActionResult<DatesRangeDto>> GetDataDatesRangeAsync(int idWell,
CancellationToken token = default) CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();

View File

@ -43,7 +43,7 @@ namespace AsbCloudWebApi.Controllers.Subsystems
/// </summary> /// </summary>
[HttpGet("stat")] [HttpGet("stat")]
[ProducesResponseType(typeof(IEnumerable<SubsystemStatDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<SubsystemStatDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetStatAsync([FromQuery] SubsystemOperationTimeRequest request, CancellationToken token = default) public async Task<IActionResult> GetStatAsync([FromQuery] SubsystemOperationTimeRequest request, CancellationToken token)
{ {
if (!await UserHasAccesToWellAsync(request.IdWell, token)) if (!await UserHasAccesToWellAsync(request.IdWell, token))
return Forbid(); return Forbid();
@ -62,7 +62,7 @@ namespace AsbCloudWebApi.Controllers.Subsystems
/// <returns> </returns> /// <returns> </returns>
[HttpGet("statByActiveWell")] [HttpGet("statByActiveWell")]
[ProducesResponseType(typeof(IEnumerable<SubsystemActiveWellStatDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<SubsystemActiveWellStatDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetStatByWellAsync(DateTime? GtDate, DateTime? LtDate, CancellationToken token = default) public async Task<IActionResult> GetStatByWellAsync(DateTime? GtDate, DateTime? LtDate, CancellationToken token)
{ {
var idCompany = User.GetCompanyId(); var idCompany = User.GetCompanyId();
if (!idCompany.HasValue) if (!idCompany.HasValue)
@ -76,7 +76,7 @@ namespace AsbCloudWebApi.Controllers.Subsystems
/// </summary> /// </summary>
[HttpGet("subsystem")] [HttpGet("subsystem")]
[ProducesResponseType(typeof(IEnumerable<SubsystemDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<SubsystemDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetSubsystemAsync([FromQuery] int? idWell, CancellationToken token = default) public async Task<IActionResult> GetSubsystemAsync([FromQuery] int? idWell, CancellationToken token)
{ {
if (idWell.HasValue) if (idWell.HasValue)
if (!await UserHasAccesToWellAsync(idWell.Value, token)) if (!await UserHasAccesToWellAsync(idWell.Value, token))
@ -90,7 +90,7 @@ namespace AsbCloudWebApi.Controllers.Subsystems
/// </summary> /// </summary>
[HttpGet("datesRange")] [HttpGet("datesRange")]
[ProducesResponseType(typeof(DatesRangeDto), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(DatesRangeDto), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetDateRangeOperationTimeAsync([FromQuery] SubsystemOperationTimeRequest request, CancellationToken token = default) public async Task<IActionResult> GetDateRangeOperationTimeAsync([FromQuery] SubsystemOperationTimeRequest request, CancellationToken token)
{ {
if (!await UserHasAccesToWellAsync(request.IdWell, token)) if (!await UserHasAccesToWellAsync(request.IdWell, token))
return Forbid(); return Forbid();
@ -106,7 +106,7 @@ namespace AsbCloudWebApi.Controllers.Subsystems
public async Task<IActionResult> GetOperationTimeAsync( public async Task<IActionResult> GetOperationTimeAsync(
[FromQuery] SubsystemOperationTimeRequest request, [FromQuery] SubsystemOperationTimeRequest request,
CancellationToken token = default) CancellationToken token)
{ {
if (!await UserHasAccesToWellAsync(request.IdWell, token)) if (!await UserHasAccesToWellAsync(request.IdWell, token))
return Forbid(); return Forbid();

View File

@ -47,7 +47,7 @@ namespace AsbCloudWebApi.Controllers.WITS
string uid, string uid,
[FromBody] IEnumerable<TDto> dtos, [FromBody] IEnumerable<TDto> dtos,
[FromServices] IWitsRecordRepository<TDto> witsRecordRepository, [FromServices] IWitsRecordRepository<TDto> witsRecordRepository,
CancellationToken token = default) CancellationToken token)
{ {
var telemetry = telemetryService.GetOrCreateTelemetryByUid(uid); var telemetry = telemetryService.GetOrCreateTelemetryByUid(uid);
await witsRecordRepository.SaveDataAsync(telemetry.Id, dtos, token).ConfigureAwait(false); await witsRecordRepository.SaveDataAsync(telemetry.Id, dtos, token).ConfigureAwait(false);

View File

@ -38,7 +38,7 @@ namespace AsbCloudWebApi.Controllers
[HttpGet] [HttpGet]
[Permission] [Permission]
[ProducesResponseType(typeof(IEnumerable<WellCompositeDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<WellCompositeDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetAsync(int idWell, CancellationToken token = default) public async Task<IActionResult> GetAsync(int idWell, CancellationToken token)
{ {
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
@ -56,7 +56,7 @@ namespace AsbCloudWebApi.Controllers
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Permission] [Permission]
public async Task<IActionResult> SaveAsync(int idWell, IEnumerable<WellCompositeDto> wellComposites, CancellationToken token = default) public async Task<IActionResult> SaveAsync(int idWell, IEnumerable<WellCompositeDto> wellComposites, CancellationToken token)
{ {
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
@ -74,7 +74,7 @@ namespace AsbCloudWebApi.Controllers
[HttpGet("getCompositeProcessMap")] [HttpGet("getCompositeProcessMap")]
[Permission] [Permission]
[ProducesResponseType(typeof(IEnumerable<ProcessMapPlanDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<ProcessMapPlanDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetCompositeProcessMap(int idWell, CancellationToken token = default) public async Task<IActionResult> GetCompositeProcessMap(int idWell, CancellationToken token)
{ {
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false)) if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
@ -83,7 +83,7 @@ namespace AsbCloudWebApi.Controllers
return Ok(result); return Ok(result);
} }
private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token = default) private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token)
{ {
int? idCompany = User.GetCompanyId(); int? idCompany = User.GetCompanyId();
return idCompany is not null && await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, return idCompany is not null && await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,

View File

@ -33,7 +33,7 @@ namespace AsbCloudWebApi.Controllers
[HttpGet] [HttpGet]
[Permission] [Permission]
[ProducesResponseType(typeof(IEnumerable<WellDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<WellDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetWellsAsync(CancellationToken token = default) public async Task<IActionResult> GetWellsAsync(CancellationToken token)
{ {
var idCompany = User.GetCompanyId(); var idCompany = User.GetCompanyId();
@ -53,7 +53,7 @@ namespace AsbCloudWebApi.Controllers
/// <returns>Список скважин</returns> /// <returns>Список скважин</returns>
[HttpGet("wellTree")] [HttpGet("wellTree")]
[ProducesResponseType(typeof(IEnumerable<DepositBranchDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<DepositBranchDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetWellTreeAsync(CancellationToken token = default) public async Task<IActionResult> GetWellTreeAsync(CancellationToken token)
{ {
var idCompany = User.GetCompanyId(); var idCompany = User.GetCompanyId();
@ -75,7 +75,7 @@ namespace AsbCloudWebApi.Controllers
[HttpGet("{idWell}")] [HttpGet("{idWell}")]
[Permission] [Permission]
[ProducesResponseType(typeof(WellDto), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(WellDto), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetAsync(int idWell, CancellationToken token = default) public async Task<IActionResult> GetAsync(int idWell, CancellationToken token)
{ {
var idCompany = User.GetCompanyId(); var idCompany = User.GetCompanyId();
@ -100,7 +100,7 @@ namespace AsbCloudWebApi.Controllers
[Permission] [Permission]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> UpdateWellAsync(WellDto dto, public async Task<IActionResult> UpdateWellAsync(WellDto dto,
CancellationToken token = default) CancellationToken token)
{ {
var idCompany = User.GetCompanyId(); var idCompany = User.GetCompanyId();
@ -127,7 +127,7 @@ namespace AsbCloudWebApi.Controllers
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> UpdateWellStateAsync(int idWell, public async Task<IActionResult> UpdateWellStateAsync(int idWell,
[Range(0, 2, ErrorMessage = "Статус некорректен")] int idState, [Range(0, 2, ErrorMessage = "Статус некорректен")] int idState,
CancellationToken token = default) CancellationToken token)
{ {
var idCompany = User.GetCompanyId(); var idCompany = User.GetCompanyId();

View File

@ -163,7 +163,7 @@ namespace AsbCloudWebApi.Controllers
[HttpGet] [HttpGet]
[Route("wellCaseCategories")] [Route("wellCaseCategories")]
[Permission] [Permission]
public async Task<IActionResult> GetWellCaseCategoriesAsync(CancellationToken token = default) public async Task<IActionResult> GetWellCaseCategoriesAsync(CancellationToken token)
{ {
var data = await fileCategoryService.GetWellCaseCategoriesAsync(token); var data = await fileCategoryService.GetWellCaseCategoriesAsync(token);
return Ok(data); return Ok(data);