CS2-3: Дополнен класс Report для контекста EF Core

This commit is contained in:
KharchenkoVV 2021-05-20 14:30:25 +05:00
parent d45f8cb429
commit 1358f7fc11
4 changed files with 29 additions and 11 deletions

View File

@ -24,6 +24,7 @@ namespace AsbCloudDb.Model
public virtual DbSet<User> Users { get; set; }
public virtual DbSet<UserRole> UserRoles { get; set; }
public virtual DbSet<Well> Wells { get; set; }
public virtual DbSet<Report> Reports { get; set; }
//public AsbCloudDbContext(string connectionString = "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")
//{

View File

@ -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; }
}
}

View File

@ -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
/// <param name="wellId">id скважины</param>
/// <param name="stepSeconds">шаг интервала</param>
/// <param name="format">формат отчета (0-PDF, 1-LASS)</param>
/// <param name="signalRConnectionId">SignalR id подключения клиента</param>
/// <param name="begin">дата начала интервала</param>
/// <param name="end">дата окончания интервала</param>
/// <returns>id фоновой задачи формирования отчета</returns>
[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)

View File

@ -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();
});
});
}