fix jsonSerializer settings;

reafctor TelemetryHub;
Add wellDepth into TelemetryMessage
This commit is contained in:
Фролов 2021-09-17 16:24:01 +05:00
parent 35cd538b1d
commit 0b1f9683b9
38 changed files with 2793 additions and 117 deletions

View File

@ -0,0 +1,10 @@
using System;
namespace AsbCloudApp.Data
{
public interface ITelemetryData: IId
{
int IdTelemetry { get; set; }
DateTime Date { get; set; }
}
}

View File

@ -5,8 +5,9 @@ namespace AsbCloudApp.Data
/// <summary>
/// Сообщение получаемое по телеметрии и отправляемое в frontend
/// </summary>
public class TelemetryDataSaubDto
public class TelemetryDataSaubDto : ITelemetryData
{
public int Id { get; set; }
//[JsonPropertyName("date")]
public DateTime Date { get; set; }

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace AsbCloudApp.Data
{
public class TelemetryDataSpinDto
public class TelemetryDataSpinDto : ITelemetryData
{
public int Id { get; set; }
public int IdTelemetry { get; set; }

View File

@ -9,6 +9,7 @@ namespace AsbCloudApp.Data
{
public int Id { get; set; }
public DateTime Date { get; set; }
public double WellDepth { get; set; }
public int IdEvent { get; set; }
public int? IdTelemetryUser { get; set; }
public string Arg0 { get; set; }

View File

@ -1,6 +1,6 @@
using AsbCloudApp.Data;
namespace AsbCloudInfrastructure.Services
namespace AsbCloudApp.Services
{
public interface ICachedCrudService<Tdto> where Tdto : IId
{

View File

@ -8,7 +8,6 @@ namespace AsbCloudApp.Services
where Tdto : Data.IId
{
List<string> Incledes { get; }
Task<int> DeleteAsync(int id, CancellationToken token = default);
Task<int> DeleteAsync(IEnumerable<int> ids, CancellationToken token = default);
Task<IEnumerable<Tdto>> GetAllAsync(CancellationToken token = default);

View File

@ -0,0 +1,15 @@
using AsbCloudApp.Data;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudApp.Services
{
public interface ITelemetryDataService<TDto> where TDto : ITelemetryData
{
Task<IEnumerable<TDto>> GetAsync(int idWell, DateTime dateBegin = default, double intervalSec = 600, int approxPointsCount = 1024, CancellationToken token = default);
Task<DatesRangeDto> GetDataDatesRangeAsync(int idWell, CancellationToken token = default);
Task<int> UpdateDataAsync(string uid, IEnumerable<TDto> dtos, CancellationToken token = default);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace AsbCloudDb.Migrations
{
public partial class AddWellDepthToMessage : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<double>(
name: "well_depth",
table: "t_telemetry_message",
type: "double precision",
nullable: false,
defaultValue: 0.0);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "well_depth",
table: "t_telemetry_message");
}
}
}

View File

@ -1225,6 +1225,10 @@ namespace AsbCloudDb.Migrations
.HasColumnName("id_telemetry_user")
.HasComment("Пользователь панели отправляющей телеметрию. не пользователь облака.");
b.Property<double>("WellDepth")
.HasColumnType("double precision")
.HasColumnName("well_depth");
b.HasKey("Id");
b.HasIndex("IdTelemetry");
@ -2161,7 +2165,7 @@ namespace AsbCloudDb.Migrations
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
.WithMany("DataSaub")
.HasForeignKey("IdTelemetry")
.HasConstraintName("t_data_saub_t_telemetry_id_fk")
.HasConstraintName("t_telemetry_data_saub_t_telemetry_id_fk")
.IsRequired();
b.Navigation("Telemetry");
@ -2172,7 +2176,7 @@ namespace AsbCloudDb.Migrations
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
.WithMany("DataSpin")
.HasForeignKey("IdTelemetry")
.HasConstraintName("t_data_spin_t_telemetry_id_fk")
.HasConstraintName("t_telemetry_data_spin_t_telemetry_id_fk")
.IsRequired();
b.Navigation("Telemetry");

View File

@ -362,7 +362,7 @@ namespace AsbCloudDb.Model
public async Task<(DateTime From, DateTime To)> GetDatesRangeAsync<TEntity>(int idTelemetry,
CancellationToken token = default)
where TEntity : class, IIdTelemetryDate
where TEntity : class, ITelemetryData
{
var dbSet = Set<TEntity>();

View File

@ -41,7 +41,7 @@ namespace AsbCloudDb.Model
IQueryable<Well> GetWellsForCompany(int idCompany);
IQueryable<User> GetUsersByLogin(string login);
Task<(DateTime From, DateTime To)> GetDatesRangeAsync<T>(int idTelemetry, CancellationToken token) where T : class, IIdTelemetryDate;
Task<(DateTime From, DateTime To)> GetDatesRangeAsync<T>(int idTelemetry, CancellationToken token) where T : class, ITelemetryData;
Task<IEnumerable<(double? MinDepth, double? MaxDepth, DateTime BeginPeriodDate)>> GetDepthToIntervalAsync(int telemetryId,
int intervalHoursTimestamp, int workStartTimestamp, double timezoneOffset, CancellationToken token);
Task<int> CreatePartitionAsync<TEntity>(string propertyName, int id, CancellationToken token = default) where TEntity : class;

View File

@ -2,6 +2,6 @@
{
public interface IId
{
public int Id { get; }
public int Id { get; set; }
}
}

View File

@ -2,7 +2,7 @@
namespace AsbCloudDb.Model
{
public interface IIdTelemetryDate
public interface ITelemetryData: IId
{
int IdTelemetry { get; set; }
DateTime Date { get; set; }

View File

@ -9,7 +9,7 @@ using System.Text.Json.Serialization;
namespace AsbCloudDb.Model
{
[Table("t_telemetry_data_saub"), Comment("набор основных данных по SAUB")]
public partial class TelemetryDataSaub : IId, IIdTelemetryDate
public partial class TelemetryDataSaub : ITelemetryData
{
[Key]
[Column("id")]

View File

@ -7,7 +7,7 @@ using System.Text.Json.Serialization;
namespace AsbCloudDb.Model
{
[Table("t_telemetry_data_spin"), Comment("набор основных данных по SpinMaster")]
public class TelemetryDataSpin
public class TelemetryDataSpin: ITelemetryData
{
[Key]
[Column("id")]

View File

@ -8,7 +8,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace AsbCloudDb.Model
{
[Table("t_telemetry_message"), Comment("Сообщения на буровых")]
public partial class TelemetryMessage : IId, IIdTelemetryDate
public partial class TelemetryMessage : IId, ITelemetryData
{
[Key]
[Column("id")]
@ -26,6 +26,9 @@ namespace AsbCloudDb.Model
[Column("date", TypeName = "timestamp with time zone")]
public DateTime Date { get; set; }
[Column("well_depth")]
public double WellDepth { get; set; }
[Column("arg0"), Comment("Аргумент №0 для вставки в шаблон сообщения")]
[StringLength(255)]
public string Arg0 { get; set; }

View File

@ -50,6 +50,10 @@ namespace AsbCloudInfrastructure
services.AddTransient<ICrudService<UserRoleDto>, CrudServiceBase<UserRoleDto, UserRole>>();
services.AddTransient<ICrudService<TelemetryDto>, CrudServiceBase<TelemetryDto, Telemetry>>();
// TelemetryData services
services.AddTransient<ITelemetryDataService<TelemetryDataSaubDto>, TelemetryDataSaubService>();
services.AddTransient<ITelemetryDataService<TelemetryDataSpinDto>, TelemetryDataSpinService>();
return services;
}
}

View File

@ -11,9 +11,9 @@ using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Services
{
public class CrudServiceBase<Tdto, TModel> : ICrudService<Tdto>
public class CrudServiceBase<TDto, TModel> : ICrudService<TDto>, IConverter<TDto, TModel>
where TDto : AsbCloudApp.Data.IId
where TModel : class, AsbCloudDb.Model.IId
where Tdto : AsbCloudApp.Data.IId
{
protected readonly IAsbCloudDbContext context;
protected readonly DbSet<TModel> dbSet;
@ -26,14 +26,14 @@ namespace AsbCloudInfrastructure.Services
dbSet = context.Set<TModel>();
}
public virtual async Task<PaginationContainer<Tdto>> GetPageAsync(int skip = 0, int take = 32, CancellationToken token = default)
public virtual async Task<PaginationContainer<TDto>> GetPageAsync(int skip = 0, int take = 32, CancellationToken token = default)
{
var query = GetQueryWithIncludes();
var count = await query
.CountAsync(token)
.ConfigureAwait(false);
var container = new PaginationContainer<Tdto>
var container = new PaginationContainer<TDto>
{
Skip = skip,
Take = take,
@ -54,7 +54,7 @@ namespace AsbCloudInfrastructure.Services
return container;
}
public virtual async Task<IEnumerable<Tdto>> GetAllAsync(CancellationToken token = default)
public virtual async Task<IEnumerable<TDto>> GetAllAsync(CancellationToken token = default)
{
var query = GetQueryWithIncludes();
var entities = await query
@ -63,7 +63,7 @@ namespace AsbCloudInfrastructure.Services
return dto;
}
public virtual async Task<Tdto> GetAsync(int id, CancellationToken token = default)
public virtual async Task<TDto> GetAsync(int id, CancellationToken token = default)
{
var query = GetQueryWithIncludes();
var entity = await query
@ -72,21 +72,21 @@ namespace AsbCloudInfrastructure.Services
return dto;
}
public virtual Task<int> InsertAsync(Tdto item, CancellationToken token = default)
public virtual Task<int> InsertAsync(TDto item, CancellationToken token = default)
{
var entity = Convert(item);
dbSet.Add(entity);
return context.SaveChangesAsync(token);
}
public virtual Task<int> InsertRangeAsync(IEnumerable<Tdto> items, CancellationToken token = default)
public virtual Task<int> InsertRangeAsync(IEnumerable<TDto> items, CancellationToken token = default)
{
var entities = items.Select(i => Convert(i));
dbSet.AddRange(entities);
return context.SaveChangesAsync(token);
}
public virtual Task<int> UpdateAsync(int id, Tdto item, CancellationToken token = default)
public virtual Task<int> UpdateAsync(int id, TDto item, CancellationToken token = default)
{
var entity = Convert(item);
dbSet.Update(entity);
@ -112,9 +112,9 @@ namespace AsbCloudInfrastructure.Services
return context.SaveChangesAsync(token);
}
public virtual Tdto Convert(TModel src) => src.Adapt<Tdto>();
public virtual TDto Convert(TModel src) => src.Adapt<TDto>();
public virtual TModel Convert(Tdto src) => src.Adapt<TModel>();
public virtual TModel Convert(TDto src) => src.Adapt<TModel>();
private IQueryable<TModel> GetQueryWithIncludes()
{

View File

@ -12,6 +12,7 @@ using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Services
{
//TODO: delete this
public class DataService : IDataService
{
private readonly IAsbCloudDbContext db;

View File

@ -0,0 +1,8 @@
namespace AsbCloudInfrastructure.Services
{
public interface IConverter<TDto, TModel>
{
TModel Convert(TDto src);
TDto Convert(TModel src);
}
}

View File

@ -0,0 +1,36 @@
using AsbCloudApp.Data;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using AsbCloudInfrastructure.Services.Cache;
using Mapster;
namespace AsbCloudInfrastructure.Services
{
public class TelemetryDataSaubService: TelemetryDataService<AsbCloudApp.Data.TelemetryDataSaubDto, AsbCloudDb.Model.TelemetryDataSaub>
{
public TelemetryDataSaubService(
IAsbCloudDbContext db,
ITelemetryService telemetryService,
CacheDb cacheDb)
:base(db, telemetryService, cacheDb)
{}
public override TelemetryDataSaub Convert(TelemetryDataSaubDto src)
{
var entity = src.Adapt<TelemetryDataSaub>();
var telemetryUser = cacheTelemetryUsers
.FirstOrDefault(u => u.IdTelemetry == src.IdTelemetry && (u.Name == src.User || u.Surname == src.User));
entity.IdUser = telemetryUser.IdUser;
return entity;
}
public override TelemetryDataSaubDto Convert(TelemetryDataSaub src)
{
var dto = src.Adapt<TelemetryDataSaubDto>();
var telemetryUser = cacheTelemetryUsers
.FirstOrDefault(u => u.IdTelemetry == src.IdTelemetry && u.IdUser == src.IdUser);
dto.User = telemetryUser.MakeDisplayName();
return dto;
}
}
}

View File

@ -0,0 +1,137 @@
using AsbCloudApp.Data;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using AsbCloudInfrastructure.Services.Cache;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Services
{
public abstract class TelemetryDataService<TDto, TModel> : ITelemetryDataService<TDto>, IConverter<TDto, TModel>
where TDto : AsbCloudApp.Data.ITelemetryData
where TModel : class, AsbCloudDb.Model.ITelemetryData
{
private readonly IAsbCloudDbContext db;
private readonly ITelemetryService telemetryService;
protected readonly CacheTable<Telemetry> cacheTelemetry;
protected readonly CacheTable<TelemetryUser> cacheTelemetryUsers;
protected readonly CacheTable<Well> cacheWells;
public TelemetryDataService(
IAsbCloudDbContext db,
ITelemetryService telemetryService,
CacheDb cacheDb)
{
this.db = db;
this.telemetryService = telemetryService;
cacheTelemetry = cacheDb.GetCachedTable<Telemetry>((AsbCloudDbContext)db);
cacheTelemetryUsers = cacheDb.GetCachedTable<TelemetryUser>((AsbCloudDbContext)db);
cacheWells = cacheDb.GetCachedTable<Well>((AsbCloudDbContext)db);
}
public virtual async Task<int> UpdateDataAsync(string uid, IEnumerable<TDto> dtos,
CancellationToken token = default)
{
if (dtos == default || !dtos.Any())
return 0;
var idTelemetry = telemetryService.GetOrCreateTemetryIdByUid(uid);
var dtoMinDate = dtos.Min(d => d.Date);
var dtoMaxDate = dtos.Max(d => d.Date);
var dataSet = db.Set<TModel>();
var oldData = await (from d in dataSet
where d.IdTelemetry == idTelemetry
&& d.Date > dtoMinDate
&& d.Date < dtoMaxDate
select d)
.AsNoTracking()
.ToListAsync(token)
.ConfigureAwait(false);
if (oldData.Any())
{
dataSet.RemoveRange(oldData);
await db.SaveChangesAsync(token).ConfigureAwait(false);
}
foreach (var dto in dtos)
{
dto.IdTelemetry = idTelemetry;
var data = Convert(dto);
data.Id = 0;
dataSet.Add(data);
}
return await db.SaveChangesAsync(token).ConfigureAwait(false);
}
public virtual async Task<IEnumerable<TDto>> GetAsync(int idWell,
DateTime dateBegin = default, double intervalSec = 600d,
int approxPointsCount = 1024, CancellationToken token = default)
{
var well = cacheWells.FirstOrDefault(w => w.Id == idWell);
if (well is null)
return default;
var telemetry = cacheTelemetry.FirstOrDefault(t => t.Id == well.IdTelemetry);
if (telemetry is null)
return default;
if (dateBegin == default)
dateBegin = DateTime.Now.AddSeconds(-intervalSec);
var datEnd = dateBegin.AddSeconds(intervalSec);
var dbSet = db.Set<TModel>();
var query = from data in dbSet
where data.IdTelemetry == telemetry.Id
&& data.Date >= dateBegin && data.Date < datEnd
select data;
var fullDataCount = await query.CountAsync(token)
.ConfigureAwait(false);
if (fullDataCount == 0)
return default;
if (fullDataCount > 1.75 * approxPointsCount)
{
var m = (int)Math.Round(1d * fullDataCount / approxPointsCount);
if (m > 1)
query = query.Where(d => d.Id % m == 0);
}
var entities = await query.AsNoTracking()
.ToListAsync(token).ConfigureAwait(false);
var dtos = entities.Select(e => Convert(e));
return dtos;
}
public virtual async Task<DatesRangeDto> GetDataDatesRangeAsync(int idWell,
CancellationToken token = default)
{
var telemetryId = telemetryService.GetIdTelemetryByIdWell(idWell);
if (telemetryId is null)
return null;
var (From, To) = await db.GetDatesRangeAsync<TModel>((int)telemetryId, token)
.ConfigureAwait(false);
return new DatesRangeDto { From = From, To = To };
}
public abstract TDto Convert(TModel src);
public abstract TModel Convert(TDto src);
}
}

View File

@ -0,0 +1,30 @@
using AsbCloudApp.Data;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using AsbCloudInfrastructure.Services.Cache;
using Mapster;
namespace AsbCloudInfrastructure.Services
{
public class TelemetryDataSpinService : TelemetryDataService<AsbCloudApp.Data.TelemetryDataSpinDto, AsbCloudDb.Model.TelemetryDataSpin>
{
public TelemetryDataSpinService(
IAsbCloudDbContext db,
ITelemetryService telemetryService,
CacheDb cacheDb)
: base(db, telemetryService, cacheDb)
{ }
public override TelemetryDataSpin Convert(TelemetryDataSpinDto src)
{
var entity = src.Adapt<TelemetryDataSpin>();
return entity;
}
public override TelemetryDataSpinDto Convert(TelemetryDataSpin src)
{
var dto = src.Adapt<TelemetryDataSpinDto>();
return dto;
}
}
}

View File

@ -24,7 +24,7 @@ namespace AsbCloudInfrastructure.Services
=> GetWellByTelemetryUid(uid)?.Id;
public double GetTimezoneOffsetByTelemetryId(int idTelemetry) =>
cacheTelemetry.FirstOrDefault(t => t.Id == idTelemetry).Info.TimeZoneOffsetTotalHours;
cacheTelemetry.FirstOrDefault(t => t.Id == idTelemetry).Info?.TimeZoneOffsetTotalHours??0d;
public void UpdateInfo(string uid, TelemetryInfoDto info)
{

View File

@ -124,7 +124,7 @@ namespace AsbCloudInfrastructure.Services
foreach (var operationDto in wellOperationDtos)
{
var entity = operationDto.Adapt<WellOperation>();
entity.Id = default;
entity.Id = 0;
entity.IdWell = idWell;
context.WellOperations.Add(entity);
}

View File

@ -1,4 +1,5 @@
using AsbCloudApp.Data;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using AsbCloudInfrastructure.Services.Cache;
using Mapster;

View File

@ -58,6 +58,7 @@ namespace AsbCloudWebApi.Controllers
return Ok();
}
//TODO: remove when panels update will be done.
/// <summary>
/// Принимает данные от разных систем по скважине
/// </summary>
@ -75,7 +76,7 @@ namespace AsbCloudWebApi.Controllers
if (idWell != null && dtos.Any())
await Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}")
.SendAsync(nameof(ITelemetryHubClient.ReceiveDataSaub), dtos), token).ConfigureAwait(false);
.SendAsync("ReceiveDataSaub", dtos), token).ConfigureAwait(false);
telemetryTracker.SaveRequestDate(uid);
return Ok();
@ -98,7 +99,7 @@ namespace AsbCloudWebApi.Controllers
if (dtos.Any())
await Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}")
.SendAsync(nameof(ITelemetryHubClient.ReceiveMessages), dtos), token).ConfigureAwait(false);
.SendAsync("ReceiveMessages", dtos), token).ConfigureAwait(false);
telemetryTracker.SaveRequestDate(uid);
return Ok();

View File

@ -1,8 +1,12 @@
using AsbCloudApp.Data;
using AsbCloudApp.Services;
using AsbCloudWebApi.SignalR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@ -11,8 +15,30 @@ namespace AsbCloudWebApi.Controllers
[ApiController]
[Authorize]
[Route("api/[controller]")]
public abstract class TelemetryDataBaseController<Tdto> : ControllerBase
public abstract class TelemetryDataBaseController<TDto> : ControllerBase
where TDto: ITelemetryData
{
private readonly ITelemetryTracker telemetryTracker;
private readonly ITelemetryService telemetryService;
private readonly ITelemetryDataService<TDto> telemetryDataService;
private readonly IWellService wellService;
private readonly IHubContext<TelemetryHub> telemetryHubContext;
public string SirnalRMethodGetDataName { get; protected set; } = "ReceiveData";
public TelemetryDataBaseController(
ITelemetryTracker telemetryTracker,
ITelemetryService telemetryService,
ITelemetryDataService<TDto> telemetryDataService,
IWellService wellService,
IHubContext<TelemetryHub> telemetryHubContext)
{
this.telemetryTracker = telemetryTracker;
this.telemetryService = telemetryService;
this.telemetryDataService = telemetryDataService;
this.wellService = wellService;
this.telemetryHubContext = telemetryHubContext;
}
/// <summary>
/// Принимает данные от разных систем по скважине
@ -23,17 +49,18 @@ namespace AsbCloudWebApi.Controllers
/// <returns></returns>
[HttpPost]
[Route("{uid}")]
public virtual async Task<IActionResult> PostDataAsync(string uid, [FromBody] IEnumerable<Tdto> dtos,
[AllowAnonymous]
public virtual async Task<IActionResult> PostDataAsync(string uid, [FromBody] IEnumerable<TDto> dtos,
CancellationToken token = default)
{
//var idWell = telemetryService.GetidWellByTelemetryUid(uid);
//await DataService.UpdateDataAsync(uid, dtos, token).ConfigureAwait(false);
var idWell = telemetryService.GetidWellByTelemetryUid(uid);
await telemetryDataService.UpdateDataAsync(uid, dtos, token).ConfigureAwait(false);
//if (idWell != null && dtos.Any())
// await Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}")
// .SendAsync(nameof(ITelemetryHubClient.ReceiveDataSaub), dtos), token).ConfigureAwait(false);
if (idWell != null && dtos.Any())
await Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}")
.SendAsync(SirnalRMethodGetDataName, dtos), token).ConfigureAwait(false);
//telemetryTracker.SaveRequestDate(uid);
telemetryTracker.SaveRequestDate(uid);
return Ok();
}
@ -52,13 +79,13 @@ namespace AsbCloudWebApi.Controllers
public virtual async Task<IActionResult> GetDataAsync(int idWell, DateTime begin = default,
int intervalSec = 600, int approxPointsCount = 1024, CancellationToken token = default)
{
//if (begin == default)
// begin = DateTime.Now.AddSeconds(-intervalSec);
//var content = await telemetryDataService.GetAsync(idWell, begin,
// intervalSec, approxPointsCount, token).ConfigureAwait(false);
if (begin == default)
begin = DateTime.Now.AddSeconds(-intervalSec);
var content = await telemetryDataService.GetAsync(idWell, begin,
intervalSec, approxPointsCount, token).ConfigureAwait(false);
//if (content is null || !content.Any())
// return NoContent();
if (content is null || !content.Any())
return NoContent();
return Ok(null);
}
@ -75,19 +102,19 @@ namespace AsbCloudWebApi.Controllers
public virtual async Task<IActionResult> GetDataDatesRangeAsync(int idWell,
CancellationToken token = default)
{
//int? idCompany = User.GetCompanyId();
int? idCompany = User.GetCompanyId();
//if (idCompany is null)
// return Forbid();
if (idCompany is null)
return Forbid();
//bool isCompanyOwnsWell = await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
// idWell, token).ConfigureAwait(false);
bool isCompanyOwnsWell = await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
idWell, token).ConfigureAwait(false);
//if (!isCompanyOwnsWell)
// return Forbid();
if (!isCompanyOwnsWell)
return Forbid();
//DatesRangeDto dataDatesRange = await telemetryDataService.GetDataDatesRangeAsync(idWell,
// token).ConfigureAwait(false);
DatesRangeDto dataDatesRange = await telemetryDataService.GetDataDatesRangeAsync(idWell,
token).ConfigureAwait(false);
return Ok(null);
}

View File

@ -1,16 +0,0 @@
using AsbCloudApp.Data;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace AsbCloudWebApi.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class TelemetryDataSaub : TelemetryDataBaseController<TelemetryDataSaubDto>
{
}
}

View File

@ -0,0 +1,29 @@
using AsbCloudApp.Data;
using AsbCloudApp.Services;
using AsbCloudWebApi.SignalR;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
namespace AsbCloudWebApi.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class TelemetryDataSaubController : TelemetryDataBaseController<TelemetryDataSaubDto>
{
public TelemetryDataSaubController(
ITelemetryTracker telemetryTracker,
ITelemetryService telemetryService,
ITelemetryDataService<TelemetryDataSaubDto> telemetryDataService,
IWellService wellService,
IHubContext<TelemetryHub> telemetryHubContext)
: base(
telemetryTracker,
telemetryService,
telemetryDataService,
wellService,
telemetryHubContext)
{
SirnalRMethodGetDataName = "ReceiveDataSaub";
}
}
}

View File

@ -1,11 +0,0 @@
using AsbCloudApp.Data;
using Microsoft.AspNetCore.Mvc;
namespace AsbCloudWebApi.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class TelemetryDataSpin : TelemetryDataBaseController<TelemetryDataSpinDto>
{
}
}

View File

@ -0,0 +1,29 @@
using AsbCloudApp.Data;
using AsbCloudApp.Services;
using AsbCloudWebApi.SignalR;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
namespace AsbCloudWebApi.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class TelemetryDataSpinController : TelemetryDataBaseController<TelemetryDataSpinDto>
{
public TelemetryDataSpinController(
ITelemetryTracker telemetryTracker,
ITelemetryService telemetryService,
ITelemetryDataService<TelemetryDataSpinDto> telemetryDataService,
IWellService wellService,
IHubContext<TelemetryHub> telemetryHubContext)
: base(
telemetryTracker,
telemetryService,
telemetryDataService,
wellService,
telemetryHubContext)
{
SirnalRMethodGetDataName = "ReceiveDataSpin";
}
}
}

View File

@ -1,13 +0,0 @@
using AsbCloudApp.Data;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace AsbCloudWebApi.SignalR
{
public interface ITelemetryHubClient
{
Task ReceiveDataSaub(IEnumerable<TelemetryDataSaubDto> dtos);
Task ReceiveMessages(IEnumerable<MessageDto> dtos);
}
}

View File

@ -10,16 +10,12 @@ namespace AsbCloudWebApi.SignalR
// https://docs.microsoft.com/ru-ru/aspnet/core/signalr/introduction?view=aspnetcore-5.0
[Authorize]
public class TelemetryHub : Hub<ITelemetryHubClient>
public class TelemetryHub : Hub
{
public Task AddToGroup(string groupName)
=> Groups.AddToGroupAsync(Context.ConnectionId, groupName.ToString());
public Task RemoveFromGroup(string groupName)
=> Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName);
public Task SendDataSaub(string groupName, IEnumerable<TelemetryDataSaubDto> data)
=> Clients.Group(groupName).ReceiveDataSaub(data);
}
}

View File

@ -10,11 +10,6 @@ namespace AsbCloudWebApi
{
public class Startup
{
private static readonly System.Text.Json.JsonSerializerOptions jsonSerializerOptions = new System.Text.Json.JsonSerializerOptions
{
NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals,
};
public Startup(IConfiguration configuration)
{
Configuration = configuration;
@ -27,9 +22,8 @@ namespace AsbCloudWebApi
services.AddControllers()
.AddJsonOptions(new System.Action<Microsoft.AspNetCore.Mvc.JsonOptions>(opts =>
{
opts.JsonSerializerOptions.NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals;
}
));
opts.JsonSerializerOptions.NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals | System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString;
}));
services.AddSwagger();

View File

@ -1,23 +1,23 @@
{
"files": {
"main.css": "/static/css/main.99536867.chunk.css",
"main.js": "/static/js/main.18d0dab1.chunk.js",
"main.js.map": "/static/js/main.18d0dab1.chunk.js.map",
"runtime-main.js": "/static/js/runtime-main.7bbed929.js",
"runtime-main.js.map": "/static/js/runtime-main.7bbed929.js.map",
"static/js/2.2d4c3e2b.chunk.js": "/static/js/2.2d4c3e2b.chunk.js",
"static/js/2.2d4c3e2b.chunk.js.map": "/static/js/2.2d4c3e2b.chunk.js.map",
"static/js/3.58b81d69.chunk.js": "/static/js/3.58b81d69.chunk.js",
"static/js/3.58b81d69.chunk.js.map": "/static/js/3.58b81d69.chunk.js.map",
"main.js": "/static/js/main.5222c3aa.chunk.js",
"main.js.map": "/static/js/main.5222c3aa.chunk.js.map",
"runtime-main.js": "/static/js/runtime-main.c0bb1130.js",
"runtime-main.js.map": "/static/js/runtime-main.c0bb1130.js.map",
"static/js/2.e07a64f5.chunk.js": "/static/js/2.e07a64f5.chunk.js",
"static/js/2.e07a64f5.chunk.js.map": "/static/js/2.e07a64f5.chunk.js.map",
"static/js/3.ffc36876.chunk.js": "/static/js/3.ffc36876.chunk.js",
"static/js/3.ffc36876.chunk.js.map": "/static/js/3.ffc36876.chunk.js.map",
"index.html": "/index.html",
"static/css/main.99536867.chunk.css.map": "/static/css/main.99536867.chunk.css.map",
"static/js/2.2d4c3e2b.chunk.js.LICENSE.txt": "/static/js/2.2d4c3e2b.chunk.js.LICENSE.txt",
"static/js/2.e07a64f5.chunk.js.LICENSE.txt": "/static/js/2.e07a64f5.chunk.js.LICENSE.txt",
"static/media/pointer.e8df778c.svg": "/static/media/pointer.e8df778c.svg"
},
"entrypoints": [
"static/js/runtime-main.7bbed929.js",
"static/js/2.2d4c3e2b.chunk.js",
"static/js/runtime-main.c0bb1130.js",
"static/js/2.e07a64f5.chunk.js",
"static/css/main.99536867.chunk.css",
"static/js/main.18d0dab1.chunk.js"
"static/js/main.5222c3aa.chunk.js"
]
}

View File

@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="manifest" href="/manifest.json"/><title>АСБ Vision</title><link href="/static/css/main.99536867.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,a,i=r[0],c=r[1],l=r[2],s=0,p=[];s<i.length;s++)a=i[s],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&p.push(o[a][0]),o[a]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(f&&f(r);p.length;)p.shift()();return u.push.apply(u,l||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var c=t[i];0!==o[c]&&(n=!1)}n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={1:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var u,i=document.createElement("script");i.charset="utf-8",i.timeout=120,a.nc&&i.setAttribute("nonce",a.nc),i.src=function(e){return a.p+"static/js/"+({}[e]||e)+"."+{3:"58b81d69"}[e]+".chunk.js"}(e);var c=new Error;u=function(r){i.onerror=i.onload=null,clearTimeout(l);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",c.name="ChunkLoadError",c.type=n,c.request=u,t[1](c)}o[e]=void 0}};var l=setTimeout((function(){u({type:"timeout",target:i})}),12e4);i.onerror=i.onload=u,document.head.appendChild(i)}return Promise.all(r)},a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,function(r){return e[r]}.bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="/",a.oe=function(e){throw console.error(e),e};var i=this.webpackJsonpasb_cloud_front_react=this.webpackJsonpasb_cloud_front_react||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var l=0;l<i.length;l++)r(i[l]);var f=c;t()}([])</script><script src="/static/js/2.2d4c3e2b.chunk.js"></script><script src="/static/js/main.18d0dab1.chunk.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="manifest" href="/manifest.json"/><title>АСБ Vision</title><link href="/static/css/main.99536867.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,a,i=r[0],c=r[1],l=r[2],s=0,p=[];s<i.length;s++)a=i[s],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&p.push(o[a][0]),o[a]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(f&&f(r);p.length;)p.shift()();return u.push.apply(u,l||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var c=t[i];0!==o[c]&&(n=!1)}n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={1:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var u,i=document.createElement("script");i.charset="utf-8",i.timeout=120,a.nc&&i.setAttribute("nonce",a.nc),i.src=function(e){return a.p+"static/js/"+({}[e]||e)+"."+{3:"ffc36876"}[e]+".chunk.js"}(e);var c=new Error;u=function(r){i.onerror=i.onload=null,clearTimeout(l);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",c.name="ChunkLoadError",c.type=n,c.request=u,t[1](c)}o[e]=void 0}};var l=setTimeout((function(){u({type:"timeout",target:i})}),12e4);i.onerror=i.onload=u,document.head.appendChild(i)}return Promise.all(r)},a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,function(r){return e[r]}.bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="/",a.oe=function(e){throw console.error(e),e};var i=this.webpackJsonpasb_cloud_front_react=this.webpackJsonpasb_cloud_front_react||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var l=0;l<i.length;l++)r(i[l]);var f=c;t()}([])</script><script src="/static/js/2.e07a64f5.chunk.js"></script><script src="/static/js/main.5222c3aa.chunk.js"></script></body></html>