diff --git a/AsbCloudDb/Model/AsbCloudDbContext.cs b/AsbCloudDb/Model/AsbCloudDbContext.cs index c7651ff6..c03e9e99 100644 --- a/AsbCloudDb/Model/AsbCloudDbContext.cs +++ b/AsbCloudDb/Model/AsbCloudDbContext.cs @@ -24,6 +24,7 @@ namespace AsbCloudDb.Model public virtual DbSet Users { get; set; } public virtual DbSet UserRoles { get; set; } public virtual DbSet Wells { get; set; } + public virtual DbSet Reports { get; set; } //public AsbCloudDbContext(string connectionString = "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True") //{ diff --git a/AsbCloudDb/Model/Report.cs b/AsbCloudDb/Model/Report.cs index b3eb7265..ad705154 100644 --- a/AsbCloudDb/Model/Report.cs +++ b/AsbCloudDb/Model/Report.cs @@ -1,11 +1,30 @@ using System; +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; namespace AsbCloudDb.Model { + [Table("t_report"), Comment("Отчеты с данными по буровым")] public class Report : IId, IIdTelemetryDate { + [Key] + [Column("id")] public int Id { get; set; } + [Column("id_telemetry")] public int IdTelemetry { get; set; } + [Column("id_well"), Comment("id скважины")] + public int WellId { get; set; } + [Column("date", TypeName = "timestamp with time zone")] public DateTime Date { get; set; } + [Column("begin", TypeName = "timestamp with time zone")] + public DateTime Begin { get; set; } + [Column("end"), Comment("timestamp with time zone")] + public DateTime End { get; set; } + [Column("step", TypeName = "размер шага в секундах")] + public int Step { get; set; } + [Column("format"), Comment("Формат отчета")] + public int Format { get; set; } + } } diff --git a/AsbCloudWebApi/Controllers/ReportController.cs b/AsbCloudWebApi/Controllers/ReportController.cs index 7635ce32..68f80b6f 100644 --- a/AsbCloudWebApi/Controllers/ReportController.cs +++ b/AsbCloudWebApi/Controllers/ReportController.cs @@ -26,8 +26,6 @@ namespace AsbCloudWebApi.Controllers this.reportsHubContext = reportsHubContext; } - private string signalRConnectionId = "0"; - private void HandleReportProgress (float progress, string operation, int id) => reportsHubContext.Clients.Group($"Report{id}").SendAsync("GetReportProgress", progress); @@ -38,18 +36,15 @@ namespace AsbCloudWebApi.Controllers /// id скважины /// шаг интервала /// формат отчета (0-PDF, 1-LASS) - /// SignalR id подключения клиента /// дата начала интервала /// дата окончания интервала /// id фоновой задачи формирования отчета [HttpPost] [Route("{wellId}/report")] [ProducesResponseType(typeof(string), (int)System.Net.HttpStatusCode.OK)] - public IActionResult CreateReport(int wellId, int stepSeconds, int format, string signalRConnectionId, + public IActionResult CreateReport(int wellId, int stepSeconds, int format, DateTime begin = default, DateTime end = default) - { - this.signalRConnectionId = signalRConnectionId; - + { int? idCustomer = User.GetCustomerId(); if (idCustomer is null) diff --git a/AsbCloudWebApi/Startup.cs b/AsbCloudWebApi/Startup.cs index 32ac89a1..4a6fa1ef 100644 --- a/AsbCloudWebApi/Startup.cs +++ b/AsbCloudWebApi/Startup.cs @@ -35,10 +35,13 @@ namespace AsbCloudWebApi { policy.AllowAnyHeader() .AllowAnyMethod() - .AllowAnyOrigin() - //.WithOrigins("http://localhost:3000") - //.AllowCredentials() - ; + .WithOrigins( + "http://0.0.0.0:3000", + "http://localhost:3000", + "http://0.0.0.0:5000", + "http://localhost:5000" + ) + .AllowCredentials(); }); }); }