forked from ddrilling/AsbCloudServer
Удаление части телеметрии по запросу (продолжение)
This commit is contained in:
parent
6c516e983e
commit
37c74a76a7
@ -1,4 +1,5 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Requests;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@ -36,5 +37,13 @@ namespace AsbCloudApp.Repositories
|
|||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> InsertRangeAsync(IEnumerable<DataSaubStatDto> dataSaubStats, CancellationToken token);
|
Task<int> InsertRangeAsync(IEnumerable<DataSaubStatDto> dataSaubStats, CancellationToken token);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление записей по запросу на удаление куска телеметрии
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,4 +68,12 @@ public interface IDetectedOperationRepository
|
|||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> DeleteAsync(DetectedOperationByTelemetryRequest request, CancellationToken token);
|
Task<int> DeleteAsync(DetectedOperationByTelemetryRequest request, CancellationToken token);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Удалить операции по запросу на удаление куска телеметрии
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">запрос</param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
|
||||||
}
|
}
|
||||||
|
@ -37,5 +37,13 @@ namespace AsbCloudApp.Repositories
|
|||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> SaveDataAsync(int idTelemetry, IEnumerable<DrillTestBaseDto> dtos, CancellationToken token);
|
Task<int> SaveDataAsync(int idTelemetry, IEnumerable<DrillTestBaseDto> dtos, CancellationToken token);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление записей drill_test по запросу на удаление куска телеметрии
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,5 +71,14 @@ namespace AsbCloudApp.Repositories
|
|||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<DatesRangeDto?> GetRangeAsync(int idWell, DateTimeOffset? geDate, DateTimeOffset? leDate, CancellationToken token);
|
Task<DatesRangeDto?> GetRangeAsync(int idWell, DateTimeOffset? geDate, DateTimeOffset? leDate, CancellationToken token);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// удаление данных ГТИ по запросу на удаление куска телеметрии
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">запрос</param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<int> DeleteAsync<TType>(TelemetryPartDeleteRequest request, CancellationToken token)
|
||||||
|
where TType : notnull;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,14 +32,12 @@ namespace AsbCloudApp.Repositories
|
|||||||
Task<IEnumerable<LimitingParameterDataDto>> GetLimitingParametersAsync(LimitingParameterRequest request, int idTelemetry, double timezoneHours, CancellationToken token);
|
Task<IEnumerable<LimitingParameterDataDto>> GetLimitingParametersAsync(LimitingParameterRequest request, int idTelemetry, double timezoneHours, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление ограничивающих параметров по ключу телеметрии и интервалу дат
|
/// Удаление ограничивающих параметров по запросу на удаление куска телеметрии
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="telemetryId"></param>
|
/// <param name="request"></param>
|
||||||
/// <param name="gDate"></param>
|
|
||||||
/// <param name="lDate"></param>
|
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> DeleteAsync(int telemetryId, DateTimeOffset? gDate, DateTimeOffset? lDate, CancellationToken token);
|
Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
25
AsbCloudApp/Requests/TelemetryPartDeleteRequest.cs
Normal file
25
AsbCloudApp/Requests/TelemetryPartDeleteRequest.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Requests;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Параметры запроса на удаление куска телеметрии
|
||||||
|
/// </summary>
|
||||||
|
public class TelemetryPartDeleteRequest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ключ телеметрии
|
||||||
|
/// </summary>
|
||||||
|
public int IdTelemetry { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// greater or equal then Date
|
||||||
|
/// </summary>
|
||||||
|
public DateTimeOffset? GeDate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// less or equal then Date
|
||||||
|
/// </summary>
|
||||||
|
public DateTimeOffset? LeDate { get; set; }
|
||||||
|
}
|
@ -29,5 +29,13 @@ namespace AsbCloudApp.Services
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task InsertAsync(string uid, IEnumerable<TelemetryMessageDto> dtos,
|
Task InsertAsync(string uid, IEnumerable<TelemetryMessageDto> dtos,
|
||||||
CancellationToken token);
|
CancellationToken token);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление сообщений по запросу на удаление куска телеметрии
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">запрос</param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
|
||||||
}
|
}
|
||||||
}
|
}
|
19
AsbCloudApp/Services/ITelemetryDataEditorService.cs
Normal file
19
AsbCloudApp/Services/ITelemetryDataEditorService.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using AsbCloudApp.Requests;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Services;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Сервис по работе с данными телеметрии
|
||||||
|
/// </summary>
|
||||||
|
public interface ITelemetryDataEditorService
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление части телеметрии по запросу
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
|
||||||
|
}
|
@ -70,5 +70,14 @@ namespace AsbCloudApp.Services
|
|||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> UpdateDataAsync(string uid, IEnumerable<TDto> dtos, CancellationToken token);
|
Task<int> UpdateDataAsync(string uid, IEnumerable<TDto> dtos, CancellationToken token);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// удалить данные по запросу
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">запрос</param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -78,15 +78,5 @@ namespace AsbCloudApp.Services
|
|||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<Stream> GetTelemetriesInfoByLastData(DateTimeOffset from, CancellationToken token);
|
Task<Stream> GetTelemetriesInfoByLastData(DateTimeOffset from, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление части телеметрии
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="telemetryId">ключ телеметрии</param>
|
|
||||||
/// <param name="gDate">начало временного диапазона</param>
|
|
||||||
/// <param name="lDate">конец временного диапазона</param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<int> DeleteAsync(int telemetryId, DateTimeOffset? gDate, DateTimeOffset? lDate, CancellationToken token);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Requests;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@ -45,5 +46,13 @@ namespace AsbCloudApp.Services
|
|||||||
/// <param name="token">The token.</param>
|
/// <param name="token">The token.</param>
|
||||||
/// <returns>A Task.</returns>
|
/// <returns>A Task.</returns>
|
||||||
Task<(DateTime begin, DateTime end, int count)?> GetStatAsync(int idTelemetry, CancellationToken token);
|
Task<(DateTime begin, DateTime end, int count)?> GetStatAsync(int idTelemetry, CancellationToken token);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Удалить записи по запросу на удаление куска телеметрии
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -493,6 +493,8 @@ namespace AsbCloudInfrastructure
|
|||||||
|
|
||||||
services.AddTransient<IWellboreService, WellboreService>();
|
services.AddTransient<IWellboreService, WellboreService>();
|
||||||
|
|
||||||
|
services.AddTransient<ITelemetryDataEditorService, TelemetryDataEditorService>();
|
||||||
|
|
||||||
services.AddTransient<DetectedOperationExportService>();
|
services.AddTransient<DetectedOperationExportService>();
|
||||||
|
|
||||||
services.AddTransient<IDailyReportService, DailyReportService>();
|
services.AddTransient<IDailyReportService, DailyReportService>();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Repositories;
|
using AsbCloudApp.Repositories;
|
||||||
|
using AsbCloudApp.Requests;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
@ -81,5 +82,32 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IQueryable<DataSaubStat> BuildQuery(TelemetryPartDeleteRequest request)
|
||||||
|
{
|
||||||
|
var query = db.Set<DataSaubStat>()
|
||||||
|
.Where(o => o.IdTelemetry == request.IdTelemetry);
|
||||||
|
|
||||||
|
if (request.GeDate is not null)
|
||||||
|
{
|
||||||
|
var geDate = request.GeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.DateStart <= geDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.LeDate is not null)
|
||||||
|
{
|
||||||
|
var leDate = request.LeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.DateEnd >= leDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token)
|
||||||
|
{
|
||||||
|
var query = BuildQuery(request);
|
||||||
|
db.Set<DataSaubStat>().RemoveRange(query);
|
||||||
|
return await db.SaveChangesAsync(token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,13 @@ public class DetectedOperationRepository : CrudRepositoryBase<DetectedOperationD
|
|||||||
return await dbContext.SaveChangesAsync(token);
|
return await dbContext.SaveChangesAsync(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token)
|
||||||
|
{
|
||||||
|
var query = BuildQuery(request);
|
||||||
|
dbContext.Set<DetectedOperation>().RemoveRange(query);
|
||||||
|
return await dbContext.SaveChangesAsync(token);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<PaginationContainer<DetectedOperationDto>> GetPageAsync(DetectedOperationByTelemetryRequest request, CancellationToken token)
|
public async Task<PaginationContainer<DetectedOperationDto>> GetPageAsync(DetectedOperationByTelemetryRequest request, CancellationToken token)
|
||||||
{
|
{
|
||||||
var skip = request.Skip ?? 0;
|
var skip = request.Skip ?? 0;
|
||||||
@ -113,6 +120,26 @@ public class DetectedOperationRepository : CrudRepositoryBase<DetectedOperationD
|
|||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IQueryable<DetectedOperation> BuildQuery(TelemetryPartDeleteRequest request)
|
||||||
|
{
|
||||||
|
var query = dbContext.Set<DetectedOperation>()
|
||||||
|
.Where(o => o.IdTelemetry == request.IdTelemetry);
|
||||||
|
|
||||||
|
if (request.GeDate is not null)
|
||||||
|
{
|
||||||
|
var geDate = request.GeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.DateStart <= geDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.LeDate is not null)
|
||||||
|
{
|
||||||
|
var leDate = request.LeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.DateEnd >= leDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
private static DetectedOperationDto Convert(DetectedOperation src, TimeSpan offset)
|
private static DetectedOperationDto Convert(DetectedOperation src, TimeSpan offset)
|
||||||
{
|
{
|
||||||
var dto = src.Adapt<DetectedOperationDto>();
|
var dto = src.Adapt<DetectedOperationDto>();
|
||||||
|
@ -84,5 +84,32 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
dto.TimeStampStart = dto.TimeStampStart.ToRemoteDateTime(dto.Telemetry?.TimeZone?.Hours ?? 0);
|
dto.TimeStampStart = dto.TimeStampStart.ToRemoteDateTime(dto.Telemetry?.TimeZone?.Hours ?? 0);
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IQueryable<DrillTest> BuildQuery(TelemetryPartDeleteRequest request)
|
||||||
|
{
|
||||||
|
var query = db.Set<DrillTest>()
|
||||||
|
.Where(o => o.IdTelemetry == request.IdTelemetry);
|
||||||
|
|
||||||
|
if (request.GeDate is not null)
|
||||||
|
{
|
||||||
|
var geDate = request.GeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.TimeStampStart <= geDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.LeDate is not null)
|
||||||
|
{
|
||||||
|
var leDate = request.LeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.TimeStampStart >= leDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token)
|
||||||
|
{
|
||||||
|
var query = BuildQuery(request);
|
||||||
|
db.Set<DrillTest>().RemoveRange(query);
|
||||||
|
return await db.SaveChangesAsync(token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Data.GTR;
|
using AsbCloudApp.Data.GTR;
|
||||||
|
using AsbCloudApp.Exceptions;
|
||||||
using AsbCloudApp.Repositories;
|
using AsbCloudApp.Repositories;
|
||||||
|
using AsbCloudApp.Requests;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb;
|
using AsbCloudDb;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudDb.Model.GTR;
|
using AsbCloudDb.Model.GTR;
|
||||||
|
using Mapster;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
@ -12,11 +16,6 @@ using System.Diagnostics;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AsbCloudApp.Exceptions;
|
|
||||||
using AsbCloudApp.Requests;
|
|
||||||
using Mapster;
|
|
||||||
using AsbCloudApp.Data;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Repository
|
namespace AsbCloudInfrastructure.Repository
|
||||||
{
|
{
|
||||||
@ -130,7 +129,7 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
return Enumerable.Empty<GtrWitsDto>();
|
return Enumerable.Empty<GtrWitsDto>();
|
||||||
|
|
||||||
if (telemetry.TimeZone is null)
|
if (telemetry.TimeZone is null)
|
||||||
throw new ArgumentInvalidException(nameof(idWell),$"Telemetry id: {telemetry.Id} can't find timezone");
|
throw new ArgumentInvalidException(nameof(idWell), $"Telemetry id: {telemetry.Id} can't find timezone");
|
||||||
|
|
||||||
var query = BuildQuery<TEntity, TType>(telemetry.Id, request);
|
var query = BuildQuery<TEntity, TType>(telemetry.Id, request);
|
||||||
|
|
||||||
@ -183,7 +182,7 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var lastDate = query
|
var lastDate = query
|
||||||
.OrderBy(e=>e.DateTime)
|
.OrderBy(e => e.DateTime)
|
||||||
.LastOrDefault()
|
.LastOrDefault()
|
||||||
?.DateTime
|
?.DateTime
|
||||||
?? DateTimeOffset.UtcNow;
|
?? DateTimeOffset.UtcNow;
|
||||||
@ -362,14 +361,15 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
if (ints.Any())
|
if (ints.Any())
|
||||||
await db.Database.ExecInsertOrIgnoreAsync(db.Set<WitsItemInt>(), ints, token);
|
await db.Database.ExecInsertOrIgnoreAsync(db.Set<WitsItemInt>(), ints, token);
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Trace.TraceError("Exception while saving GTR Wits data", ex);
|
Trace.TraceError("Exception while saving GTR Wits data", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
cache.AddOrUpdate(idTelemetry,
|
cache.AddOrUpdate(idTelemetry,
|
||||||
(_) => MakeNewCache(dtos),
|
(_) => MakeNewCache(dtos),
|
||||||
(_, oldItemsDictionary) => {
|
(_, oldItemsDictionary) =>
|
||||||
|
{
|
||||||
foreach (var record in dtos)
|
foreach (var record in dtos)
|
||||||
foreach (var item in record.Items)
|
foreach (var item in record.Items)
|
||||||
{
|
{
|
||||||
@ -398,7 +398,8 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
{
|
{
|
||||||
var items = dtos.SelectMany(record =>
|
var items = dtos.SelectMany(record =>
|
||||||
record.Items.Select(
|
record.Items.Select(
|
||||||
item => new WitsItemRecordDto {
|
item => new WitsItemRecordDto
|
||||||
|
{
|
||||||
IdItem = item.Key,
|
IdItem = item.Key,
|
||||||
IdRecord = record.Id,
|
IdRecord = record.Id,
|
||||||
Date = record.Date,
|
Date = record.Date,
|
||||||
@ -439,6 +440,50 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
Value = (TValue)dto.Value.Value,
|
Value = (TValue)dto.Value.Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private IQueryable<TEntity> BuildQuery<TEntity, TValue>(TelemetryPartDeleteRequest request)
|
||||||
|
where TEntity : WitsItemBase<TValue>
|
||||||
|
where TValue : notnull
|
||||||
|
{
|
||||||
|
var query = db.Set<TEntity>().Where(i => i.IdTelemetry == request.IdTelemetry);
|
||||||
|
|
||||||
|
if (request.GeDate is not null)
|
||||||
|
{
|
||||||
|
var geDate = request.GeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.DateTime <= geDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.LeDate is not null)
|
||||||
|
{
|
||||||
|
var leDate = request.LeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.DateTime >= leDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> DeleteAsync<TType>(TelemetryPartDeleteRequest request, CancellationToken token)
|
||||||
|
where TType : notnull
|
||||||
|
{
|
||||||
|
if (typeof(TType) == typeof(float))
|
||||||
|
return await DeleteAsync<WitsItemFloat, float>(request, token);
|
||||||
|
if (typeof(TType) == typeof(int))
|
||||||
|
return await DeleteAsync<WitsItemInt, int>(request, token);
|
||||||
|
if (typeof(TType) == typeof(string))
|
||||||
|
return await DeleteAsync<WitsItemString, string>(request, token);
|
||||||
|
|
||||||
|
return await Task.FromResult<int>(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<int> DeleteAsync<TEntity, TType>(TelemetryPartDeleteRequest request, CancellationToken token)
|
||||||
|
where TEntity : WitsItemBase<TType>
|
||||||
|
where TType : notnull
|
||||||
|
{
|
||||||
|
var query = BuildQuery<TEntity, TType>(request);
|
||||||
|
db.Set<TEntity>().RemoveRange(query);
|
||||||
|
return await db.SaveChangesAsync(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private class WitsRequest
|
private class WitsRequest
|
||||||
{
|
{
|
||||||
public int IdTelemetry { get; set; }
|
public int IdTelemetry { get; set; }
|
||||||
|
@ -21,17 +21,9 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> DeleteAsync(int telemetryId, DateTimeOffset? gDate, DateTimeOffset? lDate, CancellationToken token)
|
public async Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token)
|
||||||
{
|
{
|
||||||
var query = context.Set<LimitingParameter>()
|
var query = BuildQuery(request);
|
||||||
.Where(o => o.IdTelemetry == telemetryId);
|
|
||||||
|
|
||||||
if (gDate.HasValue)
|
|
||||||
query = query.Where(o => o.DateStart > gDate.Value.ToUniversalTime());
|
|
||||||
|
|
||||||
if (lDate.HasValue)
|
|
||||||
query = query.Where(o => o.DateStart < lDate.Value.ToUniversalTime());
|
|
||||||
|
|
||||||
context.Set<LimitingParameter>().RemoveRange(query);
|
context.Set<LimitingParameter>().RemoveRange(query);
|
||||||
return await context.SaveChangesAsync(token);
|
return await context.SaveChangesAsync(token);
|
||||||
}
|
}
|
||||||
@ -89,6 +81,26 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IQueryable<LimitingParameter> BuildQuery(TelemetryPartDeleteRequest request)
|
||||||
|
{
|
||||||
|
var query = context.Set<LimitingParameter>()
|
||||||
|
.Where(o => o.IdTelemetry == request.IdTelemetry);
|
||||||
|
|
||||||
|
if (request.GeDate is not null)
|
||||||
|
{
|
||||||
|
var geDate = request.GeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.DateStart <= geDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.LeDate is not null)
|
||||||
|
{
|
||||||
|
var leDate = request.LeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.DateEnd >= leDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using AsbCloudApp.Requests;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
@ -20,7 +21,7 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
private readonly IAsbCloudDbContext db;
|
private readonly IAsbCloudDbContext db;
|
||||||
private readonly ITelemetryService telemetryService;
|
private readonly ITelemetryService telemetryService;
|
||||||
|
|
||||||
private static readonly ConcurrentDictionary<int, TDto> cache = new ();
|
private static readonly ConcurrentDictionary<int, TDto> cache = new();
|
||||||
|
|
||||||
public WitsRecordRepository(IAsbCloudDbContext db, ITelemetryService telemetryService)
|
public WitsRecordRepository(IAsbCloudDbContext db, ITelemetryService telemetryService)
|
||||||
{
|
{
|
||||||
@ -58,6 +59,33 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
return data.Select(d => Convert(d, timezoneHours));
|
return data.Select(d => Convert(d, timezoneHours));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IQueryable<TEntity> BuildQuery(TelemetryPartDeleteRequest request)
|
||||||
|
{
|
||||||
|
var query = db.Set<TEntity>()
|
||||||
|
.Where(o => o.IdTelemetry == request.IdTelemetry);
|
||||||
|
|
||||||
|
if (request.GeDate is not null)
|
||||||
|
{
|
||||||
|
var geDate = request.GeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.DateTime <= geDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.LeDate is not null)
|
||||||
|
{
|
||||||
|
var leDate = request.LeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.DateTime >= leDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token)
|
||||||
|
{
|
||||||
|
var query = BuildQuery(request);
|
||||||
|
dbset.RemoveRange(query);
|
||||||
|
return await db.SaveChangesAsync(token);
|
||||||
|
}
|
||||||
|
|
||||||
public TDto? GetLastOrDefault(int idTelemetry)
|
public TDto? GetLastOrDefault(int idTelemetry)
|
||||||
=> cache.GetValueOrDefault(idTelemetry);
|
=> cache.GetValueOrDefault(idTelemetry);
|
||||||
|
|
||||||
@ -66,7 +94,7 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
if (!dtos.Any())
|
if (!dtos.Any())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cache.AddOrUpdate(idTelemetry, dtos.Last(), (_,_) => dtos.OrderBy(r => r.DateTime).Last());
|
cache.AddOrUpdate(idTelemetry, dtos.Last(), (_, _) => dtos.OrderBy(r => r.DateTime).Last());
|
||||||
|
|
||||||
var timezoneHours = telemetryService.GetTimezone(idTelemetry).Hours;
|
var timezoneHours = telemetryService.GetTimezone(idTelemetry).Hours;
|
||||||
var entities = dtos
|
var entities = dtos
|
||||||
|
@ -96,7 +96,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
|||||||
var allUsers = await memoryCache.GetOrCreateBasicAsync(db.Set<TelemetryUser>(), token);
|
var allUsers = await memoryCache.GetOrCreateBasicAsync(db.Set<TelemetryUser>(), token);
|
||||||
var users = allUsers.Where(u => u.IdTelemetry == telemetry.Id);
|
var users = allUsers.Where(u => u.IdTelemetry == telemetry.Id);
|
||||||
|
|
||||||
var eventsDict = events.ToDictionary(x=>x.IdEvent, x => x);
|
var eventsDict = events.ToDictionary(x => x.IdEvent, x => x);
|
||||||
var usersDict = users.ToDictionary(x => x.IdUser, x => x);
|
var usersDict = users.ToDictionary(x => x.IdUser, x => x);
|
||||||
|
|
||||||
var messagesDtoList = new List<MessageDto>();
|
var messagesDtoList = new List<MessageDto>();
|
||||||
@ -154,6 +154,33 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
|||||||
|
|
||||||
return db.SaveChangesAsync(token);
|
return db.SaveChangesAsync(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IQueryable<TelemetryMessage> BuildQuery(TelemetryPartDeleteRequest request)
|
||||||
|
{
|
||||||
|
var query = db.Set<TelemetryMessage>()
|
||||||
|
.Where(o => o.IdTelemetry == request.IdTelemetry);
|
||||||
|
|
||||||
|
if (request.GeDate is not null)
|
||||||
|
{
|
||||||
|
var geDate = request.GeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.DateTime <= geDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.LeDate is not null)
|
||||||
|
{
|
||||||
|
var leDate = request.LeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.DateTime >= leDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token)
|
||||||
|
{
|
||||||
|
var query = BuildQuery(request);
|
||||||
|
db.Set<TelemetryMessage>().RemoveRange(query);
|
||||||
|
return await db.SaveChangesAsync(token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Exceptions;
|
using AsbCloudApp.Exceptions;
|
||||||
using AsbCloudApp.Repositories;
|
using AsbCloudApp.Repositories;
|
||||||
|
using AsbCloudApp.Requests;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb;
|
using AsbCloudDb;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
@ -11,8 +12,6 @@ using System.Diagnostics;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AsbCloudApp.Requests;
|
|
||||||
using Mapster;
|
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services.SAUB
|
namespace AsbCloudInfrastructure.Services.SAUB
|
||||||
{
|
{
|
||||||
@ -163,7 +162,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
|||||||
|
|
||||||
var cache = telemetryDataCache.GetOrDefault(idTelemetry, request);
|
var cache = telemetryDataCache.GetOrDefault(idTelemetry, request);
|
||||||
|
|
||||||
if(cache is not null)
|
if (cache is not null)
|
||||||
return cache;
|
return cache;
|
||||||
|
|
||||||
var query = BuildQuery(idTelemetry, request);
|
var query = BuildQuery(idTelemetry, request);
|
||||||
@ -219,6 +218,26 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
|||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IQueryable<TEntity> BuildQuery(TelemetryPartDeleteRequest request)
|
||||||
|
{
|
||||||
|
var query = db.Set<TEntity>()
|
||||||
|
.Where(o => o.IdTelemetry == request.IdTelemetry);
|
||||||
|
|
||||||
|
if (request.GeDate is not null)
|
||||||
|
{
|
||||||
|
var geDate = request.GeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.DateTime <= geDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.LeDate is not null)
|
||||||
|
{
|
||||||
|
var leDate = request.LeDate.Value.ToUniversalTime();
|
||||||
|
query = query.Where(o => o.DateTime >= leDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task<DatesRangeDto?> GetRangeAsync(int idWell, DateTimeOffset geDate, DateTimeOffset? leDate, CancellationToken token)
|
public async Task<DatesRangeDto?> GetRangeAsync(int idWell, DateTimeOffset geDate, DateTimeOffset? leDate, CancellationToken token)
|
||||||
{
|
{
|
||||||
@ -231,7 +250,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
|||||||
var cachedRange = telemetryDataCache.GetOrDefaultCachedDataDateRange(telemetry.Id);
|
var cachedRange = telemetryDataCache.GetOrDefaultCachedDataDateRange(telemetry.Id);
|
||||||
if (cachedRange is not null)
|
if (cachedRange is not null)
|
||||||
{
|
{
|
||||||
var datesRange = new DatesRangeDto {From = cachedRange.From, To = cachedRange.To };
|
var datesRange = new DatesRangeDto { From = cachedRange.From, To = cachedRange.To };
|
||||||
if (geDate >= cachedRange.From)
|
if (geDate >= cachedRange.From)
|
||||||
datesRange.From = geDate.ToOffset(cachedRange.From.Offset);
|
datesRange.From = geDate.ToOffset(cachedRange.From.Offset);
|
||||||
|
|
||||||
@ -246,7 +265,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
|||||||
.Where(entity => entity.IdTelemetry == telemetry.Id)
|
.Where(entity => entity.IdTelemetry == telemetry.Id)
|
||||||
.Where(entity => entity.DateTime >= geDate.ToUniversalTime());
|
.Where(entity => entity.DateTime >= geDate.ToUniversalTime());
|
||||||
|
|
||||||
if(leDate.HasValue)
|
if (leDate.HasValue)
|
||||||
query = query.Where(entity => entity.DateTime <= leDate.Value.ToUniversalTime());
|
query = query.Where(entity => entity.DateTime <= leDate.Value.ToUniversalTime());
|
||||||
|
|
||||||
var groupQuery = query
|
var groupQuery = query
|
||||||
@ -282,5 +301,11 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
|||||||
|
|
||||||
protected abstract TEntity Convert(TDto src, double timezoneOffset);
|
protected abstract TEntity Convert(TDto src, double timezoneOffset);
|
||||||
|
|
||||||
|
public async Task<int> DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token)
|
||||||
|
{
|
||||||
|
var query = BuildQuery(request);
|
||||||
|
db.Set<TEntity>().RemoveRange(query);
|
||||||
|
return await db.SaveChangesAsync(token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,101 @@
|
|||||||
|
using AsbCloudApp.Data.SAUB;
|
||||||
|
using AsbCloudApp.Data.WITS;
|
||||||
|
using AsbCloudApp.Repositories;
|
||||||
|
using AsbCloudApp.Requests;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AsbCloudInfrastructure.Services.SAUB
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Сервис по работе с данными телеметрии
|
||||||
|
/// </summary>
|
||||||
|
public class TelemetryDataEditorService : ITelemetryDataEditorService
|
||||||
|
{
|
||||||
|
private readonly ITelemetryDataSaubService dataSaubService;
|
||||||
|
private readonly ITelemetryDataService<TelemetryDataSpinDto> dataSpinService;
|
||||||
|
private readonly IDataSaubStatRepository dataSaubStatRepository;
|
||||||
|
private readonly IMessageService messageService;
|
||||||
|
private readonly IDrillTestRepository drillTestRepository;
|
||||||
|
private readonly ILimitingParameterRepository limitingParameterRepository;
|
||||||
|
private readonly IDetectedOperationRepository detectedOperationRepository;
|
||||||
|
private readonly IWitsRecordRepository<Record1Dto> witsRecord1Repository;
|
||||||
|
private readonly IWitsRecordRepository<Record7Dto> witsRecord7Repository;
|
||||||
|
private readonly IWitsRecordRepository<Record8Dto> witsRecord8Repository;
|
||||||
|
private readonly IWitsRecordRepository<Record50Dto> witsRecord50Repository;
|
||||||
|
private readonly IWitsRecordRepository<Record60Dto> witsRecord60Repository;
|
||||||
|
private readonly IWitsRecordRepository<Record61Dto> witsRecord61Repository;
|
||||||
|
private readonly IGtrRepository gtrRepository;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dataSaubService"></param>
|
||||||
|
/// <param name="dataSpinService"></param>
|
||||||
|
/// <param name="dataSaubStatRepository"></param>
|
||||||
|
/// <param name="messageService"></param>
|
||||||
|
/// <param name="drillTestRepository"></param>
|
||||||
|
/// <param name="limitingParameterRepository"></param>
|
||||||
|
/// <param name="detectedOperationRepository"></param>
|
||||||
|
/// <param name="witsRecord1Repository"></param>
|
||||||
|
/// <param name="witsRecord7Repository"></param>
|
||||||
|
/// <param name="witsRecord8Repository"></param>
|
||||||
|
/// <param name="witsRecord50Repository"></param>
|
||||||
|
/// <param name="witsRecord60Repository"></param>
|
||||||
|
/// <param name="witsRecord61Repository"></param>
|
||||||
|
/// <param name="gtrRepository"></param>
|
||||||
|
public TelemetryDataEditorService(
|
||||||
|
ITelemetryDataSaubService dataSaubService,
|
||||||
|
ITelemetryDataService<TelemetryDataSpinDto> dataSpinService,
|
||||||
|
IDataSaubStatRepository dataSaubStatRepository,
|
||||||
|
IMessageService messageService,
|
||||||
|
IDrillTestRepository drillTestRepository,
|
||||||
|
ILimitingParameterRepository limitingParameterRepository,
|
||||||
|
IDetectedOperationRepository detectedOperationRepository,
|
||||||
|
IWitsRecordRepository<Record1Dto> witsRecord1Repository,
|
||||||
|
IWitsRecordRepository<Record7Dto> witsRecord7Repository,
|
||||||
|
IWitsRecordRepository<Record8Dto> witsRecord8Repository,
|
||||||
|
IWitsRecordRepository<Record50Dto> witsRecord50Repository,
|
||||||
|
IWitsRecordRepository<Record60Dto> witsRecord60Repository,
|
||||||
|
IWitsRecordRepository<Record61Dto> witsRecord61Repository,
|
||||||
|
IGtrRepository gtrRepository
|
||||||
|
)
|
||||||
|
{
|
||||||
|
this.dataSaubService = dataSaubService;
|
||||||
|
this.dataSpinService = dataSpinService;
|
||||||
|
this.dataSaubStatRepository = dataSaubStatRepository;
|
||||||
|
this.messageService = messageService;
|
||||||
|
this.drillTestRepository = drillTestRepository;
|
||||||
|
this.limitingParameterRepository = limitingParameterRepository;
|
||||||
|
this.detectedOperationRepository = detectedOperationRepository;
|
||||||
|
this.witsRecord1Repository = witsRecord1Repository;
|
||||||
|
this.witsRecord7Repository = witsRecord7Repository;
|
||||||
|
this.witsRecord8Repository = witsRecord8Repository;
|
||||||
|
this.witsRecord50Repository = witsRecord50Repository;
|
||||||
|
this.witsRecord60Repository = witsRecord60Repository;
|
||||||
|
this.witsRecord61Repository = witsRecord61Repository;
|
||||||
|
this.gtrRepository = gtrRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token)
|
||||||
|
{
|
||||||
|
await dataSaubService.DeleteAsync(request, token);
|
||||||
|
await dataSpinService.DeleteAsync(request, token);
|
||||||
|
await dataSaubStatRepository.DeleteAsync(request, token);
|
||||||
|
await messageService.DeleteAsync(request, token);
|
||||||
|
await drillTestRepository.DeleteAsync(request, token);
|
||||||
|
await limitingParameterRepository.DeleteAsync(request, token);
|
||||||
|
await detectedOperationRepository.DeleteAsync(request, token);
|
||||||
|
await witsRecord1Repository.DeleteAsync(request, token);
|
||||||
|
await witsRecord7Repository.DeleteAsync(request, token);
|
||||||
|
await witsRecord8Repository.DeleteAsync(request, token);
|
||||||
|
await witsRecord50Repository.DeleteAsync(request, token);
|
||||||
|
await witsRecord60Repository.DeleteAsync(request, token);
|
||||||
|
await witsRecord61Repository.DeleteAsync(request, token);
|
||||||
|
await gtrRepository.DeleteAsync<float>(request, token);
|
||||||
|
await gtrRepository.DeleteAsync<int>(request, token);
|
||||||
|
await gtrRepository.DeleteAsync<string>(request, token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -24,8 +24,6 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
|||||||
//TODO: методы использующие ITelemetryDataCache, скорее всего, тут не нужны
|
//TODO: методы использующие ITelemetryDataCache, скорее всего, тут не нужны
|
||||||
private readonly ITelemetryDataCache<TelemetryDataSaubDto> dataSaubCache;
|
private readonly ITelemetryDataCache<TelemetryDataSaubDto> dataSaubCache;
|
||||||
private readonly ITimezoneService timezoneService;
|
private readonly ITimezoneService timezoneService;
|
||||||
private readonly ITelemetryDataSaubService dataSaubService;
|
|
||||||
private readonly ILimitingParameterRepository limitingParameterRepository;
|
|
||||||
|
|
||||||
public ITimezoneService TimeZoneService => timezoneService;
|
public ITimezoneService TimeZoneService => timezoneService;
|
||||||
|
|
||||||
@ -33,17 +31,12 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
|||||||
IAsbCloudDbContext db,
|
IAsbCloudDbContext db,
|
||||||
IMemoryCache memoryCache,
|
IMemoryCache memoryCache,
|
||||||
ITelemetryDataCache<TelemetryDataSaubDto> dataSaubCache,
|
ITelemetryDataCache<TelemetryDataSaubDto> dataSaubCache,
|
||||||
ITimezoneService timezoneService,
|
ITimezoneService timezoneService)
|
||||||
ITelemetryDataSaubService dataSaubService,
|
|
||||||
ILimitingParameterRepository limitingParameterRepository)
|
|
||||||
{
|
{
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.memoryCache = memoryCache;
|
this.memoryCache = memoryCache;
|
||||||
this.dataSaubCache = dataSaubCache;
|
this.dataSaubCache = dataSaubCache;
|
||||||
this.timezoneService = timezoneService;
|
this.timezoneService = timezoneService;
|
||||||
|
|
||||||
this.dataSaubService = dataSaubService;
|
|
||||||
this.limitingParameterRepository = limitingParameterRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<Telemetry> GetTelemetryCache()
|
private IEnumerable<Telemetry> GetTelemetryCache()
|
||||||
@ -359,10 +352,5 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
|||||||
|
|
||||||
return affected;
|
return affected;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> DeleteAsync(int telemetryId, DateTimeOffset? gDate, DateTimeOffset? lDate, CancellationToken token)
|
|
||||||
{
|
|
||||||
return await limitingParameterRepository.DeleteAsync(telemetryId, gDate, lDate, token);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Requests;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@ -17,12 +18,15 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
public class AdminTelemetryController : CrudController<TelemetryDto, ICrudRepository<TelemetryDto>>
|
public class AdminTelemetryController : CrudController<TelemetryDto, ICrudRepository<TelemetryDto>>
|
||||||
{
|
{
|
||||||
private readonly ITelemetryService telemetryService;
|
private readonly ITelemetryService telemetryService;
|
||||||
|
private readonly ITelemetryDataEditorService telemetryEditorService;
|
||||||
|
|
||||||
public AdminTelemetryController(ICrudRepository<TelemetryDto> service,
|
public AdminTelemetryController(ICrudRepository<TelemetryDto> service,
|
||||||
ITelemetryService telemetryService)
|
ITelemetryService telemetryService,
|
||||||
|
ITelemetryDataEditorService telemetryEditorService)
|
||||||
: base(service)
|
: base(service)
|
||||||
{
|
{
|
||||||
this.telemetryService = telemetryService;
|
this.telemetryService = telemetryService;
|
||||||
|
this.telemetryEditorService = telemetryEditorService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -46,14 +50,20 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// <param name="lDate">конец интервала удаления</param>
|
/// <param name="lDate">конец интервала удаления</param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpDelete("{telemetryId}")]
|
[HttpDelete("/part/{telemetryId}")]
|
||||||
[Permission]
|
[Permission]
|
||||||
public async Task<IActionResult> DeleteAsync(int telemetryId,
|
public async Task<IActionResult> DeleteAsync(int telemetryId,
|
||||||
DateTimeOffset? gDate,
|
DateTimeOffset? gDate,
|
||||||
DateTimeOffset? lDate,
|
DateTimeOffset? lDate,
|
||||||
CancellationToken token)
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
await telemetryService.DeleteAsync(telemetryId, gDate, lDate, token);
|
var request = new TelemetryPartDeleteRequest()
|
||||||
|
{
|
||||||
|
IdTelemetry = telemetryId,
|
||||||
|
GeDate = gDate,
|
||||||
|
LeDate = lDate
|
||||||
|
};
|
||||||
|
await telemetryEditorService.DeleteAsync(request, token);
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user