Merge branch 'master' into WitsData
This commit is contained in:
commit
ba949f2dff
@ -101,11 +101,12 @@ public class SetpointController : ControllerBase, ISetpointApi
|
|||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)HttpStatusCode.Created)]
|
||||||
public async Task<IActionResult> Save(Guid setpointKey, object newValue, Guid idUser, CancellationToken token)
|
public async Task<IActionResult> Add(Guid setpointKey, object newValue, CancellationToken token)
|
||||||
{
|
{
|
||||||
await setpointRepository.Save(setpointKey, newValue, idUser, token);
|
var userId = User.GetUserId<Guid>();
|
||||||
|
await setpointRepository.Add(setpointKey, newValue, userId, token);
|
||||||
|
|
||||||
return Ok();
|
return CreatedAtAction(nameof(Add), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,17 +107,13 @@ public class TechMessagesController : ControllerBase
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ProducesResponseType(typeof(int), (int)HttpStatusCode.Created)]
|
[ProducesResponseType(typeof(int), (int)HttpStatusCode.Created)]
|
||||||
public async Task<IActionResult> InsertRange([FromBody] IEnumerable<TechMessageDto> dtos, CancellationToken token)
|
public async Task<IActionResult> AddRange([FromBody] IEnumerable<TechMessageDto> dtos, CancellationToken token)
|
||||||
{
|
{
|
||||||
var userId = User.GetUserId<Guid>();
|
var userId = User.GetUserId<Guid>();
|
||||||
foreach (var dto in dtos)
|
|
||||||
{
|
|
||||||
dto.UserId = userId;
|
|
||||||
}
|
|
||||||
|
|
||||||
var result = await techMessagesRepository.InsertRange(dtos, token);
|
var result = await techMessagesRepository.AddRange(dtos, userId, token);
|
||||||
|
|
||||||
return CreatedAtAction(nameof(InsertRange), result);
|
return CreatedAtAction(nameof(AddRange), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -66,9 +66,9 @@ public class TimeSeriesController<TDto> : ControllerBase, ITimeSeriesDataApi<TDt
|
|||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> InsertRange(IEnumerable<TDto> dtos, CancellationToken token)
|
public async Task<IActionResult> AddRange(IEnumerable<TDto> dtos, CancellationToken token)
|
||||||
{
|
{
|
||||||
var result = await timeSeriesDataRepository.InsertRange(dtos, token);
|
var result = await timeSeriesDataRepository.AddRange(dtos, token);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,9 +32,9 @@ public class TimestampedSetController : ControllerBase
|
|||||||
/// <returns>кол-во затронутых записей</returns>
|
/// <returns>кол-во затронутых записей</returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> InsertRange([FromRoute]Guid idDiscriminator, [FromBody]IEnumerable<TimestampedSetDto> sets, CancellationToken token)
|
public async Task<IActionResult> AddRange([FromRoute]Guid idDiscriminator, [FromBody]IEnumerable<TimestampedSetDto> sets, CancellationToken token)
|
||||||
{
|
{
|
||||||
var result = await repository.InsertRange(idDiscriminator, sets, token);
|
var result = await repository.AddRange(idDiscriminator, sets, token);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,5 +26,5 @@ public interface ISetpointClient
|
|||||||
Task<IApiResponse<IEnumerable<SetpointLogDto>>> GetPart(DateTimeOffset dateBegin, int take, CancellationToken token);
|
Task<IApiResponse<IEnumerable<SetpointLogDto>>> GetPart(DateTimeOffset dateBegin, int take, CancellationToken token);
|
||||||
|
|
||||||
[Post($"{BaseRoute}/")]
|
[Post($"{BaseRoute}/")]
|
||||||
Task<IApiResponse> Save(Guid setpointKey, object newValue);
|
Task<IApiResponse> Add(Guid setpointKey, object newValue);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ namespace Persistence.Client.Clients
|
|||||||
Task<IApiResponse<PaginationContainer<TechMessageDto>>> GetPage([Query] RequestDto request, CancellationToken token);
|
Task<IApiResponse<PaginationContainer<TechMessageDto>>> GetPage([Query] RequestDto request, CancellationToken token);
|
||||||
|
|
||||||
[Post($"{BaseRoute}")]
|
[Post($"{BaseRoute}")]
|
||||||
Task<IApiResponse<int>> InsertRange([Body] IEnumerable<TechMessageDto> dtos, CancellationToken token);
|
Task<IApiResponse<int>> AddRange([Body] IEnumerable<TechMessageDto> dtos, CancellationToken token);
|
||||||
|
|
||||||
[Get($"{BaseRoute}/systems")]
|
[Get($"{BaseRoute}/systems")]
|
||||||
Task<IApiResponse<IEnumerable<string>>> GetSystems(CancellationToken token);
|
Task<IApiResponse<IEnumerable<string>>> GetSystems(CancellationToken token);
|
||||||
|
@ -8,7 +8,7 @@ public interface ITimeSeriesClient<TDto>
|
|||||||
private const string BaseRoute = "/api/dataSaub";
|
private const string BaseRoute = "/api/dataSaub";
|
||||||
|
|
||||||
[Post($"{BaseRoute}")]
|
[Post($"{BaseRoute}")]
|
||||||
Task<IApiResponse<int>> InsertRange(IEnumerable<TDto> dtos);
|
Task<IApiResponse<int>> AddRange(IEnumerable<TDto> dtos);
|
||||||
|
|
||||||
[Get($"{BaseRoute}")]
|
[Get($"{BaseRoute}")]
|
||||||
Task<IApiResponse<IEnumerable<TDto>>> Get(DateTimeOffset dateBegin, DateTimeOffset dateEnd);
|
Task<IApiResponse<IEnumerable<TDto>>> Get(DateTimeOffset dateBegin, DateTimeOffset dateEnd);
|
||||||
|
@ -20,7 +20,7 @@ public interface ITimestampedSetClient
|
|||||||
/// <param name="sets"></param>
|
/// <param name="sets"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Post(baseUrl)]
|
[Post(baseUrl)]
|
||||||
Task<IApiResponse<int>> InsertRange(Guid idDiscriminator, IEnumerable<TimestampedSetDto> sets);
|
Task<IApiResponse<int>> AddRange(Guid idDiscriminator, IEnumerable<TimestampedSetDto> sets);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение данных с фильтрацией. Значение фильтра null - отключен
|
/// Получение данных с фильтрацией. Значение фильтра null - отключен
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
|
using Microsoft.AspNetCore.Mvc.TagHelpers.Cache;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Persistence.Client;
|
using Persistence.Client;
|
||||||
using Persistence.Client.Clients;
|
using Persistence.Client.Clients;
|
||||||
@ -47,7 +48,7 @@ namespace Persistence.IntegrationTests.Controllers
|
|||||||
public async Task GetCurrent_AfterSave_returns_success()
|
public async Task GetCurrent_AfterSave_returns_success()
|
||||||
{
|
{
|
||||||
//arrange
|
//arrange
|
||||||
var setpointKey = await Save();
|
var setpointKey = await Add();
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await setpointClient.GetCurrent([setpointKey]);
|
var response = await setpointClient.GetCurrent([setpointKey]);
|
||||||
@ -83,7 +84,7 @@ namespace Persistence.IntegrationTests.Controllers
|
|||||||
public async Task GetHistory_AfterSave_returns_success()
|
public async Task GetHistory_AfterSave_returns_success()
|
||||||
{
|
{
|
||||||
//arrange
|
//arrange
|
||||||
var setpointKey = await Save();
|
var setpointKey = await Add();
|
||||||
var historyMoment = DateTimeOffset.UtcNow;
|
var historyMoment = DateTimeOffset.UtcNow;
|
||||||
historyMoment = historyMoment.AddDays(1);
|
historyMoment = historyMoment.AddDays(1);
|
||||||
|
|
||||||
@ -120,7 +121,7 @@ namespace Persistence.IntegrationTests.Controllers
|
|||||||
public async Task GetLog_AfterSave_returns_success()
|
public async Task GetLog_AfterSave_returns_success()
|
||||||
{
|
{
|
||||||
//arrange
|
//arrange
|
||||||
var setpointKey = await Save();
|
var setpointKey = await Add();
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await setpointClient.GetLog([setpointKey]);
|
var response = await setpointClient.GetLog([setpointKey]);
|
||||||
@ -144,8 +145,8 @@ namespace Persistence.IntegrationTests.Controllers
|
|||||||
//assert
|
//assert
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
Assert.NotNull(response.Content);
|
Assert.NotNull(response.Content);
|
||||||
Assert.Equal(DateTimeOffset.MinValue, response.Content?.From);
|
Assert.Equal(DateTimeOffset.MinValue, response.Content!.From);
|
||||||
Assert.Equal(DateTimeOffset.MaxValue, response.Content?.To);
|
Assert.Equal(DateTimeOffset.MaxValue, response.Content!.To);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -153,7 +154,12 @@ namespace Persistence.IntegrationTests.Controllers
|
|||||||
{
|
{
|
||||||
//arrange
|
//arrange
|
||||||
dbContext.CleanupDbSet<Setpoint>();
|
dbContext.CleanupDbSet<Setpoint>();
|
||||||
await Save();
|
|
||||||
|
await Add();
|
||||||
|
|
||||||
|
var dateBegin = DateTimeOffset.MinValue;
|
||||||
|
var take = 1;
|
||||||
|
var part = await setpointClient.GetPart(dateBegin, take, new CancellationToken());
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await setpointClient.GetDatesRangeAsync(new CancellationToken());
|
var response = await setpointClient.GetDatesRangeAsync(new CancellationToken());
|
||||||
@ -161,8 +167,17 @@ namespace Persistence.IntegrationTests.Controllers
|
|||||||
//assert
|
//assert
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
Assert.NotNull(response.Content);
|
Assert.NotNull(response.Content);
|
||||||
Assert.NotNull(response.Content?.From);
|
|
||||||
Assert.NotNull(response.Content?.To);
|
var expectedValue = part.Content!
|
||||||
|
.FirstOrDefault()!.Created
|
||||||
|
.ToString("dd.MM.yyyy-HH:mm:ss");
|
||||||
|
var actualValueFrom = response.Content.From
|
||||||
|
.ToString("dd.MM.yyyy-HH:mm:ss");
|
||||||
|
Assert.Equal(expectedValue, actualValueFrom);
|
||||||
|
|
||||||
|
var actualValueTo = response.Content.To
|
||||||
|
.ToString("dd.MM.yyyy-HH:mm:ss");
|
||||||
|
Assert.Equal(expectedValue, actualValueTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -187,7 +202,7 @@ namespace Persistence.IntegrationTests.Controllers
|
|||||||
//arrange
|
//arrange
|
||||||
var dateBegin = DateTimeOffset.UtcNow;
|
var dateBegin = DateTimeOffset.UtcNow;
|
||||||
var take = 1;
|
var take = 1;
|
||||||
await Save();
|
await Add();
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await setpointClient.GetPart(dateBegin, take, new CancellationToken());
|
var response = await setpointClient.GetPart(dateBegin, take, new CancellationToken());
|
||||||
@ -201,10 +216,10 @@ namespace Persistence.IntegrationTests.Controllers
|
|||||||
[Fact]
|
[Fact]
|
||||||
public async Task Save_returns_success()
|
public async Task Save_returns_success()
|
||||||
{
|
{
|
||||||
await Save();
|
await Add();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Guid> Save()
|
private async Task<Guid> Add()
|
||||||
{
|
{
|
||||||
//arrange
|
//arrange
|
||||||
var setpointKey = Guid.NewGuid();
|
var setpointKey = Guid.NewGuid();
|
||||||
@ -215,10 +230,10 @@ namespace Persistence.IntegrationTests.Controllers
|
|||||||
};
|
};
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await setpointClient.Save(setpointKey, setpointValue);
|
var response = await setpointClient.Add(setpointKey, setpointValue);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.Created, response.StatusCode);
|
||||||
|
|
||||||
return setpointKey;
|
return setpointKey;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ namespace Persistence.IntegrationTests.Controllers
|
|||||||
};
|
};
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await techMessagesClient.InsertRange(dtos, new CancellationToken());
|
var response = await techMessagesClient.AddRange(dtos, new CancellationToken());
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||||
@ -276,7 +276,7 @@ namespace Persistence.IntegrationTests.Controllers
|
|||||||
|
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await techMessagesClient.InsertRange(dtos, new CancellationToken());
|
var response = await techMessagesClient.AddRange(dtos, new CancellationToken());
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.Equal(HttpStatusCode.Created, response.StatusCode);
|
Assert.Equal(HttpStatusCode.Created, response.StatusCode);
|
||||||
|
@ -30,7 +30,7 @@ public abstract class TimeSeriesBaseControllerTest<TEntity, TDto> : BaseIntegrat
|
|||||||
var expected = dto.Adapt<TDto>();
|
var expected = dto.Adapt<TDto>();
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await timeSeriesClient.InsertRange(new TDto[] { expected });
|
var response = await timeSeriesClient.AddRange(new TDto[] { expected });
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
|
@ -25,7 +25,7 @@ public class TimestampedSetControllerTest : BaseIntegrationTest
|
|||||||
IEnumerable<TimestampedSetDto> testSets = Generate(10, DateTimeOffset.Now.ToOffset(TimeSpan.FromHours(7)));
|
IEnumerable<TimestampedSetDto> testSets = Generate(10, DateTimeOffset.Now.ToOffset(TimeSpan.FromHours(7)));
|
||||||
|
|
||||||
// act
|
// act
|
||||||
var response = await client.InsertRange(idDiscriminator, testSets);
|
var response = await client.AddRange(idDiscriminator, testSets);
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode);
|
||||||
@ -39,7 +39,7 @@ public class TimestampedSetControllerTest : BaseIntegrationTest
|
|||||||
Guid idDiscriminator = Guid.NewGuid();
|
Guid idDiscriminator = Guid.NewGuid();
|
||||||
int count = 10;
|
int count = 10;
|
||||||
IEnumerable<TimestampedSetDto> testSets = Generate(count, DateTimeOffset.Now.ToOffset(TimeSpan.FromHours(7)));
|
IEnumerable<TimestampedSetDto> testSets = Generate(count, DateTimeOffset.Now.ToOffset(TimeSpan.FromHours(7)));
|
||||||
var insertResponse = await client.InsertRange(idDiscriminator, testSets);
|
var insertResponse = await client.AddRange(idDiscriminator, testSets);
|
||||||
|
|
||||||
// act
|
// act
|
||||||
var response = await client.Get(idDiscriminator, null, null, 0, int.MaxValue);
|
var response = await client.Get(idDiscriminator, null, null, 0, int.MaxValue);
|
||||||
@ -58,7 +58,7 @@ public class TimestampedSetControllerTest : BaseIntegrationTest
|
|||||||
Guid idDiscriminator = Guid.NewGuid();
|
Guid idDiscriminator = Guid.NewGuid();
|
||||||
int count = 10;
|
int count = 10;
|
||||||
IEnumerable<TimestampedSetDto> testSets = Generate(count, DateTimeOffset.Now.ToOffset(TimeSpan.FromHours(7)));
|
IEnumerable<TimestampedSetDto> testSets = Generate(count, DateTimeOffset.Now.ToOffset(TimeSpan.FromHours(7)));
|
||||||
var insertResponse = await client.InsertRange(idDiscriminator, testSets);
|
var insertResponse = await client.AddRange(idDiscriminator, testSets);
|
||||||
string[] props = ["A"];
|
string[] props = ["A"];
|
||||||
|
|
||||||
// act
|
// act
|
||||||
@ -86,7 +86,7 @@ public class TimestampedSetControllerTest : BaseIntegrationTest
|
|||||||
var dateMin = DateTimeOffset.Now;
|
var dateMin = DateTimeOffset.Now;
|
||||||
var dateMax = DateTimeOffset.Now.AddSeconds(count);
|
var dateMax = DateTimeOffset.Now.AddSeconds(count);
|
||||||
IEnumerable<TimestampedSetDto> testSets = Generate(count, dateMin.ToOffset(TimeSpan.FromHours(7)));
|
IEnumerable<TimestampedSetDto> testSets = Generate(count, dateMin.ToOffset(TimeSpan.FromHours(7)));
|
||||||
var insertResponse = await client.InsertRange(idDiscriminator, testSets);
|
var insertResponse = await client.AddRange(idDiscriminator, testSets);
|
||||||
var tail = testSets.OrderBy(t => t.Timestamp).Skip(count / 2).Take(int.MaxValue);
|
var tail = testSets.OrderBy(t => t.Timestamp).Skip(count / 2).Take(int.MaxValue);
|
||||||
var geDate = tail.First().Timestamp;
|
var geDate = tail.First().Timestamp;
|
||||||
var tolerance = TimeSpan.FromSeconds(1);
|
var tolerance = TimeSpan.FromSeconds(1);
|
||||||
@ -111,7 +111,7 @@ public class TimestampedSetControllerTest : BaseIntegrationTest
|
|||||||
Guid idDiscriminator = Guid.NewGuid();
|
Guid idDiscriminator = Guid.NewGuid();
|
||||||
int count = 10;
|
int count = 10;
|
||||||
IEnumerable<TimestampedSetDto> testSets = Generate(count, DateTimeOffset.Now.ToOffset(TimeSpan.FromHours(7)));
|
IEnumerable<TimestampedSetDto> testSets = Generate(count, DateTimeOffset.Now.ToOffset(TimeSpan.FromHours(7)));
|
||||||
var insertResponse = await client.InsertRange(idDiscriminator, testSets);
|
var insertResponse = await client.AddRange(idDiscriminator, testSets);
|
||||||
var expectedCount = count / 2;
|
var expectedCount = count / 2;
|
||||||
|
|
||||||
// act
|
// act
|
||||||
@ -133,7 +133,7 @@ public class TimestampedSetControllerTest : BaseIntegrationTest
|
|||||||
var expectedCount = 1;
|
var expectedCount = 1;
|
||||||
int count = 10 + expectedCount;
|
int count = 10 + expectedCount;
|
||||||
IEnumerable<TimestampedSetDto> testSets = Generate(count, DateTimeOffset.Now.ToOffset(TimeSpan.FromHours(7)));
|
IEnumerable<TimestampedSetDto> testSets = Generate(count, DateTimeOffset.Now.ToOffset(TimeSpan.FromHours(7)));
|
||||||
var insertResponse = await client.InsertRange(idDiscriminator, testSets);
|
var insertResponse = await client.AddRange(idDiscriminator, testSets);
|
||||||
|
|
||||||
// act
|
// act
|
||||||
var response = await client.Get(idDiscriminator, null, null, count - expectedCount, count);
|
var response = await client.Get(idDiscriminator, null, null, count - expectedCount, count);
|
||||||
@ -152,7 +152,7 @@ public class TimestampedSetControllerTest : BaseIntegrationTest
|
|||||||
Guid idDiscriminator = Guid.NewGuid();
|
Guid idDiscriminator = Guid.NewGuid();
|
||||||
int count = 10;
|
int count = 10;
|
||||||
IEnumerable<TimestampedSetDto> testSets = Generate(count, DateTimeOffset.Now.ToOffset(TimeSpan.FromHours(7)));
|
IEnumerable<TimestampedSetDto> testSets = Generate(count, DateTimeOffset.Now.ToOffset(TimeSpan.FromHours(7)));
|
||||||
var insertResponse = await client.InsertRange(idDiscriminator, testSets);
|
var insertResponse = await client.AddRange(idDiscriminator, testSets);
|
||||||
var expectedCount = 8;
|
var expectedCount = 8;
|
||||||
|
|
||||||
// act
|
// act
|
||||||
@ -174,7 +174,7 @@ public class TimestampedSetControllerTest : BaseIntegrationTest
|
|||||||
var dateMin = DateTimeOffset.Now;
|
var dateMin = DateTimeOffset.Now;
|
||||||
var dateMax = DateTimeOffset.Now.AddSeconds(count-1);
|
var dateMax = DateTimeOffset.Now.AddSeconds(count-1);
|
||||||
IEnumerable<TimestampedSetDto> testSets = Generate(count, dateMin.ToOffset(TimeSpan.FromHours(7)));
|
IEnumerable<TimestampedSetDto> testSets = Generate(count, dateMin.ToOffset(TimeSpan.FromHours(7)));
|
||||||
var insertResponse = await client.InsertRange(idDiscriminator, testSets);
|
var insertResponse = await client.AddRange(idDiscriminator, testSets);
|
||||||
var tolerance = TimeSpan.FromSeconds(1);
|
var tolerance = TimeSpan.FromSeconds(1);
|
||||||
|
|
||||||
// act
|
// act
|
||||||
@ -195,7 +195,7 @@ public class TimestampedSetControllerTest : BaseIntegrationTest
|
|||||||
Guid idDiscriminator = Guid.NewGuid();
|
Guid idDiscriminator = Guid.NewGuid();
|
||||||
int count = 144;
|
int count = 144;
|
||||||
IEnumerable<TimestampedSetDto> testSets = Generate(count, DateTimeOffset.Now.ToOffset(TimeSpan.FromHours(7)));
|
IEnumerable<TimestampedSetDto> testSets = Generate(count, DateTimeOffset.Now.ToOffset(TimeSpan.FromHours(7)));
|
||||||
var insertResponse = await client.InsertRange(idDiscriminator, testSets);
|
var insertResponse = await client.AddRange(idDiscriminator, testSets);
|
||||||
|
|
||||||
// act
|
// act
|
||||||
var response = await client.Count(idDiscriminator);
|
var response = await client.Count(idDiscriminator);
|
||||||
|
@ -47,7 +47,7 @@ namespace Persistence.Repository.Repositories
|
|||||||
{
|
{
|
||||||
var query = GetQueryReadOnly();
|
var query = GetQueryReadOnly();
|
||||||
var entities = await query
|
var entities = await query
|
||||||
.Where(e => e.Created > dateBegin)
|
.Where(e => e.Created >= dateBegin)
|
||||||
.Take(take)
|
.Take(take)
|
||||||
.ToArrayAsync(token);
|
.ToArrayAsync(token);
|
||||||
var dtos = entities
|
var dtos = entities
|
||||||
@ -88,7 +88,7 @@ namespace Persistence.Repository.Repositories
|
|||||||
return dtos;
|
return dtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Save(Guid setpointKey, object newValue, Guid idUser, CancellationToken token)
|
public async Task Add(Guid setpointKey, object newValue, Guid idUser, CancellationToken token)
|
||||||
{
|
{
|
||||||
var entity = new Setpoint()
|
var entity = new Setpoint()
|
||||||
{
|
{
|
||||||
|
@ -88,7 +88,7 @@ namespace Persistence.Repository.Repositories
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> InsertRange(IEnumerable<TechMessageDto> dtos, CancellationToken token)
|
public async Task<int> AddRange(IEnumerable<TechMessageDto> dtos, Guid userId, CancellationToken token)
|
||||||
{
|
{
|
||||||
|
|
||||||
var entities = new List<TechMessage>();
|
var entities = new List<TechMessage>();
|
||||||
@ -100,6 +100,7 @@ namespace Persistence.Repository.Repositories
|
|||||||
?? await CreateDrillingSystem(dto.System, token);
|
?? await CreateDrillingSystem(dto.System, token);
|
||||||
|
|
||||||
entity.SystemId = systemId;
|
entity.SystemId = systemId;
|
||||||
|
entity.UserId = userId;
|
||||||
|
|
||||||
entities.Add(entity);
|
entities.Add(entity);
|
||||||
}
|
}
|
||||||
@ -114,7 +115,7 @@ namespace Persistence.Repository.Repositories
|
|||||||
{
|
{
|
||||||
var query = GetQueryReadOnly();
|
var query = GetQueryReadOnly();
|
||||||
var entities = await query
|
var entities = await query
|
||||||
.Where(e => e.Timestamp > dateBegin)
|
.Where(e => e.Timestamp >= dateBegin)
|
||||||
.Take(take)
|
.Take(take)
|
||||||
.ToArrayAsync(token);
|
.ToArrayAsync(token);
|
||||||
var dtos = entities
|
var dtos = entities
|
||||||
|
@ -48,9 +48,9 @@ public class TimeSeriesDataCachedRepository<TEntity, TDto> : TimeSeriesDataRepos
|
|||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<int> InsertRange(IEnumerable<TDto> dtos, CancellationToken token)
|
public override async Task<int> AddRange(IEnumerable<TDto> dtos, CancellationToken token)
|
||||||
{
|
{
|
||||||
var result = await base.InsertRange(dtos, token);
|
var result = await base.AddRange(dtos, token);
|
||||||
if (result > 0)
|
if (result > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public class TimeSeriesDataRepository<TEntity, TDto> : ITimeSeriesDataRepository
|
|||||||
return dtos;
|
return dtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual async Task<int> InsertRange(IEnumerable<TDto> dtos, CancellationToken token)
|
public virtual async Task<int> AddRange(IEnumerable<TDto> dtos, CancellationToken token)
|
||||||
{
|
{
|
||||||
var entities = dtos.Select(d => d.Adapt<TEntity>());
|
var entities = dtos.Select(d => d.Adapt<TEntity>());
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public class TimestampedSetRepository : ITimestampedSetRepository
|
|||||||
this.db = db;
|
this.db = db;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<int> InsertRange(Guid idDiscriminator, IEnumerable<TimestampedSetDto> sets, CancellationToken token)
|
public Task<int> AddRange(Guid idDiscriminator, IEnumerable<TimestampedSetDto> sets, CancellationToken token)
|
||||||
{
|
{
|
||||||
var entities = sets.Select(set => new TimestampedSet(idDiscriminator, set.Timestamp.ToUniversalTime(), set.Set));
|
var entities = sets.Select(set => new TimestampedSet(idDiscriminator, set.Timestamp.ToUniversalTime(), set.Set));
|
||||||
var dbSet = db.Set<TimestampedSet>();
|
var dbSet = db.Set<TimestampedSet>();
|
||||||
|
@ -40,5 +40,5 @@ public interface ISetpointApi : ISyncApi<SetpointLogDto>
|
|||||||
/// <param name="newValue">значение</param>
|
/// <param name="newValue">значение</param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IActionResult> Save(Guid setpointKey, object newValue, Guid userId, CancellationToken token);
|
Task<IActionResult> Add(Guid setpointKey, object newValue, CancellationToken token);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public interface ITimeSeriesDataApi<TDto> : ITimeSeriesBaseDataApi<TDto>
|
|||||||
/// <param name="dtos"></param>
|
/// <param name="dtos"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IActionResult> InsertRange(IEnumerable<TDto> dtos, CancellationToken token);
|
Task<IActionResult> AddRange(IEnumerable<TDto> dtos, CancellationToken token);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ namespace Persistence.Repositories;
|
|||||||
// throw new NotImplementedException();
|
// throw new NotImplementedException();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// public async Task<int> InsertRange(int idUser, IEnumerable<TDto> dtos, CancellationToken token)
|
// public async Task<int> AddRange(int idUser, IEnumerable<TDto> dtos, CancellationToken token)
|
||||||
// {
|
// {
|
||||||
// using var transaction = dbContext.Database.BeginTransaction();
|
// using var transaction = dbContext.Database.BeginTransaction();
|
||||||
// try
|
// try
|
||||||
|
@ -59,5 +59,5 @@ public interface ISetpointRepository
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// to do
|
/// to do
|
||||||
/// id User учесть в соответствующем методе репозитория
|
/// id User учесть в соответствующем методе репозитория
|
||||||
Task Save(Guid setpointKey, object newValue, Guid idUser, CancellationToken token);
|
Task Add(Guid setpointKey, object newValue, Guid idUser, CancellationToken token);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ namespace Persistence.Repositories
|
|||||||
/// <param name="dtos"></param>
|
/// <param name="dtos"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> InsertRange(IEnumerable<TechMessageDto> dtos, CancellationToken token);
|
Task<int> AddRange(IEnumerable<TechMessageDto> dtos, Guid userId, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение списка уникальных названий систем АБ
|
/// Получение списка уникальных названий систем АБ
|
||||||
|
@ -15,5 +15,5 @@ public interface ITimeSeriesDataRepository<TDto> : ISyncRepository<TDto>, ITimeS
|
|||||||
/// <param name="dtos"></param>
|
/// <param name="dtos"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> InsertRange(IEnumerable<TDto> dtos, CancellationToken token);
|
Task<int> AddRange(IEnumerable<TDto> dtos, CancellationToken token);
|
||||||
}
|
}
|
||||||
|
@ -55,5 +55,5 @@ public interface ITimestampedSetRepository
|
|||||||
/// <param name="sets"></param>
|
/// <param name="sets"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> InsertRange(Guid idDiscriminator, IEnumerable<TimestampedSetDto> sets, CancellationToken token);
|
Task<int> AddRange(Guid idDiscriminator, IEnumerable<TimestampedSetDto> sets, CancellationToken token);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user