forked from ddrilling/AsbCloudServer
Изменил пути у методов контроллеров + мелкий рефакторинг
This commit is contained in:
parent
8b137ca851
commit
a0ef71a43d
@ -40,10 +40,10 @@ public class AutoGeneratedDailyReportController : ControllerBase
|
|||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("file")]
|
[Route("export/excel")]
|
||||||
[ProducesResponseType(typeof(PhysicalFileResult), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PhysicalFileResult), (int)HttpStatusCode.OK, "application/octet-stream")]
|
||||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
public async Task<IActionResult> GenerateAsync([FromRoute] int idWell,
|
public async Task<IActionResult> ExportAsync([FromRoute] int idWell,
|
||||||
[Required] DateOnly reportDate,
|
[Required] DateOnly reportDate,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
@ -54,7 +54,7 @@ public class AutoGeneratedDailyReportController : ControllerBase
|
|||||||
reportDate,
|
reportDate,
|
||||||
cancellationToken);
|
cancellationToken);
|
||||||
|
|
||||||
return File(reportFile.stream, "application/octet-stream", reportFile.fileName);
|
return File(reportFile.stream, reportFile.fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Data.DailyReport;
|
using AsbCloudApp.Data.DailyReport;
|
||||||
using AsbCloudApp.Exceptions;
|
using AsbCloudApp.Exceptions;
|
||||||
using AsbCloudApp.Repositories;
|
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@ -10,6 +9,7 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
@ -24,16 +24,13 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
{
|
{
|
||||||
private readonly IDailyReportService dailyReportService;
|
private readonly IDailyReportService dailyReportService;
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
private readonly IWellOperationRepository operationRepository;
|
|
||||||
|
|
||||||
public DailyReportController(
|
public DailyReportController(
|
||||||
IDailyReportService dailyReportService,
|
IDailyReportService dailyReportService,
|
||||||
IWellService wellService,
|
IWellService wellService)
|
||||||
IWellOperationRepository operationRepository)
|
|
||||||
{
|
{
|
||||||
this.dailyReportService = dailyReportService;
|
this.dailyReportService = dailyReportService;
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
this.operationRepository = operationRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -164,8 +161,9 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// <param name="date"></param>
|
/// <param name="date"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("{date}/file")]
|
[HttpGet("{date}/export/excel")]
|
||||||
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK, "application/octet-stream")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
public async Task<IActionResult> DownloadAsync(int idWell, DateOnly date, CancellationToken token)
|
public async Task<IActionResult> DownloadAsync(int idWell, DateOnly date, CancellationToken token)
|
||||||
{
|
{
|
||||||
if (!await UserHasAccesToWellAsync(idWell, token))
|
if (!await UserHasAccesToWellAsync(idWell, token))
|
||||||
@ -175,13 +173,12 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
?? throw new ArgumentInvalidException($"Скважина c id:{idWell} не найдена", nameof(idWell));
|
?? throw new ArgumentInvalidException($"Скважина c id:{idWell} не найдена", nameof(idWell));
|
||||||
|
|
||||||
var stream = await dailyReportService.MakeReportAsync(idWell, date, token);
|
var stream = await dailyReportService.MakeReportAsync(idWell, date, token);
|
||||||
if (stream is not null)
|
if (stream is null)
|
||||||
{
|
|
||||||
var fileName = $"Суточный рапорт по скважине {well.Caption} куст {well.Cluster}.xlsx";
|
|
||||||
return File(stream, "application/octet-stream", fileName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return NoContent();
|
return NoContent();
|
||||||
|
|
||||||
|
var fileName = $"Суточный рапорт по скважине {well.Caption} куст {well.Cluster}.xlsx";
|
||||||
|
return File(stream, fileName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task<bool> UserHasAccesToWellAsync(int idWell, CancellationToken token)
|
protected async Task<bool> UserHasAccesToWellAsync(int idWell, CancellationToken token)
|
||||||
|
@ -38,18 +38,19 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Возвращает шаблон для заполнения строк плановой траектории
|
/// Возвращает excel шаблон для заполнения строк плановой траектории
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Запрашиваемый файл</returns>
|
/// <returns>Запрашиваемый файл</returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("template/file")]
|
[Route("template/excel")]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK,"application/octet-stream")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
public IActionResult GetTemplate()
|
public IActionResult GetTemplate()
|
||||||
{
|
{
|
||||||
var stream = plannedTrajectoryImportService.GetTemplateFile();
|
var stream = plannedTrajectoryImportService.GetTemplateFile();
|
||||||
var fileName = "ЕЦП_шаблон_файла_плановая_траектория.xlsx";
|
var fileName = "ЕЦП_шаблон_файла_плановая_траектория.xlsx";
|
||||||
return File(stream, "application/octet-stream", fileName);
|
return File(stream, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -59,8 +60,9 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// <param name="token"> Токен отмены задачи </param>
|
/// <param name="token"> Токен отмены задачи </param>
|
||||||
/// <returns>Запрашиваемый файл</returns>
|
/// <returns>Запрашиваемый файл</returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("file")]
|
[Route("export/excel")]
|
||||||
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK, "application/octet-stream")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
public async Task<IActionResult> ExportAsync([FromRoute] int idWell, CancellationToken token)
|
public async Task<IActionResult> ExportAsync([FromRoute] int idWell, CancellationToken token)
|
||||||
{
|
{
|
||||||
if (!await CanUserAccessToWellAsync(idWell,
|
if (!await CanUserAccessToWellAsync(idWell,
|
||||||
@ -68,7 +70,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return Forbid();
|
return Forbid();
|
||||||
var stream = await plannedTrajectoryImportService.ExportAsync(idWell, token);
|
var stream = await plannedTrajectoryImportService.ExportAsync(idWell, token);
|
||||||
var fileName = await plannedTrajectoryImportService.GetFileNameAsync(idWell, token);
|
var fileName = await plannedTrajectoryImportService.GetFileNameAsync(idWell, token);
|
||||||
return File(stream, "application/octet-stream", fileName);
|
return File(stream, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -80,7 +82,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// <param name="token"> Токен отмены задачи </param>
|
/// <param name="token"> Токен отмены задачи </param>
|
||||||
/// <returns>количество успешно записанных строк в БД</returns>
|
/// <returns>количество успешно записанных строк в БД</returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("file/{deleteBeforeImport}")]
|
[Route("import/excel/{deleteBeforeImport}")]
|
||||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> ImportAsync(int idWell,
|
public async Task<IActionResult> ImportAsync(int idWell,
|
||||||
[FromForm] IFormFileCollection files,
|
[FromForm] IFormFileCollection files,
|
||||||
|
@ -100,8 +100,9 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// /// <param name="token"></param>
|
/// /// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("processMapReport/{wellId}/file")]
|
[Route("processMapReport/export/excel/{wellId}")]
|
||||||
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK, "application/octet-stream")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
public async Task<IActionResult> GetReportFileAsync(int wellId, CancellationToken token)
|
public async Task<IActionResult> GetReportFileAsync(int wellId, CancellationToken token)
|
||||||
{
|
{
|
||||||
var stream = await processMapReportService.MakeReportAsync(wellId, token);
|
var stream = await processMapReportService.MakeReportAsync(wellId, token);
|
||||||
@ -110,14 +111,12 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
var well = await wellService.GetOrDefaultAsync(wellId, token);
|
var well = await wellService.GetOrDefaultAsync(wellId, token);
|
||||||
if (well is null)
|
if (well is null)
|
||||||
return NoContent();
|
return NoContent();
|
||||||
else
|
|
||||||
{
|
var fileName = $"РТК по скважине {well.Caption} куст {well.Cluster}.xlsx";
|
||||||
var fileName = $"РТК по скважине {well.Caption} куст {well.Cluster}.xlsx";
|
return File(stream, fileName);
|
||||||
return File(stream, "application/octet-stream", fileName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -170,13 +169,13 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Запрашиваемый файл</returns>
|
/// <returns>Запрашиваемый файл</returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("template/file")]
|
[Route("template/excel")]
|
||||||
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK, "application/octet-stream")]
|
||||||
public async Task<IActionResult> GetTemplateAsync(CancellationToken cancellationToken)
|
public async Task<IActionResult> GetTemplateAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var stream = await processMapPlanImportService.GetExcelTemplateStreamAsync(cancellationToken);
|
var stream = await processMapPlanImportService.GetExcelTemplateStreamAsync(cancellationToken);
|
||||||
var fileName = "ЕЦП_шаблон_файла_РТК.xlsx";
|
var fileName = "ЕЦП_шаблон_файла_РТК.xlsx";
|
||||||
return File(stream, "application/octet-stream", fileName);
|
return File(stream, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -188,7 +187,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("file/{idWell}/{options}")]
|
[Route("import/excel/{idWell}/{options}")]
|
||||||
public async Task<IActionResult> ImportAsync(int idWell,
|
public async Task<IActionResult> ImportAsync(int idWell,
|
||||||
int options,
|
int options,
|
||||||
[Required] IFormFile file,
|
[Required] IFormFile file,
|
||||||
@ -227,8 +226,9 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("file/{idWell}")]
|
[Route("export/excel/{idWell}")]
|
||||||
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK, "application/octet-stream")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
public async Task<IActionResult> ExportAsync(int idWell, CancellationToken cancellationToken)
|
public async Task<IActionResult> ExportAsync(int idWell, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
int? idUser = User.GetUserId();
|
int? idUser = User.GetUserId();
|
||||||
@ -243,7 +243,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
|
|
||||||
var stream = await processMapPlanImportService.ExportAsync(idWell, cancellationToken);
|
var stream = await processMapPlanImportService.ExportAsync(idWell, cancellationToken);
|
||||||
var fileName = $"РТК-план по скважине {well.Caption} куст {well.Cluster}.xlsx";
|
var fileName = $"РТК-план по скважине {well.Caption} куст {well.Cluster}.xlsx";
|
||||||
return File(stream, "application/octet-stream", fileName);
|
return File(stream, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task NotifyUsersBySignalR(int idWell, CancellationToken token)
|
private async Task NotifyUsersBySignalR(int idWell, CancellationToken token)
|
||||||
|
@ -8,6 +8,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers.SAUB
|
namespace AsbCloudWebApi.Controllers.SAUB
|
||||||
{
|
{
|
||||||
@ -121,9 +122,10 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
|||||||
/// <param name="token"> Токен отмены задачи </param>
|
/// <param name="token"> Токен отмены задачи </param>
|
||||||
/// <returns>Запрашиваемый файл</returns>
|
/// <returns>Запрашиваемый файл</returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("file")]
|
[Route("export/excel")]
|
||||||
[Permission]
|
[Permission]
|
||||||
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK, "application/octet-stream")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
public async Task<IActionResult> ExportAsync(int? idWell, int? idCluster, CancellationToken token)
|
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)
|
||||||
@ -151,7 +153,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
|||||||
|
|
||||||
var stream = await detectedOperationService.ExportAsync(idsWells, token);
|
var stream = await detectedOperationService.ExportAsync(idsWells, token);
|
||||||
var fileName = "operations.xlsx";
|
var fileName = "operations.xlsx";
|
||||||
return File(stream, "application/octet-stream", fileName);
|
return File(stream, fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ using Microsoft.AspNetCore.SignalR;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System;
|
using System;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers.SAUB
|
namespace AsbCloudWebApi.Controllers.SAUB
|
||||||
{
|
{
|
||||||
@ -41,8 +42,9 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
|||||||
/// <param name="endDate">конец интервала в формате: yyyy-MM-DD HH:mm</param>
|
/// <param name="endDate">конец интервала в формате: yyyy-MM-DD HH:mm</param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("{idWell}/file")]
|
[HttpGet("{idWell}/export/csv")]
|
||||||
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK, "application/octet-stream")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
public async Task<IActionResult> GetZippedCsv(int idWell, DateTime beginDate, DateTime endDate, CancellationToken token)
|
public async Task<IActionResult> GetZippedCsv(int idWell, DateTime beginDate, DateTime endDate, CancellationToken token)
|
||||||
{
|
{
|
||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
@ -58,7 +60,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
|||||||
|
|
||||||
var stream = await telemetryDataSaubService.GetZippedCsv(idWell, beginDate, endDate, token).ConfigureAwait(false);
|
var stream = await telemetryDataSaubService.GetZippedCsv(idWell, beginDate, endDate, token).ConfigureAwait(false);
|
||||||
var fileName = $"DataSaub idWell{idWell} {beginDate:yyyy-MM-DDTHH-mm} - {endDate:yyyy-MM-DDTHH-mm}.zip";
|
var fileName = $"DataSaub idWell{idWell} {beginDate:yyyy-MM-DDTHH-mm} - {endDate:yyyy-MM-DDTHH-mm}.zip";
|
||||||
return File(stream, "application/octet-stream", fileName);
|
return File(stream, fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Exceptions;
|
|
||||||
using AsbCloudApp.Repositories;
|
using AsbCloudApp.Repositories;
|
||||||
using AsbCloudApp.Requests;
|
using AsbCloudApp.Requests;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
@ -10,7 +9,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -284,7 +282,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Permission]
|
[Permission]
|
||||||
[Route("file/{options}")]
|
[Route("import/excel/{options}")]
|
||||||
public async Task<IActionResult> ImportAsync(int idWell,
|
public async Task<IActionResult> ImportAsync(int idWell,
|
||||||
[FromForm] IFormFileCollection files,
|
[FromForm] IFormFileCollection files,
|
||||||
int options,
|
int options,
|
||||||
@ -324,12 +322,13 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// Создает excel файл с операциями по скважине
|
/// Создает excel файл с операциями по скважине
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idWell">id скважины</param>
|
/// <param name="idWell">id скважины</param>
|
||||||
/// <param name="token"> Токен отмены задачи </param>
|
/// <param name="token">Токен отмены задачи </param>
|
||||||
/// <returns>Запрашиваемый файл</returns>
|
/// <returns>Запрашиваемый файл</returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("file")]
|
[Route("export/excel")]
|
||||||
[Permission]
|
[Permission]
|
||||||
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK, "application/octet-stream")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
public async Task<IActionResult> ExportAsync([FromRoute] int idWell, CancellationToken token)
|
public async Task<IActionResult> ExportAsync([FromRoute] int idWell, CancellationToken token)
|
||||||
{
|
{
|
||||||
int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
@ -343,7 +342,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
|
|
||||||
var stream = wellOperationImportService.Export(idWell);
|
var stream = wellOperationImportService.Export(idWell);
|
||||||
var fileName = await wellService.GetWellCaptionByIdAsync(idWell, token) + "_operations.xlsx";
|
var fileName = await wellService.GetWellCaptionByIdAsync(idWell, token) + "_operations.xlsx";
|
||||||
return File(stream, "application/octet-stream", fileName);
|
return File(stream, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -378,14 +377,14 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Запрашиваемый файл</returns>
|
/// <returns>Запрашиваемый файл</returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("template/file")]
|
[Route("template/excel")]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK, "application/octet-stream")]
|
||||||
public IActionResult GetTemplate()
|
public IActionResult GetTemplate()
|
||||||
{
|
{
|
||||||
var stream = wellOperationImportService.GetExcelTemplateStream();
|
var stream = wellOperationImportService.GetExcelTemplateStream();
|
||||||
var fileName = "ЕЦП_шаблон_файла_операций.xlsx";
|
var fileName = "ЕЦП_шаблон_файла_операций.xlsx";
|
||||||
return File(stream, "application/octet-stream", fileName);
|
return File(stream, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token)
|
private async Task<bool> CanUserAccessToWellAsync(int idWell, CancellationToken token)
|
||||||
|
Loading…
Reference in New Issue
Block a user