diff --git a/AsbCloudApp/Data/ProcessMap/ProcessMapPlanDto.cs b/AsbCloudApp/Data/ProcessMap/ProcessMapPlanDto.cs index c35d4135..8849e13d 100644 --- a/AsbCloudApp/Data/ProcessMap/ProcessMapPlanDto.cs +++ b/AsbCloudApp/Data/ProcessMap/ProcessMapPlanDto.cs @@ -21,7 +21,7 @@ namespace AsbCloudApp.Data.ProcessMap public int? IdUser { get; set; } /// - /// Id режима 1-ротор, 2 - слайд + /// Id режима 0-ручной, 1-ротор, 2 - слайд /// [Range(0, 2, ErrorMessage = "Id режима должен быть либо 0-ручной либо, 1-ротор либо 2-слайд")] public int IdMode { get; set; } diff --git a/AsbCloudApp/Services/IHelpPageService.cs b/AsbCloudApp/Services/IHelpPageService.cs index 04051521..4fd675d7 100644 --- a/AsbCloudApp/Services/IHelpPageService.cs +++ b/AsbCloudApp/Services/IHelpPageService.cs @@ -27,11 +27,11 @@ public interface IHelpPageService /// /// Метод получения файла справки /// - /// + /// /// /// /// - Task<(Stream stream, string fileName)> GetFileStreamAsync(string urlPage, + Task<(Stream stream, string fileName)?> GetFileStreamAsync(string pageKey, int idCategory, CancellationToken cancellationToken); } \ No newline at end of file diff --git a/AsbCloudInfrastructure/CommonLibs/AsbSaubReport.dll b/AsbCloudInfrastructure/CommonLibs/AsbSaubReport.dll index e03f8c34..b9260919 100644 Binary files a/AsbCloudInfrastructure/CommonLibs/AsbSaubReport.dll and b/AsbCloudInfrastructure/CommonLibs/AsbSaubReport.dll differ diff --git a/AsbCloudInfrastructure/CommonLibs/AsbSaubReportLas.dll b/AsbCloudInfrastructure/CommonLibs/AsbSaubReportLas.dll index 5f24ee69..0c88a822 100644 Binary files a/AsbCloudInfrastructure/CommonLibs/AsbSaubReportLas.dll and b/AsbCloudInfrastructure/CommonLibs/AsbSaubReportLas.dll differ diff --git a/AsbCloudInfrastructure/CommonLibs/AsbSaubReportPdf.dll b/AsbCloudInfrastructure/CommonLibs/AsbSaubReportPdf.dll index a478be7c..4fd8d906 100644 Binary files a/AsbCloudInfrastructure/CommonLibs/AsbSaubReportPdf.dll and b/AsbCloudInfrastructure/CommonLibs/AsbSaubReportPdf.dll differ diff --git a/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs b/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs index 13a44914..d292e812 100644 --- a/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs +++ b/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs @@ -1,6 +1,7 @@ using AsbCloudApp.Exceptions; using AsbCloudDb.Model; using AsbSaubReport.Model; +using iText.Forms.Xfdf; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; @@ -129,6 +130,26 @@ namespace AsbCloudInfrastructure return query; } + public IQueryable GetDataSpinItems(DateTime begin, DateTime end) + { + var beginUtc = begin.ToUtcDateTimeOffset(timezoneOffset); + var endUtc = end.ToUtcDateTimeOffset(timezoneOffset); + + var query = context.TelemetryDataSpin + .Where(d => d.IdTelemetry == idTelemetry + && d.DateTime >= beginUtc + && d.DateTime <= endUtc) + .OrderBy(d => d.DateTime) + .Select(d => new DataSpinReport + { + Date = d.DateTime.DateTime.AddHours(timezoneOffset), + Mode = d.Mode, + IsWorkingSpinMaster = (d.State != 0 && d.State != 5 && d.State != 6 && d.State != 7), + IsWorkingTorqueMaster = (d.State == 7 && (d.Mode & 2) > 0), + }); + return query; + } + public IQueryable GetMessages(DateTime begin, DateTime end) { var beginUtc = begin.ToUtcDateTimeOffset(timezoneOffset); diff --git a/AsbCloudInfrastructure/Services/HelpPageService.cs b/AsbCloudInfrastructure/Services/HelpPageService.cs index 689ccbd2..0e8f40ee 100644 --- a/AsbCloudInfrastructure/Services/HelpPageService.cs +++ b/AsbCloudInfrastructure/Services/HelpPageService.cs @@ -78,20 +78,23 @@ public class HelpPageService : IHelpPageService /// /// Метод получения файла справки /// - /// + /// /// /// /// - /// - public async Task<(Stream stream, string fileName)> GetFileStreamAsync(string urlPage, + /// + public async Task<(Stream stream, string fileName)?> GetFileStreamAsync(string pageKey, int idCategory, CancellationToken cancellationToken) { - urlPage = WebUtility.UrlDecode(urlPage); + pageKey = WebUtility.UrlDecode(pageKey); - var helpPage = await helpPageRepository.GetOrDefaultByUrlPageAndIdCategoryAsync(urlPage, + var helpPage = await helpPageRepository.GetOrDefaultByUrlPageAndIdCategoryAsync(pageKey, idCategory, - cancellationToken) ?? throw new ArgumentInvalidException("Справки не существует", nameof(idCategory)); + cancellationToken); + + if(helpPage is null) + return null; string filePath = fileStorageRepository.GetFilePath(directoryNameHelpPageFiles, helpPage.IdCategory.ToString(), diff --git a/AsbCloudWebApi/Controllers/HelpPageController.cs b/AsbCloudWebApi/Controllers/HelpPageController.cs index c3a538a1..db0b5faf 100644 --- a/AsbCloudWebApi/Controllers/HelpPageController.cs +++ b/AsbCloudWebApi/Controllers/HelpPageController.cs @@ -89,14 +89,10 @@ public class HelpPageController : ControllerBase idCategory, cancellationToken); - using var fileStream = file.stream; + if (!file.HasValue) + return NoContent(); - var memoryStream = new MemoryStream(); - await fileStream.CopyToAsync(memoryStream, - cancellationToken); - memoryStream.Position = 0; - - return File(memoryStream, "application/pdf", file.fileName); + return File(file.Value.stream, "application/pdf", file.Value.fileName); } /// diff --git a/AsbCloudWebApi/Controllers/ProcessMapController.cs b/AsbCloudWebApi/Controllers/ProcessMapController.cs index 95f41405..ffa88938 100644 --- a/AsbCloudWebApi/Controllers/ProcessMapController.cs +++ b/AsbCloudWebApi/Controllers/ProcessMapController.cs @@ -204,11 +204,18 @@ namespace AsbCloudWebApi.Controllers using Stream stream = file.OpenReadStream(); - await processMapPlanImportService.ImportAsync(idWell, - idUser.Value, - (options & 1) > 0, - stream, - cancellationToken); + try + { + await processMapPlanImportService.ImportAsync(idWell, + idUser.Value, + (options & 1) > 0, + stream, + cancellationToken); + } + catch (FileFormatException ex) + { + return BadRequest(ex.Message); + } return Ok(); }