forked from ddrilling/AsbCloudServer
fix jsonSerializer settings;
reafctor TelemetryHub; Add wellDepth into TelemetryMessage
This commit is contained in:
parent
35cd538b1d
commit
0b1f9683b9
10
AsbCloudApp/Data/ITelemetryData.cs
Normal file
10
AsbCloudApp/Data/ITelemetryData.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Data
|
||||||
|
{
|
||||||
|
public interface ITelemetryData: IId
|
||||||
|
{
|
||||||
|
int IdTelemetry { get; set; }
|
||||||
|
DateTime Date { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -5,8 +5,9 @@ namespace AsbCloudApp.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сообщение получаемое по телеметрии и отправляемое в frontend
|
/// Сообщение получаемое по телеметрии и отправляемое в frontend
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TelemetryDataSaubDto
|
public class TelemetryDataSaubDto : ITelemetryData
|
||||||
{
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
//[JsonPropertyName("date")]
|
//[JsonPropertyName("date")]
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudApp.Data
|
namespace AsbCloudApp.Data
|
||||||
{
|
{
|
||||||
public class TelemetryDataSpinDto
|
public class TelemetryDataSpinDto : ITelemetryData
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int IdTelemetry { get; set; }
|
public int IdTelemetry { get; set; }
|
||||||
|
@ -9,6 +9,7 @@ namespace AsbCloudApp.Data
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
|
public double WellDepth { get; set; }
|
||||||
public int IdEvent { get; set; }
|
public int IdEvent { get; set; }
|
||||||
public int? IdTelemetryUser { get; set; }
|
public int? IdTelemetryUser { get; set; }
|
||||||
public string Arg0 { get; set; }
|
public string Arg0 { get; set; }
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudApp.Services
|
||||||
{
|
{
|
||||||
public interface ICachedCrudService<Tdto> where Tdto : IId
|
public interface ICachedCrudService<Tdto> where Tdto : IId
|
||||||
{
|
{
|
@ -8,7 +8,6 @@ namespace AsbCloudApp.Services
|
|||||||
where Tdto : Data.IId
|
where Tdto : Data.IId
|
||||||
{
|
{
|
||||||
List<string> Incledes { get; }
|
List<string> Incledes { get; }
|
||||||
|
|
||||||
Task<int> DeleteAsync(int id, CancellationToken token = default);
|
Task<int> DeleteAsync(int id, CancellationToken token = default);
|
||||||
Task<int> DeleteAsync(IEnumerable<int> ids, CancellationToken token = default);
|
Task<int> DeleteAsync(IEnumerable<int> ids, CancellationToken token = default);
|
||||||
Task<IEnumerable<Tdto>> GetAllAsync(CancellationToken token = default);
|
Task<IEnumerable<Tdto>> GetAllAsync(CancellationToken token = default);
|
||||||
|
15
AsbCloudApp/Services/ITelemetryDataService.cs
Normal file
15
AsbCloudApp/Services/ITelemetryDataService.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
2366
AsbCloudDb/Migrations/20210916094617_AddWellDepthToMessage.Designer.cs
generated
Normal file
2366
AsbCloudDb/Migrations/20210916094617_AddWellDepthToMessage.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1225,6 +1225,10 @@ namespace AsbCloudDb.Migrations
|
|||||||
.HasColumnName("id_telemetry_user")
|
.HasColumnName("id_telemetry_user")
|
||||||
.HasComment("Пользователь панели отправляющей телеметрию. не пользователь облака.");
|
.HasComment("Пользователь панели отправляющей телеметрию. не пользователь облака.");
|
||||||
|
|
||||||
|
b.Property<double>("WellDepth")
|
||||||
|
.HasColumnType("double precision")
|
||||||
|
.HasColumnName("well_depth");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("IdTelemetry");
|
b.HasIndex("IdTelemetry");
|
||||||
@ -2161,7 +2165,7 @@ namespace AsbCloudDb.Migrations
|
|||||||
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
|
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
|
||||||
.WithMany("DataSaub")
|
.WithMany("DataSaub")
|
||||||
.HasForeignKey("IdTelemetry")
|
.HasForeignKey("IdTelemetry")
|
||||||
.HasConstraintName("t_data_saub_t_telemetry_id_fk")
|
.HasConstraintName("t_telemetry_data_saub_t_telemetry_id_fk")
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Telemetry");
|
b.Navigation("Telemetry");
|
||||||
@ -2172,7 +2176,7 @@ namespace AsbCloudDb.Migrations
|
|||||||
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
|
b.HasOne("AsbCloudDb.Model.Telemetry", "Telemetry")
|
||||||
.WithMany("DataSpin")
|
.WithMany("DataSpin")
|
||||||
.HasForeignKey("IdTelemetry")
|
.HasForeignKey("IdTelemetry")
|
||||||
.HasConstraintName("t_data_spin_t_telemetry_id_fk")
|
.HasConstraintName("t_telemetry_data_spin_t_telemetry_id_fk")
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Telemetry");
|
b.Navigation("Telemetry");
|
||||||
|
@ -362,7 +362,7 @@ namespace AsbCloudDb.Model
|
|||||||
|
|
||||||
public async Task<(DateTime From, DateTime To)> GetDatesRangeAsync<TEntity>(int idTelemetry,
|
public async Task<(DateTime From, DateTime To)> GetDatesRangeAsync<TEntity>(int idTelemetry,
|
||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
where TEntity : class, IIdTelemetryDate
|
where TEntity : class, ITelemetryData
|
||||||
{
|
{
|
||||||
var dbSet = Set<TEntity>();
|
var dbSet = Set<TEntity>();
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ namespace AsbCloudDb.Model
|
|||||||
|
|
||||||
IQueryable<Well> GetWellsForCompany(int idCompany);
|
IQueryable<Well> GetWellsForCompany(int idCompany);
|
||||||
IQueryable<User> GetUsersByLogin(string login);
|
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,
|
Task<IEnumerable<(double? MinDepth, double? MaxDepth, DateTime BeginPeriodDate)>> GetDepthToIntervalAsync(int telemetryId,
|
||||||
int intervalHoursTimestamp, int workStartTimestamp, double timezoneOffset, CancellationToken token);
|
int intervalHoursTimestamp, int workStartTimestamp, double timezoneOffset, CancellationToken token);
|
||||||
Task<int> CreatePartitionAsync<TEntity>(string propertyName, int id, CancellationToken token = default) where TEntity : class;
|
Task<int> CreatePartitionAsync<TEntity>(string propertyName, int id, CancellationToken token = default) where TEntity : class;
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
{
|
{
|
||||||
public interface IId
|
public interface IId
|
||||||
{
|
{
|
||||||
public int Id { get; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace AsbCloudDb.Model
|
namespace AsbCloudDb.Model
|
||||||
{
|
{
|
||||||
public interface IIdTelemetryDate
|
public interface ITelemetryData: IId
|
||||||
{
|
{
|
||||||
int IdTelemetry { get; set; }
|
int IdTelemetry { get; set; }
|
||||||
DateTime Date { get; set; }
|
DateTime Date { get; set; }
|
@ -9,7 +9,7 @@ using System.Text.Json.Serialization;
|
|||||||
namespace AsbCloudDb.Model
|
namespace AsbCloudDb.Model
|
||||||
{
|
{
|
||||||
[Table("t_telemetry_data_saub"), Comment("набор основных данных по SAUB")]
|
[Table("t_telemetry_data_saub"), Comment("набор основных данных по SAUB")]
|
||||||
public partial class TelemetryDataSaub : IId, IIdTelemetryDate
|
public partial class TelemetryDataSaub : ITelemetryData
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
[Column("id")]
|
[Column("id")]
|
||||||
|
@ -7,7 +7,7 @@ using System.Text.Json.Serialization;
|
|||||||
namespace AsbCloudDb.Model
|
namespace AsbCloudDb.Model
|
||||||
{
|
{
|
||||||
[Table("t_telemetry_data_spin"), Comment("набор основных данных по SpinMaster")]
|
[Table("t_telemetry_data_spin"), Comment("набор основных данных по SpinMaster")]
|
||||||
public class TelemetryDataSpin
|
public class TelemetryDataSpin: ITelemetryData
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
[Column("id")]
|
[Column("id")]
|
||||||
|
@ -8,7 +8,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||||||
namespace AsbCloudDb.Model
|
namespace AsbCloudDb.Model
|
||||||
{
|
{
|
||||||
[Table("t_telemetry_message"), Comment("Сообщения на буровых")]
|
[Table("t_telemetry_message"), Comment("Сообщения на буровых")]
|
||||||
public partial class TelemetryMessage : IId, IIdTelemetryDate
|
public partial class TelemetryMessage : IId, ITelemetryData
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
[Column("id")]
|
[Column("id")]
|
||||||
@ -26,6 +26,9 @@ namespace AsbCloudDb.Model
|
|||||||
[Column("date", TypeName = "timestamp with time zone")]
|
[Column("date", TypeName = "timestamp with time zone")]
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
|
|
||||||
|
[Column("well_depth")]
|
||||||
|
public double WellDepth { get; set; }
|
||||||
|
|
||||||
[Column("arg0"), Comment("Аргумент №0 для вставки в шаблон сообщения")]
|
[Column("arg0"), Comment("Аргумент №0 для вставки в шаблон сообщения")]
|
||||||
[StringLength(255)]
|
[StringLength(255)]
|
||||||
public string Arg0 { get; set; }
|
public string Arg0 { get; set; }
|
||||||
|
@ -50,6 +50,10 @@ namespace AsbCloudInfrastructure
|
|||||||
services.AddTransient<ICrudService<UserRoleDto>, CrudServiceBase<UserRoleDto, UserRole>>();
|
services.AddTransient<ICrudService<UserRoleDto>, CrudServiceBase<UserRoleDto, UserRole>>();
|
||||||
services.AddTransient<ICrudService<TelemetryDto>, CrudServiceBase<TelemetryDto, Telemetry>>();
|
services.AddTransient<ICrudService<TelemetryDto>, CrudServiceBase<TelemetryDto, Telemetry>>();
|
||||||
|
|
||||||
|
// TelemetryData services
|
||||||
|
services.AddTransient<ITelemetryDataService<TelemetryDataSaubDto>, TelemetryDataSaubService>();
|
||||||
|
services.AddTransient<ITelemetryDataService<TelemetryDataSpinDto>, TelemetryDataSpinService>();
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,9 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
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 TModel : class, AsbCloudDb.Model.IId
|
||||||
where Tdto : AsbCloudApp.Data.IId
|
|
||||||
{
|
{
|
||||||
protected readonly IAsbCloudDbContext context;
|
protected readonly IAsbCloudDbContext context;
|
||||||
protected readonly DbSet<TModel> dbSet;
|
protected readonly DbSet<TModel> dbSet;
|
||||||
@ -26,14 +26,14 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
dbSet = context.Set<TModel>();
|
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 query = GetQueryWithIncludes();
|
||||||
var count = await query
|
var count = await query
|
||||||
.CountAsync(token)
|
.CountAsync(token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
var container = new PaginationContainer<Tdto>
|
var container = new PaginationContainer<TDto>
|
||||||
{
|
{
|
||||||
Skip = skip,
|
Skip = skip,
|
||||||
Take = take,
|
Take = take,
|
||||||
@ -54,7 +54,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
return container;
|
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 query = GetQueryWithIncludes();
|
||||||
var entities = await query
|
var entities = await query
|
||||||
@ -63,7 +63,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
return dto;
|
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 query = GetQueryWithIncludes();
|
||||||
var entity = await query
|
var entity = await query
|
||||||
@ -72,21 +72,21 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
return dto;
|
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);
|
var entity = Convert(item);
|
||||||
dbSet.Add(entity);
|
dbSet.Add(entity);
|
||||||
return context.SaveChangesAsync(token);
|
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));
|
var entities = items.Select(i => Convert(i));
|
||||||
dbSet.AddRange(entities);
|
dbSet.AddRange(entities);
|
||||||
return context.SaveChangesAsync(token);
|
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);
|
var entity = Convert(item);
|
||||||
dbSet.Update(entity);
|
dbSet.Update(entity);
|
||||||
@ -112,9 +112,9 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
return context.SaveChangesAsync(token);
|
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()
|
private IQueryable<TModel> GetQueryWithIncludes()
|
||||||
{
|
{
|
||||||
|
@ -12,6 +12,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
{
|
{
|
||||||
|
//TODO: delete this
|
||||||
public class DataService : IDataService
|
public class DataService : IDataService
|
||||||
{
|
{
|
||||||
private readonly IAsbCloudDbContext db;
|
private readonly IAsbCloudDbContext db;
|
||||||
|
8
AsbCloudInfrastructure/Services/IConverter.cs
Normal file
8
AsbCloudInfrastructure/Services/IConverter.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace AsbCloudInfrastructure.Services
|
||||||
|
{
|
||||||
|
public interface IConverter<TDto, TModel>
|
||||||
|
{
|
||||||
|
TModel Convert(TDto src);
|
||||||
|
TDto Convert(TModel src);
|
||||||
|
}
|
||||||
|
}
|
36
AsbCloudInfrastructure/Services/TelemetryDataSaubService.cs
Normal file
36
AsbCloudInfrastructure/Services/TelemetryDataSaubService.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
137
AsbCloudInfrastructure/Services/TelemetryDataService.cs
Normal file
137
AsbCloudInfrastructure/Services/TelemetryDataService.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
30
AsbCloudInfrastructure/Services/TelemetryDataSpinService.cs
Normal file
30
AsbCloudInfrastructure/Services/TelemetryDataSpinService.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -24,7 +24,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
=> GetWellByTelemetryUid(uid)?.Id;
|
=> GetWellByTelemetryUid(uid)?.Id;
|
||||||
|
|
||||||
public double GetTimezoneOffsetByTelemetryId(int idTelemetry) =>
|
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)
|
public void UpdateInfo(string uid, TelemetryInfoDto info)
|
||||||
{
|
{
|
||||||
|
@ -124,7 +124,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
foreach (var operationDto in wellOperationDtos)
|
foreach (var operationDto in wellOperationDtos)
|
||||||
{
|
{
|
||||||
var entity = operationDto.Adapt<WellOperation>();
|
var entity = operationDto.Adapt<WellOperation>();
|
||||||
entity.Id = default;
|
entity.Id = 0;
|
||||||
entity.IdWell = idWell;
|
entity.IdWell = idWell;
|
||||||
context.WellOperations.Add(entity);
|
context.WellOperations.Add(entity);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudInfrastructure.Services.Cache;
|
using AsbCloudInfrastructure.Services.Cache;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
|
@ -58,6 +58,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: remove when panels update will be done.
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Принимает данные от разных систем по скважине
|
/// Принимает данные от разных систем по скважине
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -75,7 +76,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
|
|
||||||
if (idWell != null && dtos.Any())
|
if (idWell != null && dtos.Any())
|
||||||
await Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}")
|
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);
|
telemetryTracker.SaveRequestDate(uid);
|
||||||
return Ok();
|
return Ok();
|
||||||
@ -98,7 +99,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
|
|
||||||
if (dtos.Any())
|
if (dtos.Any())
|
||||||
await Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}")
|
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);
|
telemetryTracker.SaveRequestDate(uid);
|
||||||
return Ok();
|
return Ok();
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
|
using AsbCloudWebApi.SignalR;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -11,8 +15,30 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[Route("api/[controller]")]
|
[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>
|
/// <summary>
|
||||||
/// Принимает данные от разных систем по скважине
|
/// Принимает данные от разных систем по скважине
|
||||||
@ -23,17 +49,18 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("{uid}")]
|
[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)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
//var idWell = telemetryService.GetidWellByTelemetryUid(uid);
|
var idWell = telemetryService.GetidWellByTelemetryUid(uid);
|
||||||
//await DataService.UpdateDataAsync(uid, dtos, token).ConfigureAwait(false);
|
await telemetryDataService.UpdateDataAsync(uid, dtos, token).ConfigureAwait(false);
|
||||||
|
|
||||||
//if (idWell != null && dtos.Any())
|
if (idWell != null && dtos.Any())
|
||||||
// await Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}")
|
await Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}")
|
||||||
// .SendAsync(nameof(ITelemetryHubClient.ReceiveDataSaub), dtos), token).ConfigureAwait(false);
|
.SendAsync(SirnalRMethodGetDataName, dtos), token).ConfigureAwait(false);
|
||||||
|
|
||||||
//telemetryTracker.SaveRequestDate(uid);
|
telemetryTracker.SaveRequestDate(uid);
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,13 +79,13 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
public virtual async Task<IActionResult> GetDataAsync(int idWell, DateTime begin = default,
|
public virtual async Task<IActionResult> GetDataAsync(int idWell, DateTime begin = default,
|
||||||
int intervalSec = 600, int approxPointsCount = 1024, CancellationToken token = default)
|
int intervalSec = 600, int approxPointsCount = 1024, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
//if (begin == default)
|
if (begin == default)
|
||||||
// begin = DateTime.Now.AddSeconds(-intervalSec);
|
begin = DateTime.Now.AddSeconds(-intervalSec);
|
||||||
//var content = await telemetryDataService.GetAsync(idWell, begin,
|
var content = await telemetryDataService.GetAsync(idWell, begin,
|
||||||
// intervalSec, approxPointsCount, token).ConfigureAwait(false);
|
intervalSec, approxPointsCount, token).ConfigureAwait(false);
|
||||||
|
|
||||||
//if (content is null || !content.Any())
|
if (content is null || !content.Any())
|
||||||
// return NoContent();
|
return NoContent();
|
||||||
|
|
||||||
return Ok(null);
|
return Ok(null);
|
||||||
}
|
}
|
||||||
@ -75,19 +102,19 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
public virtual async Task<IActionResult> GetDataDatesRangeAsync(int idWell,
|
public virtual async Task<IActionResult> GetDataDatesRangeAsync(int idWell,
|
||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
//int? idCompany = User.GetCompanyId();
|
int? idCompany = User.GetCompanyId();
|
||||||
|
|
||||||
//if (idCompany is null)
|
if (idCompany is null)
|
||||||
// return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
//bool isCompanyOwnsWell = await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
bool isCompanyOwnsWell = await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
|
||||||
// idWell, token).ConfigureAwait(false);
|
idWell, token).ConfigureAwait(false);
|
||||||
|
|
||||||
//if (!isCompanyOwnsWell)
|
if (!isCompanyOwnsWell)
|
||||||
// return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
//DatesRangeDto dataDatesRange = await telemetryDataService.GetDataDatesRangeAsync(idWell,
|
DatesRangeDto dataDatesRange = await telemetryDataService.GetDataDatesRangeAsync(idWell,
|
||||||
// token).ConfigureAwait(false);
|
token).ConfigureAwait(false);
|
||||||
|
|
||||||
return Ok(null);
|
return Ok(null);
|
||||||
}
|
}
|
||||||
|
@ -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>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
29
AsbCloudWebApi/Controllers/TelemetryDataSaubController.cs
Normal file
29
AsbCloudWebApi/Controllers/TelemetryDataSaubController.cs
Normal 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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +0,0 @@
|
|||||||
using AsbCloudApp.Data;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
|
||||||
{
|
|
||||||
[Route("api/[controller]")]
|
|
||||||
[ApiController]
|
|
||||||
public class TelemetryDataSpin : TelemetryDataBaseController<TelemetryDataSpinDto>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
29
AsbCloudWebApi/Controllers/TelemetryDataSpinController.cs
Normal file
29
AsbCloudWebApi/Controllers/TelemetryDataSpinController.cs
Normal 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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,16 +10,12 @@ namespace AsbCloudWebApi.SignalR
|
|||||||
// https://docs.microsoft.com/ru-ru/aspnet/core/signalr/introduction?view=aspnetcore-5.0
|
// https://docs.microsoft.com/ru-ru/aspnet/core/signalr/introduction?view=aspnetcore-5.0
|
||||||
|
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class TelemetryHub : Hub<ITelemetryHubClient>
|
public class TelemetryHub : Hub
|
||||||
{
|
{
|
||||||
public Task AddToGroup(string groupName)
|
public Task AddToGroup(string groupName)
|
||||||
=> Groups.AddToGroupAsync(Context.ConnectionId, groupName.ToString());
|
=> Groups.AddToGroupAsync(Context.ConnectionId, groupName.ToString());
|
||||||
|
|
||||||
public Task RemoveFromGroup(string groupName)
|
public Task RemoveFromGroup(string groupName)
|
||||||
=> Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName);
|
=> Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName);
|
||||||
|
|
||||||
public Task SendDataSaub(string groupName, IEnumerable<TelemetryDataSaubDto> data)
|
|
||||||
=> Clients.Group(groupName).ReceiveDataSaub(data);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,11 +10,6 @@ namespace AsbCloudWebApi
|
|||||||
{
|
{
|
||||||
public class Startup
|
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)
|
public Startup(IConfiguration configuration)
|
||||||
{
|
{
|
||||||
Configuration = configuration;
|
Configuration = configuration;
|
||||||
@ -27,9 +22,8 @@ namespace AsbCloudWebApi
|
|||||||
services.AddControllers()
|
services.AddControllers()
|
||||||
.AddJsonOptions(new System.Action<Microsoft.AspNetCore.Mvc.JsonOptions>(opts =>
|
.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();
|
services.AddSwagger();
|
||||||
|
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
{
|
{
|
||||||
"files": {
|
"files": {
|
||||||
"main.css": "/static/css/main.99536867.chunk.css",
|
"main.css": "/static/css/main.99536867.chunk.css",
|
||||||
"main.js": "/static/js/main.18d0dab1.chunk.js",
|
"main.js": "/static/js/main.5222c3aa.chunk.js",
|
||||||
"main.js.map": "/static/js/main.18d0dab1.chunk.js.map",
|
"main.js.map": "/static/js/main.5222c3aa.chunk.js.map",
|
||||||
"runtime-main.js": "/static/js/runtime-main.7bbed929.js",
|
"runtime-main.js": "/static/js/runtime-main.c0bb1130.js",
|
||||||
"runtime-main.js.map": "/static/js/runtime-main.7bbed929.js.map",
|
"runtime-main.js.map": "/static/js/runtime-main.c0bb1130.js.map",
|
||||||
"static/js/2.2d4c3e2b.chunk.js": "/static/js/2.2d4c3e2b.chunk.js",
|
"static/js/2.e07a64f5.chunk.js": "/static/js/2.e07a64f5.chunk.js",
|
||||||
"static/js/2.2d4c3e2b.chunk.js.map": "/static/js/2.2d4c3e2b.chunk.js.map",
|
"static/js/2.e07a64f5.chunk.js.map": "/static/js/2.e07a64f5.chunk.js.map",
|
||||||
"static/js/3.58b81d69.chunk.js": "/static/js/3.58b81d69.chunk.js",
|
"static/js/3.ffc36876.chunk.js": "/static/js/3.ffc36876.chunk.js",
|
||||||
"static/js/3.58b81d69.chunk.js.map": "/static/js/3.58b81d69.chunk.js.map",
|
"static/js/3.ffc36876.chunk.js.map": "/static/js/3.ffc36876.chunk.js.map",
|
||||||
"index.html": "/index.html",
|
"index.html": "/index.html",
|
||||||
"static/css/main.99536867.chunk.css.map": "/static/css/main.99536867.chunk.css.map",
|
"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"
|
"static/media/pointer.e8df778c.svg": "/static/media/pointer.e8df778c.svg"
|
||||||
},
|
},
|
||||||
"entrypoints": [
|
"entrypoints": [
|
||||||
"static/js/runtime-main.7bbed929.js",
|
"static/js/runtime-main.c0bb1130.js",
|
||||||
"static/js/2.2d4c3e2b.chunk.js",
|
"static/js/2.e07a64f5.chunk.js",
|
||||||
"static/css/main.99536867.chunk.css",
|
"static/css/main.99536867.chunk.css",
|
||||||
"static/js/main.18d0dab1.chunk.js"
|
"static/js/main.5222c3aa.chunk.js"
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -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>
|
Loading…
Reference in New Issue
Block a user