forked from ddrilling/AsbCloudServer
Сделал обязательный CancellationToken в контроллерах
This commit is contained in:
parent
386de8968f
commit
ecc62c8404
@ -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);
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
@ -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();
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
@ -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,
|
||||||
|
@ -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,
|
||||||
|
@ -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,
|
||||||
|
@ -45,8 +45,8 @@ 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> CreateReportAsync(int idWell, int stepSeconds, int format,
|
public async Task<IActionResult> CreateReportAsync(int idWell, int stepSeconds, int format,
|
||||||
DateTime begin = default, DateTime end = default,
|
CancellationToken token,
|
||||||
CancellationToken token = default)
|
DateTime begin = default, DateTime end = default)
|
||||||
{
|
{
|
||||||
var idCompany = User.GetCompanyId();
|
var idCompany = User.GetCompanyId();
|
||||||
var idUser = User.GetUserId();
|
var idUser = User.GetUserId();
|
||||||
@ -83,7 +83,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();
|
||||||
|
|
||||||
@ -114,8 +114,11 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[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(int idWell,
|
||||||
int stepSeconds, int format, DateTime begin = default,
|
int stepSeconds,
|
||||||
DateTime end = default, CancellationToken token = default)
|
int format,
|
||||||
|
CancellationToken token,
|
||||||
|
DateTime begin = default,
|
||||||
|
DateTime end = default)
|
||||||
{
|
{
|
||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
@ -142,7 +145,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();
|
||||||
|
|
||||||
|
@ -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.");
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
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;
|
||||||
@ -49,7 +48,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
|||||||
[HttpGet("{idWell}")]
|
[HttpGet("{idWell}")]
|
||||||
[Permission]
|
[Permission]
|
||||||
public async Task<ActionResult<IEnumerable<WitsRecordDto>>> GetDataAsync(int idWell, DateTime? begin,
|
public async Task<ActionResult<IEnumerable<WitsRecordDto>>> GetDataAsync(int idWell, DateTime? begin,
|
||||||
int intervalSec = 600, int approxPointsCount = 1024, CancellationToken token = default)
|
CancellationToken token, int intervalSec = 600, int approxPointsCount = 1024)
|
||||||
{
|
{
|
||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
@ -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);
|
||||||
|
@ -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();
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
@ -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,10 @@ 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, CancellationToken token,
|
||||||
int intervalSec = 600, int approxPointsCount = 1024, CancellationToken token = default)
|
DateTime begin = default,
|
||||||
|
int intervalSec = 600,
|
||||||
|
int approxPointsCount = 1024)
|
||||||
{
|
{
|
||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
@ -103,7 +105,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();
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
@ -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);
|
||||||
|
@ -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,
|
||||||
|
@ -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();
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user